gem5  v20.1.0.0
Classes | Public Types | Public Member Functions | Public Attributes | Protected Types | Protected Member Functions | Protected Attributes | List of all members
BaseCache Class Referenceabstract

A basic cache interface. More...

#include <base.hh>

Inheritance diagram for BaseCache:
ClockedObject SimObject Clocked EventManager Serializable Drainable Stats::Group Cache NoncoherentCache

Classes

struct  CacheCmdStats
 
class  CacheReqPacketQueue
 Override the default behaviour of sendDeferredPacket to enable the memory-side cache port to also send requests based on the current MSHR status. More...
 
class  CacheRequestPort
 A cache request port is used for the memory-side port of the cache, and in addition to the basic timing port that only sends response packets through a transmit list, it also offers the ability to schedule and send request packets (requests & writebacks). More...
 
class  CacheResponsePort
 A cache response port is used for the CPU-side port of the cache, and it is basically a simple timing port that uses a transmit list for responses to the CPU (or connected requestor). More...
 
struct  CacheStats
 
class  CpuSidePort
 The CPU-side port extends the base cache response port with access functions for functional, atomic and timing requests. More...
 
class  MemSidePort
 The memory-side port extends the base cache request port with access functions for functional, atomic and timing snoops. More...
 

Public Types

enum  BlockedCause { Blocked_NoMSHRs = MSHRQueue_MSHRs, Blocked_NoWBBuffers = MSHRQueue_WriteBuffer, Blocked_NoTargets, NUM_BLOCKED_CAUSES }
 Reasons for caches to be blocked. More...
 
- Public Types inherited from ClockedObject
typedef ClockedObjectParams Params
 Parameters of ClockedObject. More...
 
- Public Types inherited from SimObject
typedef SimObjectParams Params
 

Public Member Functions

void regProbePoints () override
 Registers probes. More...
 
 BaseCache (const BaseCacheParams *p, unsigned blk_size)
 
 ~BaseCache ()
 
void init () override
 init() is called after all C++ SimObjects have been created and all ports are connected. More...
 
PortgetPort (const std::string &if_name, PortID idx=InvalidPortID) override
 Get a port with a given name and index. More...
 
unsigned getBlockSize () const
 Query block size of a cache. More...
 
const AddrRangeListgetAddrRanges () const
 
MSHRallocateMissBuffer (PacketPtr pkt, Tick time, bool sched_send=true)
 
void allocateWriteBuffer (PacketPtr pkt, Tick time)
 
bool isBlocked () const
 Returns true if the cache is blocked for accesses. More...
 
void setBlocked (BlockedCause cause)
 Marks the access path of the cache as blocked for the given cause. More...
 
void clearBlocked (BlockedCause cause)
 Marks the cache as unblocked for the given cause. More...
 
void schedMemSideSendEvent (Tick time)
 Schedule a send event for the memory-side port. More...
 
bool inCache (Addr addr, bool is_secure) const
 
bool hasBeenPrefetched (Addr addr, bool is_secure) const
 
bool inMissQueue (Addr addr, bool is_secure) const
 
void incMissCount (PacketPtr pkt)
 
void incHitCount (PacketPtr pkt)
 
bool coalesce () const
 Checks if the cache is coalescing writes. More...
 
void writebackVisitor (CacheBlk &blk)
 Cache block visitor that writes back dirty cache blocks using functional writes. More...
 
void invalidateVisitor (CacheBlk &blk)
 Cache block visitor that invalidates all blocks in the cache. More...
 
virtual bool sendMSHRQueuePacket (MSHR *mshr)
 Take an MSHR, turn it into a suitable downstream packet, and send it out. More...
 
bool sendWriteQueuePacket (WriteQueueEntry *wq_entry)
 Similar to sendMSHR, but for a write-queue entry instead. More...
 
void serialize (CheckpointOut &cp) const override
 Serialize the state of the caches. More...
 
void unserialize (CheckpointIn &cp) override
 Unserialize an object. More...
 
- Public Member Functions inherited from ClockedObject
 ClockedObject (const ClockedObjectParams *p)
 
const Paramsparams () const
 
void serialize (CheckpointOut &cp) const override
 Serialize an object. More...
 
void unserialize (CheckpointIn &cp) override
 Unserialize an object. More...
 
- Public Member Functions inherited from SimObject
const Paramsparams () const
 
 SimObject (const Params *_params)
 
virtual ~SimObject ()
 
virtual const std::string name () const
 
virtual void loadState (CheckpointIn &cp)
 loadState() is called on each SimObject when restoring from a checkpoint. More...
 
virtual void initState ()
 initState() is called on each SimObject when not restoring from a checkpoint. More...
 
virtual void regProbeListeners ()
 Register probe listeners for this object. More...
 
ProbeManagergetProbeManager ()
 Get the probe manager for this object. More...
 
virtual void startup ()
 startup() is the final initialization call before simulation. More...
 
DrainState drain () override
 Provide a default implementation of the drain interface for objects that don't need draining. More...
 
void serialize (CheckpointOut &cp) const override
 Serialize an object. More...
 
void unserialize (CheckpointIn &cp) override
 Unserialize an object. More...
 
- Public Member Functions inherited from EventManager
EventQueueeventQueue () const
 
void schedule (Event &event, Tick when)
 
void deschedule (Event &event)
 
void reschedule (Event &event, Tick when, bool always=false)
 
void schedule (Event *event, Tick when)
 
void deschedule (Event *event)
 
void reschedule (Event *event, Tick when, bool always=false)
 
void wakeupEventQueue (Tick when=(Tick) -1)
 This function is not needed by the usual gem5 event loop but may be necessary in derived EventQueues which host gem5 on other schedulers. More...
 
void setCurTick (Tick newVal)
 
 EventManager (EventManager &em)
 Event manger manages events in the event queue. More...
 
 EventManager (EventManager *em)
 
 EventManager (EventQueue *eq)
 
- Public Member Functions inherited from Serializable
 Serializable ()
 
virtual ~Serializable ()
 
void serializeSection (CheckpointOut &cp, const char *name) const
 Serialize an object into a new section. More...
 
void serializeSection (CheckpointOut &cp, const std::string &name) const
 
void unserializeSection (CheckpointIn &cp, const char *name)
 Unserialize an a child object. More...
 
void unserializeSection (CheckpointIn &cp, const std::string &name)
 
- Public Member Functions inherited from Drainable
DrainState drainState () const
 Return the current drain state of an object. More...
 
virtual void notifyFork ()
 Notify a child process of a fork. More...
 
- Public Member Functions inherited from Stats::Group
 Group (Group *parent, const char *name=nullptr)
 Construct a new statistics group. More...
 
virtual ~Group ()
 
virtual void regStats ()
 Callback to set stat parameters. More...
 
virtual void resetStats ()
 Callback to reset stats. More...
 
virtual void preDumpStats ()
 Callback before stats are dumped. More...
 
void addStat (Stats::Info *info)
 Register a stat with this group. More...
 
const std::map< std::string, Group * > & getStatGroups () const
 Get all child groups associated with this object. More...
 
const std::vector< Info * > & getStats () const
 Get all stats associated with this object. More...
 
void addStatGroup (const char *name, Group *block)
 Add a stat block as a child of this block. More...
 
const InforesolveStat (std::string name) const
 Resolve a stat by its name within this group. More...
 
 Group ()=delete
 
 Group (const Group &)=delete
 
Groupoperator= (const Group &)=delete
 
- Public Member Functions inherited from Clocked
void updateClockPeriod ()
 Update the tick to the current tick. More...
 
Tick clockEdge (Cycles cycles=Cycles(0)) const
 Determine the tick when a cycle begins, by default the current one, but the argument also enables the caller to determine a future cycle. More...
 
Cycles curCycle () const
 Determine the current cycle, corresponding to a tick aligned to a clock edge. More...
 
