gem5  v21.1.0.2
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 
52 #include "base/addr_range_map.hh"
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 
59 namespace gem5
60 {
61 
71 class 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 
217  SrcType* waitingForPeer;
218 
224  void releaseLayer();
226 
234 
235  };
236 
237  class ReqLayer : public Layer<ResponsePort, RequestPort>
238  {
239  public:
247  ReqLayer(RequestPort& _port, BaseXBar& _xbar,
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 
349  PortID findPort(AddrRange addr_range);
350 
357 
367  void calcPacketTiming(PacketPtr pkt, Tick header_delay);
368 
377 
381 
384 
389  const bool useDefaultRange;
390 
391  BaseXBar(const BaseXBarParams &p);
392 
405 
406  public:
407 
408  virtual ~BaseXBar();
409 
411  Port &getPort(const std::string &if_name,
412  PortID idx=InvalidPortID) override;
413 
414  void regStats() override;
415 };
416 
417 } // namespace gem5
418 
419 #endif //__MEM_XBAR_HH__
gem5::statistics::Scalar
This is a simple scalar statistic, like a counter.
Definition: statistics.hh:1927
gem5::BaseXBar::RespLayer::sendRetry
void sendRetry(RequestPort *retry_port) override
Sending the actual retry, in a manner specific to the individual layers.
Definition: xbar.hh:277
gem5::PortID
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
Definition: types.hh:252
gem5::BaseXBar::Layer::failedTiming
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:226
gem5::BaseXBar::Layer::succeededTiming
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:214
gem5::BaseXBar
The base crossbar contains the common elements of the non-coherent and coherent crossbar.
Definition: xbar.hh:71
gem5::BaseXBar::useDefaultRange
const bool useDefaultRange
If true, use address range provided by default device.
Definition: xbar.hh:389
gem5::BaseXBar::Layer::state
State state
Definition: xbar.hh:205
gem5::BaseXBar::SnoopRespLayer::SnoopRespLayer
SnoopRespLayer(RequestPort &_port, BaseXBar &_xbar, const std::string &_name)
Create a snoop response layer and give it a name.
Definition: xbar.hh:293
gem5::BaseXBar::getPort
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:88
gem5::AddrRangeMap< PortID, 3 >
gem5::BaseXBar::width
const uint32_t width
the width of the xbar in bytes
Definition: xbar.hh:317
gem5::ResponsePort::sendRetryReq
void sendRetryReq()
Send a retry to the request port that previously attempted a sendTimingReq to this response port and ...
Definition: port.hh:401
gem5::BaseXBar::cpuSidePorts
std::vector< QueuedResponsePort * > cpuSidePorts
The memory-side ports and CPU-side ports of the crossbar.
Definition: xbar.hh:379
gem5::BaseXBar::Layer::name
const std::string name() const
Definition: xbar.hh:117
gem5::BaseXBar::Layer::sendRetry
virtual void sendRetry(SrcType *retry_port)=0
Sending the actual retry, in a manner specific to the individual layers.
gem5::BaseXBar::frontendLatency
const Cycles frontendLatency
Cycles of front-end pipeline including the delay to accept the request and to decode the address.
Definition: xbar.hh:311
gem5::BaseXBar::ReqLayer
Definition: xbar.hh:237
gem5::BaseXBar::SnoopRespLayer::sendRetry
void sendRetry(ResponsePort *retry_port) override
Sending the actual retry, in a manner specific to the individual layers.
Definition: xbar.hh:301
gem5::ResponsePort::sendRetrySnoopResp
void sendRetrySnoopResp()
Send a retry to the request port that previously attempted a sendTimingSnoopResp to this response por...
Definition: port.hh:415
gem5::BaseXBar::Layer::retryWaiting
void retryWaiting()
Send a retry to the port at the head of waitingForLayer.
Definition: xbar.cc:272
gem5::BaseXBar::Layer::releaseLayer
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:248
gem5::BaseXBar::routeTo
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
gem5::BaseXBar::Layer::tryTiming
bool tryTiming(SrcType *src_port)
Determine if the layer accepts a packet from a specific port.
Definition: xbar.cc:183
gem5::BaseXBar::Layer< RequestPort, ResponsePort >::State
State
We declare an enum to track the state of the layer.
Definition: xbar.hh:203
gem5::BaseXBar::pktCount
statistics::Vector2d pktCount
Definition: xbar.hh:403
gem5::statistics::Vector2d
A 2-Dimensional vecto of scalar stats.
Definition: statistics.hh:2055
gem5::statistics::Vector
A vector of scalar stats.
Definition: statistics.hh:2003
gem5::BaseXBar::Layer::utilization
statistics::Formula utilization
Definition: xbar.hh:233
gem5::statistics::Formula
A formula for statistics that is calculated when printed.
Definition: statistics.hh:2536
std::vector< bool >
gem5::BaseXBar::responseLatency
const Cycles responseLatency
Definition: xbar.hh:313
gem5::BaseXBar::Layer::_name
std::string _name
Definition: xbar.hh:185
gem5::BaseXBar::RespLayer
Definition: xbar.hh:260
gem5::InvalidPortID
const PortID InvalidPortID
Definition: types.hh:253
gem5::RequestPort
A RequestPort is a specialisation of a Port, which implements the default protocol for the three diff...
Definition: port.hh:77
gem5::Cycles
Cycles is a wrapper class for representing cycle counts, i.e.
Definition: types.hh:78
gem5::BaseXBar::xbarRanges
AddrRangeList xbarRanges
all contigous ranges seen by this crossbar
Definition: xbar.hh:330
stats.hh
gem5::BaseXBar::SnoopRespLayer
Definition: xbar.hh:283
gem5::DrainState
DrainState
Object drain/handover states.
Definition: drain.hh:74
gem5::BaseXBar::Layer::xbar
BaseXBar & xbar
The crossbar this layer is a part of.
Definition: xbar.hh:183
gem5::BaseXBar::forwardLatency
const Cycles forwardLatency
Definition: xbar.hh:312
addr_range_map.hh
gem5::BaseXBar::transDist
statistics::Vector transDist
Stats for transaction distribution and data passing through the crossbar.
Definition: xbar.hh:402
gem5::BaseXBar::RespLayer::RespLayer
RespLayer(ResponsePort &_port, BaseXBar &_xbar, const std::string &_name)
Create a response layer and give it a name.
Definition: xbar.hh:270
gem5::Packet
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:283
gem5::MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:326
gem5::Tick
uint64_t Tick
Tick count type.
Definition: types.hh:58
gem5::RequestPort::sendRetryResp
virtual void sendRetryResp()
Send a retry to the response port that previously attempted a sendTimingResp to this request port and...
Definition: port.hh:525
gem5::BaseXBar::recvRangeChange
virtual void recvRangeChange(PortID mem_side_port_id)
Function called by the port when the crossbar is recieving a range change.
Definition: xbar.cc:364
gem5::BaseXBar::getAddrRanges
AddrRangeList getAddrRanges() const
Return the address ranges the crossbar is responsible for.
Definition: xbar.cc:526
gem5::BaseXBar::BaseXBar
BaseXBar(const BaseXBarParams &p)
Definition: xbar.cc:57
gem5::BaseXBar::Layer::Layer
Layer(DstType &_port, BaseXBar &_xbar, const std::string &_name)
Create a layer and give it a name.
Definition: xbar.cc:143
gem5::BaseXBar::defaultPortID
PortID defaultPortID
Port that handles requests that don't match any of the interfaces.
Definition: xbar.hh:383
gem5::BaseXBar::Layer::waitingForLayer
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
gem5::ClockedObject
The ClockedObject class extends the SimObject with a clock and accessor functions to relate ticks to ...
Definition: clocked_object.hh:234
gem5::BaseXBar::~BaseXBar
virtual ~BaseXBar()
Definition: xbar.cc:78
gem5::BaseXBar::gotAllAddrRanges
bool gotAllAddrRanges
Definition: xbar.hh:376
gem5::EventFunctionWrapper
Definition: eventq.hh:1115
gem5::BaseXBar::Layer::IDLE
@ IDLE
Definition: xbar.hh:203
gem5::BaseXBar::Layer::drain
DrainState drain() override
Drain according to the normal semantics, so that the crossbar can tell the layer to drain,...
Definition: xbar.cc:588
gem5::ResponsePort
A ResponsePort is a specialization of a port.
Definition: port.hh:268
gem5::BaseXBar::ReqLayer::ReqLayer
ReqLayer(RequestPort &_port, BaseXBar &_xbar, const std::string &_name)
Create a request layer and give it a name.
Definition: xbar.hh:247
gem5::Port
Ports are used to interface objects to each other.
Definition: port.hh:61
types.hh
qport.hh
gem5::BaseXBar::pktSize
statistics::Vector2d pktSize
Definition: xbar.hh:404
clocked_object.hh
std::deque< SrcType * >
gem5::BaseXBar::Layer::RETRY
@ RETRY
Definition: xbar.hh:203
gem5::Drainable
Interface for objects that might require draining before checkpointing.
Definition: drain.hh:234
gem5::BaseXBar::defaultRange
AddrRange defaultRange
Definition: xbar.hh:332
gem5::statistics::Group
Statistics container.
Definition: group.hh:93
gem5::BaseXBar::Layer::port
DstType & port
The destination port this layer converges at.
Definition: xbar.hh:180
gem5::BaseXBar::calcPacketTiming
void calcPacketTiming(PacketPtr pkt, Tick header_delay)
Calculate the timing parameters for the packet.
Definition: xbar.cc:105
gem5::BaseXBar::Layer::recvRetry
void recvRetry()
Handle a retry from a neighbouring module.
Definition: xbar.cc:307
gem5::BaseXBar::Layer
A layer is an internal crossbar arbitration point with its own flow control.
Definition: xbar.hh:91
gem5::BaseXBar::findPort
PortID findPort(AddrRange addr_range)
Find which port connected to this crossbar (if any) should be given a packet with this address range.
Definition: xbar.cc:331
gem5::AddrRange
The AddrRange class encapsulates an address range, and supports a number of tests to check if two ran...
Definition: addr_range.hh:71
gem5::BaseXBar::Layer::occupancy
statistics::Scalar occupancy
Stats for occupancy and utilization.
Definition: xbar.hh:232
std::list< AddrRange >
gem5::BaseXBar::ReqLayer::sendRetry
void sendRetry(ResponsePort *retry_port) override
Sending the actual retry, in a manner specific to the individual layers.
Definition: xbar.hh:254
gem5::BaseXBar::headerLatency
const Cycles headerLatency
Cycles the layer is occupied processing the packet header.
Definition: xbar.hh:315
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: decoder.cc:40
gem5::BaseXBar::regStats
void regStats() override
Callback to set stat parameters.
Definition: xbar.cc:544
gem5::BaseXBar::Layer::BUSY
@ BUSY
Definition: xbar.hh:203
gem5::BaseXBar::Layer::waitingForPeer
SrcType * waitingForPeer
Track who is waiting for the retry when receiving it from a peer.
Definition: xbar.hh:217
gem5::BaseXBar::gotAddrRanges
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:375
gem5::BaseXBar::Layer::occupyLayer
void occupyLayer(Tick until)
Definition: xbar.cc:162
gem5::BaseXBar::portMap
AddrRangeMap< PortID, 3 > portMap
Definition: xbar.hh:319
gem5::BaseXBar::memSidePorts
std::vector< RequestPort * > memSidePorts
Definition: xbar.hh:380
gem5::BaseXBar::Layer::releaseEvent
EventFunctionWrapper releaseEvent
Definition: xbar.hh:225

Generated on Tue Sep 21 2021 12:25:47 for gem5 by doxygen 1.8.17