54 #ifndef __MEM_DRAM_CTRL_HH__ 55 #define __MEM_DRAM_CTRL_HH__ 59 #include <unordered_set> 64 #include "enums/AddrMap.hh" 65 #include "enums/MemSched.hh" 66 #include "enums/PageManage.hh" 70 #include "params/DRAMCtrl.hh" 155 constexpr
Command(Data::MemCommand::cmds _type, uint8_t _bank,
157 : type(_type), bank(_bank), timeStamp(time_stamp)
175 static const uint32_t NO_ROW = -1;
190 openRow(NO_ROW), bank(0), bankgr(0),
191 rdAllowedAt(0), wrAllowedAt(0), preAllowedAt(0), actAllowedAt(0),
192 rowAccesses(0), bytesAccessed(0)
457 Rank(
DRAMCtrl& _memory,
const DRAMCtrlParams* _p,
int rank);
505 return (readEntries != 0) ||
515 bool isQueueEmpty()
const;
521 void checkDrainDone();
561 void scheduleWakeUpEvent(
Tick exit_delay);
563 void processWriteDoneEvent();
566 void processActivateEvent();
569 void processPrechargeEvent();
572 void processRefreshEvent();
575 void processPowerEvent();
578 void processWakeUpEvent();
602 : burstCount(_burstCount), burstsServiced(0)
671 inline void qosValue(
const uint8_t qv) { _qosValue = qv; }
677 inline uint8_t
qosValue()
const {
return _qosValue; }
701 inline bool isRead()
const {
return read; }
711 uint32_t _row, uint16_t bank_id,
Addr _addr,
712 unsigned int _size,
Bank& bank_ref,
Rank& rank_ref)
714 _masterId(pkt->masterId()),
715 read(is_read), rank(_rank), bank(_bank), row(_row),
716 bankId(bank_id), addr(_addr), size(_size), burstHelper(NULL),
717 bankRef(bank_ref), rankRef(rank_ref), _qosValue(_pkt->qosValue())
819 unsigned int size,
bool isRead)
const;
847 Tick extra_col_delay);
858 Tick extra_col_delay);
898 Tick pre_at,
bool trace =
true);
1187 virtual void init()
override;
1188 virtual void startup()
override;
1210 #endif //__MEM_DRAM_CTRL_HH__
Enums::PageManage pageMgmt
bool enableDRAMPowerdown
Enable or disable DRAM powerdown states.
const uint32_t writeLowThreshold
const uint32_t activationLimit
Ports are used to interface objects to each other.
Stats::Scalar mergedWrBursts
PowerState
The power state captures the different operational states of the DRAM and interacts with the bus read...
const Tick entryTime
When did request enter the controller.
Stats::Scalar totalEnergy
Stats::Scalar bytesReadDRAM
void prechargeBank(Rank &rank_ref, Bank &bank_ref, Tick pre_at, bool trace=true)
Precharge a given bank and also update when the precharge is done.
#define M5_CLASS_VAR_USED
void computeStats()
Record stats values like state residency by computing the time difference from previous update...
bool retryRdReq
Remember if we have to retry a request when available.
BusState busStateNext
bus state for next request event triggered
Stats::Scalar bytesWrittenSys
virtual AddrRangeList getAddrRanges() const
Get a list of the non-overlapping address ranges the owner is responsible for.
const PortID InvalidPortID
std::vector< Command > cmdList
List of commands issued, to be sent to DRAMPpower at refresh and stats dump.
std::vector< Rank * > ranks
Vector of ranks.
A stat that calculates the per tick average of a value.
DrainState
Object drain/handover states.
void doDRAMAccess(DRAMPacket *dram_pkt)
Actually do the DRAM access - figure out the latency it will take to service the req based on bank st...
EventFunctionWrapper nextReqEvent
const MasterID _masterId
MasterID associated with the packet.
Addr getAddr() const
Get the packet address (interface compatibility with Packet)
Stats::Formula busUtilRead
std::pair< std::vector< uint32_t >, bool > minBankPrep(const DRAMPacketQueue &queue, Tick min_col_at) const
Find which are the earliest banks ready to issue an activate for the enqueued requests.
A DRAM packet stores packets along with the timestamp of when the packet entered the queue...
uint32_t writeEntries
Track number of packets in write queue going to this rank.
bool forceSelfRefreshExit() const
Trigger a self-refresh exit if there are entries enqueued Exit if there are any read entries regardle...
Stats::Vector perBankRdBursts
DRAMPacketQueue::iterator chooseNextFRFCFS(DRAMPacketQueue &queue, Tick extra_col_delay)
For FR-FCFS policy reorder the read/write queue depending on row buffer hits and earliest bursts avai...
uint32_t readEntries
Track number of packets in read queue going to this rank.
Tick lastStatsResetTick
The time when stats were last reset used to calculate average power.
MemoryPort(const std::string &name, DRAMCtrl &_memory)
const Tick frontendLatency
Pipeline latency of the controller frontend.
Stats::Vector masterReadTotalLat
Stats::Formula pageHitRate
Stats::Scalar selfRefreshEnergy
bool inPwrIdleState() const
Check if the current rank has all banks closed and is not in a low power state.
Stats::Histogram wrPerTurnAround
Stats::Formula avgWrBWSys
DRAMCtrl(const DRAMCtrlParams *p)
DrainState drain() override
Notify an object that it needs to drain its state.
MasterID masterId() const
Get the packet MasterID (interface compatibility with Packet)
std::deque< DRAMPacket * > respQueue
Response queue where read packets wait after we're done working with them, but it's not time to send ...
virtual void regStats()
Callback to set stat parameters.
unsigned int burstsServiced
Number of DRAM bursts serviced so far for a system packet.
Stats::Vector memoryStateTime
Track time spent in each power state.
RefreshState refreshState
current refresh state
Addr addr
The starting address of the DRAM packet.
A vector of scalar stats.
bool writeQueueFull(unsigned int pktCount) const
Check if the write queue has room for more entries.
Tick refreshDueAt
Keep track of when a refresh is due.
A queued port is a port that has an infinite queue for outgoing packets and thus decouples the module...
The DRAM controller is a single-channel memory controller capturing the most important timing constra...
Stats::Vector writePktSize
uint8_t rank
Current Rank index.
std::deque< DRAMPacket * > DRAMPacketQueue
const uint32_t burstLength
const uint32_t ranksPerChannel
bool readQueueFull(unsigned int pktCount) const
Check if the read queue has room for more entries.
Declaration of Statistics objects.
This is a simple scalar statistic, like a counter.
const uint32_t deviceRowBufferSize
A burst helper helps organize and manage a packet that is larger than the DRAM burst size...
const uint16_t bankId
Bank id is calculated considering banks in all the ranks eg: 2 ranks each with 8 banks, then bankId = 0 –> rank0, bank0 and bankId = 8 –> rank1, bank0.
virtual void init() override
Initialise this memory.
uint8_t outstandingEvents
Number of ACT, RD, and WR events currently scheduled Incremented when a refresh event is started as w...
EventFunctionWrapper activateEvent
Stats::Scalar writeEnergy
unsigned int numBanksActive
To track number of banks which are currently active for this rank.
Stats::Vector perBankWrBursts
void recvFunctional(PacketPtr pkt)
Receive a functional request packet from the peer.
bool isTimingMode
Remember if the memory system is in timing mode.
A basic class to track the bank state, i.e.
Addr getCtrlAddr(Addr addr)
Get an address in a dense range which starts from 0.
Declaration of the queued port.
const uint32_t maxAccessesPerRow
Max column accesses (read and write) per row, before forcefully closing it.
const uint32_t bankGroupsPerRank
Tick curTick()
The current simulated tick.
Tick recvAtomic(PacketPtr pkt)
Receive an atomic request packet from the peer.
Stats::Vector masterReadBytes
Enums::MemSched memSchedPolicy
Memory controller configuration initialized based on parameter values.
std::string csprintf(const char *format, const Args &...args)
const Tick backendLatency
Pipeline latency of the backend and PHY.
EventFunctionWrapper prechargeEvent
Stats::Scalar servicedByWrQ
void updatePowerStats(Rank &rank_ref)
This function increments the energy when called.
BurstHelper * burstHelper
A pointer to the BurstHelper if this DRAMPacket is a split packet If not a split packet (common case)...
std::vector< Bank > banks
Vector of Banks.
uint64_t Tick
Tick count type.
void qosValue(const uint8_t qv)
Set the packet QoS value (interface compatibility with Packet)
PowerState pwrState
Current power state.
EventFunctionWrapper respondEvent
BurstHelper(unsigned int _burstCount)
std::deque< Tick > actTicks
List to keep track of activate ticks.
Stats::Vector masterWriteAccesses
virtual void preDumpStats()
Callback before stats are dumped.
Stats::Formula readRowHitRate
virtual void resetStats()
Callback to reset stats.
std::vector< DRAMPacketQueue > readQueue
The controller's main read and write queues, with support for QoS reordering.
All statistics that the model needs to capture.
Stats::Formula masterReadAvgLat
Tick pwrStateTick
Track when we transitioned to the current power state.
Stats::Vector masterReadAccesses
static bool sortTime(const Command &cmd, const Command &cmd_next)
Function for sorting Command structures based on timeStamp.
Stats::Scalar prePowerDownEnergy
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Stats::Scalar bytesReadWrQ
EventFunctionWrapper writeDoneEvent
Stats::Formula avgMemAccLat
DRAMCtrl & memory
A reference to the parent DRAMCtrl instance.
virtual const std::string name() const
const uint8_t rank
Will be populated by address decoder.
void activateBank(Rank &rank_ref, Bank &bank_ref, Tick act_tick, uint32_t row)
Keep track of when row activations happen, in order to enforce the maximum number of activations in t...
PowerState pwrStatePostRefresh
Previous low-power state, which will be re-entered after refresh.
A Packet is used to encapsulate a transfer between two objects in the memory system (e...
const Tick M5_CLASS_VAR_USED tCK
Basic memory timing parameters initialized based on parameter values.
bool isRead() const
Return true if its a read packet (interface compatibility with Packet)
Stats::Scalar averagePower
const unsigned int burstCount
Number of DRAM bursts requred for a system packet.
std::unique_ptr< Packet > pendingDelete
Upstream caches need this packet until true is returned, so hold it for deletion until a subsequent c...
void addToWriteQueue(PacketPtr pkt, unsigned int pktCount)
Decode the incoming pkt, create a dram_pkt and push to the back of the write queue.
const uint32_t rowBufferSize
bool inRefIdleState() const
Check if there is no refresh and no preparation of refresh ongoing i.e.
const uint32_t devicesPerRank
PowerState pwrStateTrans
Since we are taking decisions out of order, we need to keep track of what power transition is happeni...
uint8_t _qosValue
QoS value of the encapsulated packet read at queuing time.
const uint32_t minWritesPerSwitch
Stats::Formula masterWriteRate
void accessAndRespond(PacketPtr pkt, Tick static_latency)
When a packet reaches its "readyTime" in the response Q, use the "access()" method in AbstractMemory ...
const uint32_t deviceBusWidth
Stats::Scalar bytesReadSys
Stats::Formula avgRdBWSys
EventFunctionWrapper powerEvent
const uint32_t writeHighThreshold
Enums::AddrMap addrMapping
Tick nextReqTime
The soonest you have to start thinking about the next request is the longest access time that can occ...
Stats::Scalar neitherReadNorWriteReqs
bool allRanksDrained() const
Return true once refresh is complete for all ranks and there are no additional commands enqueued...
Stats::Scalar preBackEnergy
RefreshState
The refresh state is used to control the progress of the refresh scheduling.
DRAMPacket(PacketPtr _pkt, bool is_read, uint8_t _rank, uint8_t _bank, uint32_t _row, uint16_t bank_id, Addr _addr, unsigned int _size, Bank &bank_ref, Rank &rank_ref)
EventFunctionWrapper wakeUpEvent
const std::string name() const
DRAMPacket * decodeAddr(const PacketPtr pkt, Addr dramPktAddr, unsigned int size, bool isRead) const
Address decoder to figure out physical mapping onto ranks, banks, and rows.
DRAMPower power
One DRAMPower instance per rank.
Stats::Scalar writeRowHits
unsigned int getSize() const
Get the packet size (interface compatibility with Packet)
Stats::Scalar totalIdleTime
Stat to track total DRAM idle time.
uint64_t size() const
Get the memory size.
Tick wakeUpAllowedAt
delay power-down and self-refresh exit until this requirement is met
Stats::Formula busUtilWrite
Stats::Formula writeRowHitRate
void processNextReqEvent()
Bunch of things requires to setup "events" in gem5 When event "respondEvent" occurs for example...
const std::string name() const
Return port name (for DPRINTF).
std::unordered_set< Addr > isInWriteQueue
To avoid iterating over the write queue to check for overlapping transactions, maintain a set of burs...
const uint32_t columnsPerRowBuffer
Stats::Histogram bytesPerActivate
Stats::Formula masterWriteAvgLat
Stats::Scalar actBackEnergy
EventFunctionWrapper refreshEvent
Stats::Scalar readRowHits
Simple structure to hold the values needed to keep track of commands for DRAMPower.
Stats::Formula masterReadRate
const uint32_t deviceSize
The following are basic design parameters of the memory controller, and are initialized based on para...
Addr getOffset(const Addr &a) const
Determine the offset of an address within the range.
std::vector< DRAMPacketQueue > writeQueue
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
Tick readyTime
When will request leave the controller.
const uint32_t columnsPerStripe
Stats::Scalar totMemAccLat
Data::MemCommand::cmds type
Tick nextBurstAt
Till when must we wait before issuing next RD/WR burst?
void processRespondEvent()
const uint32_t writeBufferSize
const uint32_t banksPerRank
const uint32_t readBufferSize
DRAMPower is a standalone tool which calculates the power consumed by a DRAM in the system...
uint8_t qosValue() const
Get the packet QoS value (interface compatibility with Packet)
virtual void drainResume() override
Resume execution after a successful drain.
virtual void startup() override
startup() is the final initialization call before simulation.
Addr burstAlign(Addr addr) const
Burst-align an address.
Stats::Vector masterWriteBytes
The QoS::MemCtrl is a base class for Memory objects which support QoS - it provides access to a set o...
Stats::Vector readPktSize
void addToReadQueue(PacketPtr pkt, unsigned int pktCount)
When a new read comes in, first check if the write q has a pending request to the same address...
Stats::Scalar actPowerDownEnergy
void printQs() const
Used for debugging to observe the contents of the queues.
unsigned int size
The size of this dram packet in bytes It is always equal or smaller than DRAM burst size...
bool recvTimingReq(PacketPtr)
Receive a timing request from the peer.
Stats::Vector masterWriteTotalLat
Port & getPort(const std::string &if_name, PortID idx=InvalidPortID) override
Get a port with a given name and index.
Stats::Scalar writeBursts
const PacketPtr pkt
This comes from the outside world.
constexpr Command(Data::MemCommand::cmds _type, uint8_t _bank, Tick time_stamp)
Stats::Histogram rdPerTurnAround
Rank class includes a vector of banks.
Stats::Scalar bytesWritten
bool inLowPowerState
rank is in or transitioning to power-down or self-refresh
MemoryPort port
Our incoming port, for a multi-ported controller add a crossbar in front of it.
bool isWrite() const
Return true if its a write packet (interface compatibility with Packet)
Stats::Scalar refreshEnergy
DRAMPacketQueue::iterator chooseNext(DRAMPacketQueue &queue, Tick extra_col_delay)
The memory schduler/arbiter - picks which request needs to go next, based on the specified policy suc...