Tick nextCycle () const
 Based on the clock of the object, determine the start tick of the first cycle that is at least one cycle in the future. More...
 
uint64_t frequency () const
 
Tick clockPeriod () const
 
double voltage () const
 
Cycles ticksToCycles (Tick t) const
 
Tick cyclesToTicks (Cycles c) const
 

Public Attributes

Systemsystem
 System we are currently operating in. More...
 
BaseCache::CacheStats stats
 
- Public Attributes inherited from ClockedObject
PowerStatepowerState
 

Protected Types

enum  MSHRQueueIndex { MSHRQueue_MSHRs, MSHRQueue_WriteBuffer }
 Indexes to enumerate the MSHR queues. More...
 

Protected Member Functions

void markInService (MSHR *mshr, bool pending_modified_resp)
 Mark a request as in service (sent downstream in the memory system), effectively making this MSHR the ordering point. More...
 
void markInService (WriteQueueEntry *entry)
 
bool allocOnFill (MemCmd cmd) const
 Determine whether we should allocate on a fill or not. More...
 
Addr regenerateBlkAddr (CacheBlk *blk)
 Regenerate block address using tags. More...
 
Cycles calculateTagOnlyLatency (const uint32_t delay, const Cycles lookup_lat) const
 Calculate latency of accesses that only touch the tag array. More...
 
Cycles calculateAccessLatency (const CacheBlk *blk, const uint32_t delay, const Cycles lookup_lat) const
 Calculate access latency in ticks given a tag lookup latency, and whether access was a hit or miss. More...
 
virtual bool access (PacketPtr pkt, CacheBlk *&blk, Cycles &lat, PacketList &writebacks)
 Does all the processing necessary to perform the provided request. More...
 
virtual void handleTimingReqHit (PacketPtr pkt, CacheBlk *blk, Tick request_time)
 
virtual void handleTimingReqMiss (PacketPtr pkt, CacheBlk *blk, Tick forward_time, Tick request_time)=0
 
void handleTimingReqMiss (PacketPtr pkt, MSHR *mshr, CacheBlk *blk, Tick forward_time, Tick request_time)
 
virtual void recvTimingReq (PacketPtr pkt)
 Performs the access specified by the request. More...
 
void handleUncacheableWriteResp (PacketPtr pkt)
 Handling the special case of uncacheable write responses to make recvTimingResp less cluttered. More...
 
virtual void serviceMSHRTargets (MSHR *mshr, const PacketPtr pkt, CacheBlk *blk)=0
 Service non-deferred MSHR targets using the received response. More...
 
virtual void recvTimingResp (PacketPtr pkt)
 Handles a response (cache line fill/write ack) from the bus. More...
 
virtual void recvTimingSnoopReq (PacketPtr pkt)=0
 Snoops bus transactions to maintain coherence. More...
 
virtual void recvTimingSnoopResp (PacketPtr pkt)=0
 Handle a snoop response. More...
 
virtual Cycles handleAtomicReqMiss (PacketPtr pkt, CacheBlk *&blk, PacketList &writebacks)=0
 Handle a request in atomic mode that missed in this cache. More...
 
virtual Tick recvAtomic (PacketPtr pkt)
 Performs the access specified by the request. More...
 
virtual Tick recvAtomicSnoop (PacketPtr pkt)=0
 Snoop for the provided request in the cache and return the estimated time taken. More...
 
virtual void functionalAccess (PacketPtr pkt, bool from_cpu_side)
 Performs the access specified by the request. More...
 
void cmpAndSwap (CacheBlk *blk, PacketPtr pkt)
 Handle doing the Compare and Swap function for SPARC. More...
 
QueueEntrygetNextQueueEntry ()
 Return the next queue entry to service, either a pending miss from the MSHR queue, a buffered write from the write buffer, or something from the prefetcher. More...
 
virtual void doWritebacks (PacketList &writebacks, Tick forward_time)=0
 Insert writebacks into the write buffer. More...
 
virtual void doWritebacksAtomic (PacketList &writebacks)=0
 Send writebacks down the memory hierarchy in atomic mode. More...
 
virtual PacketPtr createMissPacket (PacketPtr cpu_pkt, CacheBlk *blk, bool needs_writable, bool is_whole_line_write) const =0
 Create an appropriate downstream bus request packet. More...
 
void writebackTempBlockAtomic ()
 Send the outstanding tempBlock writeback. More...
 
bool updateCompressionData (CacheBlk *blk, const uint64_t *data, PacketList &writebacks)
 When a block is overwriten, its compression information must be updated, and it may need to be recompressed. More...
 
virtual void satisfyRequest (PacketPtr pkt, CacheBlk *blk, bool deferred_response=false, bool pending_downgrade=false)
 Perform any necessary updates to the block and perform any data exchange between the packet and the block. More...
 
void maintainClusivity (bool from_cache, CacheBlk *blk)
 Maintain the clusivity of this cache by potentially invalidating a block. More...
 
bool handleEvictions (std::vector< CacheBlk * > &evict_blks, PacketList &writebacks)
 Try to evict the given blocks. More...
 
CacheBlkhandleFill (PacketPtr pkt, CacheBlk *blk, PacketList &writebacks, bool allocate)
 Handle a fill operation caused by a received packet. More...
 
CacheBlkallocateBlock (const PacketPtr pkt, PacketList &writebacks)
 Allocate a new block and perform any necessary writebacks. More...
 
virtual M5_NODISCARD PacketPtr evictBlock (CacheBlk *blk)=0
 Evict a cache block. More...
 
void evictBlock (CacheBlk *blk, PacketList &writebacks)
 Evict a cache block. More...
 
void invalidateBlock (CacheBlk *blk)
 Invalidate a cache block. More...
 
PacketPtr writebackBlk (CacheBlk *blk)
 Create a writeback request for the given block. More...
 
PacketPtr writecleanBlk (CacheBlk *blk, Request::Flags dest, PacketId id)
 Create a writeclean request for the given block. More...
 
virtual void memWriteback () override
 Write back dirty blocks in the cache using functional accesses. More...
 
virtual void memInvalidate () override
 Invalidates all blocks in the cache. More...
 
bool isDirty () const
 Determine if there are any dirty blocks in the cache. More...
 
bool inRange (Addr addr) const
 Determine if an address is in the ranges covered by this cache. More...
 
Tick nextQueueReadyTime () const
 Find next request ready time from among possible sources. More...
 
- Protected Member Functions inherited from Drainable
 Drainable ()
 
virtual ~Drainable ()
 
virtual void drainResume ()
 Resume execution after a successful drain. More...
 
void signalDrainDone () const
 Signal that an object is drained. More...
 
- Protected Member Functions inherited from Clocked
 Clocked (ClockDomain &clk_domain)
 Create a clocked object and set the clock domain based on the parameters. More...
 
 Clocked (Clocked &)=delete
 
Clockedoperator= (Clocked &)=delete
 
virtual ~Clocked ()
 Virtual destructor due to inheritance. More...
 
void resetClock () const
 Reset the object's clock using the current global tick value. More...
 
virtual void clockPeriodUpdated ()
 A hook subclasses can implement so they can do any extra work that's needed when the clock rate is changed. More...
 

Protected Attributes

CpuSidePort cpuSidePort
 
MemSidePort memSidePort
 
MSHRQueue mshrQueue
 Miss status registers. More...
 
WriteQueue writeBuffer
 Write/writeback buffer. More...
 
BaseTagstags
 Tag and data Storage. More...
 
Compressor::Basecompressor
 Compression method being used. More...
 
Prefetcher::Baseprefetcher
 Prefetcher. More...
 
ProbePointArg< PacketPtr > * ppHit
 To probe when a cache hit occurs. More...
 
ProbePointArg< PacketPtr > * ppMiss
 To probe when a cache miss occurs. More...
 
ProbePointArg< PacketPtr > * ppFill
 To probe when a cache fill occurs. More...
 
