gem5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
dramsim2.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  * Authors: Andreas Hansson
38  */
39 
44 #ifndef __MEM_DRAMSIM2_HH__
45 #define __MEM_DRAMSIM2_HH__
46 
47 #include <queue>
48 #include <unordered_map>
49 
50 #include "mem/abstract_mem.hh"
51 #include "mem/dramsim2_wrapper.hh"
52 #include "mem/qport.hh"
53 #include "params/DRAMSim2.hh"
54 
55 class DRAMSim2 : public AbstractMemory
56 {
57  private:
58 
64  class MemoryPort : public SlavePort
65  {
66 
67  private:
68 
70 
71  public:
72 
73  MemoryPort(const std::string& _name, DRAMSim2& _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 
95 
99  bool retryReq;
100 
104  bool retryResp;
105 
110 
117  std::unordered_map<Addr, std::queue<PacketPtr> > outstandingReads;
118  std::unordered_map<Addr, std::queue<PacketPtr> > outstandingWrites;
119 
125  unsigned int nbrOutstandingReads;
126  unsigned int nbrOutstandingWrites;
127 
134 
135  unsigned int nbrOutstanding() const;
136 
144  void accessAndRespond(PacketPtr pkt);
145 
146  void sendResponse();
147 
152 
156  void tick();
157 
162 
167  std::unique_ptr<Packet> pendingDelete;
168 
169  public:
170 
171  typedef DRAMSim2Params Params;
172  DRAMSim2(const Params *p);
173 
181  void readComplete(unsigned id, uint64_t addr, uint64_t cycle);
182 
190  void writeComplete(unsigned id, uint64_t addr, uint64_t cycle);
191 
192  DrainState drain() override;
193 
194  virtual BaseSlavePort& getSlavePort(const std::string& if_name,
195  PortID idx = InvalidPortID) override;
196 
197  void init() override;
198  void startup() override;
199 
200  protected:
201 
203  void recvFunctional(PacketPtr pkt);
204  bool recvTimingReq(PacketPtr pkt);
205  void recvRespRetry();
206 
207 };
208 
209 #endif // __MEM_DRAMSIM2_HH__
MemoryPort(const std::string &_name, DRAMSim2 &_memory)
Definition: dramsim2.cc:356
Tick recvAtomic(PacketPtr pkt)
Definition: dramsim2.cc:154
Wrapper class to avoid having DRAMSim2 names like ClockDomain etc clashing with the normal gem5 world...
void recvFunctional(PacketPtr pkt)
Definition: dramsim2.cc:163
const PortID InvalidPortID
Definition: types.hh:182
DrainState drain() override
Notify an object that it needs to drain its state.
Definition: dramsim2.cc:349
DrainState
Object drain/handover states.
Definition: drain.hh:71
void recvRespRetry()
Definition: dramsim2.cc:240
The memory port has to deal with its own flow control to avoid having unbounded storage that is impli...
Definition: dramsim2.hh:64
void recvFunctional(PacketPtr pkt)
Receive a functional request packet from the master port.
Definition: dramsim2.cc:376
bool retryResp
Are we waiting for a retry for sending a response.
Definition: dramsim2.hh:104
ip6_addr_t addr
Definition: inet.hh:335
std::unique_ptr< Packet > pendingDelete
Upstream caches need this packet until true is returned, so hold it for deletion until a subsequent c...
Definition: dramsim2.hh:167
A SlavePort is a specialisation of a port.
Definition: port.hh:331
DRAMSim2Params Params
Definition: dramsim2.hh:171
unsigned int nbrOutstanding() const
Definition: dramsim2.cc:133
void readComplete(unsigned id, uint64_t addr, uint64_t cycle)
Read completion callback.
Definition: dramsim2.cc:286
A BaseSlavePort is a protocol-agnostic slave port, responsible only for the structural connection to ...
Definition: port.hh:139
std::unordered_map< Addr, std::queue< PacketPtr > > outstandingWrites
Definition: dramsim2.hh:118
unsigned int nbrOutstandingWrites
Definition: dramsim2.hh:126
AbstractMemory declaration.
void recvRespRetry()
Called by the master port if sendTimingResp was called on this slave port (causing recvTimingResp to ...
Definition: dramsim2.cc:389
void tick()
Progress the controller one clock cycle.
Definition: dramsim2.cc:139
Declaration of the queued port.
void startup() override
startup() is the final initialization call before simulation.
Definition: dramsim2.cc:94
bool recvTimingReq(PacketPtr pkt)
Definition: dramsim2.cc:177
std::deque< PacketPtr > responseQueue
Queue to hold response packets until we can send them back.
Definition: dramsim2.hh:133
AbstractMemoryParams Params
uint64_t Tick
Tick count type.
Definition: types.hh:63
DRAMSim2Wrapper declaration.
void writeComplete(unsigned id, uint64_t addr, uint64_t cycle)
Write completion callback.
Definition: dramsim2.cc:314
void accessAndRespond(PacketPtr pkt)
When a packet is ready, use the "access()" method in AbstractMemory to actually create the response p...
Definition: dramsim2.cc:250
DRAMSim2Wrapper wrapper
The actual DRAMSim2 wrapper.
Definition: dramsim2.hh:94
Tick startTick
Keep track of when the wrapper is started.
Definition: dramsim2.hh:109
A Packet is used to encapsulate a transfer between two objects in the memory system (e...
Definition: packet.hh:245
EventWrapper< DRAMSim2,&DRAMSim2::sendResponse > sendResponseEvent
Event to schedule sending of responses.
Definition: dramsim2.hh:151
virtual BaseSlavePort & getSlavePort(const std::string &if_name, PortID idx=InvalidPortID) override
Get a slave port with a given name and index.
Definition: dramsim2.cc:339
STL deque class.
Definition: stl.hh:47
EventWrapper< DRAMSim2,&DRAMSim2::tick > tickEvent
Event to schedule clock ticks.
Definition: dramsim2.hh:161
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: dramsim2.hh:117
Tick recvAtomic(PacketPtr pkt)
Receive an atomic request packet from the master port.
Definition: dramsim2.cc:370
bool retryReq
Is the connected port waiting for a retry from us.
Definition: dramsim2.hh:99
DRAMSim2(const Params *p)
Definition: dramsim2.cc:49
Cycles cycle
void sendResponse()
Definition: dramsim2.cc:103
MemoryPort port
Definition: dramsim2.hh:89
An abstract memory represents a contiguous block of physical memory, with an associated address range...
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
Definition: types.hh:181
unsigned int nbrOutstandingReads
Count the number of outstanding transactions so that we can block any further requests until there is...
Definition: dramsim2.hh:125
AddrRangeList getAddrRanges() const
Get a list of the non-overlapping address ranges the owner is responsible for.
Definition: dramsim2.cc:362
Bitfield< 0 > p
DRAMSim2 & memory
Definition: dramsim2.hh:69
bool recvTimingReq(PacketPtr pkt)
Receive a timing request from the master port.
Definition: dramsim2.cc:382
void init() override
Initialise this memory.
Definition: dramsim2.cc:78

Generated on Fri Jun 9 2017 13:03:49 for gem5 by doxygen 1.8.6