gem5  [DEVELOP-FOR-23.0]
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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 
196  uint32_t readsThisTime = 0;
197  uint32_t writesThisTime = 0;
198 
205  uint32_t readQueueSize = 0;
206  uint32_t writeQueueSize = 0;
207 
208 
210 
213 
217  uint8_t pseudoChannel;
218 
226  void setCtrl(MemCtrl* _ctrl, unsigned int command_window,
227  uint8_t pseudo_channel = 0);
228 
239 
246  virtual void setupRank(const uint8_t rank, const bool is_read) = 0;
247 
254  virtual bool allRanksDrained() const = 0;
255 
268  chooseNextFRFCFS(MemPacketQueue& queue, Tick min_col_at) const = 0;
269 
270  /*
271  * Function to calulate unloaded latency
272  */
273  virtual Tick accessLatency() const = 0;
274 
278  uint32_t bytesPerBurst() const { return burstSize; }
279 
280  /*
281  * @return time to offset next command
282  */
283  virtual Tick commandOffset() const = 0;
284 
290  virtual bool burstReady(MemPacket* pkt) const = 0;
291 
297  Tick rankDelay() const { return tCS; }
298 
303  Tick minReadToWriteDataGap() const { return std::min(tRTW, tCS); }
304 
309  Tick minWriteToReadDataGap() const { return std::min(tWTR, tCS); }
310 
324  virtual MemPacket* decodePacket(const PacketPtr pkt, Addr pkt_addr,
325  unsigned int size, bool is_read,
326  uint8_t pseudo_channel = 0)
327  {
328  panic("MemInterface decodePacket should not be executed from here.\n");
329  return nullptr;
330  }
331 
339  virtual void addRankToRankDelay(Tick cmd_at) = 0;
340 
344  virtual bool isBusy(bool read_queue_empty, bool all_writes_nvm) = 0;
345 
349  virtual std::pair<Tick, Tick>
350  doBurstAccess(MemPacket* mem_pkt, Tick next_burst_at,
351  const std::vector<MemPacketQueue>& queue) = 0;
352 
356  virtual void respondEvent(uint8_t rank)
357  {
358  panic("MemInterface respondEvent should not be executed from here.\n");
359  };
360 
364  virtual void checkRefreshState(uint8_t rank)
365  {
366  panic("MemInterface checkRefreshState (DRAM) should "
367  "not be executed from here.\n");
368  };
369 
373  virtual void drainRanks()
374  {
375  panic("MemInterface drainRanks (DRAM) should "
376  "not be executed from here.\n");
377  }
378 
382  virtual void suspend()
383  {
384  panic("MemInterface suspend (DRAM) should "
385  "not be executed from here.\n");
386  }
387 
391  virtual bool readsWaitingToIssue() const
392  {
393  panic("MemInterface readsWaitingToIssue (NVM) "
394  "should not be executed from here.\n");
395  };
396 
400  virtual void chooseRead(MemPacketQueue& queue)
401  {
402  panic("MemInterface chooseRead (NVM) should "
403  "not be executed from here.\n");
404  };
405 
409  virtual bool writeRespQueueFull() const
410  {
411  panic("MemInterface writeRespQueueFull (NVM) "
412  "should not be executed from here.\n");
413  }
414 
415  typedef MemInterfaceParams Params;
416  MemInterface(const Params &_p);
417 };
418 
419 
420 } // namespace memory
421 } // namespace gem5
422 
423 #endif //__MEM_INTERFACE_HH__
gem5::memory::MemInterface::rowsPerBank
uint32_t rowsPerBank
Definition: mem_interface.hh:142
gem5::memory::MemInterface::Bank::bank
uint8_t bank
Definition: mem_interface.hh:93
gem5::memory::MemInterface::respondEvent
virtual void respondEvent(uint8_t rank)
This function is DRAM specific.
Definition: mem_interface.hh:356
gem5::memory::MemInterface::readQueueSize
uint32_t readQueueSize
Read/write packets in the read/write queue for this interface qos/mem_ctrl.hh has similar counters,...
Definition: mem_interface.hh:205
gem5::memory::MemInterface::busState
MemCtrl::BusState busState
Definition: mem_interface.hh:209
gem5::memory::MemInterface::readToWriteDelay
Tick readToWriteDelay() const
Definition: mem_interface.hh:161
gem5::memory::MemInterface::readsWaitingToIssue
virtual bool readsWaitingToIssue() const
This function is NVM specific.
Definition: mem_interface.hh:391
gem5::memory::MemInterface::Bank::Bank
Bank()
Definition: mem_interface.hh:104
gem5::memory::MemInterface::numWritesQueued
uint32_t numWritesQueued
NVM specific variable, but declaring it here allows treating different interfaces in a more genral wa...
Definition: mem_interface.hh:184
gem5::memory::MemInterface::suspend
virtual void suspend()
This function is DRAM specific.
Definition: mem_interface.hh:382
gem5::memory::MemInterface::tBURST
const Tick tBURST
Definition: mem_interface.hh:149
memory
Definition: mem.h:38
abstract_mem.hh
gem5::memory::qos::MemCtrl::READ
@ READ
Definition: mem_ctrl.hh:83
gem5::memory::MemInterface::allRanksDrained
virtual bool allRanksDrained() const =0
Check drain state of interface.
gem5::memory::MemInterface::deviceSize
const uint32_t deviceSize
Definition: mem_interface.hh:134
gem5::memory::MemInterface::Bank
A basic class to track the bank state, i.e.
Definition: mem_interface.hh:86
gem5::memory::MemCtrl
The memory controller is a single-channel memory controller capturing the most important timing const...
Definition: mem_ctrl.hh:246
gem5::memory::MemInterface::burstsPerStripe
const uint32_t burstsPerStripe
Definition: mem_interface.hh:139
gem5::memory::MemInterface::addRankToRankDelay
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 ...
gem5::memory::MemInterface::Bank::wrAllowedAt
Tick wrAllowedAt
Definition: mem_interface.hh:97
gem5::memory::MemInterface::tCS
const Tick tCS
Definition: mem_interface.hh:148
std::vector
STL vector class.
Definition: stl.hh:37
gem5::memory::MemInterface::Bank::rowAccesses
uint32_t rowAccesses
Definition: mem_interface.hh:101
gem5::memory::qos::MemCtrl::BusState
BusState
Bus Direction.
Definition: mem_ctrl.hh:83
gem5::memory::MemInterface::Bank::preAllowedAt
Tick preAllowedAt
Definition: mem_interface.hh:98
GEM5_CLASS_VAR_USED
#define GEM5_CLASS_VAR_USED
Definition: compiler.hh:141
gem5::memory::MemInterface::burstsPerRowBuffer
const uint32_t burstsPerRowBuffer
Definition: mem_interface.hh:138
gem5::memory::MemInterface::chooseRead
virtual void chooseRead(MemPacketQueue &queue)
This function is NVM specific.
Definition: mem_interface.hh:400
gem5::memory::MemInterface::readBufferSize
const uint32_t readBufferSize
Buffer sizes for read and write queues in the controller These are passed to the controller on instan...
Definition: mem_interface.hh:176
gem5::memory::MemInterface::busStateNext
MemCtrl::BusState busStateNext
bus state for next request event triggered
Definition: mem_interface.hh:212
gem5::memory::MemInterface::MemInterface
MemInterface(const Params &_p)
Definition: mem_interface.cc:54
gem5::memory::MemInterface::minWriteToReadDataGap
Tick minWriteToReadDataGap() const
Definition: mem_interface.hh:309
gem5::memory::MemInterface::addrMapping
enums::AddrMap addrMapping
Memory controller configuration initialized based on parameter values.
Definition: mem_interface.hh:126
gem5::memory::MemInterface::drainRanks
virtual void drainRanks()
This function is DRAM specific.
Definition: mem_interface.hh:373
gem5::memory::MemInterface::Bank::bytesAccessed
uint32_t bytesAccessed
Definition: mem_interface.hh:102
gem5::memory::MemInterface::doBurstAccess
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.
gem5::memory::MemInterface::deviceRowBufferSize
const uint32_t deviceRowBufferSize
Definition: mem_interface.hh:135
gem5::memory::MemInterface::Bank::rdAllowedAt
Tick rdAllowedAt
Definition: mem_interface.hh:96
gem5::memory::MemInterface
General interface to memory device Includes functions and parameters shared across media types.
Definition: mem_interface.hh:74
gem5::memory::MemInterface::isBusy
virtual bool isBusy(bool read_queue_empty, bool all_writes_nvm)=0
This function checks if ranks are busy.
gem5::memory::MemInterface::setupRank
virtual void setupRank(const uint8_t rank, const bool is_read)=0
Setup the rank based on packet received.
gem5::memory::MemInterface::banksPerRank
const uint32_t banksPerRank
Definition: mem_interface.hh:141
gem5::memory::MemInterface::Bank::bankgr
uint8_t bankgr
Definition: mem_interface.hh:94
gem5::Packet
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:294
statistics.hh
gem5::memory::AbstractMemory
An abstract memory represents a contiguous block of physical memory, with an associated address range...
Definition: abstract_mem.hh:110
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::MemInterface::commandOffset
virtual Tick commandOffset() const =0
gem5::memory::MemInterface::burstReady
virtual bool burstReady(MemPacket *pkt) const =0
Check if a burst operation can be issued to the interface.
gem5::memory::MemInterface::rankDelay
Tick rankDelay() const
Determine the required delay for an access to a different rank.
Definition: mem_interface.hh:297
gem5::memory::MemInterface::checkRefreshState
virtual void checkRefreshState(uint8_t rank)
This function is DRAM specific.
Definition: mem_interface.hh:364
gem5::memory::MemInterface::writeBufferSize
const uint32_t writeBufferSize
Definition: mem_interface.hh:177
gem5::memory::MemInterface::devicesPerRank
const uint32_t devicesPerRank
Definition: mem_interface.hh:136
compiler.hh
mem_ctrl.hh
gem5::memory::MemInterface::minReadToWriteDataGap
Tick minReadToWriteDataGap() const
Definition: mem_interface.hh:303
std::pair
STL pair class.
Definition: stl.hh:58
gem5::memory::MemInterface::ctrl
MemCtrl * ctrl
A pointer to the parent memory controller instance.
Definition: mem_interface.hh:114
gem5::memory::MemInterface::tWTR
const Tick tWTR
Definition: mem_interface.hh:151
gem5::memory::AbstractMemory::range
AddrRange range
Definition: abstract_mem.hh:115
gem5::Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:147
gem5::memory::MemInterface::Params
MemInterfaceParams Params
Definition: mem_interface.hh:415
gem5::memory::MemInterface::rankToRankDelay
Tick rankToRankDelay() const
Definition: mem_interface.hh:166
gem5::memory::MemInterface::readsThisTime
uint32_t readsThisTime
Reads/writes performed by the controller for this interface before bus direction is switched.
Definition: mem_interface.hh:196
gem5::memory::MemInterface::writeToReadDelay
virtual Tick writeToReadDelay() const
Definition: mem_interface.hh:156
gem5::memory::MemInterface::nextBurstAt
Tick nextBurstAt
Till when the controller must wait before issuing next RD/WR burst?
Definition: mem_interface.hh:189
gem5::memory::MemInterface::Bank::openRow
uint32_t openRow
Definition: mem_interface.hh:92
gem5::memory::MemInterface::tRTW
const Tick tRTW
Definition: mem_interface.hh:150
gem5::memory::AbstractMemory::size
uint64_t size() const
Get the memory size.
Definition: abstract_mem.hh:308
gem5::memory::MemInterface::ranksPerChannel
const uint32_t ranksPerChannel
Definition: mem_interface.hh:140
gem5::memory::MemInterface::setCtrl
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.
Definition: mem_interface.cc:77
gem5::AddrRange::getOffset
Addr getOffset(const Addr &a) const
Determine the offset of an address within the range.
Definition: addr_range.hh:611
std::deque
STL deque class.
Definition: stl.hh:44
gem5::memory::MemInterface::nextReqTime
Tick nextReqTime
Definition: mem_interface.hh:190
gem5::memory::MemInterface::chooseNextFRFCFS
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...
gem5::memory::MemInterface::rowBufferSize
const uint32_t rowBufferSize
Definition: mem_interface.hh:137
gem5::memory::MemInterface::getCtrlAddr
Addr getCtrlAddr(Addr addr)
Get an address in a dense range which starts from 0.
Definition: mem_interface.hh:238
gem5::memory::MemInterface::pseudoChannel
uint8_t pseudoChannel
pseudo channel number used for HBM modeling
Definition: mem_interface.hh:217
gem5::memory::MemInterface::Bank::NO_ROW
static const uint32_t NO_ROW
Definition: mem_interface.hh:90
gem5::memory::MemInterface::bytesPerBurst
uint32_t bytesPerBurst() const
Definition: mem_interface.hh:278
gem5::memory::MemInterface::Bank::actAllowedAt
Tick actAllowedAt
Definition: mem_interface.hh:99
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: gpu_translation_state.hh:37
gem5::memory::MemInterface::writeRespQueueFull
virtual bool writeRespQueueFull() const
This function is NVM specific.
Definition: mem_interface.hh:409
gem5::memory::MemInterface::maxCommandsPerWindow
unsigned int maxCommandsPerWindow
Number of commands that can issue in the defined controller command window, used to verify command ba...
Definition: mem_interface.hh:120
gem5::memory::MemInterface::accessLatency
virtual Tick accessLatency() const =0
gem5::memory::MemInterface::burstSize
const uint32_t burstSize
General device and channel characteristics The rowsPerBank is determined based on the capacity,...
Definition: mem_interface.hh:133
gem5::memory::MemInterface::writesThisTime
uint32_t writesThisTime
Definition: mem_interface.hh:197
gem5::memory::MemInterface::tCK
const GEM5_CLASS_VAR_USED Tick tCK
General timing requirements.
Definition: mem_interface.hh:147
gem5::memory::MemInterface::decodePacket
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.
Definition: mem_interface.hh:324
panic
#define panic(...)
This implements a cprintf based panic() function.
Definition: logging.hh:188
gem5::memory::MemInterface::writeQueueSize
uint32_t writeQueueSize
Definition: mem_interface.hh:206
gem5::X86ISA::addr
Bitfield< 3 > addr
Definition: types.hh:84
eventq.hh

Generated on Sun Jul 30 2023 01:56:58 for gem5 by doxygen 1.8.17