Deleted Added
sdiff udiff text old ( 12706:456304051464 ) new ( 12969:52de9d619ce6 )
full compact
1/*
2 * Copyright (c) 2012-2018 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

--- 43 unchanged lines hidden (view full) ---

52 */
53
54#ifndef __MEM_DRAM_CTRL_HH__
55#define __MEM_DRAM_CTRL_HH__
56
57#include <deque>
58#include <string>
59#include <unordered_set>
60
61#include "base/callback.hh"
62#include "base/statistics.hh"
63#include "enums/AddrMap.hh"
64#include "enums/MemSched.hh"
65#include "enums/PageManage.hh"
66#include "mem/abstract_mem.hh"
67#include "mem/qport.hh"
68#include "params/DRAMCtrl.hh"
69#include "sim/eventq.hh"
70#include "mem/drampower.hh"
71
72/**
73 * The DRAM controller is a single-channel memory controller capturing
74 * the most important timing constraints associated with a
75 * contemporary DRAM. For multi-channel memory systems, the controller
76 * is combined with a crossbar model, with the channel address
77 * interleaving taking part in the crossbar.
78 *

--- 10 unchanged lines hidden (view full) ---

89 * controllers for future system architecture exploration",
90 * Proc. ISPASS, 2014. If you use this model as part of your research
91 * please cite the paper.
92 *
93 * The low-power functionality implements a staggered powerdown
94 * similar to that described in "Optimized Active and Power-Down Mode
95 * Refresh Control in 3D-DRAMs" by Jung et al, VLSI-SoC, 2014.
96 */
97class DRAMCtrl : public AbstractMemory
98{
99
100 private:
101
102 // For now, make use of a queued slave port to avoid dealing with
103 // flow control for the responses being sent back
104 class MemoryPort : public QueuedSlavePort
105 {

--- 19 unchanged lines hidden (view full) ---

125
126 /**
127 * Our incoming port, for a multi-ported controller add a crossbar
128 * in front of it
129 */
130 MemoryPort port;
131
132 /**
133 * Remeber if the memory system is in timing mode
134 */
135 bool isTimingMode;
136
137 /**
138 * Remember if we have to retry a request when available.
139 */
140 bool retryRdReq;
141 bool retryWrReq;
142
143 /**
144 * Bus state used to control the read/write switching and drive
145 * the scheduling of the next request.
146 */
147 enum BusState {
148 READ = 0,
149 WRITE,
150 };
151
152 BusState busState;
153
154 /* bus state for next request event triggered */
155 BusState busStateNext;
156
157 /**
158 * Simple structure to hold the values needed to keep track of
159 * commands for DRAMPower
160 */
161 struct Command {
162 Data::MemCommand::cmds type;
163 uint8_t bank;
164 Tick timeStamp;

--- 261 unchanged lines hidden (view full) ---

426 Tick wakeUpAllowedAt;
427
428 /**
429 * One DRAMPower instance per rank
430 */
431 DRAMPower power;
432
433 /**
434 * List of comamnds issued, to be sent to DRAMPpower at refresh
435 * and stats dump. Keep commands here since commands to different
436 * banks are added out of order. Will only pass commands up to
437 * curTick() to DRAMPower after sorting.
438 */
439 std::vector<Command> cmdList;
440
441 /**
442 * Vector of Banks. Each rank is made of several devices which in

--- 207 unchanged lines hidden (view full) ---

650 const Tick entryTime;
651
652 /** When will request leave the controller */
653 Tick readyTime;
654
655 /** This comes from the outside world */
656 const PacketPtr pkt;
657
658 const bool isRead;
659
660 /** Will be populated by address decoder */
661 const uint8_t rank;
662 const uint8_t bank;
663 const uint32_t row;
664
665 /**
666 * Bank id is calculated considering banks in all the ranks
667 * eg: 2 ranks each with 8 banks, then bankId = 0 --> rank0, bank0 and

--- 18 unchanged lines hidden (view full) ---

686 /**
687 * A pointer to the BurstHelper if this DRAMPacket is a split packet
688 * If not a split packet (common case), this is set to NULL
689 */
690 BurstHelper* burstHelper;
691 Bank& bankRef;
692 Rank& rankRef;
693
694 DRAMPacket(PacketPtr _pkt, bool is_read, uint8_t _rank, uint8_t _bank,
695 uint32_t _row, uint16_t bank_id, Addr _addr,
696 unsigned int _size, Bank& bank_ref, Rank& rank_ref)
697 : entryTime(curTick()), readyTime(curTick()),
698 pkt(_pkt), isRead(is_read), rank(_rank), bank(_bank), row(_row),
699 bankId(bank_id), addr(_addr), size(_size), burstHelper(NULL),
700 bankRef(bank_ref), rankRef(rank_ref)
701 { }
702
703 };
704
705 /**
706 * Bunch of things requires to setup "events" in gem5
707 * When event "respondEvent" occurs for example, the method
708 * processRespondEvent is called; no parameters are allowed
709 * in these methods
710 */
711 void processNextReqEvent();
712 EventFunctionWrapper nextReqEvent;

--- 88 unchanged lines hidden (view full) ---

801 * The memory schduler/arbiter - picks which request needs to
802 * go next, based on the specified policy such as FCFS or FR-FCFS
803 * and moves it to the head of the queue.
804 * Prioritizes accesses to the same rank as previous burst unless
805 * controller is switching command type.
806 *
807 * @param queue Queued requests to consider
808 * @param extra_col_delay Any extra delay due to a read/write switch
809 * @return true if a packet is scheduled to a rank which is available else
810 * false
811 */
812 bool chooseNext(std::deque<DRAMPacket*>& queue, Tick extra_col_delay);
813
814 /**
815 * For FR-FCFS policy reorder the read/write queue depending on row buffer
816 * hits and earliest bursts available in DRAM
817 *
818 * @param queue Queued requests to consider
819 * @param extra_col_delay Any extra delay due to a read/write switch
820 * @return true if a packet is scheduled to a rank which is available else
821 * false
822 */
823 bool reorderQueue(std::deque<DRAMPacket*>& queue, Tick extra_col_delay);
824
825 /**
826 * Find which are the earliest banks ready to issue an activate
827 * for the enqueued requests. Assumes maximum of 32 banks per rank
828 * Also checks if the bank is already prepped.
829 *
830 * @param queue Queued requests to consider
831 * @param min_col_at time of seamless burst command
832 * @return One-hot encoded mask of bank indices
833 * @return boolean indicating burst can issue seamlessly, with no gaps
834 */
835 std::pair<std::vector<uint32_t>, bool> minBankPrep(
836 const std::deque<DRAMPacket*>& queue,
837 Tick min_col_at) const;
838
839 /**
840 * Keep track of when row activations happen, in order to enforce
841 * the maximum number of activations in the activation window. The
842 * method updates the time that the banks become available based
843 * on the current limits.
844 *
845 * @param rank_ref Reference to the rank

--- 27 unchanged lines hidden (view full) ---

873 *
874 * @param addr The potentially unaligned address
875 *
876 * @return An address aligned to a DRAM burst
877 */
878 Addr burstAlign(Addr addr) const { return (addr & ~(Addr(burstSize - 1))); }
879
880 /**
881 * The controller's main read and write queues
882 */
883 std::deque<DRAMPacket*> readQueue;
884 std::deque<DRAMPacket*> writeQueue;
885
886 /**
887 * To avoid iterating over the write queue to check for
888 * overlapping transactions, maintain a set of burst addresses
889 * that are currently queued. Since we merge writes to the same
890 * location we never have more than one address to the same burst
891 * address.
892 */
893 std::unordered_set<Addr> isInWriteQueue;
894
895 /**
896 * Response queue where read packets wait after we're done working
897 * with them, but it's not time to send the response yet. The
898 * responses are stored seperately mostly to keep the code clean
899 * and help with events scheduling. For all logical purposes such
900 * as sizing the read queue, this and the main read queue need to
901 * be added together.
902 */
903 std::deque<DRAMPacket*> respQueue;
904
905 /**
906 * Vector of ranks

--- 61 unchanged lines hidden (view full) ---

968 * Memory controller configuration initialized based on parameter
969 * values.
970 */
971 Enums::MemSched memSchedPolicy;
972 Enums::AddrMap addrMapping;
973 Enums::PageManage pageMgmt;
974
975 /**
976 * Max column accesses (read and write) per row, before forefully
977 * closing it.
978 */
979 const uint32_t maxAccessesPerRow;
980
981 /**
982 * Pipeline latency of the controller frontend. The frontend
983 * contribution is added to writes (that complete when they are in
984 * the write buffer) and reads that are serviced the write buffer.

--- 43 unchanged lines hidden (view full) ---

1028 Stats::Vector readPktSize;
1029 Stats::Vector writePktSize;
1030 Stats::Vector rdQLenPdf;
1031 Stats::Vector wrQLenPdf;
1032 Stats::Histogram bytesPerActivate;
1033 Stats::Histogram rdPerTurnAround;
1034 Stats::Histogram wrPerTurnAround;
1035
1036 // Latencies summed over all requests
1037 Stats::Scalar totQLat;
1038 Stats::Scalar totMemAccLat;
1039 Stats::Scalar totBusLat;
1040
1041 // Average latencies per request
1042 Stats::Formula avgQLat;
1043 Stats::Formula avgBusLat;

--- 40 unchanged lines hidden (view full) ---

1084
1085 /**
1086 * This function increments the energy when called. If stats are
1087 * dumped periodically, note accumulated energy values will
1088 * appear in the stats (even if the stats are reset). This is a
1089 * result of the energy values coming from DRAMPower, and there
1090 * is currently no support for resetting the state.
1091 *
1092 * @param rank Currrent rank
1093 */
1094 void updatePowerStats(Rank& rank_ref);
1095
1096 /**
1097 * Function for sorting Command structures based on timeStamp
1098 *
1099 * @param a Memory Command
1100 * @param next Memory Command

--- 41 unchanged lines hidden ---