diff options
Diffstat (limited to 'src/mem/ruby/common')
-rw-r--r-- | src/mem/ruby/common/Address.hh | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/mem/ruby/common/Address.hh b/src/mem/ruby/common/Address.hh index 44dff7d83..7da5ed0fe 100644 --- a/src/mem/ruby/common/Address.hh +++ b/src/mem/ruby/common/Address.hh @@ -66,6 +66,7 @@ public: 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; @@ -162,6 +163,35 @@ physical_address_t Address::bitSelect(int small, int big) const // rips bits inc } } +// removes bits inclusive +inline +physical_address_t Address::bitRemove(int small, int big) const +{ + physical_address_t mask; + assert((unsigned)big >= (unsigned)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); + return (higher_bits | lower_bits); + } +} + inline physical_address_t Address::maskLowOrderBits(int number) const { |