WriteAllocator *const writeAllocator
 The writeAllocator drive optimizations for streaming writes. More...
 
TempCacheBlktempBlock
 Temporary cache block for occasional transitory use. More...
 
std::unique_ptr< PacketpendingDelete
 Upstream caches need this packet until true is returned, so hold it for deletion until a subsequent call. More...
 
const bool writebackClean
 Determine if clean lines should be written back or not. More...
 
PacketPtr tempBlockWriteback
 Writebacks from the tempBlock, resulting on the response path in atomic mode, must happen after the call to recvAtomic has finished (for the right ordering of the packets). More...
 
EventFunctionWrapper writebackTempBlockAtomicEvent
 An event to writeback the tempBlock after recvAtomic finishes. More...
 
const unsigned blkSize
 Block size of this cache. More...
 
const Cycles lookupLatency
 The latency of tag lookup of a cache. More...
 
const Cycles dataLatency
 The latency of data access of a cache. More...
 
const Cycles forwardLatency
 This is the forward latency of the cache. More...
 
const Cycles fillLatency
 The latency to fill a cache block. More...
 
const Cycles responseLatency
 The latency of sending reponse to its upper level cache/core on a linefill. More...
 
const bool sequentialAccess
 Whether tags and data are accessed sequentially. More...
 
const int numTarget
 The number of targets for each MSHR. More...
 
bool forwardSnoops
 Do we forward snoops from mem side port through to cpu side port? More...
 
const Enums::Clusivity clusivity
 Clusivity with respect to the upstream cache, determining if we fill into both this cache and the cache above on a miss. More...
 
const bool isReadOnly
 Is this cache read only, for example the instruction cache, or table-walker cache. More...
 
uint8_t blocked
 Bit vector of the blocking reasons for the access path. More...
 
uint64_t order
 Increasing order number assigned to each incoming request. More...
 
Cycles blockedCycle
 Stores time the cache blocked for statistics. More...
 
MSHRnoTargetMSHR
 Pointer to the MSHR that has no targets. More...
 
Counter missCount
 The number of misses to trigger an exit event. More...
 
const AddrRangeList addrRanges
 The address range to which the cache responds on the CPU side. More...
 
- Protected Attributes inherited from SimObject
const SimObjectParams * _params
 Cached copy of the object parameters. More...
 
- Protected Attributes inherited from EventManager
EventQueueeventq
 A pointer to this object's event queue. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from SimObject
static void serializeAll (CheckpointOut &cp)
 Serialize all SimObjects in the system. More...
 
static SimObjectfind (const char *name)
 Find the SimObject with the given name and return a pointer to it. More...
 
- Static Public Member Functions inherited from Serializable
static const std::string & currentSection ()
 Gets the fully-qualified name of the active section. More...
 
static void serializeAll (const std::string &cpt_dir)
 Serializes all the SimObjects. More...
 
static void unserializeGlobals (CheckpointIn &cp)
 

Detailed Description

A basic cache interface.

Implements some common functions for speed.

Definition at line 89 of file base.hh.

Member Enumeration Documentation

◆ BlockedCause

Reasons for caches to be blocked.

Enumerator
Blocked_NoMSHRs 
Blocked_NoWBBuffers 
Blocked_NoTargets 
NUM_BLOCKED_CAUSES 

Definition at line 104 of file base.hh.

◆ MSHRQueueIndex

enum BaseCache::MSHRQueueIndex
protected

Indexes to enumerate the MSHR queues.

Enumerator
MSHRQueue_MSHRs 
MSHRQueue_WriteBuffer 

Definition at line 95 of file base.hh.

Constructor & Destructor Documentation

◆ BaseCache()

BaseCache::BaseCache ( const BaseCacheParams *  p,
unsigned  blk_size 
)

Definition at line 76 of file base.cc.

References writebackTempBlockAtomic().

◆ ~BaseCache()

BaseCache::~BaseCache ( )

Definition at line 126 of file base.cc.

References tempBlock.

Member Function Documentation

◆ access()

bool BaseCache::access ( PacketPtr  pkt,
CacheBlk *&  blk,
Cycles lat,
PacketList writebacks 
)
protectedvirtual

Does all the processing necessary to perform the provided request.

Parameters
pktThe memory request to perform.
blkThe cache block to be updated.
latThe latency of the access.
writebacksList for any writebacks that need to be performed.
Returns
Boolean indicating whether the request was satisfied.

Reimplemented in Cache, and NoncoherentCache.

Definition at line 1030 of file base.cc.

References BaseTags::accessBlock(), allocateBlock(), BlkDirty, BlkReadable, blkSize, BlkWritable, calculateAccessLatency(), calculateTagOnlyLatency(), chatty_assert, MemCmd::CleanEvict, Packet::clearBlockCached(), Clocked::clockEdge(), Packet::cmd, compressor, Clocked::cyclesToTicks(), CacheBlk::data, DPRINTF, fillLatency, Queue< Entry >::findMatch(), Packet::fromCache(), Packet::getAddr(), Packet::getConstPtr(), Compressor::Base::getDecompressionLatency(), WriteQueueEntry::getNumTargets(), Packet::getSize(), WriteQueueEntry::getTarget(), Packet::hasSharers(), Packet::headerDelay, incHitCount(), incMissCount(), invalidateBlock(), Packet::isCleanEviction(), Packet::isEviction(), Packet::isLLSC(), Packet::isRead(), CacheBlk::isReadable(), isReadOnly, Packet::isRequest(), Packet::isSecure(), CacheBlk::isWritable(), Packet::isWrite(), Packet::isWriteback(), maintainClusivity(), markInService(), mshrQueue, SimObject::name(), Packet::needsResponse(), Packet::needsWritable(), Packet::payloadDelay, QueueEntry::Target::pkt, CacheBlk::print(), Packet::print(), Packet::req, satisfyRequest(), CacheBlk::setWhenReady(), CacheBlk::status, tags, updateCompressionData(), MemCmd::WritebackClean, MemCmd::WritebackDirty, writeBuffer, MemCmd::WriteClean, Packet::writeDataToBlock(), and Packet::writeThrough().

Referenced by NoncoherentCache::access(), Cache::access(), recvAtomic(), and recvTimingReq().

◆ allocateBlock()

CacheBlk * BaseCache::allocateBlock ( const PacketPtr  pkt,
PacketList writebacks 
)
protected

Allocate a new block and perform any necessary writebacks.

Find a victim block and if necessary prepare writebacks for any existing data. May return nullptr if there are no replaceable blocks. If a replaceable block is found, it inserts the new block in its place. The new block, however, is not set as valid yet.

Parameters
pktPacket holding the address to update
writebacksA list of writeback packets for the evicted blocks
Returns
the allocated block

Definition at line 1403 of file base.cc.

References addr, blkSize, Compressor::Base::compress(), compressor, DPRINTF, BaseTags::findVictim(), Packet::getAddr(), Packet::getConstPtr(), handleEvictions(), Packet::hasData(), BaseTags::insertBlock(), Packet::isSecure(), CacheBlk::print(), Compressor::Base::setDecompressionLatency(), Compressor::Base::setSizeBits(), and tags.

Referenced by access(), and handleFill().

◆ allocateMissBuffer()

MSHR* BaseCache::allocateMissBuffer ( PacketPtr  pkt,
Tick  time,
bool  sched_send = true 
)
inline

◆ allocateWriteBuffer()

void BaseCache::allocateWriteBuffer ( PacketPtr  pkt,
Tick  time 
)
inline

◆ allocOnFill()

bool BaseCache::allocOnFill ( MemCmd  cmd) const
inlineprotected

Determine whether we should allocate on a fill or not.

If this cache is mostly inclusive with regards to the upstream cache(s) we always allocate (for any non-forwarded and cacheable requests). In the case of a mostly exclusive cache, we allocate on fill if the packet did not come from a cache, thus if we: are dealing with a whole-line write (the latter behaves much like a writeback), the original target packet came from a non-caching source, or if we are performing a prefetch or LLSC.

