std::max(p->tag_latency, p->data_latency)),
cache(nullptr),
warmupBound((p->warmup_percentage/100.0) * (p->size / p->block_size)),
- warmedUp(false), numBlocks(0)
+ warmedUp(false), numBlocks(p->size / p->block_size)
{
}
BaseSetAssoc::BaseSetAssoc(const Params *p)
:BaseTags(p), assoc(p->assoc), allocAssoc(p->assoc),
+ blks(p->size / p->block_size),
+ dataBlks(new uint8_t[p->size]), // Allocate data storage in one big chunk
numSets(p->size / (p->block_size * p->assoc)),
- sequentialAccess(p->sequential_access)
+ sequentialAccess(p->sequential_access),
+ sets(p->size / (p->block_size * p->assoc))
{
// Check parameters
if (blkSize < 4 || !isPowerOf2(blkSize)) {
setMask = numSets - 1;
tagShift = setShift + floorLog2(numSets);
- sets = new SetType[numSets];
- blks = new BlkType[numSets * assoc];
- // allocate data storage in one big chunk
- numBlocks = numSets * assoc;
- dataBlks = new uint8_t[numBlocks * blkSize];
-
unsigned blkIndex = 0; // index into blks array
for (unsigned i = 0; i < numSets; ++i) {
sets[i].assoc = assoc;
}
}
-BaseSetAssoc::~BaseSetAssoc()
-{
- delete [] dataBlks;
- delete [] blks;
- delete [] sets;
-}
-
CacheBlk*
BaseSetAssoc::findBlock(Addr addr, bool is_secure) const
{
#include <cassert>
#include <cstring>
-#include <list>
+#include <memory>
+#include <vector>
#include "mem/cache/base.hh"
#include "mem/cache/blk.hh"
const unsigned assoc;
/** The allocatable associativity of the cache (alloc mask). */
unsigned allocAssoc;
+
+ /** The cache blocks. */
+ std::vector<BlkType> blks;
+ /** The data blocks, 1 per cache block. */
+ std::unique_ptr<uint8_t[]> dataBlks;
+
/** The number of sets in the cache. */
const unsigned numSets;
+
/** Whether tags and data are accessed sequentially. */
const bool sequentialAccess;
/** The cache sets. */
- SetType *sets;
-
- /** The cache blocks. */
- BlkType *blks;
- /** The data blocks, 1 per cache block. */
- uint8_t *dataBlks;
+ std::vector<SetType> sets;
/** The amount to shift the address to get the set. */
int setShift;
/**
* Destructor
*/
- virtual ~BaseSetAssoc();
+ virtual ~BaseSetAssoc() {};
/**
* Find the cache block given set and way