gem5  v22.1.0.0
mem_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 __MEM_INTERFACE_HH__
47 #define __MEM_INTERFACE_HH__
48 
49 #include <deque>
50 #include <string>
51 #include <unordered_set>
52 #include <utility>
53 #include <vector>
54 
55 #include "base/compiler.hh"
56 #include "base/statistics.hh"
57 #include "enums/AddrMap.hh"
58 #include "enums/PageManage.hh"
59 #include "mem/abstract_mem.hh"
60 #include "mem/mem_ctrl.hh"
61 #include "params/MemInterface.hh"
62 #include "sim/eventq.hh"
63 
64 namespace gem5
65 {
66 
67 namespace memory
68 {
69 
75 {
76  protected:
86  class Bank
87  {
88 
89  public:
90  static const uint32_t NO_ROW = -1;
91 
92  uint32_t openRow;
93  uint8_t bank;
94  uint8_t bankgr;
95 
100 
101  uint32_t rowAccesses;
102  uint32_t bytesAccessed;
103 
104  Bank() :
105  openRow(NO_ROW), bank(0), bankgr(0),
108  { }
109  };
110 
115 
120  unsigned int maxCommandsPerWindow;
121 
126  enums::AddrMap addrMapping;
127 
133  const uint32_t burstSize;
134  const uint32_t deviceSize;
135  const uint32_t deviceRowBufferSize;
136  const uint32_t devicesPerRank;
137  const uint32_t rowBufferSize;
138  const uint32_t burstsPerRowBuffer;
139  const uint32_t burstsPerStripe;
140  const uint32_t ranksPerChannel;
141  const uint32_t banksPerRank;
142  uint32_t rowsPerBank;
143 
148  const Tick tCS;
149  const Tick tBURST;
150  const Tick tRTW;
151  const Tick tWTR;
152 
153  /*
154  * @return delay between write and read commands
155  */
156  virtual Tick writeToReadDelay() const { return tBURST + tWTR; }
157 
158  /*
159  * @return delay between write and read commands
160  */
161  Tick readToWriteDelay() const { return tBURST + tRTW; }
162 
163  /*
164  * @return delay between accesses to different ranks
165  */
166  Tick rankToRankDelay() const { return tBURST + tCS; }
167 
168  public:
169 
176  const uint32_t readBufferSize;
177  const uint32_t writeBufferSize;
178 
184  uint32_t numWritesQueued;
185 
191 
195  uint8_t pseudoChannel;
196 
204  void setCtrl(MemCtrl* _ctrl, unsigned int command_window,
205  uint8_t pseudo_channel = 0);
206 
217 
224  virtual void setupRank(const uint8_t rank, const bool is_read) = 0;
225 
232  virtual bool allRanksDrained() const = 0;
233 
246  chooseNextFRFCFS(MemPacketQueue& queue, Tick min_col_at) const = 0;
247 
248  /*
249  * Function to calulate unloaded latency
250  */
251  virtual Tick accessLatency() const = 0;
252 
256  uint32_t bytesPerBurst() const { return burstSize; }
257 
258  /*
259  * @return time to offset next command
260  */
261  virtual Tick commandOffset() const = 0;
262 
268  virtual bool burstReady(MemPacket* pkt) const = 0;
269 
275  Tick rankDelay() const { return tCS; }
276 
281  Tick minReadToWriteDataGap() const { return std::min(tRTW, tCS); }
282 
287  Tick minWriteToReadDataGap() const { return std::min(tWTR, tCS); }
288 
302  virtual MemPacket* decodePacket(const PacketPtr pkt, Addr pkt_addr,
303  unsigned int size, bool is_read,
304  uint8_t pseudo_channel = 0)
305  {
306  panic("MemInterface decodePacket should not be executed from here.\n");
307  return nullptr;
308  }
309 
317  virtual void addRankToRankDelay(Tick cmd_at) = 0;
318 
322  virtual bool isBusy(bool read_queue_empty, bool all_writes_nvm) = 0;
323 
327  virtual std::pair<Tick, Tick>
328  doBurstAccess(MemPacket* mem_pkt, Tick next_burst_at,
329  const std::vector<MemPacketQueue>& queue) = 0;
330 
334  virtual void respondEvent(uint8_t rank)
335  {
336  panic("MemInterface respondEvent should not be executed from here.\n");
337  };
338 
342  virtual void checkRefreshState(uint8_t rank)
343  {
344  panic("MemInterface checkRefreshState (DRAM) should "
345  "not be executed from here.\n");
346  };
347 
351  virtual void drainRanks()
352  {
353  panic("MemInterface drainRanks (DRAM) should "
354  "not be executed from here.\n");
355  }
356 
360  virtual void suspend()
361  {
362  panic("MemInterface suspend (DRAM) should "
363  "not be executed from here.\n");
364  }
365 
369  virtual bool readsWaitingToIssue() const
370  {
371  panic("MemInterface readsWaitingToIssue (NVM) "
372  "should not be executed from here.\n");
373  };
374 
378  virtual void chooseRead(MemPacketQueue& queue)
379  {
380  panic("MemInterface chooseRead (NVM) should "
381  "not be executed from here.\n");
382  };
383 
387  virtual bool writeRespQueueFull() const
388  {
389  panic("MemInterface writeRespQueueFull (NVM) "
390  "should not be executed from here.\n");
391  }
392 
393  typedef MemInterfaceParams Params;
394  MemInterface(const Params &_p);
395 };
396 
397 
398 } // namespace memory
399 } // namespace gem5
400 
401 #endif //__MEM_INTERFACE_HH__
AbstractMemory declaration.
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:294
An abstract memory represents a contiguous block of physical memory, with an associated address range...
uint64_t size() const
Get the memory size.
The memory controller is a single-channel memory controller capturing the most important timing const...
Definition: mem_ctrl.hh:247
A basic class to track the bank state, i.e.
static const uint32_t NO_ROW
General interface to memory device Includes functions and parameters shared across media types.
const uint32_t burstsPerStripe
enums::AddrMap addrMapping
Memory controller configuration initialized based on parameter values.
virtual void setupRank(const uint8_t rank, const bool is_read)=0
Setup the rank based on packet received.
virtual Tick writeToReadDelay() const
MemCtrl * ctrl
A pointer to the parent memory controller instance.
const uint32_t writeBufferSize
virtual std::pair< MemPacketQueue::iterator, Tick > chooseNextFRFCFS(MemPacketQueue &queue, Tick min_col_at) const =0
For FR-FCFS policy, find first command that can issue Function will be overriden by interface to sele...
virtual void suspend()
This function is DRAM specific.
Tick rankDelay() const
Determine the required delay for an access to a different rank.
const uint32_t ranksPerChannel
virtual void addRankToRankDelay(Tick cmd_at)=0
Add rank to rank delay to bus timing to all banks in all ranks when access to an alternate interface ...
Addr getCtrlAddr(Addr addr)
Get an address in a dense range which starts from 0.
virtual Tick commandOffset() const =0
uint8_t pseudoChannel
pseudo channel number used for HBM modeling
virtual bool burstReady(MemPacket *pkt) const =0
Check if a burst operation can be issued to the interface.
virtual void checkRefreshState(uint8_t rank)
This function is DRAM specific.
virtual bool isBusy(bool read_queue_empty, bool all_writes_nvm)=0
This function checks if ranks are busy.
virtual void respondEvent(uint8_t rank)
This function is DRAM specific.
virtual std::pair< Tick, Tick > doBurstAccess(MemPacket *mem_pkt, Tick next_burst_at, const std::vector< MemPacketQueue > &queue)=0
This function performs the burst and update stats.
const uint32_t burstSize
General device and channel characteristics The rowsPerBank is determined based on the capacity,...
virtual MemPacket * decodePacket(const PacketPtr pkt, Addr pkt_addr, unsigned int size, bool is_read, uint8_t pseudo_channel=0)
Address decoder to figure out physical mapping onto ranks, banks, and rows.
MemInterfaceParams Params
virtual Tick accessLatency() const =0
unsigned int maxCommandsPerWindow
Number of commands that can issue in the defined controller command window, used to verify command ba...
virtual bool writeRespQueueFull() const
This function is NVM specific.
void setCtrl(MemCtrl *_ctrl, unsigned int command_window, uint8_t pseudo_channel=0)
Set a pointer to the controller and initialize interface based on controller parameters.
const uint32_t burstsPerRowBuffer
virtual void chooseRead(MemPacketQueue &queue)
This function is NVM specific.
const uint32_t readBufferSize
Buffer sizes for read and write queues in the controller These are passed to the controller on instan...
GEM5_CLASS_VAR_USED const Tick tCK
General timing requirements.
Tick nextBurstAt
Till when the controller must wait before issuing next RD/WR burst?
Tick minWriteToReadDataGap() const
virtual bool readsWaitingToIssue() const
This function is NVM specific.
MemInterface(const Params &_p)
uint32_t numWritesQueued
NVM specific variable, but declaring it here allows treating different interfaces in a more genral wa...
Tick minReadToWriteDataGap() const
virtual bool allRanksDrained() const =0
Check drain state of interface.
virtual void drainRanks()
This function is DRAM specific.
uint32_t bytesPerBurst() const
const uint32_t deviceRowBufferSize
A memory packet stores packets along with the timestamp of when the packet entered the queue,...
Definition: mem_ctrl.hh:99
STL deque class.
Definition: stl.hh:44
STL pair class.
Definition: stl.hh:58
STL vector class.
Definition: stl.hh:37
#define GEM5_CLASS_VAR_USED
Definition: compiler.hh:141
Addr getOffset(const Addr &a) const
Determine the offset of an address within the range.
Definition: addr_range.hh:611
#define panic(...)
This implements a cprintf based panic() function.
Definition: logging.hh:178
MemCtrl declaration.
Bitfield< 3 > addr
Definition: types.hh:84
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
Declaration of Statistics objects.
Definition: mem.h:38

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