29#ifndef __LEARNING_GEM5_SIMPLE_CACHE_SIMPLE_CACHE_HH__
30#define __LEARNING_GEM5_SIMPLE_CACHE_SIMPLE_CACHE_HH__
32#include <unordered_map>
36#include "params/SimpleCache.hh"
111 {
panic(
"recvAtomic unimpl."); }
The ClockedObject class extends the SimObject with a clock and accessor functions to relate ticks to ...
Cycles is a wrapper class for representing cycle counts, i.e.
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Ports are used to interface objects to each other.
const std::string name() const
Return port name (for DPRINTF).
A RequestPort is a specialisation of a Port, which implements the default protocol for the three diff...
A ResponsePort is a specialization of a port.
Port on the CPU-side that receives requests.
SimpleCache * owner
The object that owns this object (SimpleCache)
bool recvTimingReq(PacketPtr pkt) override
Receive a timing request from the request port.
void sendPacket(PacketPtr pkt)
Send a packet across this port.
Tick recvAtomic(PacketPtr pkt) override
Receive an atomic request packet from the request port.
CPUSidePort(const std::string &name, int id, SimpleCache *owner)
Constructor.
PacketPtr blockedPacket
If we tried to send a packet and it was blocked, store it here.
int id
Since this is a vector port, need to know what number this one is.
AddrRangeList getAddrRanges() const override
Get a list of the non-overlapping address ranges the owner is responsible for.
void recvFunctional(PacketPtr pkt) override
Receive a functional request packet from the request port.
void trySendRetry()
Send a retry to the peer port only if it is needed.
void recvRespRetry() override
Called by the request port if sendTimingResp was called on this response port (causing recvTimingResp...
bool needRetry
True if the port needs to send a retry req.
Port on the memory-side that receives responses.
SimpleCache * owner
The object that owns this object (SimpleCache)
void sendPacket(PacketPtr pkt)
Send a packet across this port.
bool recvTimingResp(PacketPtr pkt) override
Receive a timing response from the response port.
MemSidePort(const std::string &name, SimpleCache *owner)
Constructor.
PacketPtr blockedPacket
If we tried to send a packet and it was blocked, store it here.
void recvRangeChange() override
Called to receive an address range change from the peer response port.
void recvReqRetry() override
Called by the response port if sendTimingReq was called on this request port (causing recvTimingReq t...
A very simple cache object.
const unsigned capacity
Number of blocks in the cache (size of cache / block size)
void handleFunctional(PacketPtr pkt)
Handle a packet functionally.
PacketPtr originalPacket
Packet that we are currently handling.
bool blocked
True if this cache is currently blocked waiting for a response.
const Addr blockSize
The block size for the cache.
Port & getPort(const std::string &if_name, PortID idx=InvalidPortID) override
Get a port with a given name and index.
bool handleResponse(PacketPtr pkt)
Handle the respone from the memory side.
void sendRangeChange() const
Tell the CPU side to ask for our memory ranges.
SimpleCache(const SimpleCacheParams ¶ms)
constructor
void insert(PacketPtr pkt)
Insert a block into the cache.
gem5::SimpleCache::SimpleCacheStats stats
AddrRangeList getAddrRanges() const
Return the address ranges this cache is responsible for.
bool handleRequest(PacketPtr pkt, int port_id)
Handle the request from the CPU side.
MemSidePort memPort
Instantiation of the memory-side port.
Tick missTime
For tracking the miss latency.
std::unordered_map< Addr, uint8_t * > cacheStore
An incredibly simple cache storage. Maps block addresses to data.
std::vector< CPUSidePort > cpuPorts
Instantiation of the CPU-side port.
void accessTiming(PacketPtr pkt)
Access the cache for a timing access.
void sendResponse(PacketPtr pkt)
Send the packet to the CPU side.
bool accessFunctional(PacketPtr pkt)
This is where we actually update / read from the cache.
const Cycles latency
Latency to check the cache. Number of cycles for both hit and miss.
int waitingPortId
The port to send the response when we recieve it back.
This is a simple scalar statistic, like a counter.
ClockedObject declaration and implementation.
#define panic(...)
This implements a cprintf based panic() function.
const Params & params() const
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
const PortID InvalidPortID
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
uint64_t Tick
Tick count type.
Declaration of Statistics objects.
statistics::Scalar misses
statistics::Formula hitRatio
SimpleCacheStats(statistics::Group *parent)
statistics::Histogram missLatency