#include "mem/cache/replacement_policies/base.hh"
#include "mem/packet.hh"
#include "mem/request.hh"
+#include "sim/core.hh"
/**
* Cache block status bit assignments
/** holds the source requestor ID for this block. */
int srcRequestorId;
- /**
- * Tick on which the block was inserted in the cache. Its value is only
- * meaningful if the block is valid.
- */
- Tick tickInserted;
-
protected:
/**
* Represents that the indicated thread context has a "lock" on
std::list<Lock> lockList;
public:
- CacheBlk() : data(nullptr), tickInserted(0)
+ CacheBlk() : data(nullptr), _tickInserted(0)
{
invalidate();
}
*/
void setWhenReady(const Tick tick)
{
- assert(tick >= tickInserted);
+ assert(tick >= _tickInserted);
whenReady = tick;
}
/** Get the number of references to this block since insertion. */
void increaseRefCount() { _refCount++; }
+ /**
+ * Get the block's age, that is, the number of ticks since its insertion.
+ *
+ * @return The block's age.
+ */
+ Tick
+ getAge() const
+ {
+ assert(_tickInserted <= curTick());
+ return curTick() - _tickInserted;
+ }
+
/**
* Checks if the given information corresponds to this block's.
*
/** Set the number of references to this block since insertion. */
void setRefCount(const unsigned count) { _refCount = count; }
+ /** Set the current tick as this block's insertion tick. */
+ void setTickInserted() { _tickInserted = curTick(); }
+
private:
/** Data block tag value. */
Addr _tag;
/** Number of references to this block since it was brought in. */
unsigned _refCount;
+
+ /**
+ * Tick on which the block was inserted in the cache. Its value is only
+ * meaningful if the block is valid.
+ */
+ Tick _tickInserted;
};
/**
const uint32_t task_id = blk.getTaskId();
assert(task_id < ContextSwitchTaskId::NumTaskId);
stats.occupanciesTaskId[task_id]++;
- assert(blk.tickInserted <= curTick());
- Tick age = curTick() - blk.tickInserted;
+ Tick age = blk.getAge();
int age_index;
if (age / SimClock::Int::us < 10) { // <10us