RubySlicc_ComponentMapping.hh revision 6145
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
376145Snate@binkert.org#include "Global.hh"
386145Snate@binkert.org#include "RubyConfig.hh"
396145Snate@binkert.org#include "NodeID.hh"
406145Snate@binkert.org#include "MachineID.hh"
416145Snate@binkert.org#include "Address.hh"
426145Snate@binkert.org#include "Set.hh"
436145Snate@binkert.org#include "NetDest.hh"
446145Snate@binkert.org#include "GenericMachineType.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#ifdef MACHINETYPE_PersistentArbiter
656145Snate@binkert.org#define MACHINETYPE_PERSISTENTARBITER_ENUM MachineType_PersistentArbiter
666145Snate@binkert.org#else
676145Snate@binkert.org#define MACHINETYPE_PERSISTENTARBITER_ENUM MachineType_NUM
686145Snate@binkert.org#endif
696145Snate@binkert.org
706145Snate@binkert.org#ifdef MACHINETYPE_Collector
716145Snate@binkert.org#define MACHINETYPE_COLLECTOR_ENUM MachineType_Collector
726145Snate@binkert.org#else
736145Snate@binkert.org#define MACHINETYPE_COLLECTOR_ENUM MachineType_NUM
746145Snate@binkert.org#endif
756145Snate@binkert.org
766145Snate@binkert.org
776145Snate@binkert.org// used to determine the correct L1 set
786145Snate@binkert.org// input parameters are the address and number of set bits for the L1 cache
796145Snate@binkert.org// returns a value between 0 and the total number of L1 cache sets
806145Snate@binkert.orginline
816145Snate@binkert.orgint map_address_to_L1CacheSet(const Address& addr, int cache_num_set_bits)
826145Snate@binkert.org{
836145Snate@binkert.org  return addr.bitSelect(RubyConfig::dataBlockBits(),
846145Snate@binkert.org                        RubyConfig::dataBlockBits()+cache_num_set_bits-1);
856145Snate@binkert.org}
866145Snate@binkert.org
876145Snate@binkert.org// used to determine the correct L2 set
886145Snate@binkert.org// input parameters are the address and number of set bits for the L2 cache
896145Snate@binkert.org// returns a value between 0 and the total number of L2 cache sets
906145Snate@binkert.orginline
916145Snate@binkert.orgint map_address_to_L2CacheSet(const Address& addr, int cache_num_set_bits)
926145Snate@binkert.org{
936145Snate@binkert.org  assert(cache_num_set_bits == L2_CACHE_NUM_SETS_BITS);  // ensure the l2 bank mapping functions agree with l2 set bits
946145Snate@binkert.org
956145Snate@binkert.org  if (MAP_L2BANKS_TO_LOWEST_BITS) {
966145Snate@binkert.org    return addr.bitSelect(RubyConfig::dataBlockBits()+RubyConfig::L2CachePerChipBits(),
976145Snate@binkert.org                          RubyConfig::dataBlockBits()+RubyConfig::L2CachePerChipBits()+cache_num_set_bits-1);
986145Snate@binkert.org  } else {
996145Snate@binkert.org    return addr.bitSelect(RubyConfig::dataBlockBits(),
1006145Snate@binkert.org                          RubyConfig::dataBlockBits()+cache_num_set_bits-1);
1016145Snate@binkert.org  }
1026145Snate@binkert.org}
1036145Snate@binkert.org
1046145Snate@binkert.org// input parameter is the base ruby node of the L1 cache
1056145Snate@binkert.org// returns a value between 0 and total_L2_Caches_within_the_system
1066145Snate@binkert.orginline
1076145Snate@binkert.orgMachineID map_L1CacheMachId_to_L2Cache(const Address& addr, MachineID L1CacheMachId)
1086145Snate@binkert.org{
1096145Snate@binkert.org  int L2bank = 0;
1106145Snate@binkert.org  MachineID mach = {MACHINETYPE_L2CACHE_ENUM, 0};
1116145Snate@binkert.org
1126145Snate@binkert.org  if (RubyConfig::L2CachePerChipBits() > 0) {
1136145Snate@binkert.org    if (MAP_L2BANKS_TO_LOWEST_BITS) {
1146145Snate@binkert.org      L2bank = addr.bitSelect(RubyConfig::dataBlockBits(),
1156145Snate@binkert.org                         RubyConfig::dataBlockBits()+RubyConfig::L2CachePerChipBits()-1);
1166145Snate@binkert.org    } else {
1176145Snate@binkert.org      L2bank = addr.bitSelect(RubyConfig::dataBlockBits()+L2_CACHE_NUM_SETS_BITS,
1186145Snate@binkert.org                         RubyConfig::dataBlockBits()+L2_CACHE_NUM_SETS_BITS+RubyConfig::L2CachePerChipBits()-1);
1196145Snate@binkert.org    }
1206145Snate@binkert.org  }
1216145Snate@binkert.org
1226145Snate@binkert.org  assert(L2bank < RubyConfig::numberOfL2CachePerChip());
1236145Snate@binkert.org  assert(L2bank >= 0);
1246145Snate@binkert.org
1256145Snate@binkert.org  mach.num = RubyConfig::L1CacheNumToL2Base(L1CacheMachId.num)*RubyConfig::numberOfL2CachePerChip() // base #
1266145Snate@binkert.org    + L2bank;  // bank #
1276145Snate@binkert.org  assert(mach.num < RubyConfig::numberOfL2Cache());
1286145Snate@binkert.org  return mach;
1296145Snate@binkert.org}
1306145Snate@binkert.org
1316145Snate@binkert.org// used to determine the correct L2 bank
1326145Snate@binkert.org// input parameter is the base ruby node of the L2 cache
1336145Snate@binkert.org// returns a value between 0 and total_L2_Caches_within_the_system
1346145Snate@binkert.orginline
1356145Snate@binkert.orgMachineID map_L2ChipId_to_L2Cache(const Address& addr, NodeID L2ChipId)
1366145Snate@binkert.org{
1376145Snate@binkert.org  assert(L2ChipId < RubyConfig::numberOfChips());
1386145Snate@binkert.org
1396145Snate@binkert.org  int L2bank = 0;
1406145Snate@binkert.org  MachineID mach = {MACHINETYPE_L2CACHE_ENUM, 0};
1416145Snate@binkert.org
1426145Snate@binkert.org  if (RubyConfig::L2CachePerChipBits() > 0) {
1436145Snate@binkert.org    if (MAP_L2BANKS_TO_LOWEST_BITS) {
1446145Snate@binkert.org      L2bank = addr.bitSelect(RubyConfig::dataBlockBits(),
1456145Snate@binkert.org                         RubyConfig::dataBlockBits()+RubyConfig::L2CachePerChipBits()-1);
1466145Snate@binkert.org    } else {
1476145Snate@binkert.org      L2bank = addr.bitSelect(RubyConfig::dataBlockBits()+L2_CACHE_NUM_SETS_BITS,
1486145Snate@binkert.org                         RubyConfig::dataBlockBits()+L2_CACHE_NUM_SETS_BITS+RubyConfig::L2CachePerChipBits()-1);
1496145Snate@binkert.org    }
1506145Snate@binkert.org  }
1516145Snate@binkert.org
1526145Snate@binkert.org  assert(L2bank < RubyConfig::numberOfL2CachePerChip());
1536145Snate@binkert.org  assert(L2bank >= 0);
1546145Snate@binkert.org
1556145Snate@binkert.org  mach.num = L2ChipId*RubyConfig::numberOfL2CachePerChip() // base #
1566145Snate@binkert.org    + L2bank; // bank #
1576145Snate@binkert.org  assert(mach.num < RubyConfig::numberOfL2Cache());
1586145Snate@binkert.org  return mach;
1596145Snate@binkert.org}
1606145Snate@binkert.org
1616145Snate@binkert.org// used to determine the home directory
1626145Snate@binkert.org// returns a value between 0 and total_directories_within_the_system
1636145Snate@binkert.orginline
1646145Snate@binkert.orgNodeID map_Address_to_DirectoryNode(const Address& addr)
1656145Snate@binkert.org{
1666145Snate@binkert.org  NodeID dirNode = 0;
1676145Snate@binkert.org
1686145Snate@binkert.org  if (RubyConfig::memoryBits() > 0) {
1696145Snate@binkert.org    dirNode = addr.bitSelect(RubyConfig::dataBlockBits(),
1706145Snate@binkert.org                        RubyConfig::dataBlockBits()+RubyConfig::memoryBits()-1);
1716145Snate@binkert.org  }
1726145Snate@binkert.org
1736145Snate@binkert.org  //  Index indexHighPortion = address.bitSelect(MEMORY_SIZE_BITS-1, PAGE_SIZE_BITS+NUMBER_OF_MEMORY_MODULE_BITS);
1746145Snate@binkert.org  //  Index indexLowPortion  = address.bitSelect(DATA_BLOCK_BITS, PAGE_SIZE_BITS-1);
1756145Snate@binkert.org
1766145Snate@binkert.org  //Index index = indexLowPortion | (indexHighPortion << (PAGE_SIZE_BITS - DATA_BLOCK_BITS));
1776145Snate@binkert.org
1786145Snate@binkert.org/*
1796145Snate@binkert.org
1806145Snate@binkert.orgADDRESS_WIDTH    MEMORY_SIZE_BITS        PAGE_SIZE_BITS  DATA_BLOCK_BITS
1816145Snate@binkert.org  |                    |                       |               |
1826145Snate@binkert.org \ /                  \ /                     \ /             \ /       0
1836145Snate@binkert.org  -----------------------------------------------------------------------
1846145Snate@binkert.org  |       unused        |xxxxxxxxxxxxxxx|       |xxxxxxxxxxxxxxx|       |
1856145Snate@binkert.org  |                     |xxxxxxxxxxxxxxx|       |xxxxxxxxxxxxxxx|       |
1866145Snate@binkert.org  -----------------------------------------------------------------------
1876145Snate@binkert.org                        indexHighPortion         indexLowPortion
1886145Snate@binkert.org                                        <------->
1896145Snate@binkert.org                               NUMBER_OF_MEMORY_MODULE_BITS
1906145Snate@binkert.org  */
1916145Snate@binkert.org
1926145Snate@binkert.org  assert(dirNode < RubyConfig::numberOfMemories());
1936145Snate@binkert.org  assert(dirNode >= 0);
1946145Snate@binkert.org  return dirNode;
1956145Snate@binkert.org}
1966145Snate@binkert.org
1976145Snate@binkert.org// used to determine the home directory
1986145Snate@binkert.org// returns a value between 0 and total_directories_within_the_system
1996145Snate@binkert.orginline
2006145Snate@binkert.orgMachineID map_Address_to_Directory(const Address &addr)
2016145Snate@binkert.org{
2026145Snate@binkert.org  MachineID mach = {MachineType_Directory, map_Address_to_DirectoryNode(addr)};
2036145Snate@binkert.org  return mach;
2046145Snate@binkert.org}
2056145Snate@binkert.org
2066145Snate@binkert.orginline
2076145Snate@binkert.orgMachineID map_Address_to_CentralArbiterNode(const Address& addr)
2086145Snate@binkert.org{
2096145Snate@binkert.org  MachineType t = MACHINETYPE_PERSISTENTARBITER_ENUM;
2106145Snate@binkert.org  MachineID mach = {t, map_Address_to_DirectoryNode(addr)};
2116145Snate@binkert.org
2126145Snate@binkert.org  assert(mach.num < RubyConfig::numberOfMemories());
2136145Snate@binkert.org  assert(mach.num >= 0);
2146145Snate@binkert.org  return mach;
2156145Snate@binkert.org}
2166145Snate@binkert.org
2176145Snate@binkert.orginline
2186145Snate@binkert.orgNetDest getMultiStaticL2BankNetDest(const Address& addr, const Set& sharers)  // set of L2RubyNodes
2196145Snate@binkert.org{
2206145Snate@binkert.org  NetDest dest;
2216145Snate@binkert.org
2226145Snate@binkert.org  for (int i = 0; i < sharers.getSize(); i++) {
2236145Snate@binkert.org    if (sharers.isElement(i)) {
2246145Snate@binkert.org      dest.add(map_L2ChipId_to_L2Cache(addr,i));
2256145Snate@binkert.org    }
2266145Snate@binkert.org  }
2276145Snate@binkert.org  return dest;
2286145Snate@binkert.org}
2296145Snate@binkert.org
2306145Snate@binkert.orginline
2316145Snate@binkert.orgNetDest getOtherLocalL1IDs(MachineID L1)
2326145Snate@binkert.org{
2336145Snate@binkert.org  int start = (L1.num / RubyConfig::numberOfProcsPerChip()) * RubyConfig::numberOfProcsPerChip();
2346145Snate@binkert.org  NetDest ret;
2356145Snate@binkert.org
2366145Snate@binkert.org  assert(MACHINETYPE_L1CACHE_ENUM != MachineType_NUM);
2376145Snate@binkert.org
2386145Snate@binkert.org  for (int i = start; i < (start + RubyConfig::numberOfProcsPerChip()); i++) {
2396145Snate@binkert.org    if (i != L1.num) {
2406145Snate@binkert.org      MachineID mach = { MACHINETYPE_L1CACHE_ENUM, i };
2416145Snate@binkert.org      ret.add( mach );
2426145Snate@binkert.org    }
2436145Snate@binkert.org  }
2446145Snate@binkert.org
2456145Snate@binkert.org  return ret;
2466145Snate@binkert.org}
2476145Snate@binkert.org
2486145Snate@binkert.orginline
2496145Snate@binkert.orgNetDest getLocalL1IDs(MachineID mach)
2506145Snate@binkert.org{
2516145Snate@binkert.org  assert(MACHINETYPE_L1CACHE_ENUM != MachineType_NUM);
2526145Snate@binkert.org
2536145Snate@binkert.org  NetDest ret;
2546145Snate@binkert.org
2556145Snate@binkert.org  if (mach.type == MACHINETYPE_L1CACHE_ENUM) {
2566145Snate@binkert.org
2576145Snate@binkert.org    int start = (mach.num / RubyConfig::numberOfL1CachePerChip()) * RubyConfig::numberOfProcsPerChip();
2586145Snate@binkert.org
2596145Snate@binkert.org    for (int i = start; i < (start + RubyConfig::numberOfProcsPerChip()); i++) {
2606145Snate@binkert.org      MachineID mach = { MACHINETYPE_L1CACHE_ENUM, i };
2616145Snate@binkert.org      ret.add( mach );
2626145Snate@binkert.org    }
2636145Snate@binkert.org  }
2646145Snate@binkert.org  else if (mach.type == MACHINETYPE_L2CACHE_ENUM) {
2656145Snate@binkert.org
2666145Snate@binkert.org    int chip = mach.num/RubyConfig::numberOfL2CachePerChip();
2676145Snate@binkert.org    int start = ( chip*RubyConfig::numberOfL1CachePerChip());
2686145Snate@binkert.org    for (int i = start; i < (start + RubyConfig::numberOfL1CachePerChip()); i++) {
2696145Snate@binkert.org      MachineID mach = { MACHINETYPE_L1CACHE_ENUM, i };
2706145Snate@binkert.org      ret.add( mach );
2716145Snate@binkert.org    }
2726145Snate@binkert.org  }
2736145Snate@binkert.org
2746145Snate@binkert.org  return ret;
2756145Snate@binkert.org}
2766145Snate@binkert.org
2776145Snate@binkert.orginline
2786145Snate@binkert.orgNetDest getExternalL1IDs(MachineID L1)
2796145Snate@binkert.org{
2806145Snate@binkert.org  NetDest ret;
2816145Snate@binkert.org
2826145Snate@binkert.org  assert(MACHINETYPE_L1CACHE_ENUM != MachineType_NUM);
2836145Snate@binkert.org
2846145Snate@binkert.org  for (int i = 0; i < RubyConfig::numberOfProcessors(); i++) {
2856145Snate@binkert.org    // ret.add( (NodeID) i);
2866145Snate@binkert.org    MachineID mach = { MACHINETYPE_L1CACHE_ENUM, i };
2876145Snate@binkert.org    ret.add( mach );
2886145Snate@binkert.org  }
2896145Snate@binkert.org
2906145Snate@binkert.org  ret.removeNetDest(getLocalL1IDs(L1));
2916145Snate@binkert.org
2926145Snate@binkert.org  return ret;
2936145Snate@binkert.org}
2946145Snate@binkert.org
2956145Snate@binkert.orginline
2966145Snate@binkert.orgbool isLocalProcessor(MachineID thisId, MachineID tarID)
2976145Snate@binkert.org{
2986145Snate@binkert.org  int start = (thisId.num / RubyConfig::numberOfProcsPerChip()) * RubyConfig::numberOfProcsPerChip();
2996145Snate@binkert.org
3006145Snate@binkert.org  for (int i = start; i < (start + RubyConfig::numberOfProcsPerChip()); i++) {
3016145Snate@binkert.org    if (i == tarID.num) {
3026145Snate@binkert.org      return true;
3036145Snate@binkert.org    }
3046145Snate@binkert.org  }
3056145Snate@binkert.org  return false;
3066145Snate@binkert.org}
3076145Snate@binkert.org
3086145Snate@binkert.org
3096145Snate@binkert.orginline
3106145Snate@binkert.orgNetDest getAllPertinentL2Banks(const Address& addr)  // set of L2RubyNodes
3116145Snate@binkert.org{
3126145Snate@binkert.org  NetDest dest;
3136145Snate@binkert.org
3146145Snate@binkert.org  for (int i = 0; i < RubyConfig::numberOfChips(); i++) {
3156145Snate@binkert.org    dest.add(map_L2ChipId_to_L2Cache(addr,i));
3166145Snate@binkert.org  }
3176145Snate@binkert.org  return dest;
3186145Snate@binkert.org}
3196145Snate@binkert.org
3206145Snate@binkert.orginline
3216145Snate@binkert.orgbool isL1OnChip(MachineID L1machID, NodeID L2NodeID)
3226145Snate@binkert.org{
3236145Snate@binkert.org  if (L1machID.type == MACHINETYPE_L1CACHE_ENUM) {
3246145Snate@binkert.org    return (L1machID.num == L2NodeID);
3256145Snate@binkert.org  } else {
3266145Snate@binkert.org    return false;
3276145Snate@binkert.org  }
3286145Snate@binkert.org}
3296145Snate@binkert.org
3306145Snate@binkert.orginline
3316145Snate@binkert.orgbool isL2OnChip(MachineID L2machID, NodeID L2NodeID)
3326145Snate@binkert.org{
3336145Snate@binkert.org  if (L2machID.type == MACHINETYPE_L2CACHE_ENUM) {
3346145Snate@binkert.org    return (L2machID.num == L2NodeID);
3356145Snate@binkert.org  } else {
3366145Snate@binkert.org    return false;
3376145Snate@binkert.org  }
3386145Snate@binkert.org}
3396145Snate@binkert.org
3406145Snate@binkert.orginline
3416145Snate@binkert.orgNodeID closest_clockwise_distance(NodeID this_node, NodeID next_node)
3426145Snate@binkert.org{
3436145Snate@binkert.org  if (this_node <= next_node) {
3446145Snate@binkert.org    return (next_node - this_node);
3456145Snate@binkert.org  } else {
3466145Snate@binkert.org    return (next_node - this_node + RubyConfig::numberOfChips());
3476145Snate@binkert.org  }
3486145Snate@binkert.org}
3496145Snate@binkert.org
3506145Snate@binkert.orginline
3516145Snate@binkert.orgbool closer_clockwise_processor(NodeID this_node, NodeID newer, NodeID older)
3526145Snate@binkert.org{
3536145Snate@binkert.org  return (closest_clockwise_distance(this_node, newer) < closest_clockwise_distance(this_node, older));
3546145Snate@binkert.org}
3556145Snate@binkert.org
3566145Snate@binkert.orgextern inline NodeID getChipID(MachineID L2machID)
3576145Snate@binkert.org{
3586145Snate@binkert.org  return (L2machID.num%RubyConfig::numberOfChips())/RubyConfig::numberOfProcsPerChip();
3596145Snate@binkert.org}
3606145Snate@binkert.org
3616145Snate@binkert.orgextern inline NodeID machineIDToNodeID(MachineID machID)
3626145Snate@binkert.org{
3636145Snate@binkert.org  // return machID.num%RubyConfig::numberOfChips();
3646145Snate@binkert.org  return machID.num;
3656145Snate@binkert.org}
3666145Snate@binkert.org
3676145Snate@binkert.orgextern inline NodeID machineIDToVersion(MachineID machID)
3686145Snate@binkert.org{
3696145Snate@binkert.org  return machID.num/RubyConfig::numberOfChips();
3706145Snate@binkert.org}
3716145Snate@binkert.org
3726145Snate@binkert.orgextern inline MachineType machineIDToMachineType(MachineID machID)
3736145Snate@binkert.org{
3746145Snate@binkert.org  return machID.type;
3756145Snate@binkert.org}
3766145Snate@binkert.org
3776145Snate@binkert.orgextern inline NodeID L1CacheMachIDToProcessorNum(MachineID machID)
3786145Snate@binkert.org{
3796145Snate@binkert.org  assert(machID.type == MachineType_L1Cache);
3806145Snate@binkert.org  return machID.num;
3816145Snate@binkert.org}
3826145Snate@binkert.org
3836145Snate@binkert.orgextern inline NodeID L2CacheMachIDToChipID(MachineID machID)
3846145Snate@binkert.org{
3856145Snate@binkert.org  assert(machID.type == MACHINETYPE_L2CACHE_ENUM);
3866145Snate@binkert.org  return machID.num/RubyConfig::numberOfL2CachePerChip();
3876145Snate@binkert.org}
3886145Snate@binkert.org
3896145Snate@binkert.orgextern inline MachineID getCollectorDest(MachineID L1MachID)
3906145Snate@binkert.org{
3916145Snate@binkert.org  MachineID mach = {MACHINETYPE_COLLECTOR_ENUM, L1MachID.num};
3926145Snate@binkert.org  return mach;
3936145Snate@binkert.org}
3946145Snate@binkert.org
3956145Snate@binkert.orgextern inline MachineID getCollectorL1Cache(MachineID colID)
3966145Snate@binkert.org{
3976145Snate@binkert.org  MachineID mach = {MACHINETYPE_L1CACHE_ENUM, colID.num};
3986145Snate@binkert.org  return mach;
3996145Snate@binkert.org}
4006145Snate@binkert.org
4016145Snate@binkert.orgextern inline MachineID getL1MachineID(NodeID L1RubyNode)
4026145Snate@binkert.org{
4036145Snate@binkert.org  MachineID mach = {MACHINETYPE_L1CACHE_ENUM, L1RubyNode};
4046145Snate@binkert.org  return mach;
4056145Snate@binkert.org}
4066145Snate@binkert.org
4076145Snate@binkert.orgextern inline GenericMachineType ConvertMachToGenericMach(MachineType machType) {
4086145Snate@binkert.org  if (machType == MACHINETYPE_L1CACHE_ENUM) {
4096145Snate@binkert.org    return GenericMachineType_L1Cache;
4106145Snate@binkert.org  } else if (machType == MACHINETYPE_L2CACHE_ENUM) {
4116145Snate@binkert.org    return GenericMachineType_L2Cache;
4126145Snate@binkert.org  } else if (machType == MACHINETYPE_L3CACHE_ENUM) {
4136145Snate@binkert.org    return GenericMachineType_L3Cache;
4146145Snate@binkert.org  } else if (machType == MachineType_Directory) {
4156145Snate@binkert.org    return GenericMachineType_Directory;
4166145Snate@binkert.org  } else if (machType == MACHINETYPE_COLLECTOR_ENUM) {
4176145Snate@binkert.org    return GenericMachineType_Collector;
4186145Snate@binkert.org  } else {
4196145Snate@binkert.org    ERROR_MSG("cannot convert to a GenericMachineType");
4206145Snate@binkert.org    return GenericMachineType_NULL;
4216145Snate@binkert.org  }
4226145Snate@binkert.org}
4236145Snate@binkert.org
4246145Snate@binkert.org
4256145Snate@binkert.org#endif  // COMPONENTMAPPINGFNS_H
426