+ RubySystem::getBlockSizeBytes()*stride;
}
-Index
+int64
Address::memoryModuleIndex() const
{
- Index index =
+ int64 index =
bitSelect(RubySystem::getBlockSizeBits() +
RubySystem::getMemorySizeBits(), ADDRESS_WIDTH);
assert (index >= 0);
return index;
- // Index indexHighPortion =
+ // int64 indexHighPortion =
// address.bitSelect(MEMORY_SIZE_BITS - 1,
// PAGE_SIZE_BITS + NUMBER_OF_MEMORY_MODULE_BITS);
- // Index indexLowPortion =
+ // int64 indexLowPortion =
// address.bitSelect(DATA_BLOCK_BITS, PAGE_SIZE_BITS - 1);
//
- // Index index = indexLowPortion |
+ // int64 index = indexLowPortion |
// (indexHighPortion << (PAGE_SIZE_BITS - DATA_BLOCK_BITS));
/*
void makePageAddress();
void makeNextStrideAddress(int stride);
- Index memoryModuleIndex() const;
+ int64 memoryModuleIndex() const;
void print(std::ostream& out) const;
void output(std::ostream& out) const;
typedef uint64 physical_address_t;
-typedef int64 Index; // what the address bit ripper returns
typedef unsigned int LinkID;
typedef unsigned int NodeID;
typedef unsigned int SwitchID;
class AbstractReplacementPolicy
{
public:
- AbstractReplacementPolicy(Index num_sets, Index assoc);
+ AbstractReplacementPolicy(int64 num_sets, int64 assoc);
virtual ~AbstractReplacementPolicy();
/* touch a block. a.k.a. update timestamp */
- virtual void touch(Index set, Index way, Tick time) = 0;
+ virtual void touch(int64 set, int64 way, Tick time) = 0;
/* returns the way to replace */
- virtual Index getVictim(Index set) const = 0;
+ virtual int64 getVictim(int64 set) const = 0;
/* get the time of the last access */
- Tick getLastAccess(Index set, Index way);
+ Tick getLastAccess(int64 set, int64 way);
protected:
unsigned m_num_sets; /** total number of sets */
};
inline
-AbstractReplacementPolicy::AbstractReplacementPolicy(Index num_sets,
- Index assoc)
+AbstractReplacementPolicy::AbstractReplacementPolicy(int64 num_sets,
+ int64 assoc)
{
m_num_sets = num_sets;
m_assoc = assoc;
}
inline Tick
-AbstractReplacementPolicy::getLastAccess(Index set, Index way)
+AbstractReplacementPolicy::getLastAccess(int64 set, int64 way)
{
return m_last_ref_ptr[set][way];
}
}
bool
-BankedArray::tryAccess(Index idx)
+BankedArray::tryAccess(int64 idx)
{
if (accessLatency == 0)
return true;
}
unsigned int
-BankedArray::mapIndexToBank(Index idx)
+BankedArray::mapIndexToBank(int64 idx)
{
if (banks == 1) {
return 0;
{
public:
AccessRecord() : idx(0), startAccess(0), endAccess(0) {}
- Index idx;
+ int64 idx;
Tick startAccess;
Tick endAccess;
};
// otherwise, schedule the event and wait for it to complete
std::vector<AccessRecord> busyBanks;
- unsigned int mapIndexToBank(Index idx);
+ unsigned int mapIndexToBank(int64 idx);
public:
BankedArray(unsigned int banks, Cycles accessLatency, unsigned int startIndexBit);
// Note: We try the access based on the cache index, not the address
// This is so we don't get aliasing on blocks being replaced
- bool tryAccess(Index idx);
+ bool tryAccess(int64 idx);
};
}
// convert a Address to its location in the cache
-Index
+int64
CacheMemory::addressToCacheSet(const Address& address) const
{
assert(address == line_address(address));
// Given a cache index: returns the index of the tag in a set.
// returns -1 if the tag is not found.
int
-CacheMemory::findTagInSet(Index cacheSet, const Address& tag) const
+CacheMemory::findTagInSet(int64 cacheSet, const Address& tag) const
{
assert(tag == line_address(tag));
// search the set for the tags
// Given a cache index: returns the index of the tag in a set.
// returns -1 if the tag is not found.
int
-CacheMemory::findTagInSetIgnorePermissions(Index cacheSet,
+CacheMemory::findTagInSetIgnorePermissions(int64 cacheSet,
const Address& tag) const
{
assert(tag == line_address(tag));
{
assert(address == line_address(address));
DPRINTF(RubyCache, "address: %s\n", address);
- Index cacheSet = addressToCacheSet(address);
+ int64 cacheSet = addressToCacheSet(address);
int loc = findTagInSet(cacheSet, address);
if (loc != -1) {
// Do we even have a tag match?
{
assert(address == line_address(address));
DPRINTF(RubyCache, "address: %s\n", address);
- Index cacheSet = addressToCacheSet(address);
+ int64 cacheSet = addressToCacheSet(address);
int loc = findTagInSet(cacheSet, address);
if (loc != -1) {
CacheMemory::isTagPresent(const Address& address) const
{
assert(address == line_address(address));
- Index cacheSet = addressToCacheSet(address);
+ int64 cacheSet = addressToCacheSet(address);
int loc = findTagInSet(cacheSet, address);
if (loc == -1) {
{
assert(address == line_address(address));
- Index cacheSet = addressToCacheSet(address);
+ int64 cacheSet = addressToCacheSet(address);
for (int i = 0; i < m_cache_assoc; i++) {
AbstractCacheEntry* entry = m_cache[cacheSet][i];
DPRINTF(RubyCache, "address: %s\n", address);
// Find the first open slot
- Index cacheSet = addressToCacheSet(address);
+ int64 cacheSet = addressToCacheSet(address);
std::vector<AbstractCacheEntry*> &set = m_cache[cacheSet];
for (int i = 0; i < m_cache_assoc; i++) {
if (!set[i] || set[i]->m_Permission == AccessPermission_NotPresent) {
assert(address == line_address(address));
assert(isTagPresent(address));
DPRINTF(RubyCache, "address: %s\n", address);
- Index cacheSet = addressToCacheSet(address);
+ int64 cacheSet = addressToCacheSet(address);
int loc = findTagInSet(cacheSet, address);
if (loc != -1) {
delete m_cache[cacheSet][loc];
assert(address == line_address(address));
assert(!cacheAvail(address));
- Index cacheSet = addressToCacheSet(address);
+ int64 cacheSet = addressToCacheSet(address);
return m_cache[cacheSet][m_replacementPolicy_ptr->getVictim(cacheSet)]->
m_Address;
}
CacheMemory::lookup(const Address& address)
{
assert(address == line_address(address));
- Index cacheSet = addressToCacheSet(address);
+ int64 cacheSet = addressToCacheSet(address);
int loc = findTagInSet(cacheSet, address);
if(loc == -1) return NULL;
return m_cache[cacheSet][loc];
CacheMemory::lookup(const Address& address) const
{
assert(address == line_address(address));
- Index cacheSet = addressToCacheSet(address);
+ int64 cacheSet = addressToCacheSet(address);
int loc = findTagInSet(cacheSet, address);
if(loc == -1) return NULL;
return m_cache[cacheSet][loc];
void
CacheMemory::setMRU(const Address& address)
{
- Index cacheSet = addressToCacheSet(address);
+ int64 cacheSet = addressToCacheSet(address);
int loc = findTagInSet(cacheSet, address);
if(loc != -1)
{
DPRINTF(RubyCache, "Setting Lock for addr: %x to %d\n", address, context);
assert(address == line_address(address));
- Index cacheSet = addressToCacheSet(address);
+ int64 cacheSet = addressToCacheSet(address);
int loc = findTagInSet(cacheSet, address);
assert(loc != -1);
m_cache[cacheSet][loc]->m_locked = context;
{
DPRINTF(RubyCache, "Clear Lock for addr: %x\n", address);
assert(address == line_address(address));
- Index cacheSet = addressToCacheSet(address);
+ int64 cacheSet = addressToCacheSet(address);
int loc = findTagInSet(cacheSet, address);
assert(loc != -1);
m_cache[cacheSet][loc]->m_locked = -1;
CacheMemory::isLocked(const Address& address, int context)
{
assert(address == line_address(address));
- Index cacheSet = addressToCacheSet(address);
+ int64 cacheSet = addressToCacheSet(address);
int loc = findTagInSet(cacheSet, address);
assert(loc != -1);
DPRINTF(RubyCache, "Testing Lock for addr: %llx cur %d con %d\n",
private:
// convert a Address to its location in the cache
- Index addressToCacheSet(const Address& address) const;
+ int64 addressToCacheSet(const Address& address) const;
// Given a cache tag: returns the index of the tag in a set.
// returns -1 if the tag is not found.
- int findTagInSet(Index line, const Address& tag) const;
- int findTagInSetIgnorePermissions(Index cacheSet,
+ int findTagInSet(int64 line, const Address& tag) const;
+ int findTagInSetIgnorePermissions(int64 cacheSet,
const Address& tag) const;
// Private copy constructor and assignment operator
else {
assert(isPresent(address));
- Index index = address.memoryModuleIndex();
+ int64 index = address.memoryModuleIndex();
if (index < 0 || index > m_size) {
ERROR_MSG("Directory Memory Assertion: "
class LRUPolicy : public AbstractReplacementPolicy
{
public:
- LRUPolicy(Index num_sets, Index assoc);
+ LRUPolicy(int64 num_sets, int64 assoc);
~LRUPolicy();
- void touch(Index set, Index way, Tick time);
- Index getVictim(Index set) const;
+ void touch(int64 set, int64 way, Tick time);
+ int64 getVictim(int64 set) const;
};
inline
-LRUPolicy::LRUPolicy(Index num_sets, Index assoc)
+LRUPolicy::LRUPolicy(int64 num_sets, int64 assoc)
: AbstractReplacementPolicy(num_sets, assoc)
{
}
}
inline void
-LRUPolicy::touch(Index set, Index index, Tick time)
+LRUPolicy::touch(int64 set, int64 index, Tick time)
{
assert(index >= 0 && index < m_assoc);
assert(set >= 0 && set < m_num_sets);
m_last_ref_ptr[set][index] = time;
}
-inline Index
-LRUPolicy::getVictim(Index set) const
+inline int64
+LRUPolicy::getVictim(int64 set) const
{
// assert(m_assoc != 0);
Tick time, smallest_time;
- Index smallest_index;
+ int64 smallest_index;
smallest_index = 0;
smallest_time = m_last_ref_ptr[set][0];
class PseudoLRUPolicy : public AbstractReplacementPolicy
{
public:
- PseudoLRUPolicy(Index num_sets, Index assoc);
+ PseudoLRUPolicy(int64 num_sets, int64 assoc);
~PseudoLRUPolicy();
- void touch(Index set, Index way, Tick time);
- Index getVictim(Index set) const;
+ void touch(int64 set, int64 way, Tick time);
+ int64 getVictim(int64 set) const;
private:
unsigned int m_effective_assoc; /** nearest (to ceiling) power of 2 */
};
inline
-PseudoLRUPolicy::PseudoLRUPolicy(Index num_sets, Index assoc)
+PseudoLRUPolicy::PseudoLRUPolicy(int64 num_sets, int64 assoc)
: AbstractReplacementPolicy(num_sets, assoc)
{
// associativity cannot exceed capacity of tree representation
- assert(num_sets > 0 && assoc > 1 && assoc <= (Index) sizeof(uint64)*4);
+ assert(num_sets > 0 && assoc > 1 && assoc <= sizeof(uint64)*4);
m_trees = NULL;
m_num_levels = 0;
}
inline void
-PseudoLRUPolicy::touch(Index set, Index index, Tick time)
+PseudoLRUPolicy::touch(int64 set, int64 index, Tick time)
{
assert(index >= 0 && index < m_assoc);
assert(set >= 0 && set < m_num_sets);
m_last_ref_ptr[set][index] = time;
}
-inline Index
-PseudoLRUPolicy::getVictim(Index set) const
+inline int64
+PseudoLRUPolicy::getVictim(int64 set) const
{
// assert(m_assoc != 0);
- Index index = 0;
+ int64 index = 0;
int tree_index = 0;
int node_val;