gem5
v21.0.1.0
|
#include <cache_blk.hh>
Classes | |
class | Lock |
Represents that the indicated thread context has a "lock" on the block, in the LL/SC sense. More... | |
Public Types | |
enum | CoherenceBits : unsigned { WritableBit = 0x02, ReadableBit = 0x04, DirtyBit = 0x08, AllBits = 0x0E } |
Cache block's enum listing the supported coherence bits. More... | |
Public Member Functions | |
CacheBlk () | |
CacheBlk (const CacheBlk &)=delete | |
CacheBlk & | operator= (const CacheBlk &)=delete |
CacheBlk (const CacheBlk &&)=delete | |
virtual CacheBlk & | operator= (CacheBlk &&other) |
Move assignment operator. More... | |
virtual | ~CacheBlk () |
virtual void | invalidate () override |
Invalidate the block and clear all state. More... | |
void | setCoherenceBits (unsigned bits) |
Sets the corresponding coherence bits. More... | |
void | clearCoherenceBits (unsigned bits) |
Clear the corresponding coherence bits. More... | |
bool | isSet (unsigned bits) const |
Checks the given coherence bits are set. More... | |
bool | wasPrefetched () const |
Check if this block was the result of a hardware prefetch, yet to be touched. More... | |
void | clearPrefetched () |
Clear the prefetching bit. More... | |
void | setPrefetched () |
Marks this blocks as a recently prefetched block. More... | |
Tick | getWhenReady () const |
Get tick at which block's data will be available for access. More... | |
void | setWhenReady (const Tick tick) |
Set tick at which block's data will be available for access. More... | |
uint32_t | getTaskId () const |
Get the task id associated to this block. More... | |
uint32_t | getSrcRequestorId () const |
Get the requestor id associated to this block. More... | |
unsigned | getRefCount () const |
Get the number of references to this block since insertion. More... | |
void | increaseRefCount () |
Get the number of references to this block since insertion. More... | |
Tick | getAge () const |
Get the block's age, that is, the number of ticks since its insertion. More... | |
void | insert (const Addr tag, const bool is_secure, const int src_requestor_ID, const uint32_t task_ID) |
Set member variables when a block insertion occurs. More... | |
void | trackLoadLocked (PacketPtr pkt) |
Track the fact that a local locked was issued to the block. More... | |
void | clearLoadLocks (const RequestPtr &req) |
Clear the any load lock that intersect the request, and is from a different context. More... | |
std::string | print () const override |
Pretty-print tag, set and way, and interpret state bits to readable form including mapping to a MOESI state. More... | |
bool | checkWrite (PacketPtr pkt) |
Handle interaction of load-locked operations and stores. More... | |
virtual void | insert (const Addr tag, const bool is_secure) |
Insert the block by assigning it a tag and marking it valid. More... | |
![]() | |
TaggedEntry () | |
~TaggedEntry ()=default | |
virtual bool | isValid () const |
Checks if the entry is valid. More... | |
bool | isSecure () const |
Check if this block holds data from the secure memory space. More... | |
virtual Addr | getTag () const |
Get tag associated to this block. More... | |
virtual bool | matchTag (Addr tag, bool is_secure) const |
Checks if the given tag information corresponds to this entry's. More... | |
virtual void | insert (const Addr tag, const bool is_secure) |
Insert the block by assigning it a tag and marking it valid. More... | |
std::string | print () const override |
Prints relevant information about this entry. More... | |
![]() | |
ReplaceableEntry ()=default | |
virtual | ~ReplaceableEntry ()=default |
virtual void | setPosition (const uint32_t set, const uint32_t way) |
Set both the set and way. More... | |
uint32_t | getSet () const |
Get set number. More... | |
uint32_t | getWay () const |
Get way number. More... | |
Public Attributes | |
uint8_t * | data |
Contains a copy of the data in this block for easy access. More... | |
Tick | whenReady |
Which curTick() will this block be accessible. More... | |
![]() | |
std::shared_ptr< ReplacementPolicy::ReplacementData > | replacementData |
Replacement data associated to this entry. More... | |
Protected Member Functions | |
void | setTaskId (const uint32_t task_id) |
Set the task id value. More... | |
void | setSrcRequestorId (const uint32_t id) |
Set the source requestor id. More... | |
void | setRefCount (const unsigned count) |
Set the number of references to this block since insertion. More... | |
void | setTickInserted () |
Set the current tick as this block's insertion tick. More... | |
![]() | |
virtual void | setTag (Addr tag) |
Set tag associated to this block. More... | |
virtual void | setSecure () |
Set secure bit. More... | |
virtual void | setValid () |
Set valid bit. More... | |
Protected Attributes | |
std::list< Lock > | lockList |
List of thread contexts that have performed a load-locked (LL) on the block since the last store. More... | |
unsigned | coherence |
The current coherence status of this block. More... | |
![]() | |
uint32_t | _set |
Set to which this entry belongs. More... | |
uint32_t | _way |
Way (relative position within the set) to which this entry belongs. More... | |
Private Attributes | |
uint32_t | _taskId |
Task Id associated with this block. More... | |
int | _srcRequestorId |
holds the source requestor ID for this block. More... | |
unsigned | _refCount |
Number of references to this block since it was brought in. More... | |
Tick | _tickInserted |
Tick on which the block was inserted in the cache. More... | |
bool | _prefetched |
Whether this block is an unaccessed hardware prefetch. More... | |
A Basic Cache block.
Contains information regarding its coherence, prefetching status, as well as a pointer to its data.
Definition at line 67 of file cache_blk.hh.
enum CacheBlk::CoherenceBits : unsigned |
Cache block's enum listing the supported coherence bits.
The valid bit is not defined here because it is part of a TaggedEntry.
Definition at line 74 of file cache_blk.hh.
|
inline |
Definition at line 151 of file cache_blk.hh.
References invalidate().
|
delete |
|
delete |
|
inlinevirtual |
Definition at line 191 of file cache_blk.hh.
|
inline |
Handle interaction of load-locked operations and stores.
Definition at line 407 of file cache_blk.hh.
References clearLoadLocks(), Packet::isLLSC(), Packet::isWrite(), MipsISA::l, lockList, and Packet::req.
Referenced by BaseCache::satisfyRequest().
|
inline |
Clear the corresponding coherence bits.
bits | The coherence bits to be cleared. |
Definition at line 227 of file cache_blk.hh.
References bits(), and coherence.
Referenced by Cache::handleSnoop(), BaseCache::handleTimingReqMiss(), invalidate(), BaseCache::recvTimingResp(), Cache::satisfyRequest(), BaseCache::satisfyRequest(), Cache::serviceMSHRTargets(), BaseCache::writebackBlk(), BaseCache::writebackVisitor(), and BaseCache::writecleanBlk().
|
inline |
Clear the any load lock that intersect the request, and is from a different context.
Definition at line 341 of file cache_blk.hh.
References MipsISA::l, and lockList.
Referenced by checkWrite().
|
inline |
Clear the prefetching bit.
Either because it was recently used, or due to the block being invalidated.
Definition at line 251 of file cache_blk.hh.
References _prefetched.
Referenced by invalidate(), and BaseCache::recvTimingReq().
|
inline |
Get the block's age, that is, the number of ticks since its insertion.
Definition at line 298 of file cache_blk.hh.
References _tickInserted, and curTick().
Referenced by BaseTags::computeStatsVisitor().
|
inline |
Get the number of references to this block since insertion.
Definition at line 287 of file cache_blk.hh.
References _refCount.
Referenced by BaseTags::cleanupRefsVisitor(), and BaseTags::invalidate().
|
inline |
Get the requestor id associated to this block.
Definition at line 284 of file cache_blk.hh.
References _srcRequestorId.
Referenced by BaseTags::invalidate().
|
inline |
Get the task id associated to this block.
Definition at line 281 of file cache_blk.hh.
References _taskId.
Referenced by Cache::cleanEvictBlk(), BaseTags::computeStatsVisitor(), BaseCache::writebackBlk(), BaseCache::writebackVisitor(), and BaseCache::writecleanBlk().
|
inline |
Get tick at which block's data will be available for access.
Definition at line 261 of file cache_blk.hh.
References MaxTick, and whenReady.
Referenced by BaseCache::calculateAccessLatency().
|
inline |
Get the number of references to this block since insertion.
Definition at line 290 of file cache_blk.hh.
References _refCount.
Referenced by BaseSetAssoc::accessBlock(), SectorTags::accessBlock(), and insert().
|
inline |
Insert the block by assigning it a tag and marking it valid.
Touches block if it hadn't been touched previously.
tag | The tag value. |
Definition at line 90 of file tagged_entry.hh.
void CacheBlk::insert | ( | const Addr | tag, |
const bool | is_secure, | ||
const int | src_requestor_ID, | ||
const uint32_t | task_ID | ||
) |
Set member variables when a block insertion occurs.
Resets reference count to 1 (the insertion counts as a reference), and touch block if it hadn't been touched previously. Sets the insertion tick to the current tick. Marks the block valid.
tag | Block address tag. |
is_secure | Whether the block is in secure space or not. |
src_requestor_ID | The source requestor ID. |
task_ID | The new task ID. |
Definition at line 47 of file cache_blk.cc.
References increaseRefCount(), TaggedEntry::isValid(), setSrcRequestorId(), setTaskId(), and setTickInserted().
Referenced by SectorSubBlk::insert(), TempCacheBlk::insert(), BaseTags::insertBlock(), and operator=().
|
inlineoverridevirtual |
Invalidate the block and clear all state.
Reimplemented from TaggedEntry.
Reimplemented in TempCacheBlk, CompressionBlk, and SectorSubBlk.
Definition at line 196 of file cache_blk.hh.
References AllBits, clearCoherenceBits(), clearPrefetched(), TaggedEntry::invalidate(), Request::invldRequestorId, lockList, MaxTick, setRefCount(), setSrcRequestorId(), setTaskId(), setWhenReady(), and ContextSwitchTaskId::Unknown.
Referenced by CacheBlk(), SectorSubBlk::invalidate(), BaseTags::invalidate(), and TempCacheBlk::invalidate().
|
inline |
Checks the given coherence bits are set.
Definition at line 235 of file cache_blk.hh.
References bits(), coherence, and TaggedEntry::isValid().
Referenced by BaseCache::access(), Cache::cleanEvictBlk(), Cache::createMissPacket(), NoncoherentCache::evictBlock(), Cache::evictBlock(), BaseCache::functionalAccess(), Cache::handleSnoop(), BaseCache::handleTimingReqMiss(), BaseCache::invalidateVisitor(), BaseCache::isDirty(), BaseCache::maintainClusivity(), print(), CacheBlkPrintWrapper::print(), BaseCache::recvAtomic(), BaseCache::recvTimingResp(), Cache::satisfyRequest(), BaseCache::satisfyRequest(), BaseCache::sendMSHRQueuePacket(), Cache::serviceMSHRTargets(), BaseCache::writebackBlk(), BaseCache::writebackVisitor(), and BaseCache::writecleanBlk().
Move assignment operator.
This should only be used to move an existing valid entry into an invalid one, not to create a new entry. In the end the valid entry will become invalid, and the invalid, valid. All location related variables will remain the same, that is, an entry cannot move its data, just its metadata contents.
Reimplemented in CompressionBlk.
Definition at line 168 of file cache_blk.hh.
References curTick(), insert(), TaggedEntry::isValid(), lockList, setCoherenceBits(), setPrefetched(), setRefCount(), setSrcRequestorId(), setTaskId(), and setWhenReady().
Referenced by CompressionBlk::operator=().
|
inlineoverridevirtual |
Pretty-print tag, set and way, and interpret state bits to readable form including mapping to a MOESI state.
state M O E S I writable 1 0 1 0 0 dirty 1 1 0 0 0 valid 1 1 1 1 0
state writable dirty valid M 1 1 1 O 0 1 1 E 1 0 1 S 0 0 1 I 0 0 0
Note that only one cache ever has a block in Modified or Owned state, i.e., only one cache owns the block, or equivalently has the DirtyBit bit set. However, multiple caches on the same path to memory can have a block in the Exclusive state (despite the name). Exclusive means this cache has the only copy at this level of the hierarchy, i.e., there may be copies in caches above this cache (in various states), but there are no peers that have copies on this branch of the hierarchy, and no caches at or above this level on any other branch have copies either.
Reimplemented from ReplaceableEntry.
Reimplemented in CompressionBlk, SectorSubBlk, and FALRUBlk.
Definition at line 360 of file cache_blk.hh.
References coherence, csprintf(), DirtyBit, isSet(), TaggedEntry::isValid(), TaggedEntry::print(), ReadableBit, ArmISA::s, and WritableBit.
Referenced by BaseCache::access(), BaseCache::allocateBlock(), Cache::handleAtomicReqMiss(), BaseCache::handleFill(), Cache::handleSnoop(), FALRUBlk::print(), SectorSubBlk::print(), BaseCache::recvAtomic(), BaseCache::sendMSHRQueuePacket(), and BaseCache::updateCompressionData().
|
inline |
Sets the corresponding coherence bits.
bits | The coherence bits to be set. |
Definition at line 216 of file cache_blk.hh.
References bits(), coherence, and TaggedEntry::isValid().
Referenced by NoncoherentCache::access(), BaseCache::access(), BaseCache::cmpAndSwap(), BaseCache::handleFill(), operator=(), BaseCache::recvTimingResp(), BaseCache::satisfyRequest(), and Cache::serviceMSHRTargets().
|
inline |
Marks this blocks as a recently prefetched block.
Definition at line 254 of file cache_blk.hh.
References _prefetched.
Referenced by operator=(), NoncoherentCache::serviceMSHRTargets(), and Cache::serviceMSHRTargets().
|
inlineprotected |
Set the number of references to this block since insertion.
Definition at line 465 of file cache_blk.hh.
References _refCount, and X86ISA::count.
Referenced by invalidate(), and operator=().
|
inlineprotected |
Set the source requestor id.
Definition at line 462 of file cache_blk.hh.
References _srcRequestorId, and ArmISA::id.
Referenced by insert(), invalidate(), and operator=().
|
inlineprotected |
Set the task id value.
Definition at line 459 of file cache_blk.hh.
References _taskId.
Referenced by insert(), invalidate(), and operator=().
|
inlineprotected |
Set the current tick as this block's insertion tick.
Definition at line 468 of file cache_blk.hh.
References _tickInserted, and curTick().
Referenced by insert().
|
inline |
Set tick at which block's data will be available for access.
The new tick must be chronologically sequential with respect to previous accesses.
tick | New data ready tick. |
Definition at line 274 of file cache_blk.hh.
References _tickInserted, and whenReady.
Referenced by BaseCache::access(), BaseCache::handleFill(), invalidate(), and operator=().
|
inline |
Track the fact that a local locked was issued to the block.
Invalidate any previous LL to the same address.
Definition at line 323 of file cache_blk.hh.
References Packet::isLLSC(), MipsISA::l, lockList, and Packet::req.
Referenced by BaseCache::satisfyRequest().
|
inline |
Check if this block was the result of a hardware prefetch, yet to be touched.
Definition at line 245 of file cache_blk.hh.
References _prefetched.
Referenced by BaseCache::hasBeenPrefetched(), BaseCache::invalidateBlock(), and BaseCache::recvTimingReq().
|
private |
Whether this block is an unaccessed hardware prefetch.
Definition at line 487 of file cache_blk.hh.
Referenced by clearPrefetched(), setPrefetched(), and wasPrefetched().
|
private |
Number of references to this block since it was brought in.
Definition at line 478 of file cache_blk.hh.
Referenced by getRefCount(), increaseRefCount(), and setRefCount().
|
private |
holds the source requestor ID for this block.
Definition at line 475 of file cache_blk.hh.
Referenced by getSrcRequestorId(), and setSrcRequestorId().
|
private |
Task Id associated with this block.
Definition at line 472 of file cache_blk.hh.
Referenced by getTaskId(), and setTaskId().
|
private |
Tick on which the block was inserted in the cache.
Its value is only meaningful if the block is valid.
Definition at line 484 of file cache_blk.hh.
Referenced by getAge(), setTickInserted(), and setWhenReady().
|
protected |
The current coherence status of this block.
Definition at line 451 of file cache_blk.hh.
Referenced by clearCoherenceBits(), isSet(), print(), and setCoherenceBits().
uint8_t* CacheBlk::data |
Contains a copy of the data in this block for easy access.
This is used for efficient execution when the data could be actually stored in another format (COW, compressed, sub-blocked, etc). In all cases the data stored here should be kept consistant with the actual data referenced by this block.
Definition at line 100 of file cache_blk.hh.
Referenced by BaseCache::cmpAndSwap(), BaseCache::functionalAccess(), Cache::handleSnoop(), BaseCache::satisfyRequest(), CompressedTags::tagsInit(), BaseSetAssoc::tagsInit(), SectorTags::tagsInit(), FALRU::tagsInit(), TempCacheBlk::TempCacheBlk(), BaseCache::updateBlockData(), BaseCache::writebackBlk(), BaseCache::writebackVisitor(), BaseCache::writecleanBlk(), and TempCacheBlk::~TempCacheBlk().
List of thread contexts that have performed a load-locked (LL) on the block since the last store.
Definition at line 148 of file cache_blk.hh.
Referenced by checkWrite(), clearLoadLocks(), invalidate(), operator=(), and trackLoadLocked().
Tick CacheBlk::whenReady |
Which curTick() will this block be accessible.
Its value is only meaningful if the block is valid.
Definition at line 106 of file cache_blk.hh.
Referenced by getWhenReady(), and setWhenReady().