Parameters
cmdCommand of the incoming requesting packet
Returns
Whether we should allocate on the fill

Definition at line 404 of file base.hh.

References clusivity, MemCmd::isLLSC(), MemCmd::isPrefetch(), MemCmd::ReadReq, MemCmd::WriteLineReq, and MemCmd::WriteReq.

Referenced by allocateMissBuffer(), NoncoherentCache::handleAtomicReqMiss(), Cache::handleAtomicReqMiss(), and handleTimingReqMiss().

◆ calculateAccessLatency()

Cycles BaseCache::calculateAccessLatency ( const CacheBlk blk,
const uint32_t  delay,
const Cycles  lookup_lat 
) const
protected

Calculate access latency in ticks given a tag lookup latency, and whether access was a hit or miss.

Parameters
blkThe cache block that was accessed.
delayThe delay until the packet's metadata is present.
lookup_latLatency of the respective tag lookup.
Returns
The number of ticks that pass due to a block access.

Definition at line 996 of file base.cc.

References calculateTagOnlyLatency(), curTick(), dataLatency, CacheBlk::getWhenReady(), sequentialAccess, Clocked::tick, and Clocked::ticksToCycles().

Referenced by access().

◆ calculateTagOnlyLatency()

Cycles BaseCache::calculateTagOnlyLatency ( const uint32_t  delay,
const Cycles  lookup_lat 
) const
protected

Calculate latency of accesses that only touch the tag array.

See also
calculateAccessLatency
Parameters
delayThe delay until the packet's metadata is present.
lookup_latLatency of the respective tag lookup.
Returns
The number of ticks that pass due to a tag-only access.

Definition at line 987 of file base.cc.

References Clocked::ticksToCycles().

Referenced by access(), and calculateAccessLatency().

◆ clearBlocked()

void BaseCache::clearBlocked ( BlockedCause  cause)
inline

Marks the cache as unblocked for the given cause.

This also clears the blocked flags in the appropriate interfaces.

Parameters
causeThe newly unblocked cause.
Warning
Calling this function can cause a blocked request on the bus to access the cache. The cache must be in a state to handle that request.

Definition at line 1179 of file base.hh.

References blocked, BaseCache::CacheStats::blocked_cycles, blockedCycle, BaseCache::CacheResponsePort::clearBlocked(), cpuSidePort, Clocked::curCycle(), DPRINTF, and stats.

Referenced by markInService(), recvTimingResp(), and Cache::sendMSHRQueuePacket().

◆ cmpAndSwap()

void BaseCache::cmpAndSwap ( CacheBlk blk,
PacketPtr  pkt 
)
protected

Handle doing the Compare and Swap function for SPARC.

Definition at line 677 of file base.cc.

References BlkDirty, blkSize, CacheBlk::data, Packet::getOffset(), Packet::getSize(), Packet::isRequest(), ArmISA::offset, panic, Packet::req, Packet::setData(), CacheBlk::status, and Packet::writeData().

Referenced by satisfyRequest().

◆ coalesce()

bool BaseCache::coalesce ( ) const

Checks if the cache is coalescing writes.

Returns
True if the cache is coalescing writes

Definition at line 1598 of file base.cc.

References WriteAllocator::coalesce(), and writeAllocator.

Referenced by Prefetcher::Base::probeNotify().

◆ createMissPacket()

virtual PacketPtr BaseCache::createMissPacket ( PacketPtr  cpu_pkt,
CacheBlk blk,
bool  needs_writable,
bool  is_whole_line_write 
) const
protectedpure virtual

Create an appropriate downstream bus request packet.

Creates a new packet with the request to be send to the memory below, or nullptr if the current request in cpu_pkt should just be forwarded on.

Parameters
cpu_pktThe miss packet that needs to be satisfied.
blkThe referenced block, can be nullptr.
needs_writableIndicates that the block must be writable even if the request in cpu_pkt doesn't indicate that.
is_whole_line_writeTrue if there are writes for the whole line
Returns
A packet send to the memory below

Implemented in Cache, and NoncoherentCache.

Referenced by sendMSHRQueuePacket().

◆ doWritebacks()

virtual void BaseCache::doWritebacks ( PacketList writebacks,
Tick  forward_time 
)
protectedpure virtual

Insert writebacks into the write buffer.

Implemented in Cache, and NoncoherentCache.

Referenced by recvTimingReq(), recvTimingResp(), and sendMSHRQueuePacket().

◆ doWritebacksAtomic()

virtual void BaseCache::doWritebacksAtomic ( PacketList writebacks)
protectedpure virtual

Send writebacks down the memory hierarchy in atomic mode.

Implemented in Cache, and NoncoherentCache.

Referenced by recvAtomic(), and writebackTempBlockAtomic().

◆ evictBlock() [1/2]

virtual M5_NODISCARD PacketPtr BaseCache::evictBlock ( CacheBlk blk)
protectedpure virtual

Evict a cache block.

Performs a writeback if necesssary and invalidates the block

Parameters
blkBlock to invalidate
Returns
A packet with the writeback, can be nullptr

Implemented in Cache, and NoncoherentCache.

Referenced by Cache::access(), evictBlock(), handleEvictions(), recvAtomic(), and recvTimingResp().

◆ evictBlock() [2/2]

void BaseCache::evictBlock ( CacheBlk blk,
PacketList writebacks 
)
protected

Evict a cache block.

Performs a writeback if necesssary and invalidates the block

Parameters
blkBlock to invalidate
writebacksReturn a list of packets with writebacks

Definition at line 1477 of file base.cc.

References evictBlock().

◆ functionalAccess()

void BaseCache::functionalAccess ( PacketPtr  pkt,
bool  from_cpu_side 
)
protectedvirtual

◆ getAddrRanges()

const AddrRangeList& BaseCache::getAddrRanges ( ) const
inline

Definition at line 1095 of file base.hh.

References addrRanges.

◆ getBlockSize()

unsigned BaseCache::getBlockSize ( ) const
inline

Query block size of a cache.

Returns
The block size

Definition at line 1090 of file base.hh.

References blkSize.

Referenced by Prefetcher::Base::setCache().

◆ getNextQueueEntry()

QueueEntry * BaseCache::getNextQueueEntry ( )
protected

Return the next queue entry to service, either a pending miss from the MSHR queue, a buffered write from the write buffer, or something from the prefetcher.

This function is responsible for prioritizing among those sources on the fly.

Definition at line 717 of file base.cc.

References allocateMissBuffer(), blkSize, MSHRQueue::canPrefetch(), BaseCache::CacheStats::cmdStats(), curTick(), BaseTags::findBlock(), Queue< Entry >::findMatch(), Queue< Entry >::findPending(), Packet::getBlockAddr(), Queue< Entry >::getNext(), Prefetcher::Base::getPacket(), isBlocked(), Queue< Entry >::isFull(), Packet::isSecure(), System::maxRequestors(), BaseCache::CacheCmdStats::mshr_misses, mshrQueue, QueueEntry::order, prefetcher, Packet::req, stats, system, tags, and writeBuffer.

◆ getPort()

Port & BaseCache::getPort ( const std::string &  if_name,
PortID  idx = InvalidPortID 
)
overridevirtual

Get a port with a given name and index.

This is used at binding time and returns a reference to a protocol-agnostic port.

gem5 has a request and response port interface. All memory objects are connected together via ports. These ports provide a rigid interface between these memory objects. These ports implement three different memory system modes: timing, atomic, and functional. The most important mode is the timing mode and here timing mode is used for conducting cycle-level timing experiments. The other modes are only used in special circumstances and should not be used to conduct cycle-level timing experiments. The other modes are only used in special circumstances. These ports allow SimObjects to communicate with each other.

