mem-cache: Use findBlock in FALRU's block access
authorDaniel R. Carvalho <odanrc@yahoo.com.br>
Wed, 18 Apr 2018 17:42:15 +0000 (19:42 +0200)
committerDaniel Carvalho <odanrc@yahoo.com.br>
Thu, 19 Apr 2018 16:01:46 +0000 (16:01 +0000)
An access must perform a block search, which is done by findBlock.

The tagHash is indexed by tags, so use extractTag instead of re-
implementing its functionality.

Change-Id: Ib5abacbc65cddf0f2d7e4440eb5355b56998a585
Reviewed-on: https://gem5-review.googlesource.com/10082
Reviewed-by: Jason Lowe-Power <jason@lowepower.com>
Maintainer: Jason Lowe-Power <jason@lowepower.com>

src/mem/cache/tags/fa_lru.cc

index f515c4db65386ffc26a231a00a5c73900e1b7834..6abae2bb9416fe81ca6a16f40c8cd7294d6b4bfc 100644 (file)
@@ -139,10 +139,9 @@ FALRU::accessBlock(Addr addr, bool is_secure, Cycles &lat,
                    CachesMask *in_caches_mask)
 {
     CachesMask mask = 0;
-    Addr blkAddr = blkAlign(addr);
-    FALRUBlk* blk = hashLookup(blkAddr);
+    FALRUBlk* blk = static_cast<FALRUBlk*>(findBlock(addr, is_secure));
 
-    if (blk && blk->isValid()) {
+    if (blk != nullptr) {
         // If a cache hit
         lat = accessLatency;
         // Check if the block to be accessed is available. If not,
@@ -153,13 +152,12 @@ FALRU::accessBlock(Addr addr, bool is_secure, Cycles &lat,
             lat = cache->ticksToCycles(blk->whenReady - curTick()) +
             accessLatency;
         }
-        assert(blk->tag == blkAddr);
         mask = blk->inCachesMask;
+
         moveToHead(blk);
     } else {
         // If a cache miss
         lat = lookupLatency;
-        blk = nullptr;
     }
     if (in_caches_mask) {
         *in_caches_mask = mask;
@@ -174,11 +172,11 @@ FALRU::accessBlock(Addr addr, bool is_secure, Cycles &lat,
 CacheBlk*
 FALRU::findBlock(Addr addr, bool is_secure) const
 {
-    Addr blkAddr = blkAlign(addr);
-    FALRUBlk* blk = hashLookup(blkAddr);
+    Addr tag = extractTag(addr);
+    FALRUBlk* blk = hashLookup(tag);
 
     if (blk && blk->isValid()) {
-        assert(blk->tag == blkAddr);
+        assert(blk->tag == tag);
         assert(blk->isSecure() == is_secure);
     } else {
         blk = nullptr;