RubySlicc_ComponentMapping.hh revision 11308
16145Snate@binkert.org/* 26145Snate@binkert.org * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood 36145Snate@binkert.org * All rights reserved. 46145Snate@binkert.org * 56145Snate@binkert.org * Redistribution and use in source and binary forms, with or without 66145Snate@binkert.org * modification, are permitted provided that the following conditions are 76145Snate@binkert.org * met: redistributions of source code must retain the above copyright 86145Snate@binkert.org * notice, this list of conditions and the following disclaimer; 96145Snate@binkert.org * redistributions in binary form must reproduce the above copyright 106145Snate@binkert.org * notice, this list of conditions and the following disclaimer in the 116145Snate@binkert.org * documentation and/or other materials provided with the distribution; 126145Snate@binkert.org * neither the name of the copyright holders nor the names of its 136145Snate@binkert.org * contributors may be used to endorse or promote products derived from 146145Snate@binkert.org * this software without specific prior written permission. 156145Snate@binkert.org * 166145Snate@binkert.org * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 176145Snate@binkert.org * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 186145Snate@binkert.org * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 196145Snate@binkert.org * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 206145Snate@binkert.org * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 216145Snate@binkert.org * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 226145Snate@binkert.org * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 236145Snate@binkert.org * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 246145Snate@binkert.org * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 256145Snate@binkert.org * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 266145Snate@binkert.org * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 276145Snate@binkert.org */ 286145Snate@binkert.org 297039Snate@binkert.org#ifndef __MEM_RUBY_SLICC_INTERFACE_RUBYSLICC_COMPONENTMAPPINGS_HH__ 307039Snate@binkert.org#define __MEM_RUBY_SLICC_INTERFACE_RUBYSLICC_COMPONENTMAPPINGS_HH__ 316145Snate@binkert.org 327039Snate@binkert.org#include "mem/protocol/MachineType.hh" 337039Snate@binkert.org#include "mem/ruby/common/Address.hh" 3410301Snilay@cs.wisc.edu#include "mem/ruby/common/MachineID.hh" 357039Snate@binkert.org#include "mem/ruby/common/NetDest.hh" 3610301Snilay@cs.wisc.edu#include "mem/ruby/structures/DirectoryMemory.hh" 376145Snate@binkert.org 386145Snate@binkert.org// used to determine the home directory 396145Snate@binkert.org// returns a value between 0 and total_directories_within_the_system 407039Snate@binkert.orginline NodeID 4111025Snilay@cs.wisc.edumap_Address_to_DirectoryNode(Addr addr) 426145Snate@binkert.org{ 437039Snate@binkert.org return DirectoryMemory::mapAddressToDirectoryVersion(addr); 446145Snate@binkert.org} 456145Snate@binkert.org 4611308Santhony.gutierrez@amd.cominline NodeID 4711308Santhony.gutierrez@amd.commap_Address_to_TCCdirNode(Addr addr) 4811308Santhony.gutierrez@amd.com{ 4911308Santhony.gutierrez@amd.com return DirectoryMemory::mapAddressToDirectoryVersion(addr); 5011308Santhony.gutierrez@amd.com} 5111308Santhony.gutierrez@amd.com 526145Snate@binkert.org// used to determine the home directory 536145Snate@binkert.org// returns a value between 0 and total_directories_within_the_system 547039Snate@binkert.orginline MachineID 5511025Snilay@cs.wisc.edumap_Address_to_Directory(Addr addr) 566145Snate@binkert.org{ 577039Snate@binkert.org MachineID mach = 587039Snate@binkert.org {MachineType_Directory, map_Address_to_DirectoryNode(addr)}; 597039Snate@binkert.org return mach; 606145Snate@binkert.org} 616145Snate@binkert.org 6211308Santhony.gutierrez@amd.cominline MachineID 6311308Santhony.gutierrez@amd.commap_Address_to_RegionDir(Addr addr) 6411308Santhony.gutierrez@amd.com{ 6511308Santhony.gutierrez@amd.com MachineID mach = {MachineType_RegionDir, 6611308Santhony.gutierrez@amd.com map_Address_to_DirectoryNode(addr)}; 6711308Santhony.gutierrez@amd.com return mach; 6811308Santhony.gutierrez@amd.com} 6911308Santhony.gutierrez@amd.com 7011308Santhony.gutierrez@amd.cominline MachineID 7111308Santhony.gutierrez@amd.commap_Address_to_TCCdir(Addr addr) 7211308Santhony.gutierrez@amd.com{ 7311308Santhony.gutierrez@amd.com MachineID mach = 7411308Santhony.gutierrez@amd.com {MachineType_TCCdir, map_Address_to_TCCdirNode(addr)}; 7511308Santhony.gutierrez@amd.com return mach; 7611308Santhony.gutierrez@amd.com} 7711308Santhony.gutierrez@amd.com 787039Snate@binkert.orginline NetDest 797039Snate@binkert.orgbroadcast(MachineType type) 806843Sdrh5@cs.wisc.edu{ 817039Snate@binkert.org NetDest dest; 8210005Snilay@cs.wisc.edu for (NodeID i = 0; i < MachineType_base_count(type); i++) { 837039Snate@binkert.org MachineID mach = {type, i}; 847039Snate@binkert.org dest.add(mach); 857039Snate@binkert.org } 867039Snate@binkert.org return dest; 876843Sdrh5@cs.wisc.edu} 886843Sdrh5@cs.wisc.edu 897039Snate@binkert.orginline MachineID 9011025Snilay@cs.wisc.edumapAddressToRange(Addr addr, MachineType type, int low_bit, 9110005Snilay@cs.wisc.edu int num_bits, int cluster_id = 0) 926467Sdrh5@cs.wisc.edu{ 937039Snate@binkert.org MachineID mach = {type, 0}; 947039Snate@binkert.org if (num_bits == 0) 9510005Snilay@cs.wisc.edu mach.num = cluster_id; 9610005Snilay@cs.wisc.edu else 9711025Snilay@cs.wisc.edu mach.num = bitSelect(addr, low_bit, low_bit + num_bits - 1) 9810005Snilay@cs.wisc.edu + (1 << num_bits) * cluster_id; 996468Sdrh5@cs.wisc.edu return mach; 1006467Sdrh5@cs.wisc.edu} 1016467Sdrh5@cs.wisc.edu 1027039Snate@binkert.orginline NodeID 1037039Snate@binkert.orgmachineIDToNodeID(MachineID machID) 1046145Snate@binkert.org{ 1057039Snate@binkert.org return machID.num; 1066145Snate@binkert.org} 1076145Snate@binkert.org 1087039Snate@binkert.orginline MachineType 1097039Snate@binkert.orgmachineIDToMachineType(MachineID machID) 1106145Snate@binkert.org{ 1117039Snate@binkert.org return machID.type; 1126145Snate@binkert.org} 1136145Snate@binkert.org 1147039Snate@binkert.orginline int 1157039Snate@binkert.orgmachineCount(MachineType machType) 1167039Snate@binkert.org{ 1176926SBrad.Beckmann@amd.com return MachineType_base_count(machType); 1186926SBrad.Beckmann@amd.com} 1196145Snate@binkert.org 12010008Snilay@cs.wisc.eduinline MachineID 12110008Snilay@cs.wisc.educreateMachineID(MachineType type, NodeID id) 12210008Snilay@cs.wisc.edu{ 12310008Snilay@cs.wisc.edu MachineID mach = {type, id}; 12410008Snilay@cs.wisc.edu return mach; 12510008Snilay@cs.wisc.edu} 12610008Snilay@cs.wisc.edu 12711308Santhony.gutierrez@amd.cominline MachineID 12811308Santhony.gutierrez@amd.comMachineTypeAndNodeIDToMachineID(MachineType type, NodeID node) 12911308Santhony.gutierrez@amd.com{ 13011308Santhony.gutierrez@amd.com MachineID mach = {type, node}; 13111308Santhony.gutierrez@amd.com return mach; 13211308Santhony.gutierrez@amd.com} 13311308Santhony.gutierrez@amd.com 1347039Snate@binkert.org#endif // __MEM_RUBY_SLICC_INTERFACE_COMPONENTMAPPINGS_HH__ 135