Track the PC of the cache data stored in fetch so it doesn't access memory multiple...
authorKevin Lim <ktlim@umich.edu>
Wed, 12 Jul 2006 19:24:27 +0000 (15:24 -0400)
committerKevin Lim <ktlim@umich.edu>
Wed, 12 Jul 2006 19:24:27 +0000 (15:24 -0400)
--HG--
extra : convert_revision : 00b160b255e998cf99286bcc21894110c7642624

src/cpu/o3/fetch.hh
src/cpu/o3/fetch_impl.hh

index 85654cebc75f2fd87acd7ba2b62ce3e10d3fcddb..0331cf07fbc2c0dd378201769fdd0b490bef7c74 100644 (file)
@@ -404,6 +404,9 @@ class DefaultFetch
     /** The cache line being fetched. */
     uint8_t *cacheData[Impl::MaxThreads];
 
+    /** The PC of the cacheline that has been loaded. */
+    Addr cacheDataPC[Impl::MaxThreads];
+
     /** Size of instructions. */
     int instSize;
 
index de883b5ba254225779afb67bf05b0d2450a584ba..a430f44723fd47e2e7d0c90ba790207dadf93b58 100644 (file)
@@ -517,6 +517,11 @@ DefaultFetch<Impl>::fetchCacheLine(Addr fetch_PC, Fault &ret_fault, unsigned tid
     // Align the fetch PC so it's at the start of a cache block.
     fetch_PC = icacheBlockAlignPC(fetch_PC);
 
+    // If we've already got the block, no need to try to fetch it again.
+    if (fetch_PC == cacheDataPC[tid]) {
+        return true;
+    }
+
     // Setup the memReq to do a read of the first instruction's address.
     // Set the appropriate read size and flags as well.
     // Build request here.
@@ -550,6 +555,8 @@ DefaultFetch<Impl>::fetchCacheLine(Addr fetch_PC, Fault &ret_fault, unsigned tid
                                         Packet::ReadReq, Packet::Broadcast);
         data_pkt->dataStatic(cacheData[tid]);
 
+        cacheDataPC[tid] = fetch_PC;
+
         DPRINTF(Fetch, "Fetch: Doing instruction read.\n");
 
         fetchedCacheLines++;