RubySlicc_ComponentMapping.hh revision 6372
16145Snate@binkert.org 26145Snate@binkert.org/* 36145Snate@binkert.org * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood 46145Snate@binkert.org * All rights reserved. 56145Snate@binkert.org * 66145Snate@binkert.org * Redistribution and use in source and binary forms, with or without 76145Snate@binkert.org * modification, are permitted provided that the following conditions are 86145Snate@binkert.org * met: redistributions of source code must retain the above copyright 96145Snate@binkert.org * notice, this list of conditions and the following disclaimer; 106145Snate@binkert.org * redistributions in binary form must reproduce the above copyright 116145Snate@binkert.org * notice, this list of conditions and the following disclaimer in the 126145Snate@binkert.org * documentation and/or other materials provided with the distribution; 136145Snate@binkert.org * neither the name of the copyright holders nor the names of its 146145Snate@binkert.org * contributors may be used to endorse or promote products derived from 156145Snate@binkert.org * this software without specific prior written permission. 166145Snate@binkert.org * 176145Snate@binkert.org * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 186145Snate@binkert.org * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 196145Snate@binkert.org * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 206145Snate@binkert.org * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 216145Snate@binkert.org * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 226145Snate@binkert.org * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 236145Snate@binkert.org * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 246145Snate@binkert.org * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 256145Snate@binkert.org * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 266145Snate@binkert.org * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 276145Snate@binkert.org * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 286145Snate@binkert.org */ 296145Snate@binkert.org 306145Snate@binkert.org/* 316145Snate@binkert.org * $Id$ 326145Snate@binkert.org */ 336145Snate@binkert.org 346145Snate@binkert.org#ifndef COMPONENTMAPPINGFNS_H 356145Snate@binkert.org#define COMPONENTMAPPINGFNS_H 366145Snate@binkert.org 376154Snate@binkert.org#include "mem/ruby/common/Global.hh" 386154Snate@binkert.org#include "mem/ruby/system/NodeID.hh" 396154Snate@binkert.org#include "mem/ruby/system/MachineID.hh" 406154Snate@binkert.org#include "mem/ruby/common/Address.hh" 416154Snate@binkert.org#include "mem/ruby/common/Set.hh" 426154Snate@binkert.org#include "mem/ruby/common/NetDest.hh" 436154Snate@binkert.org#include "mem/protocol/GenericMachineType.hh" 446285Snate@binkert.org#include "mem/ruby/system/DirectoryMemory.hh" 456145Snate@binkert.org 466145Snate@binkert.org#ifdef MACHINETYPE_L1Cache 476145Snate@binkert.org#define MACHINETYPE_L1CACHE_ENUM MachineType_L1Cache 486145Snate@binkert.org#else 496145Snate@binkert.org#define MACHINETYPE_L1CACHE_ENUM MachineType_NUM 506145Snate@binkert.org#endif 516145Snate@binkert.org 526145Snate@binkert.org#ifdef MACHINETYPE_L2Cache 536145Snate@binkert.org#define MACHINETYPE_L2CACHE_ENUM MachineType_L2Cache 546145Snate@binkert.org#else 556145Snate@binkert.org#define MACHINETYPE_L2CACHE_ENUM MachineType_NUM 566145Snate@binkert.org#endif 576145Snate@binkert.org 586145Snate@binkert.org#ifdef MACHINETYPE_L3Cache 596145Snate@binkert.org#define MACHINETYPE_L3CACHE_ENUM MachineType_L3Cache 606145Snate@binkert.org#else 616145Snate@binkert.org#define MACHINETYPE_L3CACHE_ENUM MachineType_NUM 626145Snate@binkert.org#endif 636145Snate@binkert.org 646145Snate@binkert.org// used to determine the home directory 656145Snate@binkert.org// returns a value between 0 and total_directories_within_the_system 666145Snate@binkert.orginline 676145Snate@binkert.orgNodeID map_Address_to_DirectoryNode(const Address& addr) 686145Snate@binkert.org{ 696285Snate@binkert.org return DirectoryMemory::mapAddressToDirectoryVersion(addr); 706145Snate@binkert.org} 716145Snate@binkert.org 726145Snate@binkert.org// used to determine the home directory 736145Snate@binkert.org// returns a value between 0 and total_directories_within_the_system 746145Snate@binkert.orginline 756145Snate@binkert.orgMachineID map_Address_to_Directory(const Address &addr) 766145Snate@binkert.org{ 776145Snate@binkert.org MachineID mach = {MachineType_Directory, map_Address_to_DirectoryNode(addr)}; 786145Snate@binkert.org return mach; 796145Snate@binkert.org} 806145Snate@binkert.org 816145Snate@binkert.orginline 826285Snate@binkert.orgMachineID map_Address_to_DMA(const Address & addr) 836145Snate@binkert.org{ 846285Snate@binkert.org MachineID dma = {MachineType_DMA, 0}; 856285Snate@binkert.org return dma; 866145Snate@binkert.org} 876145Snate@binkert.org 886145Snate@binkert.orgextern inline NodeID machineIDToNodeID(MachineID machID) 896145Snate@binkert.org{ 906145Snate@binkert.org return machID.num; 916145Snate@binkert.org} 926145Snate@binkert.org 936145Snate@binkert.orgextern inline MachineType machineIDToMachineType(MachineID machID) 946145Snate@binkert.org{ 956145Snate@binkert.org return machID.type; 966145Snate@binkert.org} 976145Snate@binkert.org 986145Snate@binkert.orgextern inline NodeID L1CacheMachIDToProcessorNum(MachineID machID) 996145Snate@binkert.org{ 1006145Snate@binkert.org assert(machID.type == MachineType_L1Cache); 1016145Snate@binkert.org return machID.num; 1026145Snate@binkert.org} 1036372Sdrh5@cs.wisc.edu 1046145Snate@binkert.orgextern inline MachineID getL1MachineID(NodeID L1RubyNode) 1056145Snate@binkert.org{ 1066145Snate@binkert.org MachineID mach = {MACHINETYPE_L1CACHE_ENUM, L1RubyNode}; 1076145Snate@binkert.org return mach; 1086145Snate@binkert.org} 1096145Snate@binkert.org 1106145Snate@binkert.orgextern inline GenericMachineType ConvertMachToGenericMach(MachineType machType) { 1116145Snate@binkert.org if (machType == MACHINETYPE_L1CACHE_ENUM) { 1126145Snate@binkert.org return GenericMachineType_L1Cache; 1136145Snate@binkert.org } else if (machType == MACHINETYPE_L2CACHE_ENUM) { 1146145Snate@binkert.org return GenericMachineType_L2Cache; 1156145Snate@binkert.org } else if (machType == MACHINETYPE_L3CACHE_ENUM) { 1166145Snate@binkert.org return GenericMachineType_L3Cache; 1176145Snate@binkert.org } else if (machType == MachineType_Directory) { 1186145Snate@binkert.org return GenericMachineType_Directory; 1196145Snate@binkert.org } else { 1206145Snate@binkert.org ERROR_MSG("cannot convert to a GenericMachineType"); 1216145Snate@binkert.org return GenericMachineType_NULL; 1226145Snate@binkert.org } 1236145Snate@binkert.org} 1246145Snate@binkert.org 1256145Snate@binkert.org 1266145Snate@binkert.org#endif // COMPONENTMAPPINGFNS_H 127