58 :
BaseTags(p), assoc(p->assoc), allocAssoc(p->assoc),
59 numSets(p->
size / (p->block_size * p->assoc)),
60 sequentialAccess(p->sequential_access)
64 fatal(
"Block size must be at least 4 and a power of 2");
67 fatal(
"# of sets must be non-zero and a power of 2");
70 fatal(
"associativity must be greater than zero");
85 unsigned blkIndex = 0;
92 for (
unsigned j = 0;
j <
assoc; ++
j) {
139 std::string cache_state;
142 for (
unsigned j = 0;
j <
assoc; ++
j) {
145 cache_state +=
csprintf(
"\tset: %d block: %d %s\n",
i,
j,
149 if (cache_state.empty())
150 cache_state =
"no valid tags\n";
158 if (
blks[
i].isValid()) {
170 for (
unsigned j = 0;
j < 5; ++
j) {
176 if (
blks[
i].isValid()) {
177 assert(
blks[
i].task_id < ContextSwitchTaskId::NumTaskId);
179 assert(blks[
i].tickInserted <=
curTick());
Stats::Scalar sampledRefs
The number of reference counts sampled.
Tick whenReady
Which curTick() will this block be accessable.
Addr tag
Data block tag value.
CacheBlk * findBlockBySetAndWay(int set, int way) const override
Find the cache block given set and way.
int assoc
The associativity of this set.
Stats::Scalar totalRefs
The total number of references to a block before it is replaced.
BlkType * blks
The cache blocks.
Stats::Vector occupanciesTaskId
Occupancy of each context/cpu using the cache.
An associative set of cache blocks.
Blktype * findBlk(Addr tag, bool is_secure, int &way_id) const
Find a block matching the tag in this set.
unsigned refCount
Number of references to this block since it was brought in.
Blktype ** blks
Cache blocks in this set, maintained in LRU order 0 = MRU.
Tick curTick()
The current simulated tick.
BaseSetAssoc(const Params *p)
Construct and initialize this tag store.
std::string csprintf(const char *format, const Args &...args)
int tagShift
The amount to shift the address to get the tag.
std::string print() const override
Print all tags used.
uint64_t Tick
Tick count type.
void computeStats() override
Called prior to dumping stats to compute task occupancy.
bool isPowerOf2(const T &n)
SetType * sets
The cache sets.
void invalidate()
Invalidate the block and clear all state.
Stats::Vector2d ageTaskId
Occupancy of each context/cpu using the cache.
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
uint8_t * dataBlks
The data blocks, 1 per cache block.
const unsigned numSets
The number of sets in the cache.
bool isTouched
whether this block has been touched
int setShift
The amount to shift the address to get the set.
Declaration of a base set associative tag store.
int floorLog2(unsigned x)
std::string print() const
Pretty-print a tag, and interpret state bits to readable form including mapping to a MOESI state...
Addr extractTag(Addr addr) const override
Generate the tag from the given address.
int extractSet(Addr addr) const override
Calculate the set index from the address.
void cleanupRefs() override
Called at end of simulation to complete average block reference stats.
const unsigned assoc
The associativity of the cache.
uint32_t task_id
Task Id associated with this block.
int set
The set and way this block belongs to.
bool isValid() const
Checks that a block is valid.
CacheBlk * findBlock(Addr addr, bool is_secure) const override
Finds the given address in the cache, do not update replacement data.
virtual ~BaseSetAssoc()
Destructor.
uint8_t * data
Contains a copy of the data in this block for easy access.
unsigned setMask
Mask out all bits that aren't part of the set index.