RubySlicc_ComponentMapping.hh revision 11308:7d8836fd043d
1/* 2 * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer; 9 * redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution; 12 * neither the name of the copyright holders nor the names of its 13 * contributors may be used to endorse or promote products derived from 14 * this software without specific prior written permission. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29#ifndef __MEM_RUBY_SLICC_INTERFACE_RUBYSLICC_COMPONENTMAPPINGS_HH__ 30#define __MEM_RUBY_SLICC_INTERFACE_RUBYSLICC_COMPONENTMAPPINGS_HH__ 31 32#include "mem/protocol/MachineType.hh" 33#include "mem/ruby/common/Address.hh" 34#include "mem/ruby/common/MachineID.hh" 35#include "mem/ruby/common/NetDest.hh" 36#include "mem/ruby/structures/DirectoryMemory.hh" 37 38// used to determine the home directory 39// returns a value between 0 and total_directories_within_the_system 40inline NodeID 41map_Address_to_DirectoryNode(Addr addr) 42{ 43 return DirectoryMemory::mapAddressToDirectoryVersion(addr); 44} 45 46inline NodeID 47map_Address_to_TCCdirNode(Addr addr) 48{ 49 return DirectoryMemory::mapAddressToDirectoryVersion(addr); 50} 51 52// used to determine the home directory 53// returns a value between 0 and total_directories_within_the_system 54inline MachineID 55map_Address_to_Directory(Addr addr) 56{ 57 MachineID mach = 58 {MachineType_Directory, map_Address_to_DirectoryNode(addr)}; 59 return mach; 60} 61 62inline MachineID 63map_Address_to_RegionDir(Addr addr) 64{ 65 MachineID mach = {MachineType_RegionDir, 66 map_Address_to_DirectoryNode(addr)}; 67 return mach; 68} 69 70inline MachineID 71map_Address_to_TCCdir(Addr addr) 72{ 73 MachineID mach = 74 {MachineType_TCCdir, map_Address_to_TCCdirNode(addr)}; 75 return mach; 76} 77 78inline NetDest 79broadcast(MachineType type) 80{ 81 NetDest dest; 82 for (NodeID i = 0; i < MachineType_base_count(type); i++) { 83 MachineID mach = {type, i}; 84 dest.add(mach); 85 } 86 return dest; 87} 88 89inline MachineID 90mapAddressToRange(Addr addr, MachineType type, int low_bit, 91 int num_bits, int cluster_id = 0) 92{ 93 MachineID mach = {type, 0}; 94 if (num_bits == 0) 95 mach.num = cluster_id; 96 else 97 mach.num = bitSelect(addr, low_bit, low_bit + num_bits - 1) 98 + (1 << num_bits) * cluster_id; 99 return mach; 100} 101 102inline NodeID 103machineIDToNodeID(MachineID machID) 104{ 105 return machID.num; 106} 107 108inline MachineType 109machineIDToMachineType(MachineID machID) 110{ 111 return machID.type; 112} 113 114inline int 115machineCount(MachineType machType) 116{ 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