RubySlicc_ComponentMapping.hh revision 6926
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"
456926SBrad.Beckmann@amd.com#include "mem/protocol/MachineType.hh"
466145Snate@binkert.org
476145Snate@binkert.org#ifdef MACHINETYPE_L1Cache
486145Snate@binkert.org#define MACHINETYPE_L1CACHE_ENUM MachineType_L1Cache
496145Snate@binkert.org#else
506145Snate@binkert.org#define MACHINETYPE_L1CACHE_ENUM MachineType_NUM
516145Snate@binkert.org#endif
526145Snate@binkert.org
536145Snate@binkert.org#ifdef MACHINETYPE_L2Cache
546145Snate@binkert.org#define MACHINETYPE_L2CACHE_ENUM MachineType_L2Cache
556145Snate@binkert.org#else
566145Snate@binkert.org#define MACHINETYPE_L2CACHE_ENUM MachineType_NUM
576145Snate@binkert.org#endif
586145Snate@binkert.org
596145Snate@binkert.org#ifdef MACHINETYPE_L3Cache
606145Snate@binkert.org#define MACHINETYPE_L3CACHE_ENUM MachineType_L3Cache
616145Snate@binkert.org#else
626145Snate@binkert.org#define MACHINETYPE_L3CACHE_ENUM MachineType_NUM
636145Snate@binkert.org#endif
646145Snate@binkert.org
656785SBrad.Beckmann@amd.com#ifdef MACHINETYPE_DMA
666785SBrad.Beckmann@amd.com#define MACHINETYPE_DMA_ENUM MachineType_DMA
676785SBrad.Beckmann@amd.com#else
686785SBrad.Beckmann@amd.com#define MACHINETYPE_DMA_ENUM MachineType_NUM
696785SBrad.Beckmann@amd.com#endif
706785SBrad.Beckmann@amd.com
716145Snate@binkert.org// used to determine the home directory
726145Snate@binkert.org// returns a value between 0 and total_directories_within_the_system
736145Snate@binkert.orginline
746145Snate@binkert.orgNodeID map_Address_to_DirectoryNode(const Address& addr)
756145Snate@binkert.org{
766285Snate@binkert.org  return DirectoryMemory::mapAddressToDirectoryVersion(addr);
776145Snate@binkert.org}
786145Snate@binkert.org
796145Snate@binkert.org// used to determine the home directory
806145Snate@binkert.org// returns a value between 0 and total_directories_within_the_system
816145Snate@binkert.orginline
826145Snate@binkert.orgMachineID map_Address_to_Directory(const Address &addr)
836145Snate@binkert.org{
846145Snate@binkert.org  MachineID mach = {MachineType_Directory, map_Address_to_DirectoryNode(addr)};
856145Snate@binkert.org  return mach;
866145Snate@binkert.org}
876145Snate@binkert.org
886145Snate@binkert.orginline
896285Snate@binkert.orgMachineID map_Address_to_DMA(const Address & addr)
906145Snate@binkert.org{
916785SBrad.Beckmann@amd.com  MachineID dma = {MACHINETYPE_DMA_ENUM, 0};
926285Snate@binkert.org  return dma;
936145Snate@binkert.org}
946145Snate@binkert.org
956843Sdrh5@cs.wisc.eduinline
966843Sdrh5@cs.wisc.eduNetDest broadcast(MachineType type)
976843Sdrh5@cs.wisc.edu{
986843Sdrh5@cs.wisc.edu  NetDest dest;
996843Sdrh5@cs.wisc.edu  for (int i=0; i<MachineType_base_count(type); i++) {
1006843Sdrh5@cs.wisc.edu    MachineID mach = {type, i};
1016843Sdrh5@cs.wisc.edu    dest.add(mach);
1026843Sdrh5@cs.wisc.edu  }
1036843Sdrh5@cs.wisc.edu  return dest;
1046843Sdrh5@cs.wisc.edu}
1056843Sdrh5@cs.wisc.edu
1066467Sdrh5@cs.wisc.eduinline
1076468Sdrh5@cs.wisc.eduMachineID mapAddressToRange(const Address & addr, MachineType type, int low_bit, int num_bits)
1086467Sdrh5@cs.wisc.edu{
1096467Sdrh5@cs.wisc.edu  MachineID mach = {type, 0};
1106468Sdrh5@cs.wisc.edu  if (num_bits == 0)
1116468Sdrh5@cs.wisc.edu    return mach;
1126468Sdrh5@cs.wisc.edu  mach.num = addr.bitSelect(low_bit, low_bit+num_bits-1);
1136467Sdrh5@cs.wisc.edu  return mach;
1146467Sdrh5@cs.wisc.edu}
1156467Sdrh5@cs.wisc.edu
1166145Snate@binkert.orgextern inline NodeID machineIDToNodeID(MachineID machID)
1176145Snate@binkert.org{
1186145Snate@binkert.org  return machID.num;
1196145Snate@binkert.org}
1206145Snate@binkert.org
1216145Snate@binkert.orgextern inline MachineType machineIDToMachineType(MachineID machID)
1226145Snate@binkert.org{
1236145Snate@binkert.org  return machID.type;
1246145Snate@binkert.org}
1256145Snate@binkert.org
1266145Snate@binkert.orgextern inline NodeID L1CacheMachIDToProcessorNum(MachineID machID)
1276145Snate@binkert.org{
1286145Snate@binkert.org  assert(machID.type == MachineType_L1Cache);
1296145Snate@binkert.org  return machID.num;
1306145Snate@binkert.org}
1316372Sdrh5@cs.wisc.edu
1326145Snate@binkert.orgextern inline MachineID getL1MachineID(NodeID L1RubyNode)
1336145Snate@binkert.org{
1346145Snate@binkert.org  MachineID mach = {MACHINETYPE_L1CACHE_ENUM, L1RubyNode};
1356145Snate@binkert.org  return mach;
1366145Snate@binkert.org}
1376145Snate@binkert.org
1386145Snate@binkert.orgextern inline GenericMachineType ConvertMachToGenericMach(MachineType machType) {
1396145Snate@binkert.org  if (machType == MACHINETYPE_L1CACHE_ENUM) {
1406145Snate@binkert.org    return GenericMachineType_L1Cache;
1416145Snate@binkert.org  } else if (machType == MACHINETYPE_L2CACHE_ENUM) {
1426145Snate@binkert.org    return GenericMachineType_L2Cache;
1436145Snate@binkert.org  } else if (machType == MACHINETYPE_L3CACHE_ENUM) {
1446145Snate@binkert.org    return GenericMachineType_L3Cache;
1456145Snate@binkert.org  } else if (machType == MachineType_Directory) {
1466145Snate@binkert.org    return GenericMachineType_Directory;
1476145Snate@binkert.org  } else {
1486145Snate@binkert.org    ERROR_MSG("cannot convert to a GenericMachineType");
1496145Snate@binkert.org    return GenericMachineType_NULL;
1506145Snate@binkert.org  }
1516145Snate@binkert.org}
1526145Snate@binkert.org
1536926SBrad.Beckmann@amd.comextern inline int machineCount(MachineType machType) {
1546926SBrad.Beckmann@amd.com    return MachineType_base_count(machType);
1556926SBrad.Beckmann@amd.com}
1566145Snate@binkert.org
1576145Snate@binkert.org#endif  // COMPONENTMAPPINGFNS_H
158