RubySlicc_ComponentMapping.hh revision 11308
16157Snate@binkert.org/* 26157Snate@binkert.org * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood 36157Snate@binkert.org * All rights reserved. 46157Snate@binkert.org * 56157Snate@binkert.org * Redistribution and use in source and binary forms, with or without 66157Snate@binkert.org * modification, are permitted provided that the following conditions are 76157Snate@binkert.org * met: redistributions of source code must retain the above copyright 86157Snate@binkert.org * notice, this list of conditions and the following disclaimer; 96157Snate@binkert.org * redistributions in binary form must reproduce the above copyright 106157Snate@binkert.org * notice, this list of conditions and the following disclaimer in the 116157Snate@binkert.org * documentation and/or other materials provided with the distribution; 126157Snate@binkert.org * neither the name of the copyright holders nor the names of its 136157Snate@binkert.org * contributors may be used to endorse or promote products derived from 146157Snate@binkert.org * this software without specific prior written permission. 156157Snate@binkert.org * 166157Snate@binkert.org * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 176157Snate@binkert.org * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 186157Snate@binkert.org * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 196157Snate@binkert.org * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 206157Snate@binkert.org * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 216157Snate@binkert.org * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 226157Snate@binkert.org * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 236157Snate@binkert.org * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 246157Snate@binkert.org * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 256157Snate@binkert.org * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 266157Snate@binkert.org * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 276157Snate@binkert.org */ 286157Snate@binkert.org 296157Snate@binkert.org#ifndef __MEM_RUBY_SLICC_INTERFACE_RUBYSLICC_COMPONENTMAPPINGS_HH__ 306157Snate@binkert.org#define __MEM_RUBY_SLICC_INTERFACE_RUBYSLICC_COMPONENTMAPPINGS_HH__ 316157Snate@binkert.org 326157Snate@binkert.org#include "mem/protocol/MachineType.hh" 336157Snate@binkert.org#include "mem/ruby/common/Address.hh" 346157Snate@binkert.org#include "mem/ruby/common/MachineID.hh" 356157Snate@binkert.org#include "mem/ruby/common/NetDest.hh" 366157Snate@binkert.org#include "mem/ruby/structures/DirectoryMemory.hh" 376157Snate@binkert.org 386157Snate@binkert.org// used to determine the home directory 396157Snate@binkert.org// returns a value between 0 and total_directories_within_the_system 407768SAli.Saidi@ARM.cominline NodeID 417768SAli.Saidi@ARM.commap_Address_to_DirectoryNode(Addr addr) 427768SAli.Saidi@ARM.com{ 438492Snilay@cs.wisc.edu return DirectoryMemory::mapAddressToDirectoryVersion(addr); 446168Snate@binkert.org} 456168Snate@binkert.org 466157Snate@binkert.orginline NodeID 476157Snate@binkert.orgmap_Address_to_TCCdirNode(Addr addr) 486157Snate@binkert.org{ 496157Snate@binkert.org return DirectoryMemory::mapAddressToDirectoryVersion(addr); 506157Snate@binkert.org} 516157Snate@binkert.org 526157Snate@binkert.org// used to determine the home directory 536157Snate@binkert.org// returns a value between 0 and total_directories_within_the_system 546157Snate@binkert.orginline MachineID 556157Snate@binkert.orgmap_Address_to_Directory(Addr addr) 566157Snate@binkert.org{ 576157Snate@binkert.org MachineID mach = 586157Snate@binkert.org {MachineType_Directory, map_Address_to_DirectoryNode(addr)}; 596157Snate@binkert.org return mach; 606157Snate@binkert.org} 616157Snate@binkert.org 626157Snate@binkert.orginline MachineID 636157Snate@binkert.orgmap_Address_to_RegionDir(Addr addr) 646157Snate@binkert.org{ 656157Snate@binkert.org MachineID mach = {MachineType_RegionDir, 666157Snate@binkert.org map_Address_to_DirectoryNode(addr)}; 676157Snate@binkert.org return mach; 686157Snate@binkert.org} 696157Snate@binkert.org 706157Snate@binkert.orginline MachineID 716157Snate@binkert.orgmap_Address_to_TCCdir(Addr addr) 726157Snate@binkert.org{ 736157Snate@binkert.org MachineID mach = 746157Snate@binkert.org {MachineType_TCCdir, map_Address_to_TCCdirNode(addr)}; 756157Snate@binkert.org return mach; 766157Snate@binkert.org} 776157Snate@binkert.org 786157Snate@binkert.orginline NetDest 796157Snate@binkert.orgbroadcast(MachineType type) 806157Snate@binkert.org{ 816157Snate@binkert.org NetDest dest; 826157Snate@binkert.org for (NodeID i = 0; i < MachineType_base_count(type); i++) { 836157Snate@binkert.org MachineID mach = {type, i}; 846157Snate@binkert.org dest.add(mach); 856157Snate@binkert.org } 866157Snate@binkert.org return dest; 876157Snate@binkert.org} 886157Snate@binkert.org 898483Sgblack@eecs.umich.eduinline MachineID 908483Sgblack@eecs.umich.edumapAddressToRange(Addr addr, MachineType type, int low_bit, 916157Snate@binkert.org int num_bits, int cluster_id = 0) 926882SBrad.Beckmann@amd.com{ 936286Snate@binkert.org MachineID mach = {type, 0}; 946286Snate@binkert.org if (num_bits == 0) 956286Snate@binkert.org mach.num = cluster_id; 966286Snate@binkert.org else 978092Snilay@cs.wisc.edu mach.num = bitSelect(addr, low_bit, low_bit + num_bits - 1) 986286Snate@binkert.org + (1 << num_bits) * cluster_id; 996286Snate@binkert.org return mach; 1006157Snate@binkert.org} 1016157Snate@binkert.org 1026157Snate@binkert.orginline NodeID 1036157Snate@binkert.orgmachineIDToNodeID(MachineID machID) 1046157Snate@binkert.org{ 1056286Snate@binkert.org return machID.num; 1066157Snate@binkert.org} 1076286Snate@binkert.org 1086157Snate@binkert.orginline MachineType 1096157Snate@binkert.orgmachineIDToMachineType(MachineID machID) 1106157Snate@binkert.org{ 1118191SLisa.Hsu@amd.com return machID.type; 1126157Snate@binkert.org} 1136797SBrad.Beckmann@amd.com 1146157Snate@binkert.orginline int 1156157Snate@binkert.orgmachineCount(MachineType machType) 1166157Snate@binkert.org{ 117 return MachineType_base_count(machType); 118} 119 120inline MachineID 121createMachineID(MachineType type, NodeID id) 122{ 123 MachineID mach = {type, id}; 124 return mach; 125} 126 127inline MachineID 128MachineTypeAndNodeIDToMachineID(MachineType type, NodeID node) 129{ 130 MachineID mach = {type, node}; 131 return mach; 132} 133 134#endif // __MEM_RUBY_SLICC_INTERFACE_COMPONENTMAPPINGS_HH__ 135