-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdram_interface.hh
More file actions
882 lines (749 loc) · 27.1 KB
/
dram_interface.hh
File metadata and controls
882 lines (749 loc) · 27.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
/*
* Copyright (c) 2012-2020 ARM Limited
* All rights reserved
*
* The license below extends only to copyright in the software and shall
* not be construed as granting a license to any other intellectual
* property including but not limited to intellectual property relating
* to a hardware implementation of the functionality of the software
* licensed hereunder. You may use the software subject to the license
* terms below provided that you ensure that this notice is replicated
* unmodified and in its entirety in all distributions of the software,
* modified or unmodified, in source code or in binary form.
*
* Copyright (c) 2013 Amin Farmahini-Farahani
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met: redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer;
* redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution;
* neither the name of the copyright holders nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* @file
* DRAMInterface declaration
*/
#ifndef __DRAM_INTERFACE_HH__
#define __DRAM_INTERFACE_HH__
#include "mem/drampower.hh"
#include "mem/mem_interface.hh"
// #include "mem/policy_manager.hh"
namespace gem5
{
namespace memory
{
/**
* Interface to DRAM devices with media specific parameters,
* statistics, and functions.
* The DRAMInterface includes a class for individual ranks
* and per rank functions.
*/
class DRAMInterface : public MemInterface
{
private:
/**
* Simple structure to hold the values needed to keep track of
* commands for DRAMPower
*/
struct Command
{
Data::MemCommand::cmds type;
uint8_t bank;
Tick timeStamp;
constexpr Command(Data::MemCommand::cmds _type, uint8_t _bank,
Tick time_stamp)
: type(_type), bank(_bank), timeStamp(time_stamp)
{ }
};
/**
* The power state captures the different operational states of
* the DRAM and interacts with the bus read/write state machine,
* and the refresh state machine.
*
* PWR_IDLE : The idle state in which all banks are closed
* From here can transition to: PWR_REF, PWR_ACT,
* PWR_PRE_PDN
*
* PWR_REF : Auto-refresh state. Will transition when refresh is
* complete based on power state prior to PWR_REF
* From here can transition to: PWR_IDLE, PWR_PRE_PDN,
* PWR_SREF
*
* PWR_SREF : Self-refresh state. Entered after refresh if
* previous state was PWR_PRE_PDN
* From here can transition to: PWR_IDLE
*
* PWR_PRE_PDN : Precharge power down state
* From here can transition to: PWR_REF, PWR_IDLE
*
* PWR_ACT : Activate state in which one or more banks are open
* From here can transition to: PWR_IDLE, PWR_ACT_PDN
*
* PWR_ACT_PDN : Activate power down state
* From here can transition to: PWR_ACT
*/
enum PowerState
{
PWR_IDLE = 0,
PWR_REF,
PWR_SREF,
PWR_PRE_PDN,
PWR_ACT,
PWR_ACT_PDN
};
/**
* The refresh state is used to control the progress of the
* refresh scheduling. When normal operation is in progress the
* refresh state is idle. Once tREFI has elasped, a refresh event
* is triggered to start the following STM transitions which are
* used to issue a refresh and return back to normal operation
*
* REF_IDLE : IDLE state used during normal operation
* From here can transition to: REF_DRAIN
*
* REF_SREF_EXIT : Exiting a self-refresh; refresh event scheduled
* after self-refresh exit completes
* From here can transition to: REF_DRAIN
*
* REF_DRAIN : Drain state in which on going accesses complete.
* From here can transition to: REF_PD_EXIT
*
* REF_PD_EXIT : Evaluate pwrState and issue wakeup if needed
* Next state dependent on whether banks are open
* From here can transition to: REF_PRE, REF_START
*
* REF_PRE : Close (precharge) all open banks
* From here can transition to: REF_START
*
* REF_START : Issue refresh command and update DRAMPower stats
* From here can transition to: REF_RUN
*
* REF_RUN : Refresh running, waiting for tRFC to expire
* From here can transition to: REF_IDLE, REF_SREF_EXIT
*/
enum RefreshState
{
REF_IDLE = 0,
REF_DRAIN,
REF_PD_EXIT,
REF_SREF_EXIT,
REF_PRE,
REF_START,
REF_RUN
};
class Rank;
struct RankStats : public statistics::Group
{
RankStats(DRAMInterface &dram, Rank &rank);
void regStats() override;
void resetStats() override;
void preDumpStats() override;
Rank &rank;
/*
* Command energies
*/
statistics::Scalar actEnergy;
statistics::Scalar preEnergy;
statistics::Scalar readEnergy;
statistics::Scalar writeEnergy;
statistics::Scalar refreshEnergy;
/*
* Active Background Energy
*/
statistics::Scalar actBackEnergy;
/*
* Precharge Background Energy
*/
statistics::Scalar preBackEnergy;
/*
* Active Power-Down Energy
*/
statistics::Scalar actPowerDownEnergy;
/*
* Precharge Power-Down Energy
*/
statistics::Scalar prePowerDownEnergy;
/*
* self Refresh Energy
*/
statistics::Scalar selfRefreshEnergy;
statistics::Scalar totalEnergy;
statistics::Scalar averagePower;
/**
* Stat to track total DRAM idle time
*
*/
statistics::Scalar totalIdleTime;
/**
* Track time spent in each power state.
*/
statistics::Vector pwrStateTime;
};
/**
* Rank class includes a vector of banks. Refresh and Power state
* machines are defined per rank. Events required to change the
* state of the refresh and power state machine are scheduled per
* rank. This class allows the implementation of rank-wise refresh
* and rank-wise power-down.
*/
class Rank : public EventManager
{
private:
/**
* A reference to the parent DRAMInterface instance
*/
DRAMInterface& dram;
/**
* Since we are taking decisions out of order, we need to keep
* track of what power transition is happening at what time
*/
PowerState pwrStateTrans;
/**
* Previous low-power state, which will be re-entered after refresh.
*/
PowerState pwrStatePostRefresh;
/**
* Track when we transitioned to the current power state
*/
Tick pwrStateTick;
/**
* Keep track of when a refresh is due.
*/
Tick refreshDueAt;
/**
* Function to update Power Stats
*/
void updatePowerStats();
/**
* Schedule a power state transition in the future, and
* potentially override an already scheduled transition.
*
* @param pwr_state Power state to transition to
* @param tick Tick when transition should take place
*/
void schedulePowerEvent(PowerState pwr_state, Tick tick);
public:
/**
* Current power state.
*/
PowerState pwrState;
/**
* current refresh state
*/
RefreshState refreshState;
/**
* rank is in or transitioning to power-down or self-refresh
*/
bool inLowPowerState;
/**
* Current Rank index
*/
uint8_t rank;
/**
* Track number of packets in read queue going to this rank
*/
uint32_t readEntries;
/**
* Track number of packets in write queue going to this rank
*/
uint32_t writeEntries;
/**
* Number of ACT, RD, and WR events currently scheduled
* Incremented when a refresh event is started as well
* Used to determine when a low-power state can be entered
*/
uint8_t outstandingEvents;
/**
* delay low-power exit until this requirement is met
*/
Tick wakeUpAllowedAt;
/**
* One DRAMPower instance per rank
*/
DRAMPower power;
/**
* List of commands issued, to be sent to DRAMPpower at refresh
* and stats dump. Keep commands here since commands to different
* banks are added out of order. Will only pass commands up to
* curTick() to DRAMPower after sorting.
*/
std::vector<Command> cmdList;
/**
* Vector of Banks. Each rank is made of several devices which in
* term are made from several banks.
*/
std::vector<Bank> banks;
/**
* To track number of banks which are currently active for
* this rank.
*/
unsigned int numBanksActive;
/** List to keep track of activate ticks */
std::deque<Tick> actTicks;
/**
* Track when we issued the last read/write burst
*/
Tick lastBurstTick;
Rank(const DRAMInterfaceParams &_p, int _rank,
DRAMInterface& _dram);
const std::string name() const { return csprintf("%d", rank); }
/**
* Kick off accounting for power and refresh states and
* schedule initial refresh.
*
* @param ref_tick Tick for first refresh
*/
void startup(Tick ref_tick);
/**
* Stop the refresh events.
*/
void suspend();
/**
* Check if there is no refresh and no preparation of refresh ongoing
* i.e. the refresh state machine is in idle
*
* @param Return true if the rank is idle from a refresh point of view
*/
bool inRefIdleState() const { return refreshState == REF_IDLE; }
/**
* Check if the current rank has all banks closed and is not
* in a low power state
*
* @param Return true if the rank is idle from a bank
* and power point of view
*/
bool inPwrIdleState() const { return pwrState == PWR_IDLE; }
/**
* Trigger a self-refresh exit if there are entries enqueued
* Exit if there are any read entries regardless of the bus state.
* If we are currently issuing write commands, exit if we have any
* write commands enqueued as well.
* Could expand this in the future to analyze state of entire queue
* if needed.
*
* @return boolean indicating self-refresh exit should be scheduled
*/
bool forceSelfRefreshExit() const;
/**
* Check if the command queue of current rank is idle
*
* @param Return true if the there are no commands in Q.
* Bus direction determines queue checked.
*/
bool isQueueEmpty() const;
/**
* Let the rank check if it was waiting for requests to drain
* to allow it to transition states.
*/
void checkDrainDone();
/**
* Push command out of cmdList queue that are scheduled at
* or before curTick() to DRAMPower library
* All commands before curTick are guaranteed to be complete
* and can safely be flushed.
*/
void flushCmdList();
/**
* Computes stats just prior to dump event
*/
void computeStats();
/**
* Reset stats on a stats event
*/
void resetStats();
/**
* Schedule a transition to power-down (sleep)
*
* @param pwr_state Power state to transition to
* @param tick Absolute tick when transition should take place
*/
void powerDownSleep(PowerState pwr_state, Tick tick);
/**
* schedule and event to wake-up from power-down or self-refresh
* and update bank timing parameters
*
* @param exit_delay Relative tick defining the delay required between
* low-power exit and the next command
*/
void scheduleWakeUpEvent(Tick exit_delay);
void processWriteDoneEvent();
EventFunctionWrapper writeDoneEvent;
void processActivateEvent();
EventFunctionWrapper activateEvent;
void processPrechargeEvent();
EventFunctionWrapper prechargeEvent;
void processRefreshEvent();
EventFunctionWrapper refreshEvent;
void processPowerEvent();
EventFunctionWrapper powerEvent;
void processWakeUpEvent();
EventFunctionWrapper wakeUpEvent;
protected:
RankStats stats;
};
/**
* Function for sorting Command structures based on timeStamp
*
* @param a Memory Command
* @param next Memory Command
* @return true if timeStamp of Command 1 < timeStamp of Command 2
*/
static bool
sortTime(const Command& cmd, const Command& cmd_next)
{
return cmd.timeStamp < cmd_next.timeStamp;
}
/**
* DRAM specific device characteristics
*/
const uint32_t bankGroupsPerRank;
const bool bankGroupArch;
/**
* DRAM specific timing requirements
*/
const Tick tRL;
const Tick tWL;
const Tick tBURST_MIN;
const Tick tBURST_MAX;
const Tick tCCD_L_WR;
const Tick tCCD_L;
const Tick tRCD_RD;
const Tick tRCD_WR;
const Tick tRP;
const Tick tRAS;
const Tick tWR;
const Tick tRTP;
const Tick tRFC;
const Tick tREFI;
const Tick tRRD;
const Tick tRRD_L;
const Tick tPPD;
const Tick tAAD;
const Tick tXAW;
const Tick tXP;
const Tick tXS;
const Tick tTAGBURST;
const Tick tRL_FAST;
const Tick tHM2DQ;
const Tick tRTW_int;
const Tick tRFBD;
const Tick tRCD_FAST;
const Tick tRC_FAST;
float flushBufferHighThreshold;
const Tick clkResyncDelay;
const bool dataClockSync;
const bool burstInterleave;
const uint8_t twoCycleActivate;
const uint32_t activationLimit;
const Tick wrToRdDlySameBG;
const Tick rdToWrDlySameBG;
unsigned maxFBLen;
enums::PageManage pageMgmt;
/**
* Max column accesses (read and write) per row, before forefully
* closing it.
*/
const uint32_t maxAccessesPerRow;
// timestamp offset
uint64_t timeStampOffset;
// Holds the value of the DRAM rank of burst issued
uint8_t activeRank;
/** Enable or disable DRAM powerdown states. */
bool enableDRAMPowerdown;
/** The time when stats were last reset used to calculate average power */
Tick lastStatsResetTick;
/**
* Keep track of when row activations happen, in order to enforce
* the maximum number of activations in the activation window. The
* method updates the time that the banks become available based
* on the current limits.
*
* @param rank_ref Reference to the rank
* @param bank_ref Reference to the bank
* @param act_tick Time when the activation takes place
* @param row Index of the row
*/
Tick activateBank(Rank& rank_ref, Bank& bank_ref, Tick act_tick,
uint32_t row, bool isTagCheck);
/**
* Precharge a given bank and also update when the precharge is
* done. This will also deal with any stats related to the
* accesses to the open page.
*
* @param rank_ref The rank to precharge
* @param bank_ref The bank to precharge
* @param pre_tick Time when the precharge takes place
* @param auto_or_preall Is this an auto-precharge or precharge all command
* @param trace Is this an auto precharge then do not add to trace
*/
void prechargeBank(Rank& rank_ref, Bank& bank_ref,
Tick pre_tick, bool auto_or_preall = false,
bool trace = true);
struct DRAMStats : public statistics::Group
{
DRAMStats(DRAMInterface &dram);
void regStats() override;
void resetStats() override;
DRAMInterface &dram;
/** total number of DRAM bursts serviced */
statistics::Scalar readBursts;
statistics::Scalar readMC;
statistics::Scalar writeBursts;
statistics::Scalar writeBurstsTC;
statistics::Scalar tagResBursts;
statistics::Scalar tagBursts;
statistics::Average avgFBLenEnq;
statistics::Average avgReadFBPerEvent;
statistics::Scalar totNumberRefreshEvent;
statistics::Scalar totReadFBSent;
statistics::Scalar totReadFBFailed;
statistics::Scalar totReadFBByRdMC;
statistics::Scalar totStallToFlushFB;
statistics::Scalar totPktsPushedFB;
statistics::Scalar maxFBLenEnq;
statistics::Scalar refSchdRFB;
statistics::Scalar actDelayedDueToTagAct;
/** DRAM per bank stats */
statistics::Vector perBankRdBursts;
statistics::Vector perBankWrBursts;
// Latencies summed over all requests
statistics::Scalar totQLat;
statistics::Scalar totBusLat;
statistics::Scalar totMemAccLat;
statistics::Scalar totQLatWr;
statistics::Scalar totBusLatWr;
statistics::Scalar totMemAccLatWr;
statistics::Scalar totQLatWrTC;
statistics::Scalar totBusLatWrTC;
statistics::Scalar totMemAccLatWrTC;
// Average latencies per request
statistics::Formula avgQLat;
statistics::Formula avgBusLat;
statistics::Formula avgMemAccLat;
statistics::Formula avgQLatWr;
statistics::Formula avgBusLatWr;
statistics::Formula avgMemAccLatWr;
statistics::Formula avgQLatWrTC;
statistics::Formula avgBusLatWrTC;
statistics::Formula avgMemAccLatWrTC;
// Row hit count and rate
statistics::Scalar readRowHits;
statistics::Scalar writeRowHits;
statistics::Formula readRowHitRate;
statistics::Formula writeRowHitRate;
statistics::Histogram bytesPerActivate;
// Number of bytes transferred to/from DRAM
statistics::Scalar bytesRead;
statistics::Scalar bytesWritten;
// Average bandwidth
statistics::Formula avgRdBW;
statistics::Formula avgWrBW;
statistics::Formula peakBW;
// bus utilization
statistics::Formula busUtil;
statistics::Formula busUtilRead;
statistics::Formula busUtilWrite;
statistics::Formula pageHitRate;
statistics::Formula hitMissBusUtil;
};
DRAMStats stats;
/**
* Vector of dram ranks
*/
std::vector<Rank*> ranks;
/*
* @return delay between write and read commands
*/
Tick writeToReadDelay() const override { return tBURST + tWTR + tWL; }
/**
* Find which are the earliest banks ready to issue an activate
* for the enqueued requests. Assumes maximum of 32 banks per rank
* Also checks if the bank is already prepped.
*
* @param queue Queued requests to consider
* @param min_col_at time of seamless burst command
* @return One-hot encoded mask of bank indices
* @return boolean indicating burst can issue seamlessly, with no gaps
*/
std::pair<std::vector<uint32_t>, bool>
minBankPrep(const MemPacketQueue& queue, Tick min_col_at) const;
/*
* @return time to send a burst of data without gaps
*/
Tick
burstDelay() const
{
return (burstInterleave ? tBURST_MAX / 2 : tBURST);
}
public:
AbstractMemory* polMan;
Tick get_tRP() override { return tRP;}
Tick get_tRCD_RD() override { return tRCD_RD;}
Tick get_tRL() override { return tRL;}
// void setPolicyManager(PolicyManager* _polMan) override;
void setPolicyManager(AbstractMemory* _polMan) override;
void processReadFlushBufferEvent();
EventFunctionWrapper readFlushBufferEvent;
void processAddToFlushBufferEvent();
EventFunctionWrapper addToFlushBufferEvent;
Tick endOfReadFlushBuffPeriod;
unsigned readFlushBufferCount;
bool enableReadFlushBuffer;
bool isAlloy;
bool checkFwdMrgeInFB(Addr addr) override;
std::deque<Addr> flushBuffer;
typedef std::pair<Tick, Addr> tempFBEntry;
std::deque<tempFBEntry> tempFlushBuffer;
/**
* Initialize the DRAM interface and verify parameters
*/
void init() override;
/**
* Iterate through dram ranks and instantiate per rank startup routine
*/
void startup() override;
/**
* Setup the rank based on packet received
*
* @param integer value of rank to be setup. used to index ranks vector
* @param are we setting up rank for read or write packet?
*/
void setupRank(const uint8_t rank, const bool is_read) override;
MemPacket* decodePacket(const PacketPtr pkt, Addr pkt_addr,
unsigned int size, bool is_read,
uint8_t pseudo_channel = 0) override;
/**
* Iterate through dram ranks to exit self-refresh in order to drain
*/
void drainRanks() override;
/**
* Return true once refresh is complete for all ranks and there are no
* additional commands enqueued. (only evaluated when draining)
* This will ensure that all banks are closed, power state is IDLE, and
* power stats have been updated
*
* @return true if all ranks have refreshed, with no commands enqueued
*
*/
bool allRanksDrained() const override;
/**
* Iterate through DRAM ranks and suspend them
*/
void suspend() override;
/*
* @return time to offset next command
*/
Tick commandOffset() const override
{
return (tRP + std::max(tRCD_RD, tRCD_WR));
}
/*
* Function to calulate unloaded, closed bank access latency
*/
Tick accessLatency() const override { return (tRP + tRCD_RD + tRL); }
/**
* For FR-FCFS policy, find first DRAM command that can issue
*
* @param queue Queued requests to consider
* @param min_col_at Minimum tick for 'seamless' issue
* @return an iterator to the selected packet, else queue.end()
* @return the tick when the packet selected will issue
*/
std::pair<MemPacketQueue::iterator, Tick>
chooseNextFRFCFS(MemPacketQueue& queue, Tick min_col_at) const override;
/**
* Actually do the burst - figure out the latency it
* will take to service the req based on bank state, channel state etc
* and then update those states to account for this request. Based
* on this, update the packet's "readyTime" and move it to the
* response q from where it will eventually go back to the outside
* world.
*
* @param mem_pkt The packet created from the outside world pkt
* @param next_burst_at Minimum bus timing requirement from controller
* @param queue Reference to the read or write queue with the packet
* @return pair, tick when current burst is issued and
* tick when next burst can issue
*/
std::pair<Tick, Tick>
doBurstAccess(MemPacket* mem_pkt, Tick next_burst_at,
const std::vector<MemPacketQueue>& queue) override;
/**
* Check if a burst operation can be issued to the DRAM
*
* @param Return true if RD/WR can issue
* This requires the DRAM to be in the
* REF IDLE state
*/
bool
burstReady(MemPacket* pkt) const override
{
return ranks[pkt->rank]->inRefIdleState();
}
/**
* This function checks if ranks are actively refreshing and
* therefore busy. The function also checks if ranks are in
* the self-refresh state, in which case, a self-refresh exit
* is initiated.
* The arguments are NVM-specific and will be ignored by DRAM.
* return boolean if all ranks are in refresh and therefore busy
*/
bool isBusy(bool read_queue_empty, bool all_writes_nvm) override;
/**
* Add rank to rank delay to bus timing to all DRAM banks in alli ranks
* when access to an alternate interface is issued
*
* param cmd_at Time of current command used as starting point for
* addition of rank-to-rank delay
*/
void addRankToRankDelay(Tick cmd_at) override;
/**
* Complete response process for DRAM when read burst is complete
* This will update the counters and check if a power down state
* can be entered.
*
* @param rank Specifies rank associated with read burst
*/
void respondEvent(uint8_t rank) override;
/**
* Check the refresh state to determine if refresh needs
* to be kicked back into action after a read response
*
* @param rank Specifies rank associated with read burst
*/
void checkRefreshState(uint8_t rank) override;
/**
* The next three functions are NVM-specific and will be ignored by DRAM.
*/
bool readsWaitingToIssue() const override { return false;}
void chooseRead(MemPacketQueue& queue) override { }
bool writeRespQueueFull() const override { return false;}
Tick nextTagActAvailability(unsigned rankNumber, unsigned bankNumber) override
{ return ranks[rankNumber]->banks[bankNumber].tagActAllowedAt; }
Tick getTRCFAST() override { return tRC_FAST;}
Tick getTRLFAST() override { return tRL_FAST;}
Tick getTRCDFAST() override { return tRCD_FAST;}
void updateTagActAllowed(unsigned rankNumber, unsigned bankNumber, Tick BSlotTagBankBusyAt) override;
DRAMInterface(const DRAMInterfaceParams &_p);
};
} // namespace memory
} // namespace gem5
#endif //__DRAM_INTERFACE_HH__