}
// Check if the block to be accessed is available. If not, apply the
- // access latency on top of block->whenReady.
- if (blk->whenReady > curTick() &&
- ticksToCycles(blk->whenReady - curTick()) > lat) {
- lat += ticksToCycles(blk->whenReady - curTick());
+ // access latency on top of when the block is ready to be accessed.
+ const Tick when_ready = blk->getWhenReady();
+ if (when_ready > curTick() &&
+ ticksToCycles(when_ready - curTick()) > lat) {
+ lat += ticksToCycles(when_ready - curTick());
}
}
DPRINTF(Cache, "%s new state is %s\n", __func__, blk->print());
incHitCount(pkt);
// populate the time when the block will be ready to access.
- blk->whenReady = clockEdge(fillLatency) + pkt->headerDelay +
- pkt->payloadDelay;
+ blk->setWhenReady(clockEdge(fillLatency) + pkt->headerDelay +
+ pkt->payloadDelay);
return true;
} else if (pkt->cmd == MemCmd::CleanEvict) {
if (blk) {
incHitCount(pkt);
// populate the time when the block will be ready to access.
- blk->whenReady = clockEdge(fillLatency) + pkt->headerDelay +
- pkt->payloadDelay;
+ blk->setWhenReady(clockEdge(fillLatency) + pkt->headerDelay +
+ pkt->payloadDelay);
// if this a write-through packet it will be sent to cache
// below
return !pkt->writeThrough();
pkt->writeDataToBlock(blk->data, blkSize);
}
// We pay for fillLatency here.
- blk->whenReady = clockEdge() + fillLatency * clockPeriod() +
- pkt->payloadDelay;
+ blk->setWhenReady(clockEdge(fillLatency) + pkt->payloadDelay);
return blk;
}
/** The current status of this block. @sa CacheBlockStatusBits */
State status;
- /** Which curTick() will this block be accessible */
+ /**
+ * Which curTick() will this block be accessible. Its value is only
+ * meaningful if the block is valid.
+ */
Tick whenReady;
/** Number of references to this block since it was brought in. */
/** holds the source requestor ID for this block. */
int srcMasterId;
- /** Tick on which the block was inserted in the cache. */
+ /**
+ * Tick on which the block was inserted in the cache. Its value is only
+ * meaningful if the block is valid.
+ */
Tick tickInserted;
protected:
std::list<Lock> lockList;
public:
- CacheBlk() : data(nullptr)
+ CacheBlk() : data(nullptr), tickInserted(0)
{
invalidate();
}
whenReady = MaxTick;
refCount = 0;
srcMasterId = Request::invldMasterId;
- tickInserted = MaxTick;
lockList.clear();
}
status |= BlkSecure;
}
+ /**
+ * Get tick at which block's data will be available for access.
+ *
+ * @return Data ready tick.
+ */
+ Tick getWhenReady() const
+ {
+ return whenReady;
+ }
+
+ /**
+ * Set tick at which block's data will be available for access. The new
+ * tick must be chronologically sequential with respect to previous
+ * accesses.
+ *
+ * @param tick New data ready tick.
+ */
+ void setWhenReady(const Tick tick)
+ {
+ assert((whenReady == MaxTick) || (tick >= whenReady));
+ assert(tick >= tickInserted);
+ whenReady = tick;
+ }
+
/**
* Set member variables when a block insertion occurs. Resets reference
* count to 1 (the insertion counts as a reference), and touch block if