gem5  v20.1.0.0
simple_memobj.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017 Jason Lowe-Power
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are
7  * met: redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer;
9  * redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution;
12  * neither the name of the copyright holders nor the names of its
13  * contributors may be used to endorse or promote products derived from
14  * this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  */
28 
29 #ifndef __LEARNING_GEM5_PART2_SIMPLE_MEMOBJ_HH__
30 #define __LEARNING_GEM5_PART2_SIMPLE_MEMOBJ_HH__
31 
32 #include "mem/port.hh"
33 #include "params/SimpleMemobj.hh"
34 #include "sim/sim_object.hh"
35 
42 class SimpleMemobj : public SimObject
43 {
44  private:
45 
51  class CPUSidePort : public ResponsePort
52  {
53  private:
56 
58  bool needRetry;
59 
62 
63  public:
67  CPUSidePort(const std::string& name, SimpleMemobj *owner) :
69  blockedPacket(nullptr)
70  { }
71 
78  void sendPacket(PacketPtr pkt);
79 
87  AddrRangeList getAddrRanges() const override;
88 
93  void trySendRetry();
94 
95  protected:
100  Tick recvAtomic(PacketPtr pkt) override
101  { panic("recvAtomic unimpl."); }
102 
109  void recvFunctional(PacketPtr pkt) override;
110 
119  bool recvTimingReq(PacketPtr pkt) override;
120 
126  void recvRespRetry() override;
127  };
128 
133  class MemSidePort : public RequestPort
134  {
135  private:
138 
141 
142  public:
146  MemSidePort(const std::string& name, SimpleMemobj *owner) :
148  { }
149 
156  void sendPacket(PacketPtr pkt);
157 
158  protected:
162  bool recvTimingResp(PacketPtr pkt) override;
163 
169  void recvReqRetry() override;
170 
178  void recvRangeChange() override;
179  };
180 
188  bool handleRequest(PacketPtr pkt);
189 
197  bool handleResponse(PacketPtr pkt);
198 
205  void handleFunctional(PacketPtr pkt);
206 
214 
218  void sendRangeChange();
219 
223 
226 
228  bool blocked;
229 
230  public:
231 
234  SimpleMemobj(SimpleMemobjParams *params);
235 
246  Port &getPort(const std::string &if_name,
247  PortID idx=InvalidPortID) override;
248 };
249 
250 
251 #endif // __LEARNING_GEM5_PART2_SIMPLE_MEMOBJ_HH__
SimpleMemobj::memPort
MemSidePort memPort
Instantiation of the memory-side port.
Definition: simple_memobj.hh:225
SimpleMemobj::MemSidePort
Port on the memory-side that receives responses.
Definition: simple_memobj.hh:133
ResponsePort
A ResponsePort is a specialization of a port.
Definition: port.hh:265
SimpleMemobj::MemSidePort::recvRangeChange
void recvRangeChange() override
Called to receive an address range change from the peer responder port.
Definition: simple_memobj.cc:159
SimpleMemobj::handleRequest
bool handleRequest(PacketPtr pkt)
Handle the request from the CPU side.
Definition: simple_memobj.cc:165
SimpleMemobj::getAddrRanges
AddrRangeList getAddrRanges() const
Return the address ranges this memobj is responsible for.
Definition: simple_memobj.cc:218
SimpleMemobj::SimpleMemobj
SimpleMemobj(SimpleMemobjParams *params)
constructor
Definition: simple_memobj.cc:34
InvalidPortID
const PortID InvalidPortID
Definition: types.hh:238
SimpleMemobj::CPUSidePort::recvAtomic
Tick recvAtomic(PacketPtr pkt) override
Receive an atomic request packet from the request port.
Definition: simple_memobj.hh:100
Tick
uint64_t Tick
Tick count type.
Definition: types.hh:63
PortID
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
Definition: types.hh:237
SimpleMemobj::MemSidePort::recvTimingResp
bool recvTimingResp(PacketPtr pkt) override
Receive a timing response from the response port.
Definition: simple_memobj.cc:138
SimpleMemobj::instPort
CPUSidePort instPort
Instantiation of the CPU-side ports.
Definition: simple_memobj.hh:221
SimpleMemobj::CPUSidePort::trySendRetry
void trySendRetry()
Send a retry to the peer port only if it is needed.
Definition: simple_memobj.cc:81
SimpleMemobj::MemSidePort::owner
SimpleMemobj * owner
The object that owns this object (SimpleMemobj)
Definition: simple_memobj.hh:137
SimpleMemobj::CPUSidePort::recvRespRetry
void recvRespRetry() override
Called by the request port if sendTimingResp was called on this response port (causing recvTimingResp...
Definition: simple_memobj.cc:111
SimpleMemobj::CPUSidePort::getAddrRanges
AddrRangeList getAddrRanges() const override
Get a list of the non-overlapping address ranges the owner is responsible for.
Definition: simple_memobj.cc:75
SimpleMemobj::CPUSidePort::CPUSidePort
CPUSidePort(const std::string &name, SimpleMemobj *owner)
Constructor.
Definition: simple_memobj.hh:67
SimpleMemobj::MemSidePort::recvReqRetry
void recvReqRetry() override
Called by the response port if sendTimingReq was called on this request port (causing recvTimingReq t...
Definition: simple_memobj.cc:145
SimpleMemobj
A very simple memory object.
Definition: simple_memobj.hh:42
SimpleMemobj::CPUSidePort::recvFunctional
void recvFunctional(PacketPtr pkt) override
Receive a functional request packet from the request port.
Definition: simple_memobj.cc:92
SimpleMemobj::MemSidePort::blockedPacket
PacketPtr blockedPacket
If we tried to send a packet and it was blocked, store it here.
Definition: simple_memobj.hh:140
sim_object.hh
Port
Ports are used to interface objects to each other.
Definition: port.hh:56
port.hh
SimpleMemobj::getPort
Port & getPort(const std::string &if_name, PortID idx=InvalidPortID) override
Get a port with a given name and index.
Definition: simple_memobj.cc:44
SimpleMemobj::MemSidePort::MemSidePort
MemSidePort(const std::string &name, SimpleMemobj *owner)
Constructor.
Definition: simple_memobj.hh:146
SimpleMemobj::CPUSidePort::sendPacket
void sendPacket(PacketPtr pkt)
Send a packet across this port.
Definition: simple_memobj.cc:62
RequestPort
A RequestPort is a specialisation of a Port, which implements the default protocol for the three diff...
Definition: port.hh:74
Port::name
const std::string name() const
Return port name (for DPRINTF).
Definition: port.hh:106
SimpleMemobj::CPUSidePort::owner
SimpleMemobj * owner
The object that owns this object (SimpleMemobj)
Definition: simple_memobj.hh:55
SimObject::params
const Params * params() const
Definition: sim_object.hh:119
SimpleMemobj::handleFunctional
void handleFunctional(PacketPtr pkt)
Handle a packet functionally.
Definition: simple_memobj.cc:211
SimpleMemobj::sendRangeChange
void sendRangeChange()
Tell the CPU side to ask for our memory ranges.
Definition: simple_memobj.cc:226
SimpleMemobj::CPUSidePort::needRetry
bool needRetry
True if the port needs to send a retry req.
Definition: simple_memobj.hh:58
Packet
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:257
SimpleMemobj::CPUSidePort
Port on the CPU-side that receives requests.
Definition: simple_memobj.hh:51
SimpleMemobj::handleResponse
bool handleResponse(PacketPtr pkt)
Handle the respone from the memory side.
Definition: simple_memobj.cc:184
std::list< AddrRange >
SimpleMemobj::CPUSidePort::blockedPacket
PacketPtr blockedPacket
If we tried to send a packet and it was blocked, store it here.
Definition: simple_memobj.hh:61
SimpleMemobj::CPUSidePort::recvTimingReq
bool recvTimingReq(PacketPtr pkt) override
Receive a timing request from the request port.
Definition: simple_memobj.cc:99
panic
#define panic(...)
This implements a cprintf based panic() function.
Definition: logging.hh:171
SimpleMemobj::MemSidePort::sendPacket
void sendPacket(PacketPtr pkt)
Send a packet across this port.
Definition: simple_memobj.cc:125
SimpleMemobj::dataPort
CPUSidePort dataPort
Definition: simple_memobj.hh:222
SimpleMemobj::blocked
bool blocked
True if this is currently blocked waiting for a response.
Definition: simple_memobj.hh:228
SimObject
Abstract superclass for simulation objects.
Definition: sim_object.hh:92

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