gem5  v22.1.0.0
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__
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:294
uint64_t size() const
Get the memory size.
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
NVM rank class simply includes a vector of banks.
Rank(const NVMInterfaceParams &_p, int _rank, NVMInterface &_nvm)
std::vector< Bank > banks
Vector of NVM banks.
uint8_t rank
Current Rank index.
Interface to NVM devices with media specific parameters, statistics, and functions.
void checkRefreshState(uint8_t rank) override
This function is DRAM specific.
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.
void startup() override
startup() is the final initialization call before simulation.
void respondEvent(uint8_t rank) override
Following two functions are not required for nvm interface.
std::pair< Tick, Tick > doBurstAccess(MemPacket *pkt, Tick next_burst_at, const std::vector< MemPacketQueue > &queue) override
Actually do the burst and update stats.
void init() override
Initialize the NVM interface and verify parameters.
void setupRank(const uint8_t rank, const bool is_read) override
Setup the rank based on packet received.
void chooseRead(MemPacketQueue &queue) override
Select read command to issue asynchronously.
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.
bool readsWaitingToIssue() const override
This function is NVM specific.
Tick nextReadAt
Till when must we wait before issuing next read command?
void suspend() override
This function is DRAM specific.
NVMInterface(const NVMInterfaceParams &_p)
std::vector< Rank * > ranks
Vector of nvm ranks.
const uint32_t maxPendingReads
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...
bool isBusy(bool read_queue_empty, bool all_writes_nvm) override
This function checks if ranks are busy.
std::list< Tick > writeRespQueue
Holding queue for non-deterministic write commands, which maintains writes that have been issued but ...
bool writeRespQueueFull() const override
Check if the write response queue has reached defined threshold.
void drainRanks() override
The next three functions are DRAM-specific and will be ignored by NVM.
std::deque< Tick > readReadyQueue
bool burstReady(MemPacket *pkt) const override
Check if a burst operation can be issued to the NVM.
Tick commandOffset() const override
const Tick tREAD
NVM specific timing requirements.
EventFunctionWrapper writeRespondEvent
bool writeRespQueueEmpty() const
Check if the write response queue is empty.
Tick accessLatency() const override
EventFunctionWrapper readReadyEvent
const uint32_t maxPendingWrites
NVM specific device and channel characteristics.
bool allRanksDrained() const override
Check drain state of NVM interface.
A formula for statistics that is calculated when printed.
Definition: statistics.hh:2540
Statistics container.
Definition: group.hh:94
A simple histogram stat.
Definition: statistics.hh:2127
This is a simple scalar statistic, like a counter.
Definition: statistics.hh:1931
A vector of scalar stats.
Definition: statistics.hh:2007
STL pair class.
Definition: stl.hh:58
MemInterface declaration.
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
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
void regStats() override
Callback to set stat parameters.
statistics::Histogram pendingReads
NVM stats.
statistics::Scalar readBursts
NVM stats.
Definition: mem.h:38

Generated on Wed Dec 21 2022 10:22:37 for gem5 by doxygen 1.9.1