gem5 [DEVELOP-FOR-25.1]
Loading...
Searching...
No Matches
bridge.hh
Go to the documentation of this file.
1/*
2 * Copyright (c) 2011-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 * Copyright (c) 2006 The Regents of The University of Michigan
15 * All rights reserved.
16 *
17 * Redistribution and use in source and binary forms, with or without
18 * modification, are permitted provided that the following conditions are
19 * met: redistributions of source code must retain the above copyright
20 * notice, this list of conditions and the following disclaimer;
21 * redistributions in binary form must reproduce the above copyright
22 * notice, this list of conditions and the following disclaimer in the
23 * documentation and/or other materials provided with the distribution;
24 * neither the name of the copyright holders nor the names of its
25 * contributors may be used to endorse or promote products derived from
26 * this software without specific prior written permission.
27 *
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
31 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
32 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 */
40
46
47#ifndef __MEM_BRIDGE_HH__
48#define __MEM_BRIDGE_HH__
49
50#include <deque>
51
52#include "base/types.hh"
53#include "mem/port.hh"
54#include "params/Bridge.hh"
55#include "params/BridgeBase.hh"
56#include "sim/clocked_object.hh"
57
58namespace gem5
59{
60
78{
79 protected:
80
86 {
87
88 public:
89
90 const Tick tick;
92
93 DeferredPacket(PacketPtr _pkt, Tick _tick) : tick(_tick), pkt(_pkt)
94 { }
95 };
96
97 // Forward declaration to allow the response port to have a pointer
98 class BridgeRequestPort;
99
107 {
108
109 private:
110
113
118
121
129
132
135
137 unsigned int respQueueLimit;
138
143 std::unique_ptr<Packet> pendingDelete;
144
150 bool respQueueFull() const;
151
157 void trySendTiming();
158
161
162 public:
163
174 BridgeResponsePort(const std::string& _name, BridgeBase& _bridge,
175 BridgeRequestPort& _memSidePort, Cycles _delay,
176 int _resp_limit);
177
185 void schedTimingResp(PacketPtr pkt, Tick when);
186
192 void retryStalledReq();
193
194 protected:
195
198 bool recvTimingReq(PacketPtr pkt) override;
199
202 void recvRespRetry() override;
203
206 Tick recvAtomic(PacketPtr pkt) override;
207
211 PacketPtr pkt, MemBackdoorPtr &backdoor) override;
212
213
216 void recvFunctional(PacketPtr pkt) override;
217
221 const MemBackdoorReq &req, MemBackdoorPtr &backdoor) override;
222
223
226 AddrRangeList getAddrRanges() const override;
227 };
228
229
236 {
237
238 private:
239
242
247
250
258
260 const unsigned int reqQueueLimit;
261
267 void trySendTiming();
268
271
272 public:
273
284 BridgeRequestPort(const std::string& _name, BridgeBase& _bridge,
285 BridgeResponsePort& _cpuSidePort, Cycles _delay,
286 int _req_limit);
287
293 bool reqQueueFull() const;
294
302 void schedTimingReq(PacketPtr pkt, Tick when);
303
313
314 protected:
315
318 bool recvTimingResp(PacketPtr pkt) override;
319
322 void recvReqRetry() override;
323
326 void recvRangeChange() override;
327 };
328
331
334
335 protected:
342 virtual AddrRangeList getAddrRanges() const = 0;
343
351 virtual void recvRangeChange() {};
352
353 public:
354 Port& getPort(const std::string& if_name,
355 PortID idx=InvalidPortID) override;
356
357 void init() override;
358
360
361 BridgeBase(const Params &p);
362};
363
368class Bridge : public BridgeBase
369{
372
373 protected:
374 AddrRangeList getAddrRanges() const override;
375
376 public:
378
379 Bridge(const Params &p);
380};
381
382} // namespace gem5
383
384#endif //__MEM_BRIDGE_HH__
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,...
Port on the side that forwards requests and receives responses.
Definition bridge.hh:236
BridgeRequestPort(const std::string &_name, BridgeBase &_bridge, BridgeResponsePort &_cpuSidePort, Cycles _delay, int _req_limit)
Constructor for the BridgeRequestPort.
Definition bridge.cc:66
void recvRangeChange() override
When receiving an address range change from the peer port, pass it to the bridge.
Definition bridge.cc:407
void recvReqRetry() override
When receiving a retry request from the peer port, pass it to the bridge.
Definition bridge.cc:330
bool trySatisfyFunctional(PacketPtr pkt)
Check a functional request against the packets in our request queue.
Definition bridge.cc:390
const unsigned int reqQueueLimit
Max queue size for request packets.
Definition bridge.hh:260
EventFunctionWrapper sendEvent
Send event for the request queue.
Definition bridge.hh:270
bool reqQueueFull() const
Is this side blocked from accepting new request packets.
Definition bridge.cc:120
bool recvTimingResp(PacketPtr pkt) override
When receiving a timing request from the peer port, pass it to the bridge.
Definition bridge.cc:126
BridgeResponsePort & cpuSidePort
The response port on the other side of the bridge.
Definition bridge.hh:246
void trySendTiming()
Handle send event, scheduled when the packet at the head of the outbound queue is ready to transmit (...
Definition bridge.cc:248
std::deque< DeferredPacket > transmitList
Request packet queue.
Definition bridge.hh:257
BridgeBase & bridge
The bridge to which this port belongs.
Definition bridge.hh:241
const Cycles delay
Minimum delay though this bridge.
Definition bridge.hh:249
void schedTimingReq(PacketPtr pkt, Tick when)
Queue a request packet to be sent out later and also schedule a send if necessary.
Definition bridge.cc:218
The port on the side that receives requests and sends responses.
Definition bridge.hh:107
void trySendTiming()
Handle send event, scheduled when the packet at the head of the response queue is ready to transmit (...
Definition bridge.cc:286
void recvFunctional(PacketPtr pkt) override
When receiving a Functional request from the peer port, pass it to the bridge.
Definition bridge.cc:359
void recvRespRetry() override
When receiving a retry request from the peer port, pass it to the bridge.
Definition bridge.cc:336
Tick recvAtomicBackdoor(PacketPtr pkt, MemBackdoorPtr &backdoor) override
When receiving an Atomic backdoor request from the peer port, pass it to the bridge.
Definition bridge.cc:351
std::unique_ptr< Packet > pendingDelete
Upstream caches need this packet until true is returned, so hold it for deletion until a subsequent c...
Definition bridge.hh:143
BridgeResponsePort(const std::string &_name, BridgeBase &_bridge, BridgeRequestPort &_memSidePort, Cycles _delay, int _resp_limit)
Constructor for the BridgeResponsePort.
Definition bridge.cc:56
void retryStalledReq()
Retry any stalled request that we have failed to accept at an earlier point in time.
Definition bridge.cc:208
BridgeBase & bridge
The bridge to which this port belongs.
Definition bridge.hh:112
void recvMemBackdoorReq(const MemBackdoorReq &req, MemBackdoorPtr &backdoor) override
When receiving a Functional backdoor request from the peer port, pass it to the bridge.
Definition bridge.cc:383
bool recvTimingReq(PacketPtr pkt) override
When receiving a timing request from the peer port, pass it to the bridge.
Definition bridge.cc:148
Tick recvAtomic(PacketPtr pkt) override
When receiving an Atomic request from the peer port, pass it to the bridge.
Definition bridge.cc:342
void schedTimingResp(PacketPtr pkt, Tick when)
Queue a response packet to be sent out later and also schedule a send if necessary.
Definition bridge.cc:234
bool respQueueFull() const
Is this side blocked from accepting new response packets.
Definition bridge.cc:114
bool retryReq
If we should send a retry when space becomes available.
Definition bridge.hh:134
unsigned int outstandingResponses
Counter to track the outstanding responses.
Definition bridge.hh:131
const Cycles delay
Minimum request delay though this bridge.
Definition bridge.hh:120
AddrRangeList getAddrRanges() const override
When receiving a address range request the peer port, pass it to the bridge.
Definition bridge.cc:413
EventFunctionWrapper sendEvent
Send event for the response queue.
Definition bridge.hh:160
std::deque< DeferredPacket > transmitList
Response packet queue.
Definition bridge.hh:128
BridgeRequestPort & memSidePort
Request port on the other side of the bridge.
Definition bridge.hh:117
unsigned int respQueueLimit
Max queue size for reserved responses.
Definition bridge.hh:137
DeferredPacket(PacketPtr _pkt, Tick _tick)
Definition bridge.hh:93
Port & getPort(const std::string &if_name, PortID idx=InvalidPortID) override
Get a port with a given name and index.
Definition bridge.cc:91
BridgeResponsePort cpuSidePort
Response port of the bridge.
Definition bridge.hh:330
BridgeBase(const Params &p)
Definition bridge.cc:76
void init() override
init() is called after all C++ SimObjects have been created and all ports are connected.
Definition bridge.cc:103
virtual void recvRangeChange()
Called when the memory side port receives an address range change from the peer response port.
Definition bridge.hh:351
virtual AddrRangeList getAddrRanges() const =0
Get a list of the non-overlapping address ranges the bridge is responsible for.
BridgeRequestPort memSidePort
Request port of the bridge.
Definition bridge.hh:333
PARAMS(BridgeBase)
AddrRangeList getAddrRanges() const override
Get a list of the non-overlapping address ranges the bridge is responsible for.
Definition bridge.cc:419
Bridge(const Params &p)
Definition bridge.cc:85
const AddrRangeList ranges
Address ranges to pass through the bridge.
Definition bridge.hh:371
PARAMS(Bridge)
ClockedObject(const ClockedObjectParams &p)
ClockedObjectParams Params
Parameters of ClockedObject.
Cycles is a wrapper class for representing cycle counts, i.e.
Definition types.hh:79
const std::string _name
Definition named.hh:54
Ports are used to interface objects to each other.
Definition port.hh:62
RequestPort(const std::string &name, SimObject *_owner, PortID id=InvalidPortID)
Request port.
Definition port.cc:125
ResponsePort(const std::string &name, SimObject *_owner, PortID id=InvalidPortID)
Response port.
Definition port.cc:218
STL deque class.
Definition stl.hh:44
ClockedObject declaration and implementation.
std::list< AddrRange > AddrRangeList
Convenience typedef for a collection of address ranges.
Definition addr_range.hh:64
Port Object Declaration.
Bitfield< 0 > p
Copyright (c) 2024 Arm Limited All rights reserved.
Definition binary32.hh:36
const PortID InvalidPortID
Definition types.hh:246
MemBackdoor * MemBackdoorPtr
Definition backdoor.hh:127
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
Packet * PacketPtr

Generated on Mon Oct 27 2025 04:13:03 for gem5 by doxygen 1.14.0