gem5  v21.0.1.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Classes | Public Types | Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Private Attributes | List of all members
CacheBlk Class Reference

A Basic Cache block. More...

#include <cache_blk.hh>

Inheritance diagram for CacheBlk:
TaggedEntry ReplaceableEntry FALRUBlk SectorSubBlk TempCacheBlk CompressionBlk

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
 
CacheBlkoperator= (const CacheBlk &)=delete
 
 CacheBlk (const CacheBlk &&)=delete
 
virtual CacheBlkoperator= (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...
 
- Public Member Functions inherited from TaggedEntry
 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...
 
- Public Member Functions inherited from ReplaceableEntry
 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...
 
- Public Attributes inherited from ReplaceableEntry
std::shared_ptr< ReplacementPolicy::ReplacementDatareplacementData
 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...
 
- Protected Member Functions inherited from TaggedEntry
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< LocklockList
 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...
 
- Protected Attributes inherited from ReplaceableEntry
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...
 

Detailed Description

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.

Member Enumeration Documentation

◆ CoherenceBits

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.

Enumerator
WritableBit 

write permission

ReadableBit 

Read permission.

Note that a block can be valid but not readable if there is an outstanding write upgrade miss.

DirtyBit 

dirty (modified)

AllBits 

Helper enum value that includes all other bits.

Whenever a new bits is added, this should be updated.

Definition at line 74 of file cache_blk.hh.

Constructor & Destructor Documentation

◆ CacheBlk() [1/3]

CacheBlk::CacheBlk ( )
inline

Definition at line 151 of file cache_blk.hh.

References invalidate().

◆ CacheBlk() [2/3]

CacheBlk::CacheBlk ( const CacheBlk )
delete

◆ CacheBlk() [3/3]

CacheBlk::CacheBlk ( const CacheBlk &&  )
delete

◆ ~CacheBlk()

virtual CacheBlk::~CacheBlk ( )
inlinevirtual

Definition at line 191 of file cache_blk.hh.

Member Function Documentation

◆ checkWrite()

bool CacheBlk::checkWrite ( PacketPtr  pkt)
inline

Handle interaction of load-locked operations and stores.

Returns
True if write should proceed, false otherwise. Returns false only in the case of a failed store conditional.

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().

◆ clearCoherenceBits()

void CacheBlk::clearCoherenceBits ( unsigned  bits)
inline

◆ clearLoadLocks()

void CacheBlk::clearLoadLocks ( const RequestPtr req)
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().

◆ clearPrefetched()

void CacheBlk::clearPrefetched ( )
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().

◆ getAge()

Tick CacheBlk::getAge ( ) const
inline

Get the block's age, that is, the number of ticks since its insertion.

Returns
The block's age.

Definition at line 298 of file cache_blk.hh.

References _tickInserted, and curTick().

Referenced by BaseTags::computeStatsVisitor().

◆ getRefCount()

unsigned CacheBlk::getRefCount ( ) const
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().

◆ getSrcRequestorId()

uint32_t CacheBlk::getSrcRequestorId ( ) const
inline

Get the requestor id associated to this block.

Definition at line 284 of file cache_blk.hh.

References _srcRequestorId.

Referenced by BaseTags::invalidate().

◆ getTaskId()

uint32_t CacheBlk::getTaskId ( ) const
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().

◆ getWhenReady()

Tick CacheBlk::getWhenReady ( ) const
inline

Get tick at which block's data will be available for access.

Returns
Data ready tick.

Definition at line 261 of file cache_blk.hh.

References MaxTick, and whenReady.

Referenced by BaseCache::calculateAccessLatency().

◆ increaseRefCount()

void CacheBlk::increaseRefCount ( )
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().

◆ insert() [1/2]

virtual void TaggedEntry::insert
inline

Insert the block by assigning it a tag and marking it valid.

Touches block if it hadn't been touched previously.

Parameters
tagThe tag value.

Definition at line 90 of file tagged_entry.hh.

◆ insert() [2/2]

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.

Parameters
tagBlock address tag.
is_secureWhether the block is in secure space or not.
src_requestor_IDThe source requestor ID.
task_IDThe 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=().

◆ invalidate()

virtual void CacheBlk::invalidate ( )
inlineoverridevirtual

◆ isSet()

bool CacheBlk::isSet ( unsigned  bits) const
inline

◆ operator=() [1/2]

virtual CacheBlk& CacheBlk::operator= ( CacheBlk &&  other)
inlinevirtual

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().

◆ operator=() [2/2]

CacheBlk& CacheBlk::operator= ( const CacheBlk )
delete

◆ print()

std::string CacheBlk::print ( ) const
inlineoverridevirtual

Pretty-print tag, set and way, and interpret state bits to readable form including mapping to a MOESI state.

Returns
string with basic state information

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().

◆ setCoherenceBits()

void CacheBlk::setCoherenceBits ( unsigned  bits)
inline

Sets the corresponding coherence bits.

Parameters
bitsThe 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().

◆ setPrefetched()

void CacheBlk::setPrefetched ( )
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().

◆ setRefCount()

void CacheBlk::setRefCount ( const unsigned  count)
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=().

◆ setSrcRequestorId()

void CacheBlk::setSrcRequestorId ( const uint32_t  id)
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=().

◆ setTaskId()

void CacheBlk::setTaskId ( const uint32_t  task_id)
inlineprotected

Set the task id value.

Definition at line 459 of file cache_blk.hh.

References _taskId.

Referenced by insert(), invalidate(), and operator=().

◆ setTickInserted()

void CacheBlk::setTickInserted ( )
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().

◆ setWhenReady()

void CacheBlk::setWhenReady ( const Tick  tick)
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.

Parameters
tickNew 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=().

◆ trackLoadLocked()

void CacheBlk::trackLoadLocked ( PacketPtr  pkt)
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().

◆ wasPrefetched()

bool CacheBlk::wasPrefetched ( ) const
inline

Check if this block was the result of a hardware prefetch, yet to be touched.

Returns
True if the block was a hardware prefetch, unaccesed.

Definition at line 245 of file cache_blk.hh.

References _prefetched.

Referenced by BaseCache::hasBeenPrefetched(), BaseCache::invalidateBlock(), and BaseCache::recvTimingReq().

Member Data Documentation

◆ _prefetched

bool CacheBlk::_prefetched
private

Whether this block is an unaccessed hardware prefetch.

Definition at line 487 of file cache_blk.hh.

Referenced by clearPrefetched(), setPrefetched(), and wasPrefetched().

◆ _refCount

unsigned CacheBlk::_refCount
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().

◆ _srcRequestorId

int CacheBlk::_srcRequestorId
private

holds the source requestor ID for this block.

Definition at line 475 of file cache_blk.hh.

Referenced by getSrcRequestorId(), and setSrcRequestorId().

◆ _taskId

uint32_t CacheBlk::_taskId
private

Task Id associated with this block.

Definition at line 472 of file cache_blk.hh.

Referenced by getTaskId(), and setTaskId().

◆ _tickInserted

Tick CacheBlk::_tickInserted
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().

◆ coherence

unsigned CacheBlk::coherence
protected

The current coherence status of this block.

See also
CoherenceBits

Definition at line 451 of file cache_blk.hh.

Referenced by clearCoherenceBits(), isSet(), print(), and setCoherenceBits().

◆ data

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().

◆ lockList

std::list<Lock> CacheBlk::lockList
protected

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().

◆ whenReady

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().


The documentation for this class was generated from the following files:

Generated on Tue Jun 22 2021 15:28:36 for gem5 by doxygen 1.8.17