Parameters
if_namePort name
idxIndex in the case of a VectorPort
Returns
A reference to the given port

Reimplemented from SimObject.

Definition at line 188 of file base.cc.

References cpuSidePort, SimObject::getPort(), and memSidePort.

◆ handleAtomicReqMiss()

virtual Cycles BaseCache::handleAtomicReqMiss ( PacketPtr  pkt,
CacheBlk *&  blk,
PacketList writebacks 
)
protectedpure virtual

Handle a request in atomic mode that missed in this cache.

Creates a downstream request, sends it to the memory below and handles the response. As we are in atomic mode all operations are performed immediately.

Parameters
pktThe packet with the requests
blkThe referenced block
writebacksA list with packets for any performed writebacks
Returns
Cycles for handling the request

Implemented in Cache, and NoncoherentCache.

Referenced by recvAtomic().

◆ handleEvictions()

bool BaseCache::handleEvictions ( std::vector< CacheBlk * > &  evict_blks,
PacketList writebacks 
)
protected

Try to evict the given blocks.

If any of them is a transient eviction, that is, the block is present in the MSHR queue all evictions are cancelled since handling such cases has not been implemented.

Parameters
evict_blksBlocks marked for eviction.
writebacksList for any writebacks that need to be performed.
Returns
False if any of the evicted blocks is in transient state.

Definition at line 795 of file base.cc.

References evictBlock(), Queue< Entry >::findMatch(), MSHR::isCleaning(), mshrQueue, MSHR::needsWritable(), regenerateBlkAddr(), BaseCache::CacheStats::replacements, and stats.

Referenced by allocateBlock(), and updateCompressionData().

◆ handleFill()

CacheBlk * BaseCache::handleFill ( PacketPtr  pkt,
CacheBlk blk,
PacketList writebacks,
bool  allocate 
)
protected

Handle a fill operation caused by a received packet.

Populates a cache block and handles all outstanding requests for the satisfied fill request. This version takes two memory requests. One contains the fill data, the other is an optional target to satisfy. Note that the reason we return a list of writebacks rather than inserting them directly in the write buffer is that this function is called by both atomic and timing-mode accesses, and in atomic mode we don't mess with the write buffer (we just perform the writebacks atomically once the original request is complete).

Parameters
pktThe memory request with the fill data.
blkThe cache block if it already exists.
writebacksList for any writebacks that need to be performed.
allocateWhether to allocate a block or use the temp block
Returns
Pointer to the new cache block.

Definition at line 1306 of file base.cc.

References addr, allocateBlock(), BlkDirty, BlkReadable, blkSize, BlkWritable, Packet::cacheResponding(), chatty_assert, Clocked::clockEdge(), Packet::cmd, CacheBlk::data, DPRINTF, fillLatency, Queue< Entry >::findMatch(), Packet::getAddr(), Packet::getBlockAddr(), Packet::getSize(), Packet::hasData(), Packet::hasSharers(), Packet::headerDelay, TempCacheBlk::insert(), MemCmd::InvalidateResp, Packet::isRead(), isReadOnly, Packet::isResponse(), CacheBlk::isSecure(), Packet::isSecure(), CacheBlk::isValid(), SimObject::name(), Packet::payloadDelay, CacheBlk::print(), regenerateBlkAddr(), CacheBlk::setWhenReady(), CacheBlk::status, tempBlock, writeBuffer, and Packet::writeDataToBlock().

Referenced by NoncoherentCache::handleAtomicReqMiss(), Cache::handleAtomicReqMiss(), and recvTimingResp().

◆ handleTimingReqHit()

void BaseCache::handleTimingReqHit ( PacketPtr  pkt,
CacheBlk blk,
Tick  request_time 
)
protectedvirtual

◆ handleTimingReqMiss() [1/2]

virtual void BaseCache::handleTimingReqMiss ( PacketPtr  pkt,
CacheBlk blk,
Tick  forward_time,
Tick  request_time 
)
protectedpure virtual

◆ handleTimingReqMiss() [2/2]

void BaseCache::handleTimingReqMiss ( PacketPtr  pkt,
MSHR mshr,
CacheBlk blk,
Tick  forward_time,
Tick  request_time 
)
protected

◆ handleUncacheableWriteResp()

void BaseCache::handleUncacheableWriteResp ( PacketPtr  pkt)
protected

Handling the special case of uncacheable write responses to make recvTimingResp less cluttered.

Definition at line 390 of file base.cc.

References Clocked::clockEdge(), cpuSidePort, Packet::headerDelay, Packet::payloadDelay, responseLatency, and QueuedResponsePort::schedTimingResp().

Referenced by recvTimingResp().

◆ hasBeenPrefetched()

bool BaseCache::hasBeenPrefetched ( Addr  addr,
bool  is_secure 
) const
inline

Definition at line 1207 of file base.hh.

References addr, BaseTags::findBlock(), tags, and CacheBlk::wasPrefetched().

Referenced by Prefetcher::Base::hasBeenPrefetched().

◆ inCache()

bool BaseCache::inCache ( Addr  addr,
bool  is_secure 
) const
inline

Definition at line 1203 of file base.hh.

References addr, BaseTags::findBlock(), and tags.

Referenced by Prefetcher::Base::inCache().

◆ incHitCount()

void BaseCache::incHitCount ( PacketPtr  pkt)
inline

◆ incMissCount()

void BaseCache::incMissCount ( PacketPtr  pkt)
inline

◆ init()

void BaseCache::init ( )
overridevirtual

init() is called after all C++ SimObjects have been created and all ports are connected.

Initializations that are independent of unserialization but rely on a fully instantiated and connected SimObject graph should be done here.

Reimplemented from SimObject.

Definition at line 179 of file base.cc.

References cpuSidePort, fatal, forwardSnoops, Port::isConnected(), ResponsePort::isSnooping(), memSidePort, SimObject::name(), and ResponsePort::sendRangeChange().

◆ inMissQueue()

bool BaseCache::inMissQueue ( Addr  addr,
bool  is_secure 
) const
inline

Definition at line 1216 of file base.hh.

References addr, Queue< Entry >::findMatch(), and mshrQueue.

Referenced by Prefetcher::Base::inMissQueue().

◆ inRange()

bool BaseCache::inRange ( Addr  addr) const
protected

Determine if an address is in the ranges covered by this cache.

This is useful to filter snoops.

Parameters
addrAddress to check against
Returns
If the address in question is in range

Definition at line 200 of file base.cc.

References addr, addrRanges, and MipsISA::r.

Referenced by Cache::recvAtomicSnoop(), and Cache::recvTimingSnoopReq().

◆ invalidateBlock()

void BaseCache::invalidateBlock ( CacheBlk blk)
protected

◆ invalidateVisitor()

void BaseCache::invalidateVisitor ( CacheBlk blk)

Cache block visitor that invalidates all blocks in the cache.

@warn Dirty cache lines will not be written back to memory.

Definition at line 1627 of file base.cc.

References invalidateBlock(), CacheBlk::isDirty(), CacheBlk::isValid(), and warn_once.

Referenced by memInvalidate().

◆ isBlocked()

bool BaseCache::isBlocked ( ) const
inline

Returns true if the cache is blocked for accesses.

Definition at line 1150 of file base.hh.

References blocked.

Referenced by getNextQueueEntry(), nextQueueReadyTime(), and recvTimingResp().

◆ isDirty()

bool BaseCache::isDirty ( ) const
protected

Determine if there are any dirty blocks in the cache.

Returns
true if at least one block is dirty, false otherwise.

Definition at line 1592 of file base.cc.

References BaseTags::anyBlk(), CacheBlk::isDirty(), and tags.

Referenced by serialize().

◆ maintainClusivity()

void BaseCache::maintainClusivity ( bool  from_cache,
CacheBlk blk 
)
protected

Maintain the clusivity of this cache by potentially invalidating a block.

