gem5  v22.0.0.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
nvm_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 __NVM_INTERFACE_HH__
47 #define __NVM_INTERFACE_HH__
48 
49 #include "mem/mem_interface.hh"
50 #include "params/NVMInterface.hh"
51 
52 namespace gem5
53 {
54 
55 namespace memory
56 {
57 
64 class NVMInterface : public MemInterface
65 {
66  private:
70  class Rank : public EventManager
71  {
72  public:
73 
77  uint8_t rank;
78 
84 
85  Rank(const NVMInterfaceParams &_p, int _rank,
86  NVMInterface& _nvm);
87  };
88 
92  const uint32_t maxPendingWrites;
93  const uint32_t maxPendingReads;
94  const bool twoCycleRdWr;
95 
99  const Tick tREAD;
100  const Tick tWRITE;
101  const Tick tSEND;
102 
103  struct NVMStats : public statistics::Group
104  {
106 
107  void regStats() override;
108 
110 
114 
117 
118  // Latencies summed over all requests
122 
123  // Average latencies per request
127 
130 
131  // Average bandwidth
138 
143  };
145 
148 
149  void processReadReadyEvent();
151 
156 
166 
168 
174  bool writeRespQueueEmpty() const { return writeRespQueue.empty(); }
175 
180 
181  // keep track of reads that have issued for which data is either
182  // not yet ready or has not yet been transferred to the ctrl
183  uint16_t numPendingReads;
185 
186  public:
187  // keep track of the number of reads that have yet to be issued
188  uint16_t numReadsToIssue;
189 
193  void init() override;
194 
201  void setupRank(const uint8_t rank, const bool is_read) override;
202 
203  MemPacket* decodePacket(const PacketPtr pkt, Addr pkt_addr,
204  unsigned int size, bool is_read,
205  uint8_t pseudo_channel = 0) override;
206 
213  bool allRanksDrained() const override { return writeRespQueueEmpty(); }
214 
215  /*
216  * @return time to offset next command
217  */
218  Tick commandOffset() const override { return tBURST; }
219 
228  bool burstReady(MemPacket* pkt) const override;
229 
241  bool isBusy(bool read_queue_empty, bool all_writes_nvm) override;
252  chooseNextFRFCFS(MemPacketQueue& queue, Tick min_col_at) const override;
253 
261  void addRankToRankDelay(Tick cmd_at) override;
262 
266  void respondEvent(uint8_t rank) override { };
267 
268  void checkRefreshState(uint8_t rank) override { };
269 
273  void chooseRead(MemPacketQueue& queue) override;
274 
275  /*
276  * Function to calulate unloaded access latency
277  */
278  Tick accessLatency() const override { return (tREAD + tSEND); }
279 
285  bool
286  writeRespQueueFull() const override
287  {
288  return writeRespQueue.size() == maxPendingWrites;
289  }
290 
291  bool
292  readsWaitingToIssue() const override
293  {
294  return ((numReadsToIssue != 0) &&
296  }
297 
307  doBurstAccess(MemPacket* pkt, Tick next_burst_at,
308  const std::vector<MemPacketQueue>& queue) override;
309 
313  void drainRanks() override { }
314  void suspend() override { }
315  void startup() override { }
316 
317  NVMInterface(const NVMInterfaceParams &_p);
318 };
319 
320 } // namespace memory
321 } // namespace gem5
322 
323 #endif //__NVM_INTERFACE_HH__
gem5::statistics::Scalar
This is a simple scalar statistic, like a counter.
Definition: statistics.hh:1930
gem5::memory::NVMInterface::chooseNextFRFCFS
std::pair< MemPacketQueue::iterator, Tick > chooseNextFRFCFS(MemPacketQueue &queue, Tick min_col_at) const override
For FR-FCFS policy, find first NVM command that can issue default to first command to prepped region.
Definition: nvm_interface.cc:208
gem5::memory::NVMInterface
Interface to NVM devices with media specific parameters, statistics, and functions.
Definition: nvm_interface.hh:64
gem5::memory::NVMInterface::maxPendingReads
const uint32_t maxPendingReads
Definition: nvm_interface.hh:93
gem5::memory::NVMInterface::NVMStats::busUtilWrite
statistics::Formula busUtilWrite
Definition: nvm_interface.hh:137
gem5::memory::NVMInterface::NVMStats::busUtilRead
statistics::Formula busUtilRead
Definition: nvm_interface.hh:136
gem5::memory::NVMInterface::accessLatency
Tick accessLatency() const override
Definition: nvm_interface.hh:278
gem5::memory::MemInterface::tBURST
const Tick tBURST
Definition: mem_interface.hh:149
gem5::memory::NVMInterface::writeRespQueueFull
bool writeRespQueueFull() const override
Check if the write response queue has reached defined threshold.
Definition: nvm_interface.hh:286
memory
Definition: mem.h:38
gem5::memory::NVMInterface::NVMInterface
NVMInterface(const NVMInterfaceParams &_p)
Definition: nvm_interface.cc:55
gem5::memory::NVMInterface::readReadyEvent
EventFunctionWrapper readReadyEvent
Definition: nvm_interface.hh:150
gem5::memory::NVMInterface::chooseRead
void chooseRead(MemPacketQueue &queue) override
Select read command to issue asynchronously.
Definition: nvm_interface.cc:264
gem5::memory::NVMInterface::Rank::banks
std::vector< Bank > banks
Vector of NVM banks.
Definition: nvm_interface.hh:83
gem5::memory::NVMInterface::Rank::Rank
Rank(const NVMInterfaceParams &_p, int _rank, NVMInterface &_nvm)
Definition: nvm_interface.cc:93
gem5::memory::NVMInterface::drainRanks
void drainRanks() override
The next three functions are DRAM-specific and will be ignored by NVM.
Definition: nvm_interface.hh:313
gem5::memory::NVMInterface::addRankToRankDelay
void addRankToRankDelay(Tick cmd_at) override
Add rank to rank delay to bus timing to all NVM banks in alli ranks when access to an alternate inter...
Definition: nvm_interface.cc:588
gem5::memory::NVMInterface::allRanksDrained
bool allRanksDrained() const override
Check drain state of NVM interface.
Definition: nvm_interface.hh:213
gem5::memory::NVMInterface::processWriteRespondEvent
void processWriteRespondEvent()
Definition: nvm_interface.cc:559
gem5::memory::NVMInterface::setupRank
void setupRank(const uint8_t rank, const bool is_read) override
Setup the rank based on packet received.
Definition: nvm_interface.cc:110
gem5::memory::NVMInterface::numReadsToIssue
uint16_t numReadsToIssue
Definition: nvm_interface.hh:188
gem5::statistics::Vector
A vector of scalar stats.
Definition: statistics.hh:2006
gem5::memory::NVMInterface::NVMStats::pendingReads
statistics::Histogram pendingReads
NVM stats.
Definition: nvm_interface.hh:140
gem5::statistics::Formula
A formula for statistics that is calculated when printed.
Definition: statistics.hh:2539
std::vector< Bank >
gem5::memory::NVMInterface::tREAD
const Tick tREAD
NVM specific timing requirements.
Definition: nvm_interface.hh:99
gem5::memory::NVMInterface::Rank
NVM rank class simply includes a vector of banks.
Definition: nvm_interface.hh:70
gem5::memory::NVMInterface::NVMStats::avgQLat
statistics::Formula avgQLat
Definition: nvm_interface.hh:124
gem5::memory::NVMInterface::checkRefreshState
void checkRefreshState(uint8_t rank) override
This function is DRAM specific.
Definition: nvm_interface.hh:268
gem5::memory::NVMInterface::twoCycleRdWr
const bool twoCycleRdWr
Definition: nvm_interface.hh:94
gem5::memory::NVMInterface::tWRITE
const Tick tWRITE
Definition: nvm_interface.hh:100
gem5::memory::NVMInterface::NVMStats::avgBusLat
statistics::Formula avgBusLat
Definition: nvm_interface.hh:125
gem5::memory::NVMInterface::readReadyQueue
std::deque< Tick > readReadyQueue
Definition: nvm_interface.hh:167
gem5::memory::NVMInterface::NVMStats::peakBW
statistics::Formula peakBW
Definition: nvm_interface.hh:134
gem5::memory::NVMInterface::NVMStats::totBusLat
statistics::Scalar totBusLat
Definition: nvm_interface.hh:120
gem5::memory::NVMInterface::maxPendingWrites
const uint32_t maxPendingWrites
NVM specific device and channel characteristics.
Definition: nvm_interface.hh:92
gem5::statistics::Histogram
A simple histogram stat.
Definition: statistics.hh:2126
gem5::EventManager
Definition: eventq.hh:987
gem5::memory::NVMInterface::NVMStats::totMemAccLat
statistics::Scalar totMemAccLat
Definition: nvm_interface.hh:121
mem_interface.hh
gem5::memory::MemInterface
General interface to memory device Includes functions and parameters shared across media types.
Definition: mem_interface.hh:74
gem5::memory::NVMInterface::NVMStats::bytesRead
statistics::Scalar bytesRead
Definition: nvm_interface.hh:128
gem5::memory::NVMInterface::numPendingReads
uint16_t numPendingReads
Definition: nvm_interface.hh:183
gem5::memory::NVMInterface::decodePacket
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.
Definition: nvm_interface.cc:122
gem5::Packet
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:291
gem5::memory::NVMInterface::writeRespondEvent
EventFunctionWrapper writeRespondEvent
Definition: nvm_interface.hh:147
gem5::Tick
uint64_t Tick
Tick count type.
Definition: types.hh:58
gem5::memory::MemPacket
A memory packet stores packets along with the timestamp of when the packet entered the queue,...
Definition: mem_ctrl.hh:98
gem5::memory::NVMInterface::suspend
void suspend() override
This function is DRAM specific.
Definition: nvm_interface.hh:314
gem5::memory::NVMInterface::tSEND
const Tick tSEND
Definition: nvm_interface.hh:101
gem5::memory::NVMInterface::NVMStats::totQLat
statistics::Scalar totQLat
Definition: nvm_interface.hh:119
gem5::memory::NVMInterface::NVMStats::NVMStats
NVMStats(NVMInterface &nvm)
Definition: nvm_interface.cc:622
gem5::memory::NVMInterface::processReadReadyEvent
void processReadReadyEvent()
Definition: nvm_interface.cc:359
std::pair
STL pair class.
Definition: stl.hh:58
gem5::memory::NVMInterface::NVMStats::avgWrBW
statistics::Formula avgWrBW
Definition: nvm_interface.hh:133
gem5::memory::NVMInterface::isBusy
bool isBusy(bool read_queue_empty, bool all_writes_nvm) override
This function checks if ranks are busy.
Definition: nvm_interface.cc:605
gem5::memory::NVMInterface::NVMStats::avgMemAccLat
statistics::Formula avgMemAccLat
Definition: nvm_interface.hh:126
gem5::Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:147
gem5::memory::NVMInterface::init
void init() override
Initialize the NVM interface and verify parameters.
Definition: nvm_interface.cc:105
gem5::memory::NVMInterface::NVMStats::writeBursts
statistics::Scalar writeBursts
Definition: nvm_interface.hh:113
gem5::memory::NVMInterface::burstReady
bool burstReady(MemPacket *pkt) const override
Check if a burst operation can be issued to the NVM.
Definition: nvm_interface.cc:404
gem5::memory::NVMInterface::NVMStats::avgRdBW
statistics::Formula avgRdBW
Definition: nvm_interface.hh:132
gem5::EventFunctionWrapper
Definition: eventq.hh:1115
gem5::memory::AbstractMemory::size
uint64_t size() const
Get the memory size.
Definition: abstract_mem.hh:301
gem5::memory::NVMInterface::NVMStats::bytesPerBank
statistics::Histogram bytesPerBank
Definition: nvm_interface.hh:142
gem5::memory::NVMInterface::commandOffset
Tick commandOffset() const override
Definition: nvm_interface.hh:218
gem5::memory::NVMInterface::respondEvent
void respondEvent(uint8_t rank) override
Following two functions are not required for nvm interface.
Definition: nvm_interface.hh:266
gem5::memory::NVMInterface::ranks
std::vector< Rank * > ranks
Vector of nvm ranks.
Definition: nvm_interface.hh:155
gem5::memory::NVMInterface::doBurstAccess
std::pair< Tick, Tick > doBurstAccess(MemPacket *pkt, Tick next_burst_at, const std::vector< MemPacketQueue > &queue) override
Actually do the burst and update stats.
Definition: nvm_interface.cc:413
gem5::memory::NVMInterface::NVMStats::perBankWrBursts
statistics::Vector perBankWrBursts
Definition: nvm_interface.hh:116
gem5::memory::NVMInterface::NVMStats::regStats
void regStats() override
Callback to set stat parameters.
Definition: nvm_interface.cc:680
gem5::memory::NVMInterface::Rank::rank
uint8_t rank
Current Rank index.
Definition: nvm_interface.hh:77
std::deque< Tick >
gem5::memory::NVMInterface::NVMStats::readBursts
statistics::Scalar readBursts
NVM stats.
Definition: nvm_interface.hh:112
gem5::memory::NVMInterface::stats
NVMStats stats
Definition: nvm_interface.hh:144
gem5::memory::NVMInterface::NVMStats::busUtil
statistics::Formula busUtil
Definition: nvm_interface.hh:135
gem5::memory::NVMInterface::NVMStats
Definition: nvm_interface.hh:103
gem5::statistics::Group
Statistics container.
Definition: group.hh:93
gem5::memory::NVMInterface::NVMStats::perBankRdBursts
statistics::Vector perBankRdBursts
Definition: nvm_interface.hh:115
gem5::memory::NVMInterface::NVMStats::nvm
NVMInterface & nvm
Definition: nvm_interface.hh:109
gem5::memory::NVMInterface::NVMStats::pendingWrites
statistics::Histogram pendingWrites
Definition: nvm_interface.hh:141
gem5::memory::NVMInterface::startup
void startup() override
startup() is the final initialization call before simulation.
Definition: nvm_interface.hh:315
gem5::memory::NVMInterface::nextReadAt
Tick nextReadAt
Till when must we wait before issuing next read command?
Definition: nvm_interface.hh:179
std::list< Tick >
gem5::memory::NVMInterface::writeRespQueue
std::list< Tick > writeRespQueue
Holding queue for non-deterministic write commands, which maintains writes that have been issued but ...
Definition: nvm_interface.hh:165
gem5::memory::NVMInterface::readsWaitingToIssue
bool readsWaitingToIssue() const override
This function is NVM specific.
Definition: nvm_interface.hh:292
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: gpu_translation_state.hh:37
gem5::memory::NVMInterface::numReadDataReady
uint16_t numReadDataReady
Definition: nvm_interface.hh:184
gem5::memory::NVMInterface::NVMStats::bytesWritten
statistics::Scalar bytesWritten
Definition: nvm_interface.hh:129
gem5::memory::NVMInterface::writeRespQueueEmpty
bool writeRespQueueEmpty() const
Check if the write response queue is empty.
Definition: nvm_interface.hh:174

Generated on Thu Jun 16 2022 10:41:56 for gem5 by doxygen 1.8.17