RubySlicc_ComponentMapping.hh revision 10005
16145Snate@binkert.org/* 26145Snate@binkert.org * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood 36145Snate@binkert.org * All rights reserved. 46145Snate@binkert.org * 56145Snate@binkert.org * Redistribution and use in source and binary forms, with or without 66145Snate@binkert.org * modification, are permitted provided that the following conditions are 76145Snate@binkert.org * met: redistributions of source code must retain the above copyright 86145Snate@binkert.org * notice, this list of conditions and the following disclaimer; 96145Snate@binkert.org * redistributions in binary form must reproduce the above copyright 106145Snate@binkert.org * notice, this list of conditions and the following disclaimer in the 116145Snate@binkert.org * documentation and/or other materials provided with the distribution; 126145Snate@binkert.org * neither the name of the copyright holders nor the names of its 136145Snate@binkert.org * contributors may be used to endorse or promote products derived from 146145Snate@binkert.org * this software without specific prior written permission. 156145Snate@binkert.org * 166145Snate@binkert.org * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 176145Snate@binkert.org * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 186145Snate@binkert.org * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 196145Snate@binkert.org * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 206145Snate@binkert.org * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 216145Snate@binkert.org * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 226145Snate@binkert.org * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 236145Snate@binkert.org * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 246145Snate@binkert.org * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 256145Snate@binkert.org * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 266145Snate@binkert.org * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 276145Snate@binkert.org */ 286145Snate@binkert.org 297039Snate@binkert.org#ifndef __MEM_RUBY_SLICC_INTERFACE_RUBYSLICC_COMPONENTMAPPINGS_HH__ 307039Snate@binkert.org#define __MEM_RUBY_SLICC_INTERFACE_RUBYSLICC_COMPONENTMAPPINGS_HH__ 316145Snate@binkert.org 327039Snate@binkert.org#include "mem/protocol/MachineType.hh" 337039Snate@binkert.org#include "mem/ruby/common/Address.hh" 346154Snate@binkert.org#include "mem/ruby/common/Global.hh" 357039Snate@binkert.org#include "mem/ruby/common/NetDest.hh" 367039Snate@binkert.org#include "mem/ruby/system/DirectoryMemory.hh" 377039Snate@binkert.org#include "mem/ruby/system/MachineID.hh" 386145Snate@binkert.org 396145Snate@binkert.org// used to determine the home directory 406145Snate@binkert.org// returns a value between 0 and total_directories_within_the_system 417039Snate@binkert.orginline NodeID 427039Snate@binkert.orgmap_Address_to_DirectoryNode(const Address& addr) 436145Snate@binkert.org{ 447039Snate@binkert.org return DirectoryMemory::mapAddressToDirectoryVersion(addr); 456145Snate@binkert.org} 466145Snate@binkert.org 476145Snate@binkert.org// used to determine the home directory 486145Snate@binkert.org// returns a value between 0 and total_directories_within_the_system 497039Snate@binkert.orginline MachineID 507039Snate@binkert.orgmap_Address_to_Directory(const Address &addr) 516145Snate@binkert.org{ 527039Snate@binkert.org MachineID mach = 537039Snate@binkert.org {MachineType_Directory, map_Address_to_DirectoryNode(addr)}; 547039Snate@binkert.org return mach; 556145Snate@binkert.org} 566145Snate@binkert.org 577039Snate@binkert.orginline NetDest 587039Snate@binkert.orgbroadcast(MachineType type) 596843Sdrh5@cs.wisc.edu{ 607039Snate@binkert.org NetDest dest; 6110005Snilay@cs.wisc.edu for (NodeID i = 0; i < MachineType_base_count(type); i++) { 627039Snate@binkert.org MachineID mach = {type, i}; 637039Snate@binkert.org dest.add(mach); 647039Snate@binkert.org } 657039Snate@binkert.org return dest; 666843Sdrh5@cs.wisc.edu} 676843Sdrh5@cs.wisc.edu 687039Snate@binkert.orginline MachineID 697039Snate@binkert.orgmapAddressToRange(const Address & addr, MachineType type, int low_bit, 7010005Snilay@cs.wisc.edu int num_bits, int cluster_id = 0) 716467Sdrh5@cs.wisc.edu{ 727039Snate@binkert.org MachineID mach = {type, 0}; 737039Snate@binkert.org if (num_bits == 0) 7410005Snilay@cs.wisc.edu mach.num = cluster_id; 7510005Snilay@cs.wisc.edu else 7610005Snilay@cs.wisc.edu mach.num = addr.bitSelect(low_bit, low_bit + num_bits - 1) 7710005Snilay@cs.wisc.edu + (1 << num_bits) * cluster_id; 786468Sdrh5@cs.wisc.edu return mach; 796467Sdrh5@cs.wisc.edu} 806467Sdrh5@cs.wisc.edu 817039Snate@binkert.orginline NodeID 827039Snate@binkert.orgmachineIDToNodeID(MachineID machID) 836145Snate@binkert.org{ 847039Snate@binkert.org return machID.num; 856145Snate@binkert.org} 866145Snate@binkert.org 877039Snate@binkert.orginline MachineType 887039Snate@binkert.orgmachineIDToMachineType(MachineID machID) 896145Snate@binkert.org{ 907039Snate@binkert.org return machID.type; 916145Snate@binkert.org} 926145Snate@binkert.org 937039Snate@binkert.orginline int 947039Snate@binkert.orgmachineCount(MachineType machType) 957039Snate@binkert.org{ 966926SBrad.Beckmann@amd.com return MachineType_base_count(machType); 976926SBrad.Beckmann@amd.com} 986145Snate@binkert.org 997039Snate@binkert.org#endif // __MEM_RUBY_SLICC_INTERFACE_COMPONENTMAPPINGS_HH__ 100