This method works in conjunction with satisfyRequest, but is separate to allow us to handle all MSHR targets before potentially dropping a block.

Parameters
from_cacheWhether we have dealt with a packet from a cache
blkThe block that should potentially be dropped

Definition at line 1294 of file base.cc.

References clusivity, invalidateBlock(), CacheBlk::isDirty(), and CacheBlk::isValid().

Referenced by access(), NoncoherentCache::handleAtomicReqMiss(), Cache::handleAtomicReqMiss(), and Cache::serviceMSHRTargets().

◆ markInService() [1/2]

void BaseCache::markInService ( MSHR mshr,
bool  pending_modified_resp 
)
inlineprotected

Mark a request as in service (sent downstream in the memory system), effectively making this MSHR the ordering point.

Definition at line 371 of file base.hh.

References Blocked_NoMSHRs, clearBlocked(), Queue< Entry >::isFull(), MSHRQueue::markInService(), and mshrQueue.

Referenced by access(), Cache::recvTimingSnoopReq(), Cache::sendMSHRQueuePacket(), sendMSHRQueuePacket(), and sendWriteQueuePacket().

◆ markInService() [2/2]

void BaseCache::markInService ( WriteQueueEntry entry)
inlineprotected

◆ memInvalidate()

void BaseCache::memInvalidate ( )
overrideprotectedvirtual

Invalidates all blocks in the cache.

@warn Dirty cache lines will not be written back to memory. Make sure to call functionalWriteback() first if you want the to write them to memory.

Reimplemented from SimObject.

Definition at line 1586 of file base.cc.

References BaseTags::forEachBlk(), invalidateVisitor(), and tags.

◆ memWriteback()

void BaseCache::memWriteback ( )
overrideprotectedvirtual

Write back dirty blocks in the cache using functional accesses.

Reimplemented from SimObject.

Definition at line 1580 of file base.cc.

References BaseTags::forEachBlk(), tags, and writebackVisitor().

◆ nextQueueReadyTime()

Tick BaseCache::nextQueueReadyTime ( ) const
protected

Find next request ready time from among possible sources.

Definition at line 1640 of file base.cc.

References MSHRQueue::canPrefetch(), isBlocked(), mshrQueue, Prefetcher::Base::nextPrefetchReadyTime(), Queue< Entry >::nextReadyTime(), prefetcher, and writeBuffer.

◆ recvAtomic()

Tick BaseCache::recvAtomic ( PacketPtr  pkt)
protectedvirtual

◆ recvAtomicSnoop()

virtual Tick BaseCache::recvAtomicSnoop ( PacketPtr  pkt)
protectedpure virtual

Snoop for the provided request in the cache and return the estimated time taken.

Parameters
pktThe memory request to snoop
Returns
The number of ticks required for the snoop.

Implemented in Cache, and NoncoherentCache.

◆ recvTimingReq()

void BaseCache::recvTimingReq ( PacketPtr  pkt)
protectedvirtual

◆ recvTimingResp()

void BaseCache::recvTimingResp ( PacketPtr  pkt)
protectedvirtual

Handles a response (cache line fill/write ack) from the bus.

Parameters
pktThe response packet

Reimplemented in NoncoherentCache.

Definition at line 402 of file base.cc.

References WriteAllocator::allocate(), MSHR::allocOnFill(), BlkReadable, Blocked_NoMSHRs, Blocked_NoTargets, MSHRQueue::canPrefetch(), clearBlocked(), Clocked::clockEdge(), Packet::cmd, BaseCache::CacheStats::cmdStats(), curTick(), Queue< Entry >::deallocate(), doWritebacks(), DPRINTF, evictBlock(), BaseTags::findBlock(), forwardLatency, Packet::getAddr(), MSHR::getTarget(), handleFill(), handleUncacheableWriteResp(), MemCmd::HardPFResp, Packet::headerDelay, isBlocked(), Packet::isClean(), Packet::isError(), MSHR::isForward, Queue< Entry >::isFull(), Packet::isInvalidate(), Packet::isRead(), Packet::isResponse(), Packet::isSecure(), CacheBlk::isValid(), CacheBlk::isWritable(), Packet::isWrite(), MSHRQueue::markPending(), System::maxRequestors(), MaxTick, BaseCache::CacheCmdStats::mshr_miss_latency, BaseCache::CacheCmdStats::mshr_uncacheable_lat, mshrQueue, SimObject::name(), Prefetcher::Base::nextPrefetchReadyTime(), noTargetMSHR, panic_if, Packet::payloadDelay, QueueEntry::Target::pkt, Packet::popSenderState(), ppFill, prefetcher, Packet::print(), MSHR::promoteDeferredTargets(), MSHR::promoteReadable(), MSHR::promoteWritable(), QueueEntry::Target::recvTime, Packet::req, schedMemSideSendEvent(), serviceMSHRTargets(), stats, CacheBlk::status, system, tags, tempBlock, MemCmd::UpgradeResp, MSHR::wasWholeLineWrite, and writeAllocator.

Referenced by NoncoherentCache::recvTimingResp(), and Cache::recvTimingSnoopResp().

◆ recvTimingSnoopReq()

virtual void BaseCache::recvTimingSnoopReq ( PacketPtr  pkt)
protectedpure virtual

Snoops bus transactions to maintain coherence.

Parameters
pktThe current bus transaction.

Implemented in Cache, and NoncoherentCache.

◆ recvTimingSnoopResp()

virtual void BaseCache::recvTimingSnoopResp ( PacketPtr  pkt)
protectedpure virtual

Handle a snoop response.

Parameters
pktSnoop response packet

Implemented in Cache, and NoncoherentCache.

◆ regenerateBlkAddr()

Addr BaseCache::regenerateBlkAddr ( CacheBlk blk)
protected

Regenerate block address using tags.

Block address regeneration depends on whether we're using a temporary block or not.

Parameters
blkThe block to regenerate address.
Returns
The block's address.

Definition at line 169 of file base.cc.

References TempCacheBlk::getAddr(), BaseTags::regenerateBlkAddr(), tags, and tempBlock.

Referenced by Cache::cleanEvictBlk(), handleEvictions(), handleFill(), writebackBlk(), writebackVisitor(), and writecleanBlk().

◆ regProbePoints()

void BaseCache::regProbePoints ( )
overridevirtual

Registers probes.

Reimplemented from SimObject.

Definition at line 2274 of file base.cc.

References SimObject::getProbeManager(), ppFill, ppHit, and ppMiss.

◆ satisfyRequest()

void BaseCache::satisfyRequest ( PacketPtr  pkt,
CacheBlk blk,
bool  deferred_response = false,
bool  pending_downgrade = false 
)
protectedvirtual

Perform any necessary updates to the block and perform any data exchange between the packet and the block.

The flags of the packet are also set accordingly.

Parameters
pktRequest packet from upstream that hit a block
blkCache block that the packet hit
deferred_responseWhether this request originally missed
pending_downgradeWhether the writable flag is to be removed

Reimplemented in Cache, and NoncoherentCache.

Definition at line 904 of file base.cc.

References BlkDirty, blkSize, CacheBlk::checkWrite(), Packet::cmd, cmpAndSwap(), CacheBlk::data, DPRINTF, BaseTags::extractBlkOffset(), Packet::getAddr(), Packet::getAtomicOp(), Packet::getOffset(), Packet::getSize(), Packet::hasRespData(), Packet::hasSharers(), invalidateBlock(), Packet::isAtomicOp(), Packet::isClean(), CacheBlk::isDirty(), Packet::isInvalidate(), Packet::isLLSC(), Packet::isRead(), Packet::isRequest(), Packet::isUpgrade(), CacheBlk::isValid(), CacheBlk::isWritable(), Packet::isWrite(), ArmISA::offset, Packet::print(), Packet::setCacheResponding(), Packet::setData(), Packet::setDataFromBlock(), CacheBlk::status, MemCmd::SwapReq, tags, CacheBlk::trackLoadLocked(), and Packet::writeDataToBlock().

