summaryrefslogtreecommitdiff
path: root/src/mem/ruby/common/Address.hh
diff options
context:
space:
mode:
authorNilay Vaish <nilay@cs.wisc.edu>2015-08-14 12:04:51 -0500
committerNilay Vaish <nilay@cs.wisc.edu>2015-08-14 12:04:51 -0500
commit91a84c5b3cfb888794ac0245c066a4724b9a0871 (patch)
tree79a8b41aff56655dbd187934d2709fdd7488c6ed /src/mem/ruby/common/Address.hh
parent9ea5d9cad9381e05004de28ef25309ebe94c3a79 (diff)
downloadgem5-91a84c5b3cfb888794ac0245c066a4724b9a0871.tar.xz
ruby: replace Address by Addr
This patch eliminates the type Address defined by the ruby memory system. This memory system would now use the type Addr that is in use by the rest of the system.
Diffstat (limited to 'src/mem/ruby/common/Address.hh')
-rw-r--r--src/mem/ruby/common/Address.hh195
1 files changed, 10 insertions, 185 deletions
diff --git a/src/mem/ruby/common/Address.hh b/src/mem/ruby/common/Address.hh
index d47ff9ac5..6210baa5c 100644
--- a/src/mem/ruby/common/Address.hh
+++ b/src/mem/ruby/common/Address.hh
@@ -34,193 +34,18 @@
#include <iostream>
#include "base/hashmap.hh"
-#include "mem/ruby/common/TypeDefines.hh"
+#include "base/types.hh"
const uint32_t ADDRESS_WIDTH = 64; // address width in bytes
-class Address;
-typedef Address PhysAddress;
-typedef Address VirtAddress;
-
-class Address
-{
- public:
- Address()
- : m_address(0)
- { }
-
- explicit
- Address(physical_address_t address)
- : m_address(address)
- { }
-
- Address(const Address& obj);
- Address& operator=(const Address& obj);
-
- void setAddress(physical_address_t address) { m_address = address; }
- physical_address_t getAddress() const {return m_address;}
- // selects bits inclusive
- physical_address_t bitSelect(unsigned int small, unsigned int big) const;
- physical_address_t bitRemove(unsigned int small, unsigned int big) const;
- physical_address_t maskLowOrderBits(unsigned int number) const;
- physical_address_t maskHighOrderBits(unsigned int number) const;
- physical_address_t shiftLowOrderBits(unsigned int number) const;
-
- physical_address_t getLineAddress() const;
- physical_address_t getOffset() const;
- void makeLineAddress();
- void makeNextStrideAddress(int stride);
-
- int64 memoryModuleIndex() const;
-
- void print(std::ostream& out) const;
- void output(std::ostream& out) const;
- void input(std::istream& in);
-
- void
- setOffset(int offset)
- {
- // first, zero out the offset bits
- makeLineAddress();
- m_address |= (physical_address_t) offset;
- }
-
- private:
- physical_address_t m_address;
-};
-
-inline Address
-line_address(const Address& addr)
-{
- Address temp(addr);
- temp.makeLineAddress();
- return temp;
-}
-
-inline bool
-operator<(const Address& obj1, const Address& obj2)
-{
- return obj1.getAddress() < obj2.getAddress();
-}
-
-inline std::ostream&
-operator<<(std::ostream& out, const Address& obj)
-{
- obj.print(out);
- out << std::flush;
- return out;
-}
-
-inline bool
-operator==(const Address& obj1, const Address& obj2)
-{
- return (obj1.getAddress() == obj2.getAddress());
-}
-
-inline bool
-operator!=(const Address& obj1, const Address& obj2)
-{
- return (obj1.getAddress() != obj2.getAddress());
-}
-
-// rips bits inclusive
-inline physical_address_t
-Address::bitSelect(unsigned int small, unsigned int big) const
-{
- physical_address_t mask;
- assert(big >= 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);
- }
-}
-
-// removes bits inclusive
-inline physical_address_t
-Address::bitRemove(unsigned int small, unsigned int big) const
-{
- physical_address_t mask;
- assert(big >= small);
-
- if (small >= ADDRESS_WIDTH - 1) {
- return m_address;
- } else if (big >= ADDRESS_WIDTH - 1) {
- mask = (physical_address_t)~0 >> small;
- return (m_address & mask);
- } else if (small == 0) {
- mask = (physical_address_t)~0 << big;
- return (m_address & mask);
- } else {
- mask = ~((physical_address_t)~0 << small);
- physical_address_t lower_bits = m_address & mask;
- mask = (physical_address_t)~0 << (big + 1);
- physical_address_t higher_bits = m_address & mask;
-
- // Shift the valid high bits over the removed section
- higher_bits = higher_bits >> (big - small + 1);
- return (higher_bits | lower_bits);
- }
-}
-
-inline physical_address_t
-Address::maskLowOrderBits(unsigned int number) const
-{
- physical_address_t mask;
-
- if (number >= ADDRESS_WIDTH - 1) {
- mask = ~0;
- } else {
- mask = (physical_address_t)~0 << number;
- }
- return (m_address & mask);
-}
-
-inline physical_address_t
-Address::maskHighOrderBits(unsigned int number) const
-{
- physical_address_t mask;
-
- if (number >= ADDRESS_WIDTH - 1) {
- mask = ~0;
- } else {
- mask = (physical_address_t)~0 >> number;
- }
- return (m_address & mask);
-}
-
-inline physical_address_t
-Address::shiftLowOrderBits(unsigned int number) const
-{
- return (m_address >> number);
-}
-
-Address next_stride_address(const Address& addr, int stride);
-
-__hash_namespace_begin
-template <> struct hash<Address>
-{
- size_t
- operator()(const Address &s) const
- {
- return (size_t)s.getAddress();
- }
-};
-__hash_namespace_end
-
-namespace std {
-template <> struct equal_to<Address>
-{
- bool
- operator()(const Address& s1, const Address& s2) const
- {
- return s1 == s2;
- }
-};
-} // namespace std
+// selects bits inclusive
+Addr bitSelect(Addr addr, unsigned int small, unsigned int big);
+Addr bitRemove(Addr addr, unsigned int small, unsigned int big);
+Addr maskLowOrderBits(Addr addr, unsigned int number);
+Addr maskHighOrderBits(Addr addr, unsigned int number);
+Addr shiftLowOrderBits(Addr addr, unsigned int number);
+Addr getOffset(Addr addr);
+Addr makeLineAddress(Addr addr);
+Addr makeNextStrideAddress(Addr addr, int stride);
#endif // __MEM_RUBY_COMMON_ADDRESS_HH__