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/ruby/common/Address.hh"
3310301Snilay@cs.wisc.edu#include "mem/ruby/common/MachineID.hh"
347039Snate@binkert.org#include "mem/ruby/common/NetDest.hh"
3514184Sgabeblack@google.com#include "mem/ruby/protocol/MachineType.hh"
3610301Snilay@cs.wisc.edu#include "mem/ruby/structures/DirectoryMemory.hh"
376145Snate@binkert.org
387039Snate@binkert.orginline NetDest
397039Snate@binkert.orgbroadcast(MachineType type)
406843Sdrh5@cs.wisc.edu{
417039Snate@binkert.org    NetDest dest;
4210005Snilay@cs.wisc.edu    for (NodeID i = 0; i < MachineType_base_count(type); i++) {
437039Snate@binkert.org        MachineID mach = {type, i};
447039Snate@binkert.org        dest.add(mach);
457039Snate@binkert.org    }
467039Snate@binkert.org    return dest;
476843Sdrh5@cs.wisc.edu}
486843Sdrh5@cs.wisc.edu
497039Snate@binkert.orginline MachineID
5011025Snilay@cs.wisc.edumapAddressToRange(Addr addr, MachineType type, int low_bit,
5110005Snilay@cs.wisc.edu                  int num_bits, int cluster_id = 0)
526467Sdrh5@cs.wisc.edu{
537039Snate@binkert.org    MachineID mach = {type, 0};
547039Snate@binkert.org    if (num_bits == 0)
5510005Snilay@cs.wisc.edu        mach.num = cluster_id;
5610005Snilay@cs.wisc.edu    else
5711025Snilay@cs.wisc.edu        mach.num = bitSelect(addr, low_bit, low_bit + num_bits - 1)
5810005Snilay@cs.wisc.edu            + (1 << num_bits) * cluster_id;
596468Sdrh5@cs.wisc.edu    return mach;
606467Sdrh5@cs.wisc.edu}
616467Sdrh5@cs.wisc.edu
627039Snate@binkert.orginline NodeID
637039Snate@binkert.orgmachineIDToNodeID(MachineID machID)
646145Snate@binkert.org{
657039Snate@binkert.org    return machID.num;
666145Snate@binkert.org}
676145Snate@binkert.org
687039Snate@binkert.orginline MachineType
697039Snate@binkert.orgmachineIDToMachineType(MachineID machID)
706145Snate@binkert.org{
717039Snate@binkert.org    return machID.type;
726145Snate@binkert.org}
736145Snate@binkert.org
747039Snate@binkert.orginline int
757039Snate@binkert.orgmachineCount(MachineType machType)
767039Snate@binkert.org{
776926SBrad.Beckmann@amd.com    return MachineType_base_count(machType);
786926SBrad.Beckmann@amd.com}
796145Snate@binkert.org
8010008Snilay@cs.wisc.eduinline MachineID
8110008Snilay@cs.wisc.educreateMachineID(MachineType type, NodeID id)
8210008Snilay@cs.wisc.edu{
8310008Snilay@cs.wisc.edu    MachineID mach = {type, id};
8410008Snilay@cs.wisc.edu    return mach;
8510008Snilay@cs.wisc.edu}
8610008Snilay@cs.wisc.edu
8711308Santhony.gutierrez@amd.cominline MachineID
8811308Santhony.gutierrez@amd.comMachineTypeAndNodeIDToMachineID(MachineType type, NodeID node)
8911308Santhony.gutierrez@amd.com{
9011308Santhony.gutierrez@amd.com    MachineID mach = {type, node};
9111308Santhony.gutierrez@amd.com    return mach;
9211308Santhony.gutierrez@amd.com}
9311308Santhony.gutierrez@amd.com
947039Snate@binkert.org#endif  // __MEM_RUBY_SLICC_INTERFACE_COMPONENTMAPPINGS_HH__
95