gem5 v24.0.0.0
Loading...
Searching...
No Matches
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
36namespace gem5
37{
38
45class SimpleMemobj : public SimObject
46{
47 private:
48
55 {
56 private:
59
62
65
66 public:
70 CPUSidePort(const std::string& name, SimpleMemobj *owner) :
72 blockedPacket(nullptr)
73 { }
74
81 void sendPacket(PacketPtr pkt);
82
90 AddrRangeList getAddrRanges() const override;
91
96 void trySendRetry();
97
98 protected:
104 { panic("recvAtomic unimpl."); }
105
112 void recvFunctional(PacketPtr pkt) override;
113
122 bool recvTimingReq(PacketPtr pkt) override;
123
129 void recvRespRetry() override;
130 };
131
137 {
138 private:
141
144
145 public:
149 MemSidePort(const std::string& name, SimpleMemobj *owner) :
151 { }
152
159 void sendPacket(PacketPtr pkt);
160
161 protected:
165 bool recvTimingResp(PacketPtr pkt) override;
166
172 void recvReqRetry() override;
173
181 void recvRangeChange() override;
182 };
183
191 bool handleRequest(PacketPtr pkt);
192
200 bool handleResponse(PacketPtr pkt);
201
208 void handleFunctional(PacketPtr pkt);
209
217
221 void sendRangeChange();
222
226
229
232
233 public:
234
237 SimpleMemobj(const SimpleMemobjParams &params);
238
249 Port &getPort(const std::string &if_name,
250 PortID idx=InvalidPortID) override;
251};
252
253} // namespace gem5
254
255#endif // __LEARNING_GEM5_PART2_SIMPLE_MEMOBJ_HH__
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition packet.hh:295
Ports are used to interface objects to each other.
Definition port.hh:62
const std::string name() const
Return port name (for DPRINTF).
Definition port.hh:111
A RequestPort is a specialisation of a Port, which implements the default protocol for the three diff...
Definition port.hh:136
A ResponsePort is a specialization of a port.
Definition port.hh:349
Abstract superclass for simulation objects.
Port on the CPU-side that receives requests.
PacketPtr blockedPacket
If we tried to send a packet and it was blocked, store it here.
SimpleMemobj * owner
The object that owns this object (SimpleMemobj)
bool recvTimingReq(PacketPtr pkt) override
Receive a timing request from the request port.
void recvFunctional(PacketPtr pkt) override
Receive a functional request packet from the request port.
CPUSidePort(const std::string &name, SimpleMemobj *owner)
Constructor.
AddrRangeList getAddrRanges() const override
Get a list of the non-overlapping address ranges the owner is responsible for.
void recvRespRetry() override
Called by the request port if sendTimingResp was called on this response port (causing recvTimingResp...
void trySendRetry()
Send a retry to the peer port only if it is needed.
void sendPacket(PacketPtr pkt)
Send a packet across this port.
Tick recvAtomic(PacketPtr pkt) override
Receive an atomic request packet from the request port.
bool needRetry
True if the port needs to send a retry req.
Port on the memory-side that receives responses.
void recvRangeChange() override
Called to receive an address range change from the peer responder port.
PacketPtr blockedPacket
If we tried to send a packet and it was blocked, store it here.
MemSidePort(const std::string &name, SimpleMemobj *owner)
Constructor.
SimpleMemobj * owner
The object that owns this object (SimpleMemobj)
bool recvTimingResp(PacketPtr pkt) override
Receive a timing response from the response port.
void recvReqRetry() override
Called by the response port if sendTimingReq was called on this request port (causing recvTimingReq t...
void sendPacket(PacketPtr pkt)
Send a packet across this port.
A very simple memory object.
bool handleResponse(PacketPtr pkt)
Handle the respone from the memory side.
MemSidePort memPort
Instantiation of the memory-side port.
Port & getPort(const std::string &if_name, PortID idx=InvalidPortID) override
Get a port with a given name and index.
bool handleRequest(PacketPtr pkt)
Handle the request from the CPU side.
CPUSidePort instPort
Instantiation of the CPU-side ports.
AddrRangeList getAddrRanges() const
Return the address ranges this memobj is responsible for.
bool blocked
True if this is currently blocked waiting for a response.
SimpleMemobj(const SimpleMemobjParams &params)
constructor
void handleFunctional(PacketPtr pkt)
Handle a packet functionally.
void sendRangeChange()
Tell the CPU side to ask for our memory ranges.
#define panic(...)
This implements a cprintf based panic() function.
Definition logging.hh:188
const Params & params() const
Port Object Declaration.
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
Definition binary32.hh:36
const PortID InvalidPortID
Definition types.hh:246
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
Definition types.hh:245
uint64_t Tick
Tick count type.
Definition types.hh:58

Generated on Tue Jun 18 2024 16:24:04 for gem5 by doxygen 1.11.0