tempBlock = new TempCacheBlk(blkSize);
- tags->setCache(this);
+ tags->init(this);
if (prefetcher)
prefetcher->setCache(this);
}
* @}
*/
+ /**
+ * Set the parent cache back pointer.
+ *
+ * @param _cache Pointer to parent cache.
+ */
+ void setCache(BaseCache *_cache);
+
public:
typedef BaseTagsParams Params;
BaseTags(const Params *p);
virtual ~BaseTags() {}
/**
- * Set the parent cache back pointer.
+ * Initialize blocks and set the parent cache back pointer.
+ *
* @param _cache Pointer to parent cache.
*/
- void setCache(BaseCache *_cache);
+ virtual void init(BaseCache *_cache) = 0;
/**
* Register local statistics.
setShift = floorLog2(blkSize);
setMask = numSets - 1;
tagShift = setShift + floorLog2(numSets);
+}
+
+void
+BaseSetAssoc::init(BaseCache* cache)
+{
+ // Set parent cache
+ setCache(cache);
+ // Initialize blocks
unsigned blkIndex = 0; // index into blks array
for (unsigned i = 0; i < numSets; ++i) {
sets[i].assoc = assoc;
*/
virtual ~BaseSetAssoc() {};
+ /**
+ * Initialize blocks and set the parent cache back pointer.
+ *
+ * @param _cache Pointer to parent cache.
+ */
+ void init(BaseCache *_cache) override;
+
/**
* This function updates the tags when a block is invalidated. It also
* updates the replacement data.
fatal("Cache Size must be power of 2 for now");
blks = new FALRUBlk[numBlocks];
+}
+
+FALRU::~FALRU()
+{
+ delete[] blks;
+}
+
+void
+FALRU::init(BaseCache* cache)
+{
+ // Set parent cache
+ setCache(cache);
head = &(blks[0]);
head->prev = nullptr;
cacheTracking.init(head, tail);
}
-FALRU::~FALRU()
-{
- delete[] blks;
-}
-
void
FALRU::regStats()
{
// TrackedCaches class
//#define FALRU_DEBUG
+class BaseCache;
class ReplaceableEntry;
// A bitmask of the caches we are keeping track of. Currently the
FALRU(const Params *p);
~FALRU();
+ /**
+ * Initialize blocks and set the parent cache back pointer.
+ *
+ * @param _cache Pointer to parent cache.
+ */
+ void init(BaseCache *_cache) override;
+
/**
* Register the stats for this object.
*/
fatal_if(!isPowerOf2(numBlocksPerSector),
"# of blocks per sector must be non-zero and a power of 2");
fatal_if(assoc <= 0, "associativity must be greater than zero");
+}
+
+void
+SectorTags::init(BaseCache* cache)
+{
+ // Set parent cache
+ setCache(cache);
// Initialize all sets
unsigned sec_blk_index = 0; // index into sector blks array
#include "mem/cache/tags/base.hh"
#include "params/SectorTags.hh"
+class BaseCache;
class BaseReplacementPolicy;
class ReplaceableEntry;
*/
virtual ~SectorTags() {};
+ /**
+ * Initialize blocks and set the parent cache back pointer.
+ *
+ * @param _cache Pointer to parent cache.
+ */
+ void init(BaseCache *_cache) override;
+
/**
* This function updates the tags when a block is invalidated but does
* not invalidate the block itself. It also updates the replacement data.