mem-cache: Virtualize block print
[gem5.git] / src / mem / cache / blk.hh
index 97e1d42d9b53557894157fb8209e5bba9dcefb74..6d91e5584fdd9c18972376b3ca103c7b58c3a973 100644 (file)
@@ -108,12 +108,6 @@ class CacheBlk : public ReplaceableEntry
     /** Which curTick() will this block be accessible */
     Tick whenReady;
 
-    /**
-     * The set and way this block belongs to.
-     * @todo Move this into subclasses when we fix CacheTags to use them.
-     */
-    int set, way;
-
     /** Number of references to this block since it was brought in. */
     unsigned refCount;
 
@@ -298,12 +292,12 @@ class CacheBlk : public ReplaceableEntry
     }
 
     /**
-     * Pretty-print a tag, and interpret state bits to readable form
+     * Pretty-print tag, set and way, and interpret state bits to readable form
      * including mapping to a MOESI state.
      *
      * @return string with basic state information
      */
-    std::string print() const
+    virtual std::string print() const
     {
         /**
          *  state       M   O   E   S   I
@@ -340,8 +334,9 @@ class CacheBlk : public ReplaceableEntry
           default:    s = 'T'; break; // @TODO add other types
         }
         return csprintf("state: %x (%c) valid: %d writable: %d readable: %d "
-                        "dirty: %d tag: %x", status, s, isValid(),
-                        isWritable(), isReadable(), isDirty(), tag);
+                        "dirty: %d | tag: %#x set: %#x way: %#x", status, s,
+                        isValid(), isWritable(), isReadable(), isDirty(), tag,
+                        getSet(), getWay());
     }
 
     /**
@@ -406,10 +401,17 @@ class TempCacheBlk final : public CacheBlk
     Addr _addr;
 
   public:
-    TempCacheBlk() : CacheBlk() {}
+    /**
+     * Creates a temporary cache block, with its own storage.
+     * @param size The size (in bytes) of this cache block.
+     */
+    TempCacheBlk(unsigned size) : CacheBlk()
+    {
+        data = new uint8_t[size];
+    }
     TempCacheBlk(const TempCacheBlk&) = delete;
     TempCacheBlk& operator=(const TempCacheBlk&) = delete;
-    ~TempCacheBlk() {};
+    ~TempCacheBlk() { delete [] data; };
 
     /**
      * Invalidate the block and clear all state.