d3f67886369d44d276b0f0a2861e6608601abcf8
2 * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
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;
9 * redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution;
12 * neither the name of the copyright holders nor the names of its
13 * contributors may be used to endorse or promote products derived from
14 * this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
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.
29 #include "mem/ruby/common/Address.hh"
30 #include "mem/ruby/system/System.hh"
33 Address::getLineAddress() const
35 return bitSelect(RubySystem::getBlockSizeBits(), ADDRESS_WIDTH
);
39 Address::getOffset() const
41 return bitSelect(0, RubySystem::getBlockSizeBits() - 1);
45 Address::makeLineAddress()
47 m_address
= maskLowOrderBits(RubySystem::getBlockSizeBits());
50 // returns the next stride address based on line address
52 Address::makeNextStrideAddress(int stride
)
54 m_address
= maskLowOrderBits(RubySystem::getBlockSizeBits())
55 + RubySystem::getBlockSizeBytes()*stride
;
59 Address::memoryModuleIndex() const
62 bitSelect(RubySystem::getBlockSizeBits() +
63 RubySystem::getMemorySizeBits(), ADDRESS_WIDTH
);
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);
73 // Index index = indexLowPortion |
74 // (indexHighPortion << (PAGE_SIZE_BITS - DATA_BLOCK_BITS));
77 Round-robin mapping of addresses, at page size granularity
79 ADDRESS_WIDTH MEMORY_SIZE_BITS PAGE_SIZE_BITS DATA_BLOCK_BITS
82 -----------------------------------------------------------------------
83 | unused |xxxxxxxxxxxxxxx| |xxxxxxxxxxxxxxx| |
84 | |xxxxxxxxxxxxxxx| |xxxxxxxxxxxxxxx| |
85 -----------------------------------------------------------------------
86 indexHighPortion indexLowPortion
88 NUMBER_OF_MEMORY_MODULE_BITS
93 Address::print(std::ostream
& out
) const
96 out
<< "[" << hex
<< "0x" << m_address
<< "," << " line 0x"
97 << maskLowOrderBits(RubySystem::getBlockSizeBits()) << dec
<< "]"
102 Address::output(std::ostream
& out
) const
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
;
112 Address::input(std::istream
& in
)
114 // Note: this only works with addresses in the form "ffff", not
115 // "0xffff". This code should always be able to read in addresses
116 // written out by the above output() method. Please don't change
117 // this without talking to Milo first.
118 in
>> std::hex
>> m_address
>> std::dec
;
121 Address::Address(const Address
& obj
)
123 m_address
= obj
.m_address
;
127 Address::operator=(const Address
& obj
)
132 m_address
= obj
.m_address
;