summaryrefslogtreecommitdiff
path: root/src/mem/cache/tags/base_set_assoc.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/mem/cache/tags/base_set_assoc.cc')
-rw-r--r--src/mem/cache/tags/base_set_assoc.cc62
1 files changed, 15 insertions, 47 deletions
diff --git a/src/mem/cache/tags/base_set_assoc.cc b/src/mem/cache/tags/base_set_assoc.cc
index 543231cd9..1a04c08a9 100644
--- a/src/mem/cache/tags/base_set_assoc.cc
+++ b/src/mem/cache/tags/base_set_assoc.cc
@@ -42,7 +42,7 @@
/**
* @file
- * Definitions of a base set associative tag store.
+ * Definitions of a conventional tag store.
*/
#include "mem/cache/tags/base_set_assoc.hh"
@@ -52,27 +52,14 @@
#include "base/intmath.hh"
BaseSetAssoc::BaseSetAssoc(const Params *p)
- :BaseTags(p), assoc(p->assoc), allocAssoc(p->assoc),
- blks(p->size / p->block_size),
- numSets(p->size / (p->block_size * p->assoc)),
+ :BaseTags(p), allocAssoc(p->assoc), blks(p->size / p->block_size),
sequentialAccess(p->sequential_access),
- sets(p->size / (p->block_size * p->assoc)),
replacementPolicy(p->replacement_policy)
{
// Check parameters
if (blkSize < 4 || !isPowerOf2(blkSize)) {
fatal("Block size must be at least 4 and a power of 2");
}
- if (!isPowerOf2(numSets)) {
- fatal("# of sets must be non-zero and a power of 2");
- }
- if (assoc <= 0) {
- fatal("associativity must be greater than zero");
- }
-
- setShift = floorLog2(blkSize);
- setMask = numSets - 1;
- tagShift = setShift + floorLog2(numSets);
}
void
@@ -81,35 +68,19 @@ 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].resize(assoc);
-
- // link in the data blocks
- for (unsigned j = 0; j < assoc; ++j) {
- // Select block within the set to be linked
- BlkType*& blk = sets[i][j];
-
- // Locate next cache block
- blk = &blks[blkIndex];
-
- // Associate a data chunk to the block
- blk->data = &dataBlks[blkSize*blkIndex];
+ // Initialize all blocks
+ for (unsigned blk_index = 0; blk_index < numBlocks; blk_index++) {
+ // Locate next cache block
+ BlkType* blk = &blks[blk_index];
- // Associate a replacement data entry to the block
- blk->replacementData = replacementPolicy->instantiateEntry();
+ // Link block to indexing policy
+ indexingPolicy->setEntry(blk, blk_index);
- // Setting the tag to j is just to prevent long chains in the
- // hash table; won't matter because the block is invalid
- blk->tag = j;
+ // Associate a data chunk to the block
+ blk->data = &dataBlks[blkSize*blk_index];
- // Set its index
- blk->setPosition(i, j);
-
- // Update block index
- ++blkIndex;
- }
+ // Associate a replacement data entry to the block
+ blk->replacementData = replacementPolicy->instantiateEntry();
}
}
@@ -125,14 +96,11 @@ BaseSetAssoc::invalidate(CacheBlk *blk)
replacementPolicy->invalidate(blk->replacementData);
}
-ReplaceableEntry*
-BaseSetAssoc::findBlockBySetAndWay(int set, int way) const
-{
- return sets[set][way];
-}
-
BaseSetAssoc *
BaseSetAssocParams::create()
{
+ // There must be a indexing policy
+ fatal_if(!indexing_policy, "An indexing policy is required");
+
return new BaseSetAssoc(this);
}