cacheTracking.regStats(name());
}
-FALRUBlk *
-FALRU::hashLookup(Addr addr) const
-{
- tagIterator iter = tagHash.find(addr);
- if (iter != tagHash.end()) {
- return (*iter).second;
- }
- return nullptr;
-}
-
void
FALRU::invalidate(CacheBlk *blk)
{
moveToTail((FALRUBlk*)blk);
// Erase block entry in the hash table
- tagHash.erase(blk->tag);
+ tagHash.erase(std::make_pair(blk->tag, blk->isSecure()));
}
CacheBlk*
CachesMask mask = 0;
FALRUBlk* blk = static_cast<FALRUBlk*>(findBlock(addr, is_secure));
- if (blk != nullptr) {
+ if (blk && blk->isValid()) {
// If a cache hit
lat = accessLatency;
// Check if the block to be accessed is available. If not,
CacheBlk*
FALRU::findBlock(Addr addr, bool is_secure) const
{
+ FALRUBlk* blk = nullptr;
+
Addr tag = extractTag(addr);
- FALRUBlk* blk = hashLookup(tag);
+ auto iter = tagHash.find(std::make_pair(tag, is_secure));
+ if (iter != tagHash.end()) {
+ blk = (*iter).second;
+ }
if (blk && blk->isValid()) {
assert(blk->tag == tag);
assert(blk->isSecure() == is_secure);
- } else {
- blk = nullptr;
}
+
return blk;
}
moveToHead(falruBlk);
// Insert new block in the hash table
- tagHash[falruBlk->tag] = falruBlk;
+ tagHash[std::make_pair(blk->tag, blk->isSecure())] = falruBlk;
}
void
}
// Record stats for the actual cache too
- if (blk) {
+ if (blk && blk->isValid()) {
hits[numTrackedCaches]++;
} else {
misses[numTrackedCaches]++;
FALRUBlk *tail;
/** Hash table type mapping addresses to cache block pointers. */
- typedef std::unordered_map<Addr, FALRUBlk *, std::hash<Addr> > hash_t;
- /** Iterator into the address hash table. */
- typedef hash_t::const_iterator tagIterator;
+ struct PairHash
+ {
+ template <class T1, class T2>
+ std::size_t operator()(const std::pair<T1, T2> &p) const
+ {
+ return std::hash<T1>()(p.first) ^ std::hash<T2>()(p.second);
+ }
+ };
+ typedef std::pair<Addr, bool> TagHashKey;
+ typedef std::unordered_map<TagHashKey, FALRUBlk *, PairHash> TagHash;
/** The address hash table. */
- hash_t tagHash;
-
- /**
- * Find the cache block for the given address.
- * @param addr The address to find.
- * @return The cache block of the address, if any.
- */
- FALRUBlk * hashLookup(Addr addr) const;
+ TagHash tagHash;
/**
* Move a cache block to the MRU position.