Address.hh (7811:a8fc35183c10) Address.hh (8091:04078b1214dd)
1/*
2 * Copyright (c) 1999 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;

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

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
29#ifndef __MEM_RUBY_COMMON_ADDRESS_HH__
30#define __MEM_RUBY_COMMON_ADDRESS_HH__
31
1/*
2 * Copyright (c) 1999 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;

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

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
29#ifndef __MEM_RUBY_COMMON_ADDRESS_HH__
30#define __MEM_RUBY_COMMON_ADDRESS_HH__
31
32#include <cassert>
32#include <iomanip>
33
34#include "base/hashmap.hh"
35#include "mem/ruby/common/Global.hh"
36#include "mem/ruby/system/MachineID.hh"
37#include "mem/ruby/system/NodeID.hh"
33#include <iomanip>
34
35#include "base/hashmap.hh"
36#include "mem/ruby/common/Global.hh"
37#include "mem/ruby/system/MachineID.hh"
38#include "mem/ruby/system/NodeID.hh"
38#include "mem/ruby/system/System.hh"
39
40const int ADDRESS_WIDTH = 64; // address width in bytes
41
42class Address;
43typedef Address PhysAddress;
44typedef Address VirtAddress;
45
46class Address

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

62 physical_address_t getAddress() const {return m_address;}
63 // selects bits inclusive
64 physical_address_t bitSelect(int small, int big) const;
65 physical_address_t bitRemove(int small, int big) const;
66 physical_address_t maskLowOrderBits(int number) const;
67 physical_address_t maskHighOrderBits(int number) const;
68 physical_address_t shiftLowOrderBits(int number) const;
69
39
40const int ADDRESS_WIDTH = 64; // address width in bytes
41
42class Address;
43typedef Address PhysAddress;
44typedef Address VirtAddress;
45
46class Address

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

62 physical_address_t getAddress() const {return m_address;}
63 // selects bits inclusive
64 physical_address_t bitSelect(int small, int big) const;
65 physical_address_t bitRemove(int small, int big) const;
66 physical_address_t maskLowOrderBits(int number) const;
67 physical_address_t maskHighOrderBits(int number) const;
68 physical_address_t shiftLowOrderBits(int number) const;
69
70 physical_address_t
71 getLineAddress() const
72 {
73 return bitSelect(RubySystem::getBlockSizeBits(), ADDRESS_WIDTH);
74 }
70 physical_address_t getLineAddress() const;
71 physical_address_t getOffset() const;
72 void makeLineAddress();
73 void makeNextStrideAddress(int stride);
75
74
76 physical_address_t
77 getOffset() const
78 {
79 return bitSelect(0, RubySystem::getBlockSizeBits() - 1);
80 }
81
82 void
83 makeLineAddress()
84 {
85 m_address = maskLowOrderBits(RubySystem::getBlockSizeBits());
86 }
87
88 // returns the next stride address based on line address
89 void
90 makeNextStrideAddress(int stride)
91 {
92 m_address = maskLowOrderBits(RubySystem::getBlockSizeBits())
93 + RubySystem::getBlockSizeBytes()*stride;
94 }
95
96 int getBankSetNum() const;
97 int getBankSetDist() const;
98
99 Index memoryModuleIndex() const;
100
101 void print(std::ostream& out) const;
102 void output(std::ostream& out) const;
103 void input(std::istream& in);

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

219}
220
221inline physical_address_t
222Address::shiftLowOrderBits(int number) const
223{
224 return (m_address >> number);
225}
226
75 int getBankSetNum() const;
76 int getBankSetDist() const;
77
78 Index memoryModuleIndex() const;
79
80 void print(std::ostream& out) const;
81 void output(std::ostream& out) const;
82 void input(std::istream& in);

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

198}
199
200inline physical_address_t
201Address::shiftLowOrderBits(int number) const
202{
203 return (m_address >> number);
204}
205
227inline integer_t
228Address::memoryModuleIndex() const
229{
230 integer_t index =
231 bitSelect(RubySystem::getBlockSizeBits() +
232 RubySystem::getMemorySizeBits(), ADDRESS_WIDTH);
233 assert (index >= 0);
234 return index;
235
236 // Index indexHighPortion =
237 // address.bitSelect(MEMORY_SIZE_BITS - 1,
238 // PAGE_SIZE_BITS + NUMBER_OF_MEMORY_MODULE_BITS);
239 // Index indexLowPortion =
240 // address.bitSelect(DATA_BLOCK_BITS, PAGE_SIZE_BITS - 1);
241 //
242 // Index index = indexLowPortion |
243 // (indexHighPortion << (PAGE_SIZE_BITS - DATA_BLOCK_BITS));
244
245 /*
246 Round-robin mapping of addresses, at page size granularity
247
248ADDRESS_WIDTH MEMORY_SIZE_BITS PAGE_SIZE_BITS DATA_BLOCK_BITS
249 | | | |
250 \ / \ / \ / \ / 0
251 -----------------------------------------------------------------------
252 | unused |xxxxxxxxxxxxxxx| |xxxxxxxxxxxxxxx| |
253 | |xxxxxxxxxxxxxxx| |xxxxxxxxxxxxxxx| |
254 -----------------------------------------------------------------------
255 indexHighPortion indexLowPortion
256 <------->
257 NUMBER_OF_MEMORY_MODULE_BITS
258 */
259}
260
261inline void
262Address::print(std::ostream& out) const
263{
264 using namespace std;
265 out << "[" << hex << "0x" << m_address << "," << " line 0x"
266 << maskLowOrderBits(RubySystem::getBlockSizeBits()) << dec << "]"
267 << flush;
268}
269
270class Address;
271namespace __hash_namespace {
272template <> struct hash<Address>
273{
274 size_t
275 operator()(const Address &s) const
276 {
277 return (size_t)s.getAddress();

--- 16 unchanged lines hidden ---
206class Address;
207namespace __hash_namespace {
208template <> struct hash<Address>
209{
210 size_t
211 operator()(const Address &s) const
212 {
213 return (size_t)s.getAddress();

--- 16 unchanged lines hidden ---