gem5  v20.1.0.0
dramsim3.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013 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  * Redistribution and use in source and binary forms, with or without
15  * modification, are permitted provided that the following conditions are
16  * met: redistributions of source code must retain the above copyright
17  * notice, this list of conditions and the following disclaimer;
18  * redistributions in binary form must reproduce the above copyright
19  * notice, this list of conditions and the following disclaimer in the
20  * documentation and/or other materials provided with the distribution;
21  * neither the name of the copyright holders nor the names of its
22  * contributors may be used to endorse or promote products derived from
23  * this software without specific prior written permission.
24  *
25  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36  *
37  */
38 
43 #ifndef __MEM_DRAMSIM3_HH__
44 #define __MEM_DRAMSIM3_HH__
45 
46 #include <functional>
47 #include <queue>
48 #include <unordered_map>
49 
50 #include "mem/abstract_mem.hh"
51 #include "mem/dramsim3_wrapper.hh"
52 #include "mem/qport.hh"
53 #include "params/DRAMsim3.hh"
54 
55 class DRAMsim3 : public AbstractMemory
56 {
57  private:
58 
64  class MemoryPort : public ResponsePort
65  {
66 
67  private:
68 
70 
71  public:
72 
73  MemoryPort(const std::string& _name, DRAMsim3& _memory);
74 
75  protected:
76 
78 
79  void recvFunctional(PacketPtr pkt);
80 
81  bool recvTimingReq(PacketPtr pkt);
82 
83  void recvRespRetry();
84 
86 
87  };
88 
90 
94  std::function<void(uint64_t)> read_cb;
95  std::function<void(uint64_t)> write_cb;
96 
101 
105  bool retryReq;
106 
110  bool retryResp;
111 
116 
123  std::unordered_map<Addr, std::queue<PacketPtr> > outstandingReads;
124  std::unordered_map<Addr, std::queue<PacketPtr> > outstandingWrites;
125 
131  unsigned int nbrOutstandingReads;
132  unsigned int nbrOutstandingWrites;
133 
140 
141 
142  unsigned int nbrOutstanding() const;
143 
151  void accessAndRespond(PacketPtr pkt);
152 
153  void sendResponse();
154 
159 
163  void tick();
164 
169 
174  std::unique_ptr<Packet> pendingDelete;
175 
176  public:
177 
178  typedef DRAMsim3Params Params;
179  DRAMsim3(const Params *p);
180 
188  void readComplete(unsigned id, uint64_t addr);
189 
197  void writeComplete(unsigned id, uint64_t addr);
198 
199  DrainState drain() override;
200 
201  virtual Port& getPort(const std::string& if_name,
202  PortID idx = InvalidPortID) override;
203 
204  void init() override;
205  void startup() override;
206 
207  void resetStats() override;
208 
209  protected:
210 
212  void recvFunctional(PacketPtr pkt);
213  bool recvTimingReq(PacketPtr pkt);
214  void recvRespRetry();
215 
216 };
217 
218 #endif // __MEM_DRAMSIM3_HH__
DRAMsim3::outstandingWrites
std::unordered_map< Addr, std::queue< PacketPtr > > outstandingWrites
Definition: dramsim3.hh:124
DRAMsim3::readComplete
void readComplete(unsigned id, uint64_t addr)
Read completion callback.
Definition: dramsim3.cc:287
DRAMsim3::write_cb
std::function< void(uint64_t)> write_cb
Definition: dramsim3.hh:95
ResponsePort
A ResponsePort is a specialization of a port.
Definition: port.hh:265
DRAMsim3::wrapper
DRAMsim3Wrapper wrapper
The actual DRAMsim3 wrapper.
Definition: dramsim3.hh:100
DRAMsim3::recvTimingReq
bool recvTimingReq(PacketPtr pkt)
Definition: dramsim3.cc:178
DRAMsim3::MemoryPort::MemoryPort
MemoryPort(const std::string &_name, DRAMsim3 &_memory)
Definition: dramsim3.cc:353
DRAMsim3::Params
DRAMsim3Params Params
Definition: dramsim3.hh:178
InvalidPortID
const PortID InvalidPortID
Definition: types.hh:238
abstract_mem.hh
DRAMsim3::sendResponse
void sendResponse()
Definition: dramsim3.cc:101
DRAMsim3::writeComplete
void writeComplete(unsigned id, uint64_t addr)
Write completion callback.
Definition: dramsim3.cc:313
DRAMsim3::init
void init() override
init() is called after all C++ SimObjects have been created and all ports are connected.
Definition: dramsim3.cc:71
DRAMsim3::recvFunctional
void recvFunctional(PacketPtr pkt)
Definition: dramsim3.cc:164
DRAMsim3::tick
void tick()
Progress the controller one clock cycle.
Definition: dramsim3.cc:137
Tick
uint64_t Tick
Tick count type.
Definition: types.hh:63
DRAMsim3::outstandingReads
std::unordered_map< Addr, std::queue< PacketPtr > > outstandingReads
Keep track of what packets are outstanding per address, and do so separately for reads and writes.
Definition: dramsim3.hh:123
PortID
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
Definition: types.hh:237
DRAMsim3::getPort
virtual Port & getPort(const std::string &if_name, PortID idx=InvalidPortID) override
Get a port with a given name and index.
Definition: dramsim3.cc:336
DRAMsim3::MemoryPort::memory
DRAMsim3 & memory
Definition: dramsim3.hh:69
DRAMsim3Wrapper
Wrapper class to avoid having DRAMsim3 names like ClockDomain etc clashing with the normal gem5 world...
Definition: dramsim3_wrapper.hh:67
DRAMsim3
Definition: dramsim3.hh:55
DRAMsim3::responseQueue
std::deque< PacketPtr > responseQueue
Queue to hold response packets until we can send them back.
Definition: dramsim3.hh:139
DRAMsim3::nbrOutstanding
unsigned int nbrOutstanding() const
Definition: dramsim3.cc:131
DRAMsim3::MemoryPort::recvRespRetry
void recvRespRetry()
Called by the peer if sendTimingResp was called on this protocol (causing recvTimingResp to be called...
Definition: dramsim3.cc:386
EventFunctionWrapper
Definition: eventq.hh:1101
DrainState
DrainState
Object drain/handover states.
Definition: drain.hh:71
AbstractMemory
An abstract memory represents a contiguous block of physical memory, with an associated address range...
Definition: abstract_mem.hh:104
DRAMsim3::retryResp
bool retryResp
Are we waiting for a retry for sending a response.
Definition: dramsim3.hh:110
DRAMsim3::port
MemoryPort port
Definition: dramsim3.hh:89
DRAMsim3::MemoryPort::getAddrRanges
AddrRangeList getAddrRanges() const
Get a list of the non-overlapping address ranges the owner is responsible for.
Definition: dramsim3.cc:359
dramsim3_wrapper.hh
Port
Ports are used to interface objects to each other.
Definition: port.hh:56
DRAMsim3::nbrOutstandingWrites
unsigned int nbrOutstandingWrites
Definition: dramsim3.hh:132
DRAMsim3::pendingDelete
std::unique_ptr< Packet > pendingDelete
Upstream caches need this packet until true is returned, so hold it for deletion until a subsequent c...
Definition: dramsim3.hh:174
DRAMsim3::startup
void startup() override
startup() is the final initialization call before simulation.
Definition: dramsim3.cc:87
DRAMsim3::MemoryPort::recvTimingReq
bool recvTimingReq(PacketPtr pkt)
Receive a timing request from the peer.
Definition: dramsim3.cc:379
DRAMsim3::DRAMsim3
DRAMsim3(const Params *p)
Definition: dramsim3.cc:48
DRAMsim3::retryReq
bool retryReq
Is the connected port waiting for a retry from us.
Definition: dramsim3.hh:105
DRAMsim3::recvRespRetry
void recvRespRetry()
Definition: dramsim3.cc:241
DRAMsim3::accessAndRespond
void accessAndRespond(PacketPtr pkt)
When a packet is ready, use the "access()" method in AbstractMemory to actually create the response p...
Definition: dramsim3.cc:251
DRAMsim3::recvAtomic
Tick recvAtomic(PacketPtr pkt)
Definition: dramsim3.cc:155
DRAMsim3::nbrOutstandingReads
unsigned int nbrOutstandingReads
Count the number of outstanding transactions so that we can block any further requests until there is...
Definition: dramsim3.hh:131
DRAMsim3::sendResponseEvent
EventFunctionWrapper sendResponseEvent
Event to schedule sending of responses.
Definition: dramsim3.hh:158
DRAMsim3::tickEvent
EventFunctionWrapper tickEvent
Event to schedule clock ticks.
Definition: dramsim3.hh:168
qport.hh
Packet
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:257
std::deque
STL deque class.
Definition: stl.hh:44
addr
ip6_addr_t addr
Definition: inet.hh:423
DRAMsim3::MemoryPort::recvAtomic
Tick recvAtomic(PacketPtr pkt)
Receive an atomic request packet from the peer.
Definition: dramsim3.cc:367
DRAMsim3::startTick
Tick startTick
Keep track of when the wrapper is started.
Definition: dramsim3.hh:115
AbstractMemory::Params
AbstractMemoryParams Params
Definition: abstract_mem.hh:207
MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:323
std::list< AddrRange >
DRAMsim3::drain
DrainState drain() override
Draining is the process of clearing out the states of SimObjects.These are the SimObjects that are pa...
Definition: dramsim3.cc:346
DRAMsim3::resetStats
void resetStats() override
Callback to reset stats.
Definition: dramsim3.cc:96
DRAMsim3::MemoryPort::recvFunctional
void recvFunctional(PacketPtr pkt)
Receive a functional request packet from the peer.
Definition: dramsim3.cc:373
DRAMsim3::read_cb
std::function< void(uint64_t)> read_cb
Callback functions.
Definition: dramsim3.hh:94
DRAMsim3::MemoryPort
The memory port has to deal with its own flow control to avoid having unbounded storage that is impli...
Definition: dramsim3.hh:64

Generated on Wed Sep 30 2020 14:02:13 for gem5 by doxygen 1.8.17