gem5  v20.0.0.3
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 SlavePort
52  {
53  private:
56 
58  bool needRetry;
59 
62 
63  public:
67  CPUSidePort(const std::string& name, SimpleMemobj *owner) :
68  SlavePort(name, owner), owner(owner), needRetry(false),
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 MasterPort
134  {
135  private:
138 
141 
142  public:
146  MemSidePort(const std::string& name, SimpleMemobj *owner) :
147  MasterPort(name, owner), owner(owner), blockedPacket(nullptr)
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__
A MasterPort is a specialisation of a BaseMasterPort, which implements the default protocol for the t...
Definition: port.hh:71
#define panic(...)
This implements a cprintf based panic() function.
Definition: logging.hh:163
bool handleResponse(PacketPtr pkt)
Handle the respone from the memory side.
SimpleMemobj * owner
The object that owns this object (SimpleMemobj)
Ports are used to interface objects to each other.
Definition: port.hh:56
bool recvTimingReq(PacketPtr pkt) override
Receive a timing request from the master port.
void sendRangeChange() const
Called by the owner to send a range change.
Definition: port.hh:282
Port on the memory-side that receives responses.
AddrRangeList getAddrRanges() const override
Get a list of the non-overlapping address ranges the owner is responsible for.
const PortID InvalidPortID
Definition: types.hh:236
bool needRetry
True if the port needs to send a retry req.
CPUSidePort dataPort
PacketPtr blockedPacket
If we tried to send a packet and it was blocked, store it here.
A SlavePort is a specialisation of a port.
Definition: port.hh:254
SimpleMemobj(SimpleMemobjParams *params)
constructor
SimpleMemobj * owner
The object that owns this object (SimpleMemobj)
Port & getPort(const std::string &if_name, PortID idx=InvalidPortID) override
Get a port with a given name and index.
bool blocked
True if this is currently blocked waiting for a response.
uint64_t Tick
Tick count type.
Definition: types.hh:61
Port Object Declaration.
const Params * params() const
Definition: sim_object.hh:119
A Packet is used to encapsulate a transfer between two objects in the memory system (e...
Definition: packet.hh:249
bool handleRequest(PacketPtr pkt)
Handle the request from the CPU side.
CPUSidePort(const std::string &name, SimpleMemobj *owner)
Constructor.
A very simple memory object.
void sendPacket(PacketPtr pkt)
Send a packet across this port.
CPUSidePort instPort
Instantiation of the CPU-side ports.
Port on the CPU-side that receives requests.
const std::string name() const
Return port name (for DPRINTF).
Definition: port.hh:102
void handleFunctional(PacketPtr pkt)
Handle a packet functionally.
void trySendRetry()
Send a retry to the peer port only if it is needed.
MemSidePort memPort
Instantiation of the memory-side port.
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
Definition: types.hh:235
MemSidePort(const std::string &name, SimpleMemobj *owner)
Constructor.
void recvFunctional(PacketPtr pkt) override
Receive a functional request packet from the master port.
PacketPtr blockedPacket
If we tried to send a packet and it was blocked, store it here.
Tick recvAtomic(PacketPtr pkt) override
Receive an atomic request packet from the master port.
Abstract superclass for simulation objects.
Definition: sim_object.hh:93
void recvRespRetry() override
Called by the master port if sendTimingResp was called on this slave port (causing recvTimingResp to ...

Generated on Fri Jul 3 2020 15:53:03 for gem5 by doxygen 1.8.13