RubySlicc_ComponentMapping.hh (6926:775342cda4db) RubySlicc_ComponentMapping.hh (7039:bc0b6ea676b5)
1
2/*
3 * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met: redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer;

--- 12 unchanged lines hidden (view full) ---

22 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29
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;

--- 12 unchanged lines hidden (view full) ---

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
30/*
31 * $Id$
32 */
29#ifndef __MEM_RUBY_SLICC_INTERFACE_RUBYSLICC_COMPONENTMAPPINGS_HH__
30#define __MEM_RUBY_SLICC_INTERFACE_RUBYSLICC_COMPONENTMAPPINGS_HH__
33
31
34#ifndef COMPONENTMAPPINGFNS_H
35#define COMPONENTMAPPINGFNS_H
36
37#include "mem/ruby/common/Global.hh"
38#include "mem/ruby/system/NodeID.hh"
39#include "mem/ruby/system/MachineID.hh"
32#include "mem/protocol/GenericMachineType.hh"
33#include "mem/protocol/MachineType.hh"
40#include "mem/ruby/common/Address.hh"
34#include "mem/ruby/common/Address.hh"
41#include "mem/ruby/common/Set.hh"
35#include "mem/ruby/common/Global.hh"
42#include "mem/ruby/common/NetDest.hh"
36#include "mem/ruby/common/NetDest.hh"
43#include "mem/protocol/GenericMachineType.hh"
37#include "mem/ruby/common/Set.hh"
44#include "mem/ruby/system/DirectoryMemory.hh"
38#include "mem/ruby/system/DirectoryMemory.hh"
45#include "mem/protocol/MachineType.hh"
39#include "mem/ruby/system/MachineID.hh"
40#include "mem/ruby/system/NodeID.hh"
46
47#ifdef MACHINETYPE_L1Cache
48#define MACHINETYPE_L1CACHE_ENUM MachineType_L1Cache
49#else
50#define MACHINETYPE_L1CACHE_ENUM MachineType_NUM
51#endif
52
53#ifdef MACHINETYPE_L2Cache

--- 11 unchanged lines hidden (view full) ---

65#ifdef MACHINETYPE_DMA
66#define MACHINETYPE_DMA_ENUM MachineType_DMA
67#else
68#define MACHINETYPE_DMA_ENUM MachineType_NUM
69#endif
70
71// used to determine the home directory
72// returns a value between 0 and total_directories_within_the_system
41
42#ifdef MACHINETYPE_L1Cache
43#define MACHINETYPE_L1CACHE_ENUM MachineType_L1Cache
44#else
45#define MACHINETYPE_L1CACHE_ENUM MachineType_NUM
46#endif
47
48#ifdef MACHINETYPE_L2Cache

--- 11 unchanged lines hidden (view full) ---

