RubySlicc_ComponentMapping.hh revision 6785
15222Sksewell@umich.edu 25254Sksewell@umich.edu/* 35254Sksewell@umich.edu * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood 45254Sksewell@umich.edu * All rights reserved. 55222Sksewell@umich.edu * 65254Sksewell@umich.edu * Redistribution and use in source and binary forms, with or without 75254Sksewell@umich.edu * modification, are permitted provided that the following conditions are 85254Sksewell@umich.edu * met: redistributions of source code must retain the above copyright 95254Sksewell@umich.edu * notice, this list of conditions and the following disclaimer; 105254Sksewell@umich.edu * redistributions in binary form must reproduce the above copyright 115254Sksewell@umich.edu * notice, this list of conditions and the following disclaimer in the 125254Sksewell@umich.edu * documentation and/or other materials provided with the distribution; 135254Sksewell@umich.edu * neither the name of the copyright holders nor the names of its 145254Sksewell@umich.edu * contributors may be used to endorse or promote products derived from 155254Sksewell@umich.edu * this software without specific prior written permission. 165222Sksewell@umich.edu * 175254Sksewell@umich.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 185254Sksewell@umich.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 195254Sksewell@umich.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 205254Sksewell@umich.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 215254Sksewell@umich.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 225254Sksewell@umich.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 235254Sksewell@umich.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 245254Sksewell@umich.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 255254Sksewell@umich.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 265254Sksewell@umich.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 275254Sksewell@umich.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 285222Sksewell@umich.edu */ 295254Sksewell@umich.edu 305254Sksewell@umich.edu/* 315254Sksewell@umich.edu * $Id$ 325222Sksewell@umich.edu */ 335222Sksewell@umich.edu 346379Sgblack@eecs.umich.edu#ifndef COMPONENTMAPPINGFNS_H 356379Sgblack@eecs.umich.edu#define COMPONENTMAPPINGFNS_H 365222Sksewell@umich.edu 376379Sgblack@eecs.umich.edu#include "mem/ruby/common/Global.hh" 385222Sksewell@umich.edu#include "mem/ruby/system/NodeID.hh" 395222Sksewell@umich.edu#include "mem/ruby/system/MachineID.hh" 405222Sksewell@umich.edu#include "mem/ruby/common/Address.hh" 415222Sksewell@umich.edu#include "mem/ruby/common/Set.hh" 426378Sgblack@eecs.umich.edu#include "mem/ruby/common/NetDest.hh" 436378Sgblack@eecs.umich.edu#include "mem/protocol/GenericMachineType.hh" 446378Sgblack@eecs.umich.edu#include "mem/ruby/system/DirectoryMemory.hh" 456379Sgblack@eecs.umich.edu 466379Sgblack@eecs.umich.edu#ifdef MACHINETYPE_L1Cache 475222Sksewell@umich.edu#define MACHINETYPE_L1CACHE_ENUM MachineType_L1Cache 485222Sksewell@umich.edu#else 496378Sgblack@eecs.umich.edu#define MACHINETYPE_L1CACHE_ENUM MachineType_NUM 506379Sgblack@eecs.umich.edu#endif 516379Sgblack@eecs.umich.edu 526379Sgblack@eecs.umich.edu#ifdef MACHINETYPE_L2Cache 536379Sgblack@eecs.umich.edu#define MACHINETYPE_L2CACHE_ENUM MachineType_L2Cache 545222Sksewell@umich.edu#else 555222Sksewell@umich.edu#define MACHINETYPE_L2CACHE_ENUM MachineType_NUM 566378Sgblack@eecs.umich.edu#endif 576378Sgblack@eecs.umich.edu 585222Sksewell@umich.edu#ifdef MACHINETYPE_L3Cache 595222Sksewell@umich.edu#define MACHINETYPE_L3CACHE_ENUM MachineType_L3Cache 605222Sksewell@umich.edu#else 615222Sksewell@umich.edu#define MACHINETYPE_L3CACHE_ENUM MachineType_NUM 625222Sksewell@umich.edu#endif 636378Sgblack@eecs.umich.edu 645222Sksewell@umich.edu#ifdef MACHINETYPE_DMA 656378Sgblack@eecs.umich.edu#define MACHINETYPE_DMA_ENUM MachineType_DMA 665222Sksewell@umich.edu#else 675222Sksewell@umich.edu#define MACHINETYPE_DMA_ENUM MachineType_NUM 686378Sgblack@eecs.umich.edu#endif 696378Sgblack@eecs.umich.edu 705222Sksewell@umich.edu// used to determine the number of acks to wait for 716378Sgblack@eecs.umich.eduint getNumberOfLastLevelCaches(); 725222Sksewell@umich.edu 735222Sksewell@umich.edu// used to determine the home directory 746378Sgblack@eecs.umich.edu// returns a value between 0 and total_directories_within_the_system 756378Sgblack@eecs.umich.eduinline 765222Sksewell@umich.eduNodeID map_Address_to_DirectoryNode(const Address& addr) 775222Sksewell@umich.edu{ 785222Sksewell@umich.edu return DirectoryMemory::mapAddressToDirectoryVersion(addr); 795222Sksewell@umich.edu} 805222Sksewell@umich.edu 816378Sgblack@eecs.umich.edu// used to determine the home directory 825222Sksewell@umich.edu// returns a value between 0 and total_directories_within_the_system 836378Sgblack@eecs.umich.eduinline 845222Sksewell@umich.eduMachineID map_Address_to_Directory(const Address &addr) 855222Sksewell@umich.edu{ 866378Sgblack@eecs.umich.edu MachineID mach = {MachineType_Directory, map_Address_to_DirectoryNode(addr)}; 876378Sgblack@eecs.umich.edu return mach; 885222Sksewell@umich.edu} 896378Sgblack@eecs.umich.edu 905222Sksewell@umich.eduinline 915222Sksewell@umich.eduMachineID map_Address_to_DMA(const Address & addr) 926378Sgblack@eecs.umich.edu{ 936378Sgblack@eecs.umich.edu MachineID dma = {MACHINETYPE_DMA_ENUM, 0}; 945222Sksewell@umich.edu return dma; 955222Sksewell@umich.edu} 965222Sksewell@umich.edu 976378Sgblack@eecs.umich.eduinline 985222Sksewell@umich.eduMachineID mapAddressToRange(const Address & addr, MachineType type, int low_bit, int num_bits) 995222Sksewell@umich.edu{ 1006378Sgblack@eecs.umich.edu MachineID mach = {type, 0}; 1016378Sgblack@eecs.umich.edu if (num_bits == 0) 1025222Sksewell@umich.edu return mach; 1036378Sgblack@eecs.umich.edu mach.num = addr.bitSelect(low_bit, low_bit+num_bits-1); 1045222Sksewell@umich.edu return mach; 1055222Sksewell@umich.edu} 1065222Sksewell@umich.edu 1075222Sksewell@umich.eduextern inline NodeID machineIDToNodeID(MachineID machID) 1086378Sgblack@eecs.umich.edu{ 1096378Sgblack@eecs.umich.edu return machID.num; 1105222Sksewell@umich.edu} 1115222Sksewell@umich.edu 1125222Sksewell@umich.eduextern inline MachineType machineIDToMachineType(MachineID machID) 1135222Sksewell@umich.edu{ 1146379Sgblack@eecs.umich.edu return machID.type; 1156378Sgblack@eecs.umich.edu} 1166378Sgblack@eecs.umich.edu 1176379Sgblack@eecs.umich.eduextern inline NodeID L1CacheMachIDToProcessorNum(MachineID machID) 1185222Sksewell@umich.edu{ 1195222Sksewell@umich.edu assert(machID.type == MachineType_L1Cache); 1205222Sksewell@umich.edu return machID.num; 1216379Sgblack@eecs.umich.edu} 1226379Sgblack@eecs.umich.edu 1235222Sksewell@umich.eduextern inline MachineID getL1MachineID(NodeID L1RubyNode) 1246379Sgblack@eecs.umich.edu{ 1255222Sksewell@umich.edu MachineID mach = {MACHINETYPE_L1CACHE_ENUM, L1RubyNode}; 1265222Sksewell@umich.edu return mach; 1275222Sksewell@umich.edu} 1285222Sksewell@umich.edu 1295222Sksewell@umich.eduextern inline GenericMachineType ConvertMachToGenericMach(MachineType machType) { 1306378Sgblack@eecs.umich.edu if (machType == MACHINETYPE_L1CACHE_ENUM) { 1315222Sksewell@umich.edu return GenericMachineType_L1Cache; 1326378Sgblack@eecs.umich.edu } else if (machType == MACHINETYPE_L2CACHE_ENUM) { 1336378Sgblack@eecs.umich.edu return GenericMachineType_L2Cache; 1345222Sksewell@umich.edu } else if (machType == MACHINETYPE_L3CACHE_ENUM) { 1356379Sgblack@eecs.umich.edu return GenericMachineType_L3Cache; 1366379Sgblack@eecs.umich.edu } else if (machType == MachineType_Directory) { 1375222Sksewell@umich.edu return GenericMachineType_Directory; 1385222Sksewell@umich.edu } else { 1395222Sksewell@umich.edu ERROR_MSG("cannot convert to a GenericMachineType"); 1405222Sksewell@umich.edu return GenericMachineType_NULL; 1416378Sgblack@eecs.umich.edu } 1426378Sgblack@eecs.umich.edu} 1436378Sgblack@eecs.umich.edu 1445222Sksewell@umich.edu 1455222Sksewell@umich.edu#endif // COMPONENTMAPPINGFNS_H 1465222Sksewell@umich.edu