RubySlicc_ComponentMapping.hh revision 11025
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" 3410301Snilay@cs.wisc.edu#include "mem/ruby/common/MachineID.hh" 357039Snate@binkert.org#include "mem/ruby/common/NetDest.hh" 3610301Snilay@cs.wisc.edu#include "mem/ruby/structures/DirectoryMemory.hh" 376145Snate@binkert.org 386145Snate@binkert.org// used to determine the home directory 396145Snate@binkert.org// returns a value between 0 and total_directories_within_the_system 407039Snate@binkert.orginline NodeID 4111025Snilay@cs.wisc.edumap_Address_to_DirectoryNode(Addr addr) 426145Snate@binkert.org{ 437039Snate@binkert.org return DirectoryMemory::mapAddressToDirectoryVersion(addr); 446145Snate@binkert.org} 456145Snate@binkert.org 466145Snate@binkert.org// used to determine the home directory 476145Snate@binkert.org// returns a value between 0 and total_directories_within_the_system 487039Snate@binkert.orginline MachineID 4911025Snilay@cs.wisc.edumap_Address_to_Directory(Addr addr) 506145Snate@binkert.org{ 517039Snate@binkert.org MachineID mach = 527039Snate@binkert.org {MachineType_Directory, map_Address_to_DirectoryNode(addr)}; 537039Snate@binkert.org return mach; 546145Snate@binkert.org} 556145Snate@binkert.org 567039Snate@binkert.orginline NetDest 577039Snate@binkert.orgbroadcast(MachineType type) 586843Sdrh5@cs.wisc.edu{ 597039Snate@binkert.org NetDest dest; 6010005Snilay@cs.wisc.edu for (NodeID i = 0; i < MachineType_base_count(type); i++) { 617039Snate@binkert.org MachineID mach = {type, i}; 627039Snate@binkert.org dest.add(mach); 637039Snate@binkert.org } 647039Snate@binkert.org return dest; 656843Sdrh5@cs.wisc.edu} 666843Sdrh5@cs.wisc.edu 677039Snate@binkert.orginline MachineID 6811025Snilay@cs.wisc.edumapAddressToRange(Addr addr, MachineType type, int low_bit, 6910005Snilay@cs.wisc.edu int num_bits, int cluster_id = 0) 706467Sdrh5@cs.wisc.edu{ 717039Snate@binkert.org MachineID mach = {type, 0}; 727039Snate@binkert.org if (num_bits == 0) 7310005Snilay@cs.wisc.edu mach.num = cluster_id; 7410005Snilay@cs.wisc.edu else 7511025Snilay@cs.wisc.edu mach.num = bitSelect(addr, low_bit, low_bit + num_bits - 1) 7610005Snilay@cs.wisc.edu + (1 << num_bits) * cluster_id; 776468Sdrh5@cs.wisc.edu return mach; 786467Sdrh5@cs.wisc.edu} 796467Sdrh5@cs.wisc.edu 807039Snate@binkert.orginline NodeID 817039Snate@binkert.orgmachineIDToNodeID(MachineID machID) 826145Snate@binkert.org{ 837039Snate@binkert.org return machID.num; 846145Snate@binkert.org} 856145Snate@binkert.org 867039Snate@binkert.orginline MachineType 877039Snate@binkert.orgmachineIDToMachineType(MachineID machID) 886145Snate@binkert.org{ 897039Snate@binkert.org return machID.type; 906145Snate@binkert.org} 916145Snate@binkert.org 927039Snate@binkert.orginline int 937039Snate@binkert.orgmachineCount(MachineType machType) 947039Snate@binkert.org{ 956926SBrad.Beckmann@amd.com return MachineType_base_count(machType); 966926SBrad.Beckmann@amd.com} 976145Snate@binkert.org 9810008Snilay@cs.wisc.eduinline MachineID 9910008Snilay@cs.wisc.educreateMachineID(MachineType type, NodeID id) 10010008Snilay@cs.wisc.edu{ 10110008Snilay@cs.wisc.edu MachineID mach = {type, id}; 10210008Snilay@cs.wisc.edu return mach; 10310008Snilay@cs.wisc.edu} 10410008Snilay@cs.wisc.edu 1057039Snate@binkert.org#endif // __MEM_RUBY_SLICC_INTERFACE_COMPONENTMAPPINGS_HH__ 106