60#ifdef MACHINETYPE_DMA
61#define MACHINETYPE_DMA_ENUM MachineType_DMA
62#else
63#define MACHINETYPE_DMA_ENUM MachineType_NUM
64#endif
65
66// used to determine the home directory
67// returns a value between 0 and total_directories_within_the_system
73inline
74NodeID map_Address_to_DirectoryNode(const Address& addr)
68inline NodeID
69map_Address_to_DirectoryNode(const Address& addr)
75{
70{
76 return DirectoryMemory::mapAddressToDirectoryVersion(addr);
71 return DirectoryMemory::mapAddressToDirectoryVersion(addr);
77}
78
79// used to determine the home directory
80// returns a value between 0 and total_directories_within_the_system
72}
73
74// used to determine the home directory
75// returns a value between 0 and total_directories_within_the_system
81inline
82MachineID map_Address_to_Directory(const Address &addr)
76inline MachineID
77map_Address_to_Directory(const Address &addr)
83{
78{
84 MachineID mach = {MachineType_Directory, map_Address_to_DirectoryNode(addr)};
85 return mach;
79 MachineID mach =
80 {MachineType_Directory, map_Address_to_DirectoryNode(addr)};
81 return mach;
86}
87
82}
83
88inline
89MachineID map_Address_to_DMA(const Address & addr)
84inline MachineID
85map_Address_to_DMA(const Address & addr)
90{
86{
91 MachineID dma = {MACHINETYPE_DMA_ENUM, 0};
92 return dma;
87 MachineID dma = {MACHINETYPE_DMA_ENUM, 0};
88 return dma;
93}
94
89}
90
95inline
96NetDest broadcast(MachineType type)
91inline NetDest
92broadcast(MachineType type)
97{
93{
98 NetDest dest;
99 for (int i=0; i<MachineType_base_count(type); i++) {
100 MachineID mach = {type, i};
101 dest.add(mach);
102 }
103 return dest;
94 NetDest dest;
95 for (int i = 0; i < MachineType_base_count(type); i++) {
96 MachineID mach = {type, i};
97 dest.add(mach);
98 }
99 return dest;
104}
105
100}
101
106inline
107MachineID mapAddressToRange(const Address & addr, MachineType type, int low_bit, int num_bits)
102inline MachineID
103mapAddressToRange(const Address & addr, MachineType type, int low_bit,
104 int num_bits)
108{
105{
109 MachineID mach = {type, 0};
110 if (num_bits == 0)
106 MachineID mach = {type, 0};
107 if (num_bits == 0)
108 return mach;
109 mach.num = addr.bitSelect(low_bit, low_bit + num_bits - 1);
111 return mach;
110 return mach;
112 mach.num = addr.bitSelect(low_bit, low_bit+num_bits-1);
113 return mach;
114}
115
111}
112
116extern inline NodeID machineIDToNodeID(MachineID machID)
113inline NodeID
114machineIDToNodeID(MachineID machID)
117{
115{
118 return machID.num;
116 return machID.num;
119}
120
117}
118
121extern inline MachineType machineIDToMachineType(MachineID machID)
119inline MachineType
120machineIDToMachineType(MachineID machID)
122{
121{
123 return machID.type;
122 return machID.type;
124}
125
123}
124
126extern inline NodeID L1CacheMachIDToProcessorNum(MachineID machID)
125inline NodeID
126L1CacheMachIDToProcessorNum(MachineID machID)
127{
127{
128 assert(machID.type == MachineType_L1Cache);
129 return machID.num;
128 assert(machID.type == MachineType_L1Cache);
129 return machID.num;
130}
131
130}
131
132extern inline MachineID getL1MachineID(NodeID L1RubyNode)
132inline MachineID
133getL1MachineID(NodeID L1RubyNode)
133{
134{
134 MachineID mach = {MACHINETYPE_L1CACHE_ENUM, L1RubyNode};
135 return mach;
135 MachineID mach = {MACHINETYPE_L1CACHE_ENUM, L1RubyNode};
136 return mach;
136}
137
137}
138
138extern inline GenericMachineType ConvertMachToGenericMach(MachineType machType) {
139 if (machType == MACHINETYPE_L1CACHE_ENUM) {
140 return GenericMachineType_L1Cache;
141 } else if (machType == MACHINETYPE_L2CACHE_ENUM) {
142 return GenericMachineType_L2Cache;
143 } else if (machType == MACHINETYPE_L3CACHE_ENUM) {
144 return GenericMachineType_L3Cache;
145 } else if (machType == MachineType_Directory) {
146 return GenericMachineType_Directory;
147 } else {
139inline GenericMachineType
140ConvertMachToGenericMach(MachineType machType)
141{
142 if (machType == MACHINETYPE_L1CACHE_ENUM)
143 return GenericMachineType_L1Cache;
144
145 if (machType == MACHINETYPE_L2CACHE_ENUM)
146 return GenericMachineType_L2Cache;
147
148 if (machType == MACHINETYPE_L3CACHE_ENUM)
149 return GenericMachineType_L3Cache;
150
151 if (machType == MachineType_Directory)
152 return GenericMachineType_Directory;
153
148 ERROR_MSG("cannot convert to a GenericMachineType");
149 return GenericMachineType_NULL;
154 ERROR_MSG("cannot convert to a GenericMachineType");
155 return GenericMachineType_NULL;
150 }
151}
152
156}
157
153extern inline int machineCount(MachineType machType) {
158inline int
159machineCount(MachineType machType)
160{
154 return MachineType_base_count(machType);
155}
156
161 return MachineType_base_count(machType);
162}
163
157#endif // COMPONENTMAPPINGFNS_H
164#endif // __MEM_RUBY_SLICC_INTERFACE_COMPONENTMAPPINGS_HH__