Address.cc (7055:4e24742201d7) | Address.cc (8091:04078b1214dd) |
---|---|
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; --- 13 unchanged lines hidden (view full) --- 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 29#include "mem/ruby/common/Address.hh" | 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; --- 13 unchanged lines hidden (view full) --- 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 29#include "mem/ruby/common/Address.hh" |
30#include "mem/ruby/system/System.hh" |
|
30 | 31 |
32physical_address_t 33Address::getLineAddress() const 34{ 35 return bitSelect(RubySystem::getBlockSizeBits(), ADDRESS_WIDTH); 36} 37 38physical_address_t 39Address::getOffset() const 40{ 41 return bitSelect(0, RubySystem::getBlockSizeBits() - 1); 42} 43 |
|
31void | 44void |
45Address::makeLineAddress() 46{ 47 m_address = maskLowOrderBits(RubySystem::getBlockSizeBits()); 48} 49 50// returns the next stride address based on line address 51void 52Address::makeNextStrideAddress(int stride) 53{ 54 m_address = maskLowOrderBits(RubySystem::getBlockSizeBits()) 55 + RubySystem::getBlockSizeBytes()*stride; 56} 57 58integer_t 59Address::memoryModuleIndex() const 60{ 61 integer_t index = 62 bitSelect(RubySystem::getBlockSizeBits() + 63 RubySystem::getMemorySizeBits(), ADDRESS_WIDTH); 64 assert (index >= 0); 65 return index; 66 67 // Index indexHighPortion = 68 // address.bitSelect(MEMORY_SIZE_BITS - 1, 69 // PAGE_SIZE_BITS + NUMBER_OF_MEMORY_MODULE_BITS); 70 // Index indexLowPortion = 71 // address.bitSelect(DATA_BLOCK_BITS, PAGE_SIZE_BITS - 1); 72 // 73 // Index index = indexLowPortion | 74 // (indexHighPortion << (PAGE_SIZE_BITS - DATA_BLOCK_BITS)); 75 76 /* 77 Round-robin mapping of addresses, at page size granularity 78 79ADDRESS_WIDTH MEMORY_SIZE_BITS PAGE_SIZE_BITS DATA_BLOCK_BITS 80 | | | | 81 \ / \ / \ / \ / 0 82 ----------------------------------------------------------------------- 83 | unused |xxxxxxxxxxxxxxx| |xxxxxxxxxxxxxxx| | 84 | |xxxxxxxxxxxxxxx| |xxxxxxxxxxxxxxx| | 85 ----------------------------------------------------------------------- 86 indexHighPortion indexLowPortion 87 <-------> 88 NUMBER_OF_MEMORY_MODULE_BITS 89 */ 90} 91 92void 93Address::print(std::ostream& out) const 94{ 95 using namespace std; 96 out << "[" << hex << "0x" << m_address << "," << " line 0x" 97 << maskLowOrderBits(RubySystem::getBlockSizeBits()) << dec << "]" 98 << flush; 99} 100 101void |
|
32Address::output(std::ostream& out) const 33{ 34 // Note: this outputs addresses in the form "ffff", not "0xffff". 35 // This code should always be able to write out addresses in a 36 // format that can be read in by the below input() method. Please 37 // don't change this without talking to Milo first. 38 out << std::hex << m_address << std::dec; 39} --- 27 unchanged lines hidden --- | 102Address::output(std::ostream& out) const 103{ 104 // Note: this outputs addresses in the form "ffff", not "0xffff". 105 // This code should always be able to write out addresses in a 106 // format that can be read in by the below input() method. Please 107 // don't change this without talking to Milo first. 108 out << std::hex << m_address << std::dec; 109} --- 27 unchanged lines hidden --- |