RubySlicc_ComponentMapping.hh revision 10301:44839e8febbd
1955SN/A/*
2955SN/A * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
31762SN/A * All rights reserved.
4955SN/A *
5955SN/A * Redistribution and use in source and binary forms, with or without
6955SN/A * modification, are permitted provided that the following conditions are
7955SN/A * met: redistributions of source code must retain the above copyright
8955SN/A * notice, this list of conditions and the following disclaimer;
9955SN/A * redistributions in binary form must reproduce the above copyright
10955SN/A * notice, this list of conditions and the following disclaimer in the
11955SN/A * documentation and/or other materials provided with the distribution;
12955SN/A * neither the name of the copyright holders nor the names of its
13955SN/A * contributors may be used to endorse or promote products derived from
14955SN/A * this software without specific prior written permission.
15955SN/A *
16955SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17955SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18955SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19955SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20955SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21955SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22955SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23955SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24955SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25955SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26955SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27955SN/A */
282665Ssaidi@eecs.umich.edu
294762Snate@binkert.org#ifndef __MEM_RUBY_SLICC_INTERFACE_RUBYSLICC_COMPONENTMAPPINGS_HH__
30955SN/A#define __MEM_RUBY_SLICC_INTERFACE_RUBYSLICC_COMPONENTMAPPINGS_HH__
315522Snate@binkert.org
326143Snate@binkert.org#include "mem/protocol/MachineType.hh"
334762Snate@binkert.org#include "mem/ruby/common/Address.hh"
345522Snate@binkert.org#include "mem/ruby/common/MachineID.hh"
35955SN/A#include "mem/ruby/common/NetDest.hh"
365522Snate@binkert.org#include "mem/ruby/structures/DirectoryMemory.hh"
37955SN/A
385522Snate@binkert.org// used to determine the home directory
394202Sbinkertn@umich.edu// returns a value between 0 and total_directories_within_the_system
405742Snate@binkert.orginline NodeID
41955SN/Amap_Address_to_DirectoryNode(const Address& addr)
424381Sbinkertn@umich.edu{
434381Sbinkertn@umich.edu    return DirectoryMemory::mapAddressToDirectoryVersion(addr);
44955SN/A}
45955SN/A
46955SN/A// used to determine the home directory
474202Sbinkertn@umich.edu// returns a value between 0 and total_directories_within_the_system
48955SN/Ainline MachineID
494382Sbinkertn@umich.edumap_Address_to_Directory(const Address &addr)
504382Sbinkertn@umich.edu{
514382Sbinkertn@umich.edu    MachineID mach =
526654Snate@binkert.org        {MachineType_Directory, map_Address_to_DirectoryNode(addr)};
535517Snate@binkert.org    return mach;
546143Snate@binkert.org}
556143Snate@binkert.org
566143Snate@binkert.orginline NetDest
576143Snate@binkert.orgbroadcast(MachineType type)
586143Snate@binkert.org{
596143Snate@binkert.org    NetDest dest;
606143Snate@binkert.org    for (NodeID i = 0; i < MachineType_base_count(type); i++) {
616143Snate@binkert.org        MachineID mach = {type, i};
626143Snate@binkert.org        dest.add(mach);
636143Snate@binkert.org    }
646143Snate@binkert.org    return dest;
656143Snate@binkert.org}
666143Snate@binkert.org
676143Snate@binkert.orginline MachineID
686143Snate@binkert.orgmapAddressToRange(const Address & addr, MachineType type, int low_bit,
694762Snate@binkert.org                  int num_bits, int cluster_id = 0)
706143Snate@binkert.org{
716143Snate@binkert.org    MachineID mach = {type, 0};
726143Snate@binkert.org    if (num_bits == 0)
736143Snate@binkert.org        mach.num = cluster_id;
746143Snate@binkert.org    else
756143Snate@binkert.org        mach.num = addr.bitSelect(low_bit, low_bit + num_bits - 1)
766143Snate@binkert.org            + (1 << num_bits) * cluster_id;
776143Snate@binkert.org    return mach;
786143Snate@binkert.org}
796143Snate@binkert.org
806143Snate@binkert.orginline NodeID
816143Snate@binkert.orgmachineIDToNodeID(MachineID machID)
826143Snate@binkert.org{
836143Snate@binkert.org    return machID.num;
846143Snate@binkert.org}
856143Snate@binkert.org
866143Snate@binkert.orginline MachineType
876143Snate@binkert.orgmachineIDToMachineType(MachineID machID)
886143Snate@binkert.org{
896143Snate@binkert.org    return machID.type;
906143Snate@binkert.org}
916143Snate@binkert.org
926143Snate@binkert.orginline int
936143Snate@binkert.orgmachineCount(MachineType machType)
946143Snate@binkert.org{
956143Snate@binkert.org    return MachineType_base_count(machType);
966143Snate@binkert.org}
976143Snate@binkert.org
986143Snate@binkert.orginline MachineID
996143Snate@binkert.orgcreateMachineID(MachineType type, NodeID id)
1006143Snate@binkert.org{
1016143Snate@binkert.org    MachineID mach = {type, id};
1026143Snate@binkert.org    return mach;
1036143Snate@binkert.org}
1046143Snate@binkert.org
1056143Snate@binkert.org#endif  // __MEM_RUBY_SLICC_INTERFACE_COMPONENTMAPPINGS_HH__
1066143Snate@binkert.org