46#ifndef __MEM_CTRL_HH__
47#define __MEM_CTRL_HH__
51#include <unordered_set>
57#include "enums/MemSched.hh"
60#include "params/MemCtrl.hh"
207 uint8_t _rank, uint8_t _bank, uint32_t _row, uint16_t bank_id,
208 Addr _addr,
unsigned int _size)
720 Tick max_multi_cmd_split = 0);
729 assert(pseudo_channel == 0);
740 assert(pseudo_channel == 0);
755 assert(pseudo_channel == 0);
778 virtual void init()
override;
779 virtual void startup()
override;
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 queued port is a port that has an infinite queue for outgoing packets and thus decouples the module...
A burst helper helps organize and manage a packet that is larger than the memory burst size.
unsigned int burstsServiced
Number of bursts serviced so far for a system packet.
BurstHelper(unsigned int _burstCount)
const unsigned int burstCount
Number of bursts requred for a system packet.
void recvFunctional(PacketPtr pkt) override
Receive a functional request packet from the peer.
MemoryPort(const std::string &name, MemCtrl &_ctrl)
bool recvTimingReq(PacketPtr) override
Receive a timing request from the peer.
AddrRangeList getAddrRanges() const override
Get a list of the non-overlapping address ranges the owner is responsible for.
Tick recvAtomic(PacketPtr pkt) override
Receive an atomic request packet from the peer.
void disableSanityCheck()
Tick recvAtomicBackdoor(PacketPtr pkt, MemBackdoorPtr &backdoor) override
Receive an atomic request packet from the peer, and optionally provide a backdoor to the data being a...
void recvMemBackdoorReq(const MemBackdoorReq &req, MemBackdoorPtr &backdoor) override
Receive a request for a back door to a range of memory.
The memory controller is a single-channel memory controller capturing the most important timing const...
virtual void recvFunctional(PacketPtr pkt)
virtual void pruneBurstTick()
Remove commands that have already issued from burstTicks.
uint32_t writeLowThreshold
enums::MemSched memSchedPolicy
Memory controller configuration initialized based on parameter values.
bool recvFunctionalLogic(PacketPtr pkt, MemInterface *mem_intr)
bool inReadBusState(bool next_state, const MemInterface *mem_intr) const
Check the current direction of the memory channel.
bool retryRdReq
Remember if we have to retry a request when available.
void printQs() const
Used for debugging to observe the contents of the queues.
const uint32_t minReadsPerSwitch
virtual void startup() override
startup() is the final initialization call before simulation.
void addToWriteQueue(PacketPtr pkt, unsigned int pkt_count, MemInterface *mem_intr)
Decode the incoming pkt, create a mem_pkt and push to the back of the write queue.
Tick recvAtomicLogic(PacketPtr pkt, MemInterface *mem_intr)
std::deque< MemPacket * > respQueue
Response queue where read packets wait after we're done working with them, but it's not time to send ...
MemoryPort port
Our incoming port, for a multi-ported controller add a crossbar in front of it.
uint32_t writeHighThreshold
std::unique_ptr< Packet > pendingDelete
Upstream caches need this packet until true is returned, so hold it for deletion until a subsequent c...
std::vector< MemPacketQueue > writeQueue
virtual Tick verifyMultiCmd(Tick cmd_tick, Tick max_cmds_per_burst, Tick max_multi_cmd_split=0)
Check for command bus contention for multi-cycle (2 currently) command.
EventFunctionWrapper respondEvent
virtual MemPacketQueue::iterator chooseNext(MemPacketQueue &queue, Tick extra_col_delay, MemInterface *mem_intr)
The memory schduler/arbiter - picks which request needs to go next, based on the specified policy suc...
virtual std::pair< MemPacketQueue::iterator, Tick > chooseNextFRFCFS(MemPacketQueue &queue, Tick extra_col_delay, MemInterface *mem_intr)
For FR-FCFS policy reorder the read/write queue depending on row buffer hits and earliest bursts avai...
std::vector< MemPacketQueue > & selQueue(bool is_read)
Select either the read or write queue.
bool readQueueFull(unsigned int pkt_count) const
Check if the read queue has room for more entries.
virtual Tick doBurstAccess(MemPacket *mem_pkt, MemInterface *mem_intr)
Actually do the burst based on media specific access function.
virtual void processNextReqEvent(MemInterface *mem_intr, MemPacketQueue &resp_queue, EventFunctionWrapper &resp_event, EventFunctionWrapper &next_req_event, bool &retry_wr_req)
Bunch of things requires to setup "events" in gem5 When event "respondEvent" occurs for example,...
bool addToReadQueue(PacketPtr pkt, unsigned int pkt_count, MemInterface *mem_intr)
When a new read comes in, first check if the write q has a pending request to the same address....
std::unordered_multiset< Tick > burstTicks
Holds count of commands issued in burst window starting at defined Tick.
virtual bool requestEventScheduled(uint8_t pseudo_channel=0) const
Is there a read/write burst Event scheduled?
virtual Addr burstAlign(Addr addr, MemInterface *mem_intr) const
Burst-align an address.
bool inWriteBusState(bool next_state, const MemInterface *mem_intr) const
Check the current direction of the memory channel.
const uint32_t minWritesPerSwitch
bool writeQueueFull(unsigned int pkt_count) const
Check if the write queue has room for more entries.
virtual void init() override
init() is called after all C++ SimObjects have been created and all ports are connected.
const Tick backendLatency
Pipeline latency of the backend and PHY.
uint32_t readBufferSize
The following are basic design parameters of the memory controller, and are initialized based on para...
virtual void recvMemBackdoorReq(const MemBackdoorReq &req, MemBackdoorPtr &backdoor)
virtual void restartScheduler(Tick tick, uint8_t pseudo_channel=0)
restart the controller This can be used by interfaces to restart the scheduler after maintainence com...
const Tick frontendLatency
Pipeline latency of the controller frontend.
virtual bool respondEventScheduled(uint8_t pseudo_channel=0) const
Is there a respondEvent scheduled?
virtual bool respQEmpty()
Tick nextReqTime
The soonest you have to start thinking about the next request is the longest access time that can occ...
virtual bool allIntfDrained() const
Ensure that all interfaced have drained commands.
EventFunctionWrapper nextReqEvent
virtual bool packetReady(MemPacket *pkt, MemInterface *mem_intr)
Determine if there is a packet that can issue.
virtual Tick verifySingleCmd(Tick cmd_tick, Tick max_cmds_per_burst, bool row_cmd)
Check for command bus contention for single cycle command.
virtual bool nvmWriteBlock(MemInterface *mem_intr)
Will check if all writes are for nvm interface and nvm's write resp queue is full.
virtual void processRespondEvent(MemInterface *mem_intr, MemPacketQueue &queue, EventFunctionWrapper &resp_event, bool &retry_rd_req)
virtual void accessAndRespond(PacketPtr pkt, Tick static_latency, MemInterface *mem_intr)
When a packet reaches its "readyTime" in the response Q, use the "access()" method in AbstractMemory ...
virtual Tick minWriteToReadDataGap()
Calculate the minimum delay used when scheduling a write-to-read transision.
virtual bool recvTimingReq(PacketPtr pkt)
virtual Tick minReadToWriteDataGap()
Calculate the minimum delay used when scheduling a read-to-write transision.
DrainState drain() override
Draining is the process of clearing out the states of SimObjects.These are the SimObjects that are pa...
std::vector< MemPacketQueue > readQueue
The controller's main read and write queues, with support for QoS reordering.
bool isTimingMode
Remember if the memory system is in timing mode.
virtual Tick recvAtomic(PacketPtr pkt)
Port & getPort(const std::string &if_name, PortID idx=InvalidPortID) override
Get a port with a given name and index.
virtual bool memBusy(MemInterface *mem_intr)
Checks if the memory interface is already busy.
virtual AddrRangeList getAddrRanges()
Tick nextBurstAt
Till when must we wait before issuing next RD/WR burst?
MemCtrl(const MemCtrlParams &p)
virtual Tick recvAtomicBackdoor(PacketPtr pkt, MemBackdoorPtr &backdoor)
Tick getBurstWindow(Tick cmd_tick)
Calculate burst window aligned tick.
std::unordered_set< Addr > isInWriteQueue
To avoid iterating over the write queue to check for overlapping transactions, maintain a set of burs...
virtual bool pktSizeCheck(MemPacket *mem_pkt, MemInterface *mem_intr) const
Check if mem pkt's size is sane.
virtual void drainResume() override
Resume execution after a successful drain.
const Tick commandWindow
Length of a command window, used to check command bandwidth.
virtual void nonDetermReads(MemInterface *mem_intr)
Will access memory interface and select non-deterministic reads to issue.
General interface to memory device Includes functions and parameters shared across media types.
A memory packet stores packets along with the timestamp of when the packet entered the queue,...
Tick readyTime
When will request leave the controller.
const bool dram
Does this packet access DRAM?
Addr getAddr() const
Get the packet address (interface compatibility with Packet)
void qosValue(const uint8_t qv)
Set the packet QoS value (interface compatibility with Packet)
const uint8_t pseudoChannel
pseudo channel num
const uint16_t bankId
Bank id is calculated considering banks in all the ranks eg: 2 ranks each with 8 banks,...
uint8_t _qosValue
QoS value of the encapsulated packet read at queuing time.
BurstHelper * burstHelper
A pointer to the BurstHelper if this MemPacket is a split packet If not a split packet (common case),...
unsigned int size
The size of this dram packet in bytes It is always equal or smaller than the burst size.
MemPacket(PacketPtr _pkt, bool is_read, bool is_dram, uint8_t _channel, uint8_t _rank, uint8_t _bank, uint32_t _row, uint16_t bank_id, Addr _addr, unsigned int _size)
Addr addr
The starting address of the packet.
bool isDram() const
Return true if its a DRAM access.
const RequestorID _requestorId
RequestorID associated with the packet.
bool isRead() const
Return true if its a read packet (interface compatibility with Packet)
const Tick entryTime
When did request enter the controller.
const PacketPtr pkt
This comes from the outside world.
RequestorID requestorId() const
Get the packet RequestorID (interface compatibility with Packet)
unsigned int getSize() const
Get the packet size (interface compatibility with Packet)
bool isWrite() const
Return true if its a write packet (interface compatibility with Packet)
uint8_t qosValue() const
Get the packet QoS value (interface compatibility with Packet)
const uint8_t rank
Will be populated by address decoder.
The qos::MemCtrl is a base class for Memory objects which support QoS - it provides access to a set o...
uint8_t schedule(RequestorID id, uint64_t data)
A stat that calculates the per tick average of a value.
This is a simple scalar statistic, like a counter.
A vector of scalar stats.
DrainState
Object drain/handover states.
bool scheduled() const
Determine if the current event is scheduled.
std::deque< MemPacket * > MemPacketQueue
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
const PortID InvalidPortID
Tick curTick()
The universal simulation clock.
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 the queued port.
Declaration of Statistics objects.
statistics::Scalar writeReqs
statistics::Scalar mergedWrBursts
statistics::Scalar readReqs
statistics::Scalar servicedByWrQ
statistics::Histogram rdPerTurnAround
statistics::Vector readPktSize
statistics::Scalar numWrRetry
statistics::Scalar totGap
statistics::Scalar numRdRetry
statistics::Formula requestorReadAvgLat
statistics::Scalar readBursts
void regStats() override
Callback to set stat parameters.
statistics::Formula requestorWriteAvgLat
statistics::Vector requestorReadTotalLat
statistics::Vector requestorWriteTotalLat
statistics::Vector requestorWriteBytes
statistics::Formula avgGap
statistics::Scalar writeBursts
statistics::Vector writePktSize
statistics::Histogram wrPerTurnAround
statistics::Vector requestorWriteAccesses
statistics::Formula avgRdBWSys
statistics::Scalar bytesReadSys
statistics::Average avgRdQLen
statistics::Scalar neitherReadNorWriteReqs
statistics::Formula requestorReadRate
statistics::Vector requestorReadAccesses
statistics::Scalar bytesWrittenSys
statistics::Average avgWrQLen
statistics::Vector wrQLenPdf
statistics::Formula requestorWriteRate
statistics::Formula avgWrBWSys
statistics::Scalar bytesReadWrQ
statistics::Vector requestorReadBytes
statistics::Vector rdQLenPdf