gem5 v24.0.0.0
Loading...
Searching...
No Matches
xbar.hh
Go to the documentation of this file.
1/*
2 * Copyright (c) 2011-2015, 2018-2020 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) 2002-2005 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#ifndef __MEM_XBAR_HH__
47#define __MEM_XBAR_HH__
48
49#include <deque>
50#include <unordered_map>
51
53#include "base/types.hh"
54#include "mem/qport.hh"
55#include "params/BaseXBar.hh"
56#include "sim/clocked_object.hh"
57#include "sim/stats.hh"
58
59namespace gem5
60{
61
71class BaseXBar : public ClockedObject
72{
73
74 protected:
75
90 template <typename SrcType, typename DstType>
91 class Layer : public Drainable, public statistics::Group
92 {
93
94 public:
95
104 Layer(DstType& _port, BaseXBar& _xbar, const std::string& _name);
105
115 DrainState drain() override;
116
117 const std::string name() const { return _name; }
118
119
130 bool tryTiming(SrcType* src_port);
131
139 void succeededTiming(Tick busy_time);
140
150 void failedTiming(SrcType* src_port, Tick busy_time);
151
152 void occupyLayer(Tick until);
153
158 void retryWaiting();
159
165 void recvRetry();
166
167 protected:
168
175 virtual void sendRetry(SrcType* retry_port) = 0;
176
177 private:
178
180 DstType& port;
181
184
185 std::string _name;
186
203 enum State { IDLE, BUSY, RETRY };
204
206
212
218
224 void releaseLayer();
226
234
235 };
236
237 class ReqLayer : public Layer<ResponsePort, RequestPort>
238 {
239 public:
248 const std::string& _name) :
249 Layer(_port, _xbar, _name)
250 {}
251
252 protected:
253 void
254 sendRetry(ResponsePort* retry_port) override
255 {
256 retry_port->sendRetryReq();
257 }
258 };
259
260 class RespLayer : public Layer<RequestPort, ResponsePort>
261 {
262 public:
271 const std::string& _name) :
272 Layer(_port, _xbar, _name)
273 {}
274
275 protected:
276 void
277 sendRetry(RequestPort* retry_port) override
278 {
279 retry_port->sendRetryResp();
280 }
281 };
282
283 class SnoopRespLayer : public Layer<ResponsePort, RequestPort>
284 {
285 public:
294 const std::string& _name) :
295 Layer(_port, _xbar, _name)
296 {}
297
298 protected:
299
300 void
301 sendRetry(ResponsePort* retry_port) override
302 {
303 retry_port->sendRetrySnoopResp();
304 }
305 };
306
317 const uint32_t width;
318
320
327 std::unordered_map<RequestPtr, PortID> routeTo;
328
331
333
340 virtual void recvRangeChange(PortID mem_side_port_id);
341
350 PortID findPort(AddrRange addr_range, PacketPtr pkt=nullptr);
351
352 PortID
354 {
355 return findPort(pkt->getAddrRange(), pkt);
356 }
357
364
374 void calcPacketTiming(PacketPtr pkt, Tick header_delay);
375
384
388
391
396 const bool useDefaultRange;
397
398 BaseXBar(const BaseXBarParams &p);
399
412
413 public:
414
415 virtual ~BaseXBar();
416
418 Port &getPort(const std::string &if_name,
419 PortID idx=InvalidPortID) override;
420
421 void regStats() override;
422};
423
424} // namespace gem5
425
426#endif //__MEM_XBAR_HH__
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,...
The AddrRangeMap uses an STL map to implement an interval tree for address decoding.
The AddrRange class encapsulates an address range, and supports a number of tests to check if two ran...
Definition addr_range.hh:82
A layer is an internal crossbar arbitration point with its own flow control.
Definition xbar.hh:92
statistics::Formula utilization
Definition xbar.hh:233
std::string _name
Definition xbar.hh:185
State
We declare an enum to track the state of the layer.
Definition xbar.hh:203
statistics::Scalar occupancy
Stats for occupancy and utilization.
Definition xbar.hh:232
void recvRetry()
Handle a retry from a neighbouring module.
Definition xbar.cc:310
DrainState drain() override
Drain according to the normal semantics, so that the crossbar can tell the layer to drain,...
Definition xbar.cc:598
std::deque< SrcType * > waitingForLayer
A deque of ports that retry should be called on because the original send was delayed due to a busy l...
Definition xbar.hh:211
bool tryTiming(SrcType *src_port)
Determine if the layer accepts a packet from a specific port.
Definition xbar.cc:186
const std::string name() const
Definition xbar.hh:117
EventFunctionWrapper releaseEvent
Definition xbar.hh:225
Layer(DstType &_port, BaseXBar &_xbar, const std::string &_name)
Create a layer and give it a name.
Definition xbar.cc:146
SrcType * waitingForPeer
Track who is waiting for the retry when receiving it from a peer.
Definition xbar.hh:217
void occupyLayer(Tick until)
Definition xbar.cc:165
void retryWaiting()
Send a retry to the port at the head of waitingForLayer.
Definition xbar.cc:275
DstType & port
The destination port this layer converges at.
Definition xbar.hh:180
void failedTiming(SrcType *src_port, Tick busy_time)
Deal with a destination port not accepting a packet by potentially adding the source port to the retr...
Definition xbar.cc:229
void releaseLayer()
Release the layer after being occupied and return to an idle state where we proceed to send a retry t...
Definition xbar.cc:251
void succeededTiming(Tick busy_time)
Deal with a destination port accepting a packet by potentially removing the source port from the retr...
Definition xbar.cc:217
virtual void sendRetry(SrcType *retry_port)=0
Sending the actual retry, in a manner specific to the individual layers.
BaseXBar & xbar
The crossbar this layer is a part of.
Definition xbar.hh:183
void sendRetry(ResponsePort *retry_port) override
Sending the actual retry, in a manner specific to the individual layers.
Definition xbar.hh:254
ReqLayer(RequestPort &_port, BaseXBar &_xbar, const std::string &_name)
Create a request layer and give it a name.
Definition xbar.hh:247
RespLayer(ResponsePort &_port, BaseXBar &_xbar, const std::string &_name)
Create a response layer and give it a name.
Definition xbar.hh:270
void sendRetry(RequestPort *retry_port) override
Sending the actual retry, in a manner specific to the individual layers.
Definition xbar.hh:277
void sendRetry(ResponsePort *retry_port) override
Sending the actual retry, in a manner specific to the individual layers.
Definition xbar.hh:301
SnoopRespLayer(RequestPort &_port, BaseXBar &_xbar, const std::string &_name)
Create a snoop response layer and give it a name.
Definition xbar.hh:293
The base crossbar contains the common elements of the non-coherent and coherent crossbar.
Definition xbar.hh:72
PortID defaultPortID
Port that handles requests that don't match any of the interfaces.
Definition xbar.hh:390
bool gotAllAddrRanges
Definition xbar.hh:383
std::vector< RequestPort * > memSidePorts
Definition xbar.hh:387
AddrRange defaultRange
Definition xbar.hh:332
const Cycles headerLatency
Cycles the layer is occupied processing the packet header.
Definition xbar.hh:315
const Cycles frontendLatency
Cycles of front-end pipeline including the delay to accept the request and to decode the address.
Definition xbar.hh:311
PortID findPort(AddrRange addr_range, PacketPtr pkt=nullptr)
Find which port connected to this crossbar (if any) should be given a packet with this address range.
Definition xbar.cc:334
statistics::Vector transDist
Stats for transaction distribution and data passing through the crossbar.
Definition xbar.hh:409
const bool useDefaultRange
If true, use address range provided by default device.
Definition xbar.hh:396
PortID findPort(PacketPtr pkt)
Definition xbar.hh:353
std::unordered_map< RequestPtr, PortID > routeTo
Remember where request packets came from so that we can route responses to the appropriate port.
Definition xbar.hh:327
statistics::Vector2d pktCount
Definition xbar.hh:410
BaseXBar(const BaseXBarParams &p)
Definition xbar.cc:60
std::vector< QueuedResponsePort * > cpuSidePorts
The memory-side ports and CPU-side ports of the crossbar.
Definition xbar.hh:386
Port & getPort(const std::string &if_name, PortID idx=InvalidPortID) override
A function used to return the port associated with this object.
Definition xbar.cc:91
void regStats() override
Callback to set stat parameters.
Definition xbar.cc:554
const Cycles forwardLatency
Definition xbar.hh:312
AddrRangeList xbarRanges
all contigous ranges seen by this crossbar
Definition xbar.hh:330
AddrRangeMap< PortID, 3 > portMap
Definition xbar.hh:319
const uint32_t width
the width of the xbar in bytes
Definition xbar.hh:317
statistics::Vector2d pktSize
Definition xbar.hh:411
std::vector< bool > gotAddrRanges
Remember for each of the memory-side ports of the crossbar if we got an address range from the connec...
Definition xbar.hh:382
virtual void recvRangeChange(PortID mem_side_port_id)
Function called by the port when the crossbar is recieving a range change.
Definition xbar.cc:374
void calcPacketTiming(PacketPtr pkt, Tick header_delay)
Calculate the timing parameters for the packet.
Definition xbar.cc:108
const Cycles responseLatency
Definition xbar.hh:313
virtual ~BaseXBar()
Definition xbar.cc:81
AddrRangeList getAddrRanges() const
Return the address ranges the crossbar is responsible for.
Definition xbar.cc:536
The ClockedObject class extends the SimObject with a clock and accessor functions to relate ticks to ...
Cycles is a wrapper class for representing cycle counts, i.e.
Definition types.hh:79
Interface for objects that might require draining before checkpointing.
Definition drain.hh:235
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition packet.hh:295
AddrRange getAddrRange() const
Get address range to which this packet belongs.
Definition packet.cc:243
Ports are used to interface objects to each other.
Definition port.hh:62
A RequestPort is a specialisation of a Port, which implements the default protocol for the three diff...
Definition port.hh:136
virtual void sendRetryResp()
Send a retry to the response port that previously attempted a sendTimingResp to this request port and...
Definition port.hh:637
A ResponsePort is a specialization of a port.
Definition port.hh:349
void sendRetrySnoopResp()
Send a retry to the request port that previously attempted a sendTimingSnoopResp to this response por...
Definition port.hh:503
void sendRetryReq()
Send a retry to the request port that previously attempted a sendTimingReq to this response port and ...
Definition port.hh:489
A formula for statistics that is calculated when printed.
Statistics container.
Definition group.hh:93
This is a simple scalar statistic, like a counter.
A 2-Dimensional vecto of scalar stats.
A vector of scalar stats.
STL deque class.
Definition stl.hh:44
STL vector class.
Definition stl.hh:37
ClockedObject declaration and implementation.
DrainState
Object drain/handover states.
Definition drain.hh:75
Bitfield< 0 > p
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
Declaration of the queued port.

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