1d0
<
30,32c29,30
< /*
< * $Id$
< */
---
> #ifndef __MEM_RUBY_COMMON_ADDRESS_HH__
> #define __MEM_RUBY_COMMON_ADDRESS_HH__
34,36d31
< #ifndef ADDRESS_H
< #define ADDRESS_H
<
41,42d35
< #include "mem/ruby/system/System.hh"
< #include "mem/ruby/system/NodeID.hh"
43a37,38
> #include "mem/ruby/system/NodeID.hh"
> #include "mem/ruby/system/System.hh"
51,55c46,51
< class Address {
< public:
< // Constructors
< Address() { m_address = 0; }
< explicit Address(physical_address_t address) { m_address = address; }
---
> class Address
> {
> public:
> Address()
> : m_address(0)
> { }
57,58c53,56
< Address(const Address& obj);
< Address& operator=(const Address& obj);
---
> explicit
> Address(physical_address_t address)
> : m_address(address)
> { }
60,61c58,59
< // Destructor
< // ~Address();
---
> Address(const Address& obj);
> Address& operator=(const Address& obj);
63c61,68
< // Public Methods
---
> void setAddress(physical_address_t address) { m_address = address; }
> physical_address_t getAddress() const {return m_address;}
> // selects bits inclusive
> physical_address_t bitSelect(int small, int big) const;
> physical_address_t bitRemove(int small, int big) const;
> physical_address_t maskLowOrderBits(int number) const;
> physical_address_t maskHighOrderBits(int number) const;
> physical_address_t shiftLowOrderBits(int number) const;
65,76c70,74
< void setAddress(physical_address_t address) { m_address = address; }
< physical_address_t getAddress() const {return m_address;}
< // selects bits inclusive
< physical_address_t bitSelect(int small, int big) const;
< physical_address_t bitRemove(int small, int big) const;
< physical_address_t maskLowOrderBits(int number) const;
< physical_address_t maskHighOrderBits(int number) const;
< physical_address_t shiftLowOrderBits(int number) const;
< physical_address_t getLineAddress() const
< { return bitSelect(RubySystem::getBlockSizeBits(), ADDRESS_WIDTH); }
< physical_address_t getOffset() const
< { return bitSelect(0, RubySystem::getBlockSizeBits()-1); }
---
> physical_address_t
> getLineAddress() const
> {
> return bitSelect(RubySystem::getBlockSizeBits(), ADDRESS_WIDTH);
> }
78,85c76,80
< void makeLineAddress() { m_address = maskLowOrderBits(RubySystem::getBlockSizeBits()); }
< // returns the next stride address based on line address
< void makeNextStrideAddress( int stride) {
< m_address = maskLowOrderBits(RubySystem::getBlockSizeBits())
< + RubySystem::getBlockSizeBytes()*stride;
< }
< int getBankSetNum() const;
< int getBankSetDist() const;
---
> physical_address_t
> getOffset() const
> {
> return bitSelect(0, RubySystem::getBlockSizeBits() - 1);
> }
87c82,86
< Index memoryModuleIndex() const;
---
> void
> makeLineAddress()
> {
> m_address = maskLowOrderBits(RubySystem::getBlockSizeBits());
> }
89,91c88,94
< void print(ostream& out) const;
< void output(ostream& out) const;
< void input(istream& in);
---
> // returns the next stride address based on line address
> void
> makeNextStrideAddress(int stride)
> {
> m_address = maskLowOrderBits(RubySystem::getBlockSizeBits())
> + RubySystem::getBlockSizeBytes()*stride;
> }
93,97c96,97
< void setOffset( int offset ){
< // first, zero out the offset bits
< makeLineAddress();
< m_address |= (physical_address_t) offset;
< }
---
> int getBankSetNum() const;
> int getBankSetDist() const;
99,100c99
< private:
< // Private Methods
---
> Index memoryModuleIndex() const;
102,104c101,103
< // Private copy constructor and assignment operator
< // Address(const Address& obj);
< // Address& operator=(const Address& obj);
---
> void print(ostream& out) const;
> void output(ostream& out) const;
> void input(istream& in);
106,107c105,114
< // Data Members (m_ prefix)
< physical_address_t m_address;
---
> void
> setOffset(int offset)
> {
> // first, zero out the offset bits
> makeLineAddress();
> m_address |= (physical_address_t) offset;
> }
>
> private:
> physical_address_t m_address;
110,111c117,123
< inline
< Address line_address(const Address& addr) { Address temp(addr); temp.makeLineAddress(); return temp; }
---
> inline Address
> line_address(const Address& addr)
> {
> Address temp(addr);
> temp.makeLineAddress();
> return temp;
> }
113,122c125,126
< // Output operator declaration
< ostream& operator<<(ostream& out, const Address& obj);
< // comparison operator declaration
< bool operator==(const Address& obj1, const Address& obj2);
< bool operator!=(const Address& obj1, const Address& obj2);
< bool operator<(const Address& obj1, const Address& obj2);
< /* Address& operator=(const physical_address_t address); */
<
< inline
< bool operator<(const Address& obj1, const Address& obj2)
---
> inline bool
> operator<(const Address& obj1, const Address& obj2)
124c128
< return obj1.getAddress() < obj2.getAddress();
---
> return obj1.getAddress() < obj2.getAddress();
127,131c131,132
< // ******************* Definitions *******************
<
< // Output operator definition
< inline
< ostream& operator<<(ostream& out, const Address& obj)
---
> inline ostream&
> operator<<(ostream& out, const Address& obj)
133,135c134,136
< obj.print(out);
< out << flush;
< return out;
---
> obj.print(out);
> out << flush;
> return out;
138,139c139,140
< inline
< bool operator==(const Address& obj1, const Address& obj2)
---
> inline bool
> operator==(const Address& obj1, const Address& obj2)
141c142
< return (obj1.getAddress() == obj2.getAddress());
---
> return (obj1.getAddress() == obj2.getAddress());
144,145c145,146
< inline
< bool operator!=(const Address& obj1, const Address& obj2)
---
> inline bool
> operator!=(const Address& obj1, const Address& obj2)
147c148
< return (obj1.getAddress() != obj2.getAddress());
---
> return (obj1.getAddress() != obj2.getAddress());
150,151c151,153
< inline
< physical_address_t Address::bitSelect(int small, int big) const // rips bits inclusive
---
> // rips bits inclusive
> inline physical_address_t
> Address::bitSelect(int small, int big) const
153,154c155,156
< physical_address_t mask;
< assert((unsigned)big >= (unsigned)small);
---
> physical_address_t mask;
> assert((unsigned)big >= (unsigned)small);
156,163c158,165
< if (big >= ADDRESS_WIDTH - 1) {
< return (m_address >> small);
< } else {
< mask = ~((physical_address_t)~0 << (big + 1));
< // FIXME - this is slow to manipulate a 64-bit number using 32-bits
< physical_address_t partial = (m_address & mask);
< return (partial >> small);
< }
---
> if (big >= ADDRESS_WIDTH - 1) {
> return (m_address >> small);
> } else {
> mask = ~((physical_address_t)~0 << (big + 1));
> // FIXME - this is slow to manipulate a 64-bit number using 32-bits
> physical_address_t partial = (m_address & mask);
> return (partial >> small);
> }
167,168c169,170
< inline
< physical_address_t Address::bitRemove(int small, int big) const
---
> inline physical_address_t
> Address::bitRemove(int small, int big) const
187d188
< //
189d189
< //
195,196c195,196
< inline
< physical_address_t Address::maskLowOrderBits(int number) const
---
> inline physical_address_t
> Address::maskLowOrderBits(int number) const
201c201
< mask = ~0;
---
> mask = ~0;
203c203
< mask = (physical_address_t)~0 << number;
---
> mask = (physical_address_t)~0 << number;
208,209c208,209
< inline
< physical_address_t Address::maskHighOrderBits(int number) const
---
> inline physical_address_t
> Address::maskHighOrderBits(int number) const
211c211
< physical_address_t mask;
---
> physical_address_t mask;
213,218c213,218
< if (number >= ADDRESS_WIDTH - 1) {
< mask = ~0;
< } else {
< mask = (physical_address_t)~0 >> number;
< }
< return (m_address & mask);
---
> if (number >= ADDRESS_WIDTH - 1) {
> mask = ~0;
> } else {
> mask = (physical_address_t)~0 >> number;
> }
> return (m_address & mask);
221,222c221,222
< inline
< physical_address_t Address::shiftLowOrderBits(int number) const
---
> inline physical_address_t
> Address::shiftLowOrderBits(int number) const
224c224
< return (m_address >> number);
---
> return (m_address >> number);
227,228c227,228
< inline
< integer_t Address::memoryModuleIndex() const
---
> inline integer_t
> Address::memoryModuleIndex() const
230,232c230,234
< integer_t index = bitSelect(RubySystem::getBlockSizeBits()+RubySystem::getMemorySizeBits(), ADDRESS_WIDTH);
< assert (index >= 0);
< return index;
---
> integer_t index =
> bitSelect(RubySystem::getBlockSizeBits() +
> RubySystem::getMemorySizeBits(), ADDRESS_WIDTH);
> assert (index >= 0);
> return index;
234,235c236,243
< // Index indexHighPortion = address.bitSelect(MEMORY_SIZE_BITS-1, PAGE_SIZE_BITS+NUMBER_OF_MEMORY_MODULE_BITS);
< // Index indexLowPortion = address.bitSelect(DATA_BLOCK_BITS, PAGE_SIZE_BITS-1);
---
> // Index indexHighPortion =
> // address.bitSelect(MEMORY_SIZE_BITS - 1,
> // PAGE_SIZE_BITS + NUMBER_OF_MEMORY_MODULE_BITS);
> // Index indexLowPortion =
> // address.bitSelect(DATA_BLOCK_BITS, PAGE_SIZE_BITS - 1);
> //
> // Index index = indexLowPortion |
> // (indexHighPortion << (PAGE_SIZE_BITS - DATA_BLOCK_BITS));
237c245,246
< //Index index = indexLowPortion | (indexHighPortion << (PAGE_SIZE_BITS - DATA_BLOCK_BITS));
---
> /*
> Round-robin mapping of addresses, at page size granularity
239,241d247
< /*
< Round-robin mapping of addresses, at page size granularity
<
252c258
< */
---
> */
255,256c261,262
< inline
< void Address::print(ostream& out) const
---
> inline void
> Address::print(ostream& out) const
259c265,267
< out << "[" << hex << "0x" << m_address << "," << " line 0x" << maskLowOrderBits(RubySystem::getBlockSizeBits()) << dec << "]" << flush;
---
> out << "[" << hex << "0x" << m_address << "," << " line 0x"
> << maskLowOrderBits(RubySystem::getBlockSizeBits()) << dec << "]"
> << flush;
264,268c272,281
< template <> struct hash<Address>
< {
< size_t operator()(const Address &s) const { return (size_t) s.getAddress(); }
< };
< }
---
> template <> struct hash<Address>
> {
> size_t
> operator()(const Address &s) const
> {
> return (size_t)s.getAddress();
> }
> };
> /* namespace __hash_namespace */ }
>
270,274c283,291
< template <> struct equal_to<Address>
< {
< bool operator()(const Address& s1, const Address& s2) const { return s1 == s2; }
< };
< }
---
> template <> struct equal_to<Address>
> {
> bool
> operator()(const Address& s1, const Address& s2) const
> {
> return s1 == s2;
> }
> };
> /* namespace std */ }
276,277c293
< #endif //ADDRESS_H
<
---
> #endif // __MEM_RUBY_COMMON_ADDRESS_HH__