gem5 v24.0.0.0
Loading...
Searching...
No Matches
dram_interface.hh
Go to the documentation of this file.
1/*
2 * Copyright (c) 2012-2020 ARM Limited
3 * All rights reserved
4 *
5 * The license below extends only to copyright in the software and shall
6 * not be construed as granting a license to any other intellectual
7 * property including but not limited to intellectual property relating
8 * to a hardware implementation of the functionality of the software
9 * licensed hereunder. You may use the software subject to the license
10 * terms below provided that you ensure that this notice is replicated
11 * unmodified and in its entirety in all distributions of the software,
12 * modified or unmodified, in source code or in binary form.
13 *
14 * Copyright (c) 2013 Amin Farmahini-Farahani
15 * All rights reserved.
16 *
17 * Redistribution and use in source and binary forms, with or without
18 * modification, are permitted provided that the following conditions are
19 * met: redistributions of source code must retain the above copyright
20 * notice, this list of conditions and the following disclaimer;
21 * redistributions in binary form must reproduce the above copyright
22 * notice, this list of conditions and the following disclaimer in the
23 * documentation and/or other materials provided with the distribution;
24 * neither the name of the copyright holders nor the names of its
25 * contributors may be used to endorse or promote products derived from
26 * this software without specific prior written permission.
27 *
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
31 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
32 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 */
40
46#ifndef __DRAM_INTERFACE_HH__
47#define __DRAM_INTERFACE_HH__
48
49#include "mem/drampower.hh"
50#include "mem/mem_interface.hh"
51#include "params/DRAMInterface.hh"
52
53namespace gem5
54{
55
56namespace memory
57{
58
66{
67 private:
72 struct Command
73 {
74 Data::MemCommand::cmds type;
75 uint8_t bank;
77
78 constexpr Command(Data::MemCommand::cmds _type, uint8_t _bank,
79 Tick time_stamp)
80 : type(_type), bank(_bank), timeStamp(time_stamp)
81 { }
82 };
83
120
161
162 class Rank;
164 {
166
167 void regStats() override;
168 void resetStats() override;
169 void preDumpStats() override;
170
172
173 /*
174 * Command energies
175 */
181
182 /*
183 * Active Background Energy
184 */
186
187 /*
188 * Precharge Background Energy
189 */
191
192 /*
193 * Active Power-Down Energy
194 */
196
197 /*
198 * Precharge Power-Down Energy
199 */
201
202 /*
203 * self Refresh Energy
204 */
206
209
215
220 };
221
229 class Rank : public EventManager
230 {
231 private:
232
237
243
248
253
258
262 void updatePowerStats();
263
271 void schedulePowerEvent(PowerState pwr_state, Tick tick);
272
273 public:
274
279
284
289
293 uint8_t rank;
294
298 uint32_t readEntries;
299
303 uint32_t writeEntries;
304
311
316
321
329
335
340 unsigned int numBanksActive;
341
344
349
350 Rank(const DRAMInterfaceParams &_p, int _rank,
351 DRAMInterface& _dram);
352
353 const std::string name() const { return csprintf("%d", rank); }
354
361 void startup(Tick ref_tick);
362
366 void suspend();
367
374 bool inRefIdleState() const { return refreshState == REF_IDLE; }
375
383 bool
385 {
386 // If powerdown is not enabled, then the ranks never go to idle
387 // states. In that case return true here to prevent checkpointing
388 // from getting stuck waiting for DRAM to be idle.
390 return true;
391 }
392
393 return pwrState == PWR_IDLE;
394 }
395
406 bool forceSelfRefreshExit() const;
407
414 bool isQueueEmpty() const;
415
420 void checkDrainDone();
421
428 void flushCmdList();
429
433 void computeStats();
434
438 void resetStats();
439
446 void powerDownSleep(PowerState pwr_state, Tick tick);
447
455 void scheduleWakeUpEvent(Tick exit_delay);
456
459
462
465
466 void processRefreshEvent();
468
469 void processPowerEvent();
471
472 void processWakeUpEvent();
474
475 protected:
477 };
478
486 static bool
487 sortTime(const Command& cmd, const Command& cmd_next)
488 {
489 return cmd.timeStamp < cmd_next.timeStamp;
490 }
491
495 const uint32_t bankGroupsPerRank;
496 const bool bankGroupArch;
497
501 const Tick tRL;
502 const Tick tWL;
509 const Tick tRP;
510 const Tick tRAS;
511 const Tick tWR;
512 const Tick tRTP;
513 const Tick tRFC;
514 const Tick tREFI;
515 const Tick tRRD;
517 const Tick tPPD;
518 const Tick tAAD;
519 const Tick tXAW;
520 const Tick tXP;
521 const Tick tXS;
523 const bool dataClockSync;
524 const bool burstInterleave;
525 const uint8_t twoCycleActivate;
526 const uint32_t activationLimit;
529
530
531 enums::PageManage pageMgmt;
536 const uint32_t maxAccessesPerRow;
537
538 // timestamp offset
540
541 // Holds the value of the DRAM rank of burst issued
542 uint8_t activeRank;
543
546
549
561 void activateBank(Rank& rank_ref, Bank& bank_ref, Tick act_tick,
562 uint32_t row);
563
575 void prechargeBank(Rank& rank_ref, Bank& bank_ref,
576 Tick pre_tick, bool auto_or_preall = false,
577 bool trace = true);
578
626
628
633
634 /*
635 * @return delay between write and read commands
636 */
637 Tick writeToReadDelay() const override { return tBURST + tWTR + tWL; }
638
650 minBankPrep(const MemPacketQueue& queue, Tick min_col_at) const;
651
652 /*
653 * @return time to send a burst of data without gaps
654 */
655 Tick
657 {
658 return (burstInterleave ? tBURST_MAX / 2 : tBURST);
659 }
660
661 public:
665 void init() override;
666
670 void startup() override;
671
678 void setupRank(const uint8_t rank, const bool is_read) override;
679
680 MemPacket* decodePacket(const PacketPtr pkt, Addr pkt_addr,
681 unsigned int size, bool is_read,
682 uint8_t pseudo_channel = 0) override;
683
687 void drainRanks() override;
688
698 bool allRanksDrained() const override;
699
703 void suspend() override;
704
705 /*
706 * @return time to offset next command
707 */
708 Tick commandOffset() const override
709 {
710 return (tRP + std::max(tRCD_RD, tRCD_WR));
711 }
712
713 /*
714 * Function to calulate unloaded, closed bank access latency
715 */
716 Tick accessLatency() const override { return (tRP + tRCD_RD + tRL); }
717
727 chooseNextFRFCFS(MemPacketQueue& queue, Tick min_col_at) const override;
728
744 doBurstAccess(MemPacket* mem_pkt, Tick next_burst_at,
745 const std::vector<MemPacketQueue>& queue) override;
746
754 bool
755 burstReady(MemPacket* pkt) const override
756 {
757 return ranks[pkt->rank]->inRefIdleState();
758 }
759
768 bool isBusy(bool read_queue_empty, bool all_writes_nvm) override;
769
777 void addRankToRankDelay(Tick cmd_at) override;
778
786 void respondEvent(uint8_t rank) override;
787
794 void checkRefreshState(uint8_t rank) override;
795
799 bool readsWaitingToIssue() const override { return false;}
800 void chooseRead(MemPacketQueue& queue) override { }
801 bool writeRespQueueFull() const override { return false;}
802
803 DRAMInterface(const DRAMInterfaceParams &_p);
804};
805
806} // namespace memory
807} // namespace gem5
808
809#endif //__DRAM_INTERFACE_HH__
DRAMPower is a standalone tool which calculates the power consumed by a DRAM in the system.
Definition drampower.hh:57
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition packet.hh:295
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 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.
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.
std::deque< Tick > actTicks
List to keep track of activate ticks.
bool inLowPowerState
rank is in or transitioning to power-down or self-refresh
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...
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.
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.
void suspend()
Stop the refresh events.
void updatePowerStats()
Function to update Power Stats.
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
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.
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.
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.
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...
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.
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.
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,...
Definition mem_ctrl.hh:99
const uint8_t rank
Will be populated by address decoder.
Definition mem_ctrl.hh:123
A formula for statistics that is calculated when printed.
Statistics container.
Definition group.hh:93
A simple histogram stat.
This is a simple scalar statistic, like a counter.
A vector of scalar stats.
STL deque class.
Definition stl.hh:44
STL pair class.
Definition stl.hh:58
STL vector class.
Definition stl.hh:37
DRAMPower declaration.
MemInterface declaration.
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
Definition binary32.hh:36
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition types.hh:147
uint64_t Tick
Tick count type.
Definition types.hh:58
std::string csprintf(const char *format, const Args &...args)
Definition cprintf.hh:161
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)
statistics::Vector perBankRdBursts
DRAM per bank stats.
void resetStats() override
Callback to reset stats.
void regStats() override
Callback to set stat parameters.
statistics::Scalar readBursts
total number of DRAM bursts serviced
void resetStats() override
Callback to reset stats.
void preDumpStats() override
Callback before stats are dumped.
statistics::Vector pwrStateTime
Track time spent in each power state.
void regStats() override
Callback to set stat parameters.
statistics::Scalar totalIdleTime
Stat to track total DRAM idle time.
RankStats(DRAMInterface &dram, Rank &rank)
Definition mem.h:38

Generated on Tue Jun 18 2024 16:24:05 for gem5 by doxygen 1.11.0