46#ifndef __DRAM_INTERFACE_HH__
47#define __DRAM_INTERFACE_HH__
51#include "params/DRAMInterface.hh"
74 Data::MemCommand::cmds
type;
78 constexpr Command(Data::MemCommand::cmds _type, uint8_t _bank,
350 Rank(
const DRAMInterfaceParams &_p,
int _rank,
576 Tick pre_tick,
bool auto_or_preall =
false,
665 void init()
override;
678 void setupRank(
const uint8_t rank,
const bool is_read)
override;
681 unsigned int size,
bool is_read,
682 uint8_t pseudo_channel = 0)
override;
757 return ranks[pkt->
rank]->inRefIdleState();
768 bool isBusy(
bool read_queue_empty,
bool all_writes_nvm)
override;
DRAMPower is a standalone tool which calculates the power consumed by a DRAM in the system.
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
uint64_t size() const
Get the memory size.
Rank class includes a vector of banks.
void computeStats()
Computes stats just prior to dump event.
void processWriteDoneEvent()
void powerDownSleep(PowerState pwr_state, Tick tick)
Schedule a transition to power-down (sleep)
void checkDrainDone()
Let the rank check if it was waiting for requests to drain to allow it to transition states.
DRAMInterface & dram
A reference to the parent DRAMInterface instance.
EventFunctionWrapper refreshEvent
void resetStats()
Reset stats on a stats event.
DRAMPower power
One DRAMPower instance per rank.
bool inPwrIdleState() const
Check if the current rank has all banks closed and is not in a low power state.
uint8_t outstandingEvents
Number of ACT, RD, and WR events currently scheduled Incremented when a refresh event is started as w...
bool inRefIdleState() const
Check if there is no refresh and no preparation of refresh ongoing i.e.
PowerState pwrState
Current power state.
void processRefreshEvent()
EventFunctionWrapper activateEvent
std::deque< Tick > actTicks
List to keep track of activate ticks.
void processActivateEvent()
bool inLowPowerState
rank is in or transitioning to power-down or self-refresh
EventFunctionWrapper prechargeEvent
uint32_t readEntries
Track number of packets in read queue going to this rank.
RefreshState refreshState
current refresh state
Tick pwrStateTick
Track when we transitioned to the current power state.
PowerState pwrStatePostRefresh
Previous low-power state, which will be re-entered after refresh.
PowerState pwrStateTrans
Since we are taking decisions out of order, we need to keep track of what power transition is happeni...
void processPrechargeEvent()
EventFunctionWrapper powerEvent
unsigned int numBanksActive
To track number of banks which are currently active for this rank.
std::vector< Command > cmdList
List of commands issued, to be sent to DRAMPpower at refresh and stats dump.
std::vector< Bank > banks
Vector of Banks.
Tick lastBurstTick
Track when we issued the last read/write burst.
void scheduleWakeUpEvent(Tick exit_delay)
schedule and event to wake-up from power-down or self-refresh and update bank timing parameters
Tick wakeUpAllowedAt
delay low-power exit until this requirement is met
Tick refreshDueAt
Keep track of when a refresh is due.
void processWakeUpEvent()
const std::string name() const
void schedulePowerEvent(PowerState pwr_state, Tick tick)
Schedule a power state transition in the future, and potentially override an already scheduled transi...
uint8_t rank
Current Rank index.
EventFunctionWrapper wakeUpEvent
void suspend()
Stop the refresh events.
void updatePowerStats()
Function to update Power Stats.
EventFunctionWrapper writeDoneEvent
bool isQueueEmpty() const
Check if the command queue of current rank is idle.
Rank(const DRAMInterfaceParams &_p, int _rank, DRAMInterface &_dram)
bool forceSelfRefreshExit() const
Trigger a self-refresh exit if there are entries enqueued Exit if there are any read entries regardle...
uint32_t writeEntries
Track number of packets in write queue going to this rank.
void flushCmdList()
Push command out of cmdList queue that are scheduled at or before curTick() to DRAMPower library All ...
Interface to DRAM devices with media specific parameters, statistics, and functions.
std::vector< Rank * > ranks
Vector of dram ranks.
Tick commandOffset() const override
const Tick clkResyncDelay
void checkRefreshState(uint8_t rank) override
Check the refresh state to determine if refresh needs to be kicked back into action after a read resp...
void respondEvent(uint8_t rank) override
Complete response process for DRAM when read burst is complete This will update the counters and chec...
const uint32_t maxAccessesPerRow
Max column accesses (read and write) per row, before forefully closing it.
Tick lastStatsResetTick
The time when stats were last reset used to calculate average power.
const Tick rdToWrDlySameBG
bool allRanksDrained() const override
Return true once refresh is complete for all ranks and there are no additional commands enqueued.
void addRankToRankDelay(Tick cmd_at) override
Add rank to rank delay to bus timing to all DRAM banks in alli ranks when access to an alternate inte...
std::pair< Tick, Tick > doBurstAccess(MemPacket *mem_pkt, Tick next_burst_at, const std::vector< MemPacketQueue > &queue) override
Actually do the burst - figure out the latency it will take to service the req based on bank state,...
void drainRanks() override
Iterate through dram ranks to exit self-refresh in order to drain.
const bool burstInterleave
bool isBusy(bool read_queue_empty, bool all_writes_nvm) override
This function checks if ranks are actively refreshing and therefore busy.
void prechargeBank(Rank &rank_ref, Bank &bank_ref, Tick pre_tick, bool auto_or_preall=false, bool trace=true)
Precharge a given bank and also update when the precharge is done.
const uint32_t bankGroupsPerRank
DRAM specific device characteristics.
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...
std::pair< MemPacketQueue::iterator, Tick > chooseNextFRFCFS(MemPacketQueue &queue, Tick min_col_at) const override
For FR-FCFS policy, find first DRAM command that can issue.
const uint32_t activationLimit
bool writeRespQueueFull() const override
This function is NVM specific.
PowerState
The power state captures the different operational states of the DRAM and interacts with the bus read...
const Tick wrToRdDlySameBG
MemPacket * decodePacket(const PacketPtr pkt, Addr pkt_addr, unsigned int size, bool is_read, uint8_t pseudo_channel=0) override
Address decoder to figure out physical mapping onto ranks, banks, and rows.
const Tick tRL
DRAM specific timing requirements.
RefreshState
The refresh state is used to control the progress of the refresh scheduling.
void startup() override
Iterate through dram ranks and instantiate per rank startup routine.
bool enableDRAMPowerdown
Enable or disable DRAM powerdown states.
Tick writeToReadDelay() const override
Tick accessLatency() const override
std::pair< std::vector< uint32_t >, bool > minBankPrep(const MemPacketQueue &queue, Tick min_col_at) const
Find which are the earliest banks ready to issue an activate for the enqueued requests.
static bool sortTime(const Command &cmd, const Command &cmd_next)
Function for sorting Command structures based on timeStamp.
void chooseRead(MemPacketQueue &queue) override
This function is NVM specific.
void init() override
Initialize the DRAM interface and verify parameters.
bool readsWaitingToIssue() const override
The next three functions are NVM-specific and will be ignored by DRAM.
enums::PageManage pageMgmt
DRAMInterface(const DRAMInterfaceParams &_p)
void suspend() override
Iterate through DRAM ranks and suspend them.
void setupRank(const uint8_t rank, const bool is_read) override
Setup the rank based on packet received.
const uint8_t twoCycleActivate
bool burstReady(MemPacket *pkt) const override
Check if a burst operation can be issued to the DRAM.
A basic class to track the bank state, i.e.
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,...
const uint8_t rank
Will be populated by address decoder.
This is a simple scalar statistic, like a counter.
A vector of scalar stats.
MemInterface declaration.
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
uint64_t Tick
Tick count type.
std::string csprintf(const char *format, const Args &...args)
Simple structure to hold the values needed to keep track of commands for DRAMPower.
constexpr Command(Data::MemCommand::cmds _type, uint8_t _bank, Tick time_stamp)
Data::MemCommand::cmds type
statistics::Formula avgQLat
statistics::Formula avgRdBW
statistics::Scalar dramBytesWritten
statistics::Formula writeRowHitRate
statistics::Formula pageHitRate
statistics::Scalar totBusLat
statistics::Vector perBankRdBursts
DRAM per bank stats.
statistics::Scalar writeRowHits
statistics::Formula peakBW
statistics::Formula busUtilRead
statistics::Formula avgWrBW
void resetStats() override
Callback to reset stats.
statistics::Formula avgMemAccLat
statistics::Histogram bytesPerActivate
void regStats() override
Callback to set stat parameters.
statistics::Formula busUtilWrite
statistics::Scalar readBursts
total number of DRAM bursts serviced
statistics::Scalar readRowHits
statistics::Vector perBankWrBursts
DRAMStats(DRAMInterface &dram)
statistics::Scalar dramBytesRead
statistics::Scalar totQLat
statistics::Formula avgBusLat
statistics::Formula readRowHitRate
statistics::Scalar writeBursts
statistics::Scalar totMemAccLat
statistics::Formula busUtil
void resetStats() override
Callback to reset stats.
statistics::Scalar actBackEnergy
void preDumpStats() override
Callback before stats are dumped.
statistics::Scalar selfRefreshEnergy
statistics::Scalar actEnergy
statistics::Scalar totalEnergy
statistics::Scalar preEnergy
statistics::Vector pwrStateTime
Track time spent in each power state.
statistics::Scalar writeEnergy
void regStats() override
Callback to set stat parameters.
statistics::Scalar actPowerDownEnergy
statistics::Scalar preBackEnergy
statistics::Scalar readEnergy
statistics::Scalar averagePower
statistics::Scalar prePowerDownEnergy
statistics::Scalar refreshEnergy
statistics::Scalar totalIdleTime
Stat to track total DRAM idle time.
RankStats(DRAMInterface &dram, Rank &rank)