gem5  v19.0.0.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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  * Authors: Jason Lowe-Power
29  */
30 
31 #ifndef __LEARNING_GEM5_PART2_SIMPLE_MEMOBJ_HH__
32 #define __LEARNING_GEM5_PART2_SIMPLE_MEMOBJ_HH__
33 
34 #include "mem/port.hh"
35 #include "params/SimpleMemobj.hh"
36 #include "sim/sim_object.hh"
37 
44 class SimpleMemobj : public SimObject
45 {
46  private:
47 
53  class CPUSidePort : public SlavePort
54  {
55  private:
58 
60  bool needRetry;
61 
64 
65  public:
69  CPUSidePort(const std::string& name, SimpleMemobj *owner) :
70  SlavePort(name, owner), owner(owner), needRetry(false),
71  blockedPacket(nullptr)
72  { }
73 
80  void sendPacket(PacketPtr pkt);
81 
89  AddrRangeList getAddrRanges() const override;
90 
95  void trySendRetry();
96 
97  protected:
102  Tick recvAtomic(PacketPtr pkt) override
103  { panic("recvAtomic unimpl."); }
104 
111  void recvFunctional(PacketPtr pkt) override;
112 
121  bool recvTimingReq(PacketPtr pkt) override;
122 
128  void recvRespRetry() override;
129  };
130 
135  class MemSidePort : public MasterPort
136  {
137  private:
140 
143 
144  public:
148  MemSidePort(const std::string& name, SimpleMemobj *owner) :
149  MasterPort(name, owner), owner(owner), blockedPacket(nullptr)
150  { }
151 
158  void sendPacket(PacketPtr pkt);
159 
160  protected:
164  bool recvTimingResp(PacketPtr pkt) override;
165 
171  void recvReqRetry() override;
172 
180  void recvRangeChange() override;
181  };
182 
190  bool handleRequest(PacketPtr pkt);
191 
199  bool handleResponse(PacketPtr pkt);
200 
207  void handleFunctional(PacketPtr pkt);
208 
216 
220  void sendRangeChange();
221 
225 
228 
230  bool blocked;
231 
232  public:
233 
236  SimpleMemobj(SimpleMemobjParams *params);
237 
248  Port &getPort(const std::string &if_name,
249  PortID idx=InvalidPortID) override;
250 };
251 
252 
253 #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:75
#define panic(...)
This implements a cprintf based panic() function.
Definition: logging.hh:167
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:60
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:286
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:238
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:258
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:63
const Params * params() const
Definition: sim_object.hh:114
Port Object Declaration.
A Packet is used to encapsulate a transfer between two objects in the memory system (e...
Definition: packet.hh:255
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:106
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:237
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:96
void recvRespRetry() override
Called by the master port if sendTimingResp was called on this slave port (causing recvTimingResp to ...

Generated on Fri Feb 28 2020 16:27:01 for gem5 by doxygen 1.8.13