gem5  v20.1.0.0
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 
68 class BaseXBar : public ClockedObject
69 {
70 
71  protected:
72 
87  template <typename SrcType, typename DstType>
88  class Layer : public Drainable, public Stats::Group
89  {
90 
91  public:
92 
101  Layer(DstType& _port, BaseXBar& _xbar, const std::string& _name);
102 
112  DrainState drain() override;
113 
114  const std::string name() const { return _name; }
115 
116 
127  bool tryTiming(SrcType* src_port);
128 
136  void succeededTiming(Tick busy_time);
137 
147  void failedTiming(SrcType* src_port, Tick busy_time);
148 
149  void occupyLayer(Tick until);
150 
155  void retryWaiting();
156 
162  void recvRetry();
163 
164  protected:
165 
172  virtual void sendRetry(SrcType* retry_port) = 0;
173 
174  private:
175 
177  DstType& port;
178 
181 
182  std::string _name;
183 
200  enum State { IDLE, BUSY, RETRY };
201 
203 
209 
214  SrcType* waitingForPeer;
215 
221  void releaseLayer();
223 
231 
232  };
233 
234  class ReqLayer : public Layer<ResponsePort, RequestPort>
235  {
236  public:
244  ReqLayer(RequestPort& _port, BaseXBar& _xbar,
245  const std::string& _name) :
246  Layer(_port, _xbar, _name)
247  {}
248 
249  protected:
250  void
251  sendRetry(ResponsePort* retry_port) override
252  {
253  retry_port->sendRetryReq();
254  }
255  };
256 
257  class RespLayer : public Layer<RequestPort, ResponsePort>
258  {
259  public:
268  const std::string& _name) :
269  Layer(_port, _xbar, _name)
270  {}
271 
272  protected:
273  void
274  sendRetry(RequestPort* retry_port) override
275  {
276  retry_port->sendRetryResp();
277  }
278  };
279 
280  class SnoopRespLayer : public Layer<ResponsePort, RequestPort>
281  {
282  public:
291  const std::string& _name) :
292  Layer(_port, _xbar, _name)
293  {}
294 
295  protected:
296 
297  void
298  sendRetry(ResponsePort* retry_port) override
299  {
300  retry_port->sendRetrySnoopResp();
301  }
302  };
303 
314  const uint32_t width;
315 
317 
324  std::unordered_map<RequestPtr, PortID> routeTo;
325 
328 
330 
337  virtual void recvRangeChange(PortID mem_side_port_id);
338 
346  PortID findPort(AddrRange addr_range);
347 
354 
364  void calcPacketTiming(PacketPtr pkt, Tick header_delay);
365 
374 
378 
381 
386  const bool useDefaultRange;
387 
388  BaseXBar(const BaseXBarParams *p);
389 
402 
403  public:
404 
405  virtual ~BaseXBar();
406 
408  Port &getPort(const std::string &if_name,
409  PortID idx=InvalidPortID) override;
410 
411  void regStats() override;
412 };
413 
414 #endif //__MEM_XBAR_HH__
BaseXBar::Layer::retryWaiting
void retryWaiting()
Send a retry to the port at the head of waitingForLayer.
Definition: xbar.cc:268
BaseXBar::Layer::occupancy
Stats::Scalar occupancy
Stats for occupancy and utilization.
Definition: xbar.hh:229
BaseXBar::defaultRange
AddrRange defaultRange
Definition: xbar.hh:329
BaseXBar::forwardLatency
const Cycles forwardLatency
Definition: xbar.hh:309
ResponsePort
A ResponsePort is a specialization of a port.
Definition: port.hh:265
BaseXBar::cpuSidePorts
std::vector< QueuedResponsePort * > cpuSidePorts
The memory-side ports and CPU-side ports of the crossbar.
Definition: xbar.hh:376
BaseXBar::SnoopRespLayer
Definition: xbar.hh:280
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:372
BaseXBar::gotAllAddrRanges
bool gotAllAddrRanges
Definition: xbar.hh:373
BaseXBar::transDist
Stats::Vector transDist
Stats for transaction distribution and data passing through the crossbar.
Definition: xbar.hh:399
BaseXBar::RespLayer
Definition: xbar.hh:257
InvalidPortID
const PortID InvalidPortID
Definition: types.hh:238
BaseXBar::~BaseXBar
virtual ~BaseXBar()
Definition: xbar.cc:74
BaseXBar::Layer< RequestPort, ResponsePort >::State
State
We declare an enum to track the state of the layer.
Definition: xbar.hh:200
Tick
uint64_t Tick
Tick count type.
Definition: types.hh:63
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:84
PortID
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
Definition: types.hh:237
BaseXBar::RespLayer::RespLayer
RespLayer(ResponsePort &_port, BaseXBar &_xbar, const std::string &_name)
Create a response layer and give it a name.
Definition: xbar.hh:267
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:327
std::vector< bool >
BaseXBar::getAddrRanges
AddrRangeList getAddrRanges() const
Return the address ranges the crossbar is responsible for.
Definition: xbar.cc:522
BaseXBar::RespLayer::sendRetry
void sendRetry(RequestPort *retry_port) override
Sending the actual retry, in a manner specific to the individual layers.
Definition: xbar.hh:274
BaseXBar::Layer::utilization
Stats::Formula utilization
Definition: xbar.hh:230
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:308
Stats::Vector
A vector of scalar stats.
Definition: statistics.hh:2575
BaseXBar::BaseXBar
BaseXBar(const BaseXBarParams *p)
Definition: xbar.cc:54
ClockedObject
The ClockedObject class extends the SimObject with a clock and accessor functions to relate ticks to ...
Definition: clocked_object.hh:231
BaseXBar::defaultPortID
PortID defaultPortID
Port that handles requests that don't match any of the interfaces.
Definition: xbar.hh:380
BaseXBar::Layer::BUSY
@ BUSY
Definition: xbar.hh:200
EventFunctionWrapper
Definition: eventq.hh:1101
DrainState
DrainState
Object drain/handover states.
Definition: drain.hh:71
Stats::Scalar
This is a simple scalar statistic, like a counter.
Definition: statistics.hh:2533
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:290
stats.hh
BaseXBar::Layer::IDLE
@ IDLE
Definition: xbar.hh:200
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:210
Drainable
Interface for objects that might require draining before checkpointing.
Definition: drain.hh:230
AddrRange
The AddrRange class encapsulates an address range, and supports a number of tests to check if two ran...
Definition: addr_range.hh:68
addr_range_map.hh
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:222
BaseXBar::ReqLayer
Definition: xbar.hh:234
BaseXBar::Layer::_name
std::string _name
Definition: xbar.hh:182
Port
Ports are used to interface objects to each other.
Definition: port.hh:56
BaseXBar::useDefaultRange
const bool useDefaultRange
If true, use address range provided by default device.
Definition: xbar.hh:386
BaseXBar::Layer::port
DstType & port
The destination port this layer converges at.
Definition: xbar.hh:177
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:324
AddrRangeMap< PortID, 3 >
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:522
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:208
BaseXBar::Layer::occupyLayer
void occupyLayer(Tick until)
Definition: xbar.cc:158
BaseXBar::pktSize
Stats::Vector2d pktSize
Definition: xbar.hh:401
RequestPort
A RequestPort is a specialisation of a Port, which implements the default protocol for the three diff...
Definition: port.hh:74
BaseXBar::SnoopRespLayer::sendRetry
void sendRetry(ResponsePort *retry_port) override
Sending the actual retry, in a manner specific to the individual layers.
Definition: xbar.hh:298
BaseXBar::Layer::sendRetry
virtual void sendRetry(SrcType *retry_port)=0
Sending the actual retry, in a manner specific to the individual layers.
BaseXBar::Layer::Layer
Layer(DstType &_port, BaseXBar &_xbar, const std::string &_name)
Create a layer and give it a name.
Definition: xbar.cc:139
BaseXBar::Layer
A layer is an internal crossbar arbitration point with its own flow control.
Definition: xbar.hh:88
BaseXBar::portMap
AddrRangeMap< PortID, 3 > portMap
Definition: xbar.hh:316
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:360
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:584
Stats::Vector2d
A 2-Dimensional vecto of scalar stats.
Definition: statistics.hh:2603
BaseXBar::Layer::xbar
BaseXBar & xbar
The crossbar this layer is a part of.
Definition: xbar.hh:180
types.hh
qport.hh
BaseXBar::Layer::releaseEvent
EventFunctionWrapper releaseEvent
Definition: xbar.hh:222
clocked_object.hh
BaseXBar::headerLatency
const Cycles headerLatency
Cycles the layer is occupied processing the packet header.
Definition: xbar.hh:312
Stats::Formula
A formula for statistics that is calculated when printed.
Definition: statistics.hh:3037
Packet
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:257
std::deque< SrcType * >
Stats::Group
Statistics container.
Definition: group.hh:83
BaseXBar::Layer::tryTiming
bool tryTiming(SrcType *src_port)
Determine if the layer accepts a packet from a specific port.
Definition: xbar.cc:179
BaseXBar::Layer::waitingForPeer
SrcType * waitingForPeer
Track who is waiting for the retry when receiving it from a peer.
Definition: xbar.hh:214
BaseXBar::responseLatency
const Cycles responseLatency
Definition: xbar.hh:310
BaseXBar::ReqLayer::sendRetry
void sendRetry(ResponsePort *retry_port) override
Sending the actual retry, in a manner specific to the individual layers.
Definition: xbar.hh:251
ResponsePort::sendRetrySnoopResp
void sendRetrySnoopResp()
Send a retry to the request port that previously attempted a sendTimingSnoopResp to this response por...
Definition: port.hh:412
Cycles
Cycles is a wrapper class for representing cycle counts, i.e.
Definition: types.hh:83
BaseXBar::Layer::state
State state
Definition: xbar.hh:202
ResponsePort::sendRetryReq
void sendRetryReq()
Send a retry to the request port that previously attempted a sendTimingReq to this response port and ...
Definition: port.hh:398
BaseXBar::pktCount
Stats::Vector2d pktCount
Definition: xbar.hh:400
MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:323
std::list< AddrRange >
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:244
BaseXBar::xbarRanges
AddrRangeList xbarRanges
all contigous ranges seen by this crossbar
Definition: xbar.hh:327
BaseXBar::Layer::RETRY
@ RETRY
Definition: xbar.hh:200
BaseXBar::regStats
void regStats() override
Callback to set stat parameters.
Definition: xbar.cc:540
BaseXBar
The base crossbar contains the common elements of the non-coherent and coherent crossbar.
Definition: xbar.hh:68
BaseXBar::Layer::recvRetry
void recvRetry()
Handle a retry from a neighbouring module.
Definition: xbar.cc:303
BaseXBar::calcPacketTiming
void calcPacketTiming(PacketPtr pkt, Tick header_delay)
Calculate the timing parameters for the packet.
Definition: xbar.cc:101
BaseXBar::ReqLayer::ReqLayer
ReqLayer(RequestPort &_port, BaseXBar &_xbar, const std::string &_name)
Create a request layer and give it a name.
Definition: xbar.hh:244
BaseXBar::memSidePorts
std::vector< RequestPort * > memSidePorts
Definition: xbar.hh:377
BaseXBar::Layer::name
const std::string name() const
Definition: xbar.hh:114
BaseXBar::width
const uint32_t width
the width of the xbar in bytes
Definition: xbar.hh:314

Generated on Wed Sep 30 2020 14:02:14 for gem5 by doxygen 1.8.17