Referenced by access(), NoncoherentCache::satisfyRequest(), and Cache::satisfyRequest().

◆ schedMemSideSendEvent()

void BaseCache::schedMemSideSendEvent ( Tick  time)
inline

Schedule a send event for the memory-side port.

If already scheduled, this may reschedule the event at an earlier time. When the specified time is reached, the port is free to send either a response, a request, or a prefetch request.

Parameters
timeThe time when to attempt sending a packet.

Definition at line 1198 of file base.hh.

References memSidePort, and BaseCache::CacheRequestPort::schedSendEvent().

Referenced by allocateMissBuffer(), allocateWriteBuffer(), recvTimingReq(), and recvTimingResp().

◆ sendMSHRQueuePacket()

bool BaseCache::sendMSHRQueuePacket ( MSHR mshr)
virtual

◆ sendWriteQueuePacket()

bool BaseCache::sendWriteQueuePacket ( WriteQueueEntry wq_entry)

Similar to sendMSHR, but for a write-queue entry instead.

Create the packet, and send it, and if successful also mark the entry in service.

Parameters
wq_entryThe write-queue entry to turn into a packet and send
Returns
True if the port is waiting for a retry

Definition at line 1760 of file base.cc.

References DPRINTF, WriteQueueEntry::getTarget(), markInService(), memSidePort, QueueEntry::Target::pkt, Packet::print(), and RequestPort::sendTimingReq().

Referenced by WriteQueueEntry::sendPacket().

◆ serialize()

void BaseCache::serialize ( CheckpointOut cp) const
overridevirtual

Serialize the state of the caches.

We currently don't support checkpointing cache state, so this panics.

Implements Serializable.

Definition at line 1784 of file base.cc.

References isDirty(), SERIALIZE_SCALAR, and warn.

◆ serviceMSHRTargets()

virtual void BaseCache::serviceMSHRTargets ( MSHR mshr,
const PacketPtr  pkt,
CacheBlk blk 
)
protectedpure virtual

Service non-deferred MSHR targets using the received response.

Iterates through the list of targets that can be serviced with the current response.

Parameters
mshrThe MSHR that corresponds to the reponse
pktThe response packet
blkThe reference block

Implemented in Cache, and NoncoherentCache.

Referenced by recvTimingResp().

◆ setBlocked()

void BaseCache::setBlocked ( BlockedCause  cause)
inline

Marks the access path of the cache as blocked for the given cause.

This also sets the blocked flag in the response interface.

Parameters
causeThe reason for the cache blocking.

Definition at line 1160 of file base.hh.

References blocked, BaseCache::CacheStats::blocked_causes, blockedCycle, cpuSidePort, Clocked::curCycle(), DPRINTF, BaseCache::CacheResponsePort::setBlocked(), and stats.

Referenced by allocateMissBuffer(), allocateWriteBuffer(), and handleTimingReqMiss().

◆ unserialize()

void BaseCache::unserialize ( CheckpointIn cp)
overridevirtual

Unserialize an object.

Read an object's state from the current checkpoint section.

Parameters
cpCheckpoint state

Implements Serializable.

Definition at line 1804 of file base.cc.

References fatal, and UNSERIALIZE_SCALAR.

◆ updateCompressionData()

bool BaseCache::updateCompressionData ( CacheBlk blk,
const uint64_t *  data,
PacketList writebacks 
)
protected

When a block is overwriten, its compression information must be updated, and it may need to be recompressed.

If the compression size changes, the block may either become smaller, in which case there is no side effect, or bigger (data expansion; fat write), in which case the block might not fit in its current location anymore. If that happens, there are usually two options to be taken:

  • The co-allocated blocks must be evicted to make room for this block. Simpler, but ignores replacement data.
  • The block itself is moved elsewhere (used in policies where the CF determines the location of the block).

This implementation uses the first approach.

Notice that this is only called for writebacks, which means that L1 caches (which see regular Writes), do not support compression.

See also
CompressedTags
Parameters
blkThe block to be overwriten.
dataA pointer to the data to be compressed (blk's new data).
writebacksList for any writebacks that need to be performed.
Returns
Whether operation is successful or not.

Definition at line 832 of file base.cc.

References SectorBlk::blks, SuperBlk::canCoAllocate(), Compressor::Base::compress(), compressor, data, BaseCache::CacheStats::dataExpansions, DPRINTF, SectorSubBlk::getSectorBlock(), CompressionBlk::getSizeBits(), handleEvictions(), CompressionBlk::isCompressed(), SuperBlk::isCompressed(), CacheBlk::print(), CompressionBlk::setCompressed(), CompressionBlk::setDecompressionLatency(), CompressionBlk::setSizeBits(), CompressionBlk::setUncompressed(), stats, and tempBlock.

Referenced by access().

◆ writebackBlk()

PacketPtr BaseCache::writebackBlk ( CacheBlk blk)
protected

◆ writebackTempBlockAtomic()

void BaseCache::writebackTempBlockAtomic ( )
inlineprotected

Send the outstanding tempBlock writeback.

To be called after recvAtomic finishes in cases where the block we filled is in fact the tempBlock, and now needs to be written back.

Definition at line 642 of file base.hh.

References doWritebacksAtomic(), and tempBlockWriteback.

Referenced by BaseCache(), and recvAtomic().

◆ writebackVisitor()

void BaseCache::writebackVisitor ( CacheBlk blk)

◆ writecleanBlk()

PacketPtr BaseCache::writecleanBlk ( CacheBlk blk,
Request::Flags  dest,
PacketId  id 
)
protected

Create a writeclean request for the given block.

Creates a request that writes the block to the cache below without evicting the block from the current cache.

Parameters
blkThe block to write clean.
destThe destination of the write clean operation.
idUse the given packet id for the write clean operation.
Returns
The generated write clean packet.

Definition at line 1534 of file base.cc.

References Packet::allocate(), BlkDirty, blkSize, BlkWritable, compressor, CacheBlk::data, DPRINTF, Compressor::Base::getDecompressionLatency(), CacheBlk::isDirty(), CacheBlk::isSecure(), CacheBlk::isWritable(), Packet::payloadDelay, Packet::print(), regenerateBlkAddr(), Request::SECURE, Packet::setDataFromBlock(), Packet::setHasSharers(), Packet::setWriteThrough(), CacheBlk::status, CacheBlk::task_id, Request::wbRequestorId, and MemCmd::WriteClean.

Referenced by Cache::handleSnoop(), recvAtomic(), and sendMSHRQueuePacket().

Member Data Documentation

◆ addrRanges

const AddrRangeList BaseCache::addrRanges
protected

The address range to which the cache responds on the CPU side.

Normally this is all possible memory addresses.

Definition at line 917 of file base.hh.

Referenced by getAddrRanges(), and inRange().

◆ blkSize

const unsigned BaseCache::blkSize
protected

◆ blocked

uint8_t BaseCache::blocked
protected

Bit vector of the blocking reasons for the access path.

See also
BlockedCause

Definition at line 900 of file base.hh.

Referenced by BaseCache::CacheResponsePort::clearBlocked(), clearBlocked(), isBlocked(), setBlocked(), and BaseCache::CpuSidePort::tryTiming().

◆ blockedCycle

Cycles BaseCache::blockedCycle
protected

Stores time the cache blocked for statistics.

Definition at line 906 of file base.hh.

Referenced by clearBlocked(), and setBlocked().

◆ clusivity

const Enums::Clusivity BaseCache::clusivity
protected

Clusivity with respect to the upstream cache, determining if we fill into both this cache and the cache above on a miss.

Note that we currently do not support strict clusivity policies.

Definition at line 886 of file base.hh.

Referenced by allocOnFill(), Cache::createMissPacket(), and maintainClusivity().

◆ compressor

Compressor::Base* BaseCache::compressor
protected

Compression method being used.

Definition at line 323 of file base.hh.

Referenced by access(), allocateBlock(), allocateWriteBuffer(), Cache::handleSnoop(), updateCompressionData(), writebackBlk(), and writecleanBlk().

◆ cpuSidePort

CpuSidePort BaseCache::cpuSidePort
protected

◆ dataLatency

const Cycles BaseCache::dataLatency
protected

The latency of data access of a cache.

It occurs when there is an access to the cache.

Definition at line 851 of file base.hh.

Referenced by calculateAccessLatency().

◆ fillLatency

const Cycles BaseCache::fillLatency
protected

The latency to fill a cache block.

Definition at line 861 of file base.hh.

Referenced by access(), and handleFill().

◆ forwardLatency

const Cycles BaseCache::forwardLatency
protected

This is the forward latency of the cache.

It occurs when there is a cache miss and a request is forwarded downstream, in particular an outbound miss.

Definition at line 858 of file base.hh.

Referenced by Cache::doTimingSupplyResponse(), Cache::handleSnoop(), recvTimingReq(), recvTimingResp(), and Cache::recvTimingSnoopResp().

◆ forwardSnoops

bool BaseCache::forwardSnoops
protected

Do we forward snoops from mem side port through to cpu side port?

Definition at line 879 of file base.hh.

Referenced by Cache::handleSnoop(), init(), Cache::isCachedAbove(), and Cache::sendMSHRQueuePacket().

◆ isReadOnly

const bool BaseCache::isReadOnly
protected

Is this cache read only, for example the instruction cache, or table-walker cache.

A cache that is read only should never see any writes, and should never get any dirty data (and hence never have to do any writebacks).

Definition at line 894 of file base.hh.

Referenced by Cache::access(), access(), Cache::createMissPacket(), handleFill(), Cache::handleSnoop(), Cache::serviceMSHRTargets(), and writebackBlk().

◆ lookupLatency

const Cycles BaseCache::lookupLatency
protected

The latency of tag lookup of a cache.

It occurs when there is an access to the cache.

Definition at line 845 of file base.hh.

Referenced by Cache::access(), recvAtomic(), Cache::recvAtomicSnoop(), and Cache::recvTimingSnoopReq().

◆ memSidePort

MemSidePort BaseCache::memSidePort
protected

◆ missCount

Counter BaseCache::missCount
protected

The number of misses to trigger an exit event.

Definition at line 912 of file base.hh.

Referenced by incMissCount().

◆ mshrQueue

MSHRQueue BaseCache::mshrQueue
protected

◆ noTargetMSHR

MSHR* BaseCache::noTargetMSHR
protected

Pointer to the MSHR that has no targets.

Definition at line 909 of file base.hh.

Referenced by handleTimingReqMiss(), and recvTimingResp().

◆ numTarget

const int BaseCache::numTarget
protected

The number of targets for each MSHR.

Definition at line 876 of file base.hh.

Referenced by handleTimingReqMiss(), and Cache::recvTimingSnoopReq().

◆ order

uint64_t BaseCache::order
protected

Increasing order number assigned to each incoming request.

Definition at line 903 of file base.hh.

Referenced by allocateMissBuffer(), allocateWriteBuffer(), handleTimingReqMiss(), and Cache::recvTimingSnoopReq().

◆ pendingDelete

std::unique_ptr<Packet> BaseCache::pendingDelete
protected

Upstream caches need this packet until true is returned, so hold it for deletion until a subsequent call.

Definition at line 365 of file base.hh.

Referenced by handleTimingReqHit(), handleTimingReqMiss(), and Cache::recvTimingReq().

◆ ppFill

ProbePointArg<PacketPtr>* BaseCache::ppFill
protected

To probe when a cache fill occurs.

Definition at line 335 of file base.hh.

Referenced by recvTimingResp(), and regProbePoints().

◆ ppHit

ProbePointArg<PacketPtr>* BaseCache::ppHit
protected

To probe when a cache hit occurs.

Definition at line 329 of file base.hh.

Referenced by recvTimingReq(), and regProbePoints().

◆ ppMiss

ProbePointArg<PacketPtr>* BaseCache::ppMiss
protected

To probe when a cache miss occurs.

Definition at line 332 of file base.hh.

Referenced by recvTimingReq(), and regProbePoints().

◆ prefetcher

Prefetcher::Base* BaseCache::prefetcher
protected

◆ responseLatency

const Cycles BaseCache::responseLatency
protected

The latency of sending reponse to its upper level cache/core on a linefill.

The responseLatency parameter captures this latency.

Definition at line 868 of file base.hh.

Referenced by handleUncacheableWriteResp(), NoncoherentCache::serviceMSHRTargets(), and Cache::serviceMSHRTargets().

◆ sequentialAccess

const bool BaseCache::sequentialAccess
protected

Whether tags and data are accessed sequentially.

Definition at line 873 of file base.hh.

Referenced by calculateAccessLatency().

◆ stats

BaseCache::CacheStats BaseCache::stats

◆ system

System* BaseCache::system

◆ tags

BaseTags* BaseCache::tags
protected

◆ tempBlock

TempCacheBlk* BaseCache::tempBlock
protected

Temporary cache block for occasional transitory use.

We use the tempBlock to fill when allocation fails (e.g., when there is an outstanding request that accesses the victim block) or when we want to avoid allocation (e.g., exclusive caches)

Definition at line 359 of file base.hh.

Referenced by handleFill(), invalidateBlock(), recvAtomic(), recvTimingResp(), regenerateBlkAddr(), updateCompressionData(), and ~BaseCache().

◆ tempBlockWriteback

PacketPtr BaseCache::tempBlockWriteback
protected

Writebacks from the tempBlock, resulting on the response path in atomic mode, must happen after the call to recvAtomic has finished (for the right ordering of the packets).

We therefore need to hold on to the packets, and have a method and an event to send them.

Definition at line 635 of file base.hh.

Referenced by recvAtomic(), and writebackTempBlockAtomic().

◆ writeAllocator

WriteAllocator* const BaseCache::writeAllocator
protected

The writeAllocator drive optimizations for streaming writes.

It first determines whether a WriteReq MSHR should be delayed, thus ensuring that we wait longer in cases when we are write coalescing and allowing all the bytes of the line to be written before the MSHR packet is sent downstream. This works in unison with the tracking in the MSHR to check if the entire line is written. The write mode also affects the behaviour on filling any whole-line writes. Normally the cache allocates the line when receiving the InvalidateResp, but after seeing enough consecutive lines we switch to using the tempBlock, and thus end up not allocating the line, and instead turning the whole-line write into a writeback straight away.

Definition at line 351 of file base.hh.

Referenced by coalesce(), Cache::handleAtomicReqMiss(), handleTimingReqMiss(), recvTimingResp(), and sendMSHRQueuePacket().

◆ writebackClean

const bool BaseCache::writebackClean
protected

Determine if clean lines should be written back or not.

In cases where a downstream cache is mostly inclusive we likely want it to act as a victim cache also for lines that have not been modified. Hence, we cannot simply drop the line (or send a clean evict), but rather need to send the actual data.

Definition at line 626 of file base.hh.

Referenced by Cache::cleanEvictBlk(), Cache::doWritebacks(), NoncoherentCache::evictBlock(), Cache::evictBlock(), and writebackBlk().

◆ writebackTempBlockAtomicEvent

EventFunctionWrapper BaseCache::writebackTempBlockAtomicEvent
protected

An event to writeback the tempBlock after recvAtomic finishes.

To avoid other calls to recvAtomic getting in between, we create this event with a higher priority.

Definition at line 654 of file base.hh.

Referenced by recvAtomic().

◆ writeBuffer

WriteQueue BaseCache::writeBuffer
protected

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

Generated on Wed Sep 30 2020 14:02:21 for gem5 by doxygen 1.8.17