gem5 v24.0.0.0
Loading...
Searching...
No Matches
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
64namespace gem5
65{
66
67namespace 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;
103
105 openRow(NO_ROW), bank(0), bankgr(0),
108 { }
109 };
110
115
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;
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
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
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
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__
AbstractMemory declaration.
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition packet.hh:295
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.
General interface to memory device Includes functions and parameters shared across media types.
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.
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.
virtual void suspend()
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.
Tick rankDelay() const
Determine the required delay for an access to a different rank.
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.
uint32_t readsThisTime
Reads/writes performed by the controller for this interface before bus direction is switched.
uint32_t readQueueSize
Read/write packets in the read/write queue for this interface qos/mem_ctrl.hh has similar counters,...
virtual void respondEvent(uint8_t rank)
This function is DRAM specific.
const uint32_t burstSize
General device and channel characteristics The rowsPerBank is determined based on the capacity,...
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.
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...
MemCtrl::BusState busStateNext
bus state for next request event triggered
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?
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...
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.
#define panic(...)
This implements a cprintf based panic() function.
Definition logging.hh:188
MemCtrl declaration.
Bitfield< 3 > addr
Definition types.hh:84
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
Definition binary32.hh:36
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 Tue Jun 18 2024 16:24:05 for gem5 by doxygen 1.11.0