RubySlicc_ComponentMapping.hh revision 7039
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/GenericMachineType.hh" 337039Snate@binkert.org#include "mem/protocol/MachineType.hh" 347039Snate@binkert.org#include "mem/ruby/common/Address.hh" 356154Snate@binkert.org#include "mem/ruby/common/Global.hh" 367039Snate@binkert.org#include "mem/ruby/common/NetDest.hh" 377039Snate@binkert.org#include "mem/ruby/common/Set.hh" 387039Snate@binkert.org#include "mem/ruby/system/DirectoryMemory.hh" 397039Snate@binkert.org#include "mem/ruby/system/MachineID.hh" 406154Snate@binkert.org#include "mem/ruby/system/NodeID.hh" 416145Snate@binkert.org 426145Snate@binkert.org#ifdef MACHINETYPE_L1Cache 436145Snate@binkert.org#define MACHINETYPE_L1CACHE_ENUM MachineType_L1Cache 446145Snate@binkert.org#else 456145Snate@binkert.org#define MACHINETYPE_L1CACHE_ENUM MachineType_NUM 466145Snate@binkert.org#endif 476145Snate@binkert.org 486145Snate@binkert.org#ifdef MACHINETYPE_L2Cache 496145Snate@binkert.org#define MACHINETYPE_L2CACHE_ENUM MachineType_L2Cache 506145Snate@binkert.org#else 516145Snate@binkert.org#define MACHINETYPE_L2CACHE_ENUM MachineType_NUM 526145Snate@binkert.org#endif 536145Snate@binkert.org 546145Snate@binkert.org#ifdef MACHINETYPE_L3Cache 556145Snate@binkert.org#define MACHINETYPE_L3CACHE_ENUM MachineType_L3Cache 566145Snate@binkert.org#else 576145Snate@binkert.org#define MACHINETYPE_L3CACHE_ENUM MachineType_NUM 586145Snate@binkert.org#endif 596145Snate@binkert.org 606785SBrad.Beckmann@amd.com#ifdef MACHINETYPE_DMA 616785SBrad.Beckmann@amd.com#define MACHINETYPE_DMA_ENUM MachineType_DMA 626785SBrad.Beckmann@amd.com#else 636785SBrad.Beckmann@amd.com#define MACHINETYPE_DMA_ENUM MachineType_NUM 646785SBrad.Beckmann@amd.com#endif 656785SBrad.Beckmann@amd.com 666145Snate@binkert.org// used to determine the home directory 676145Snate@binkert.org// returns a value between 0 and total_directories_within_the_system 687039Snate@binkert.orginline NodeID 697039Snate@binkert.orgmap_Address_to_DirectoryNode(const Address& addr) 706145Snate@binkert.org{ 717039Snate@binkert.org return DirectoryMemory::mapAddressToDirectoryVersion(addr); 726145Snate@binkert.org} 736145Snate@binkert.org 746145Snate@binkert.org// used to determine the home directory 756145Snate@binkert.org// returns a value between 0 and total_directories_within_the_system 767039Snate@binkert.orginline MachineID 777039Snate@binkert.orgmap_Address_to_Directory(const Address &addr) 786145Snate@binkert.org{ 797039Snate@binkert.org MachineID mach = 807039Snate@binkert.org {MachineType_Directory, map_Address_to_DirectoryNode(addr)}; 817039Snate@binkert.org return mach; 826145Snate@binkert.org} 836145Snate@binkert.org 847039Snate@binkert.orginline MachineID 857039Snate@binkert.orgmap_Address_to_DMA(const Address & addr) 866145Snate@binkert.org{ 877039Snate@binkert.org MachineID dma = {MACHINETYPE_DMA_ENUM, 0}; 887039Snate@binkert.org return dma; 896145Snate@binkert.org} 906145Snate@binkert.org 917039Snate@binkert.orginline NetDest 927039Snate@binkert.orgbroadcast(MachineType type) 936843Sdrh5@cs.wisc.edu{ 947039Snate@binkert.org NetDest dest; 957039Snate@binkert.org for (int i = 0; i < MachineType_base_count(type); i++) { 967039Snate@binkert.org MachineID mach = {type, i}; 977039Snate@binkert.org dest.add(mach); 987039Snate@binkert.org } 997039Snate@binkert.org return dest; 1006843Sdrh5@cs.wisc.edu} 1016843Sdrh5@cs.wisc.edu 1027039Snate@binkert.orginline MachineID 1037039Snate@binkert.orgmapAddressToRange(const Address & addr, MachineType type, int low_bit, 1047039Snate@binkert.org int num_bits) 1056467Sdrh5@cs.wisc.edu{ 1067039Snate@binkert.org MachineID mach = {type, 0}; 1077039Snate@binkert.org if (num_bits == 0) 1087039Snate@binkert.org return mach; 1097039Snate@binkert.org mach.num = addr.bitSelect(low_bit, low_bit + num_bits - 1); 1106468Sdrh5@cs.wisc.edu return mach; 1116467Sdrh5@cs.wisc.edu} 1126467Sdrh5@cs.wisc.edu 1137039Snate@binkert.orginline NodeID 1147039Snate@binkert.orgmachineIDToNodeID(MachineID machID) 1156145Snate@binkert.org{ 1167039Snate@binkert.org return machID.num; 1176145Snate@binkert.org} 1186145Snate@binkert.org 1197039Snate@binkert.orginline MachineType 1207039Snate@binkert.orgmachineIDToMachineType(MachineID machID) 1216145Snate@binkert.org{ 1227039Snate@binkert.org return machID.type; 1236145Snate@binkert.org} 1246145Snate@binkert.org 1257039Snate@binkert.orginline NodeID 1267039Snate@binkert.orgL1CacheMachIDToProcessorNum(MachineID machID) 1276145Snate@binkert.org{ 1287039Snate@binkert.org assert(machID.type == MachineType_L1Cache); 1297039Snate@binkert.org return machID.num; 1306145Snate@binkert.org} 1316372Sdrh5@cs.wisc.edu 1327039Snate@binkert.orginline MachineID 1337039Snate@binkert.orggetL1MachineID(NodeID L1RubyNode) 1346145Snate@binkert.org{ 1357039Snate@binkert.org MachineID mach = {MACHINETYPE_L1CACHE_ENUM, L1RubyNode}; 1367039Snate@binkert.org return mach; 1376145Snate@binkert.org} 1386145Snate@binkert.org 1397039Snate@binkert.orginline GenericMachineType 1407039Snate@binkert.orgConvertMachToGenericMach(MachineType machType) 1417039Snate@binkert.org{ 1427039Snate@binkert.org if (machType == MACHINETYPE_L1CACHE_ENUM) 1437039Snate@binkert.org return GenericMachineType_L1Cache; 1447039Snate@binkert.org 1457039Snate@binkert.org if (machType == MACHINETYPE_L2CACHE_ENUM) 1467039Snate@binkert.org return GenericMachineType_L2Cache; 1477039Snate@binkert.org 1487039Snate@binkert.org if (machType == MACHINETYPE_L3CACHE_ENUM) 1497039Snate@binkert.org return GenericMachineType_L3Cache; 1507039Snate@binkert.org 1517039Snate@binkert.org if (machType == MachineType_Directory) 1527039Snate@binkert.org return GenericMachineType_Directory; 1537039Snate@binkert.org 1546145Snate@binkert.org ERROR_MSG("cannot convert to a GenericMachineType"); 1556145Snate@binkert.org return GenericMachineType_NULL; 1566145Snate@binkert.org} 1576145Snate@binkert.org 1587039Snate@binkert.orginline int 1597039Snate@binkert.orgmachineCount(MachineType machType) 1607039Snate@binkert.org{ 1616926SBrad.Beckmann@amd.com return MachineType_base_count(machType); 1626926SBrad.Beckmann@amd.com} 1636145Snate@binkert.org 1647039Snate@binkert.org#endif // __MEM_RUBY_SLICC_INTERFACE_COMPONENTMAPPINGS_HH__ 165