53 #ifndef __MEM_DRAM_CTRL_HH__
54 #define __MEM_DRAM_CTRL_HH__
58 #include <unordered_set>
62 #include "enums/AddrMap.hh"
63 #include "enums/MemSched.hh"
64 #include "enums/PageManage.hh"
67 #include "params/DRAMCtrl.hh"
165 constexpr
Command(Data::MemCommand::cmds _type, uint8_t _bank,
671 uint32_t _row, uint16_t bank_id,
Addr _addr,
672 unsigned int _size,
Bank& bank_ref,
Rank& rank_ref)
812 Tick min_col_at)
const;
839 Tick pre_at,
bool trace =
true);
1087 virtual void init()
override;
1088 virtual void startup()
override;
1110 #endif //__MEM_DRAM_CTRL_HH__
Stats::Scalar bytesWritten
Enums::PageManage pageMgmt
const uint32_t writeLowThreshold
Stats::Scalar totMemAccLat
const uint32_t activationLimit
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 preBackEnergy
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.
void printQs() const
Used for debugging to observe the contents of the queues.
#define M5_CLASS_VAR_USED
Stats::Scalar readRowHits
bool retryRdReq
Remember if we have to retry a request when available.
const PortID InvalidPortID
std::vector< Command > cmdList
List of comamnds 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...
RankDumpCallback(Rank *r)
bool writeQueueFull(unsigned int pktCount) const
Check if the write queue has room for more entries.
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.
const std::string name() const
Return port name (for DPRINTF).
Stats::Histogram bytesPerActivate
Stats::Scalar bytesReadWrQ
uint32_t readEntries
Track number of packets in read queue going to this rank.
Stats::Histogram rdPerTurnAround
MemoryPort(const std::string &name, DRAMCtrl &_memory)
const Tick frontendLatency
Pipeline latency of the controller frontend.
Stats::Formula pageHitRate
Stats::Scalar writeEnergy
bool recvTimingReq(PacketPtr pkt)
DRAMCtrl(const DRAMCtrlParams *p)
DrainState drain() override
Notify an object that it needs to drain its state.
std::deque< DRAMPacket * > respQueue
Response queue where read packets wait after we're done working with them, but it's not time to send ...
unsigned int burstsServiced
Number of DRAM bursts serviced so far for a system packet.
RefreshState refreshState
current refresh state
Addr addr
The starting address of the DRAM packet.
A vector of scalar stats.
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...
Stats::Formula busUtilWrite
Stats::Scalar selfRefreshEnergy
The DRAM controller is a single-channel memory controller capturing the most important timing constra...
uint8_t rank
Current Rank index.
Stats::Scalar mergedWrBursts
const uint32_t burstLength
Stats::Scalar writeBursts
const uint32_t ranksPerChannel
A BaseSlavePort is a protocol-agnostic slave port, responsible only for the structural connection to ...
Declaration of Statistics objects.
Stats::Vector perBankRdBursts
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.
void computeStats()
Computes stats just prior to dump event.
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...
void startup(Tick ref_tick)
Kick off accounting for power and refresh states and schedule initial refresh.
virtual BaseSlavePort & getSlavePort(const std::string &if_name, PortID idx=InvalidPortID) override
Get a slave port with a given name and index.
unsigned int numBanksActive
To track number of banks which are currently active for this rank.
Stats::Vector writePktSize
Stats::Scalar totalIdleTime
Stat to track total DRAM idle time.
void recvFunctional(PacketPtr pkt)
Receive a functional request packet from the master port.
bool isTimingMode
Remeber if the memory system is in timing mode.
void processWriteDoneEvent()
Stats::Scalar actPowerDownEnergy
A basic class to track the bank state, i.e.
AbstractMemory declaration.
Stats::Histogram wrPerTurnAround
Declaration of the queued port.
const uint32_t maxAccessesPerRow
Max column accesses (read and write) per row, before forefully closing it.
const uint32_t bankGroupsPerRank
Tick curTick()
The current simulated tick.
Addr burstAlign(Addr addr) const
Burst-align an address.
Tick recvAtomic(PacketPtr pkt)
Receive an atomic request packet from the master port.
EventWrapper< DRAMCtrl,&DRAMCtrl::processNextReqEvent > nextReqEvent
Stats::Formula avgRdBWSys
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.
Rank(DRAMCtrl &_memory, const DRAMCtrlParams *_p)
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.
PowerState pwrState
Current power state.
void checkDrainDone()
Let the rank check if it was waiting for requests to drain to allow it to transition states...
void regStats() override
Register Statistics.
BurstHelper(unsigned int _burstCount)
std::deque< Tick > actTicks
List to keep track of activate ticks.
bool chooseNext(std::deque< DRAMPacket * > &queue, Tick extra_col_delay)
The memory schduler/arbiter - picks which request needs to go next, based on the specified policy suc...
Stats::Vector readPktSize
Tick recvAtomic(PacketPtr pkt)
Stats::Formula avgMemAccLat
Stats::Scalar bytesReadDRAM
Tick pwrStateTick
Track when we transitioned to the current power state.
static bool sortTime(const Command &cmd, const Command &cmd_next)
Function for sorting Command structures based on timeStamp.
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
std::pair< uint64_t, bool > minBankPrep(const std::deque< DRAMPacket * > &queue, Tick min_col_at) const
Find which are the earliest banks ready to issue an activate for the enqueued requests.
Stats::Formula readRowHitRate
DRAMCtrl & memory
A reference to the parent DRAMCtrl instance.
bool reorderQueue(std::deque< DRAMPacket * > &queue, Tick extra_col_delay)
For FR-FCFS policy reorder the read/write queue depending on row buffer hits and earliest bursts avai...
const uint8_t rank
Will be populated by address decoder.
Stats::Formula avgWrBWSys
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...
bool inPwrIdleState() const
Check if the current rank has all banks closed and is not in a low power state.
const Tick M5_CLASS_VAR_USED tCK
Basic memory timing parameters initialized based on parameter values.
uint64_t size() const
Get the memory size.
EventWrapper< Rank,&Rank::processRefreshEvent > refreshEvent
Stats::Scalar servicedByWrQ
void processRefreshEvent()
const std::string name() const
DRAMPacket * decodeAddr(PacketPtr pkt, Addr dramPktAddr, unsigned int size, bool isRead)
Address decoder to figure out physical mapping onto ranks, banks, and rows.
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.
static const uint32_t NO_ROW
const uint32_t rowBufferSize
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...
const uint32_t minWritesPerSwitch
void suspend()
Stop the refresh events.
Stats::Scalar refreshEnergy
void schedulePowerEvent(PowerState pwr_state, Tick tick)
Schedule a power state transition in the future, and potentially override an already scheduled transi...
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
void updatePowerStats()
Function to update Power Stats.
const uint32_t writeHighThreshold
EventWrapper< Rank,&Rank::processActivateEvent > activateEvent
Enums::AddrMap addrMapping
Tick nextReqTime
The soonest you have to start thinking about the next request is the longest access time that can occ...
EventWrapper< DRAMCtrl,&DRAMCtrl::processRespondEvent > respondEvent
void processPrechargeEvent()
EventWrapper< Rank,&Rank::processWakeUpEvent > wakeUpEvent
virtual const std::string name() const
void powerDownSleep(PowerState pwr_state, Tick tick)
Schedule a transition to power-down (sleep)
std::deque< DRAMPacket * > writeQueue
bool lowPowerEntryReady() const
Check if the current rank is idle and should enter a low-pwer state.
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)
bool readQueueFull(unsigned int pktCount) const
Check if the read queue has room for more entries.
void processActivateEvent()
DRAMPower power
One DRAMPower instance per rank.
Stats::Scalar averagePower
Tick wakeUpAllowedAt
delay power-down and self-refresh exit until this requirement is met
Stats::Scalar actBackEnergy
Stats::Vector pwrStateTime
Track time spent in each power state.
void processNextReqEvent()
Bunch of things requires to setup "events" in gem5 When event "respondEvent" occurs for example...
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
void recvFunctional(PacketPtr pkt)
EventWrapper< Rank,&Rank::processPowerEvent > powerEvent
An abstract memory represents a contiguous block of physical memory, with an associated address range...
Simple structure to hold the values needed to keep track of commands for DRAMPower.
BusState
Bus state used to control the read/write switching and drive the scheduling of the next request...
Stats::Scalar bytesReadSys
void processWakeUpEvent()
const uint32_t deviceSize
The following are basic design parameters of the memory controller, and are initialized based on para...
Stats::Formula busUtilRead
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
std::deque< DRAMPacket * > readQueue
The controller's main read and write queues.
Tick readyTime
When will request leave the controller.
const uint32_t columnsPerStripe
bool isAvailable() const
Check if the current rank is available for scheduling.
Data::MemCommand::cmds type
Stats::Scalar prePowerDownEnergy
virtual AddrRangeList getAddrRanges() const
Get a list of the non-overlapping address ranges the owner is responsible for.
bool allRanksDrained() const
Return true once refresh is complete for all ranks and there are no additional commands enqueued...
void processRespondEvent()
const uint32_t writeBufferSize
const uint32_t banksPerRank
Stats::Scalar totalEnergy
const uint32_t readBufferSize
DRAMPower is a standalone tool which calculates the power consumed by a DRAM in the system...
Stats::Formula writeRowHitRate
virtual void drainResume() override
Resume execution after a successful drain.
Stats::Scalar bytesWrittenSys
Stats::Vector perBankWrBursts
virtual void startup() override
startup() is the final initialization call before simulation.
Tick busBusyUntil
Till when has the main data bus been spoken for already?
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...
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 master port.
EventWrapper< Rank,&Rank::processPrechargeEvent > prechargeEvent
const PacketPtr pkt
This comes from the outside world.
void scheduleWakeUpEvent(Tick exit_delay)
schedule and event to wake-up from power-down or self-refresh and update bank timing parameters ...
Stats::Scalar writeRowHits
constexpr Command(Data::MemCommand::cmds _type, uint8_t _bank, Tick time_stamp)
Rank class includes a vector of banks.
bool forceSelfRefreshExit() const
Trigger a self-refresh exit if there are entries enqueued Exit if there are any read entries regardle...
bool inLowPowerState
rank is in or transitioning to power-down or self-refresh
EventWrapper< Rank,&Rank::processWriteDoneEvent > writeDoneEvent
MemoryPort port
Our incoming port, for a multi-ported controller add a crossbar in front of it.
void flushCmdList()
Push command out of cmdList queue that are scheduled at or before curTick() to DRAMPower library All ...
virtual void process()
virtual process function that is invoked when the callback queue is executed.
Stats::Scalar neitherReadNorWrite