gem5  v20.0.0.2
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
hmc_controller.cc
Go to the documentation of this file.
1 #include "mem/hmc_controller.hh"
2 
3 #include "base/random.hh"
4 #include "base/trace.hh"
5 #include "debug/HMCController.hh"
6 
7 HMCController::HMCController(const HMCControllerParams* p) :
9  n_master_ports(p->port_master_connection_count),
10  rr_counter(0)
11 {
12  assert(p->port_slave_connection_count == 1);
13 }
14 
16 HMCControllerParams::create()
17 {
18  return new HMCController(this);
19 }
20 
21 // Since this module is a load distributor, all its master ports have the same
22 // range so we should keep only one of the ranges and ignore the others
24 {
25  if (master_port_id == 0)
26  {
27  gotAllAddrRanges = true;
28  BaseXBar::recvRangeChange(master_port_id);
29  }
30  else
31  gotAddrRanges[master_port_id] = true;
32 }
33 
35 {
36  int current_value = rr_counter;
37  rr_counter++;
39  rr_counter = 0;
40  return current_value;
41 }
42 
44 {
45  // determine the source port based on the id
46  SlavePort *src_port = slavePorts[slave_port_id];
47 
48  // we should never see express snoops on a non-coherent component
49  assert(!pkt->isExpressSnoop());
50 
51  // For now, this is a simple round robin counter, for distribution the
52  // load among the serial links
53  PortID master_port_id = rotate_counter();
54 
55  // test if the layer should be considered occupied for the current
56  // port
57  if (!reqLayers[master_port_id]->tryTiming(src_port)) {
58  DPRINTF(HMCController, "recvTimingReq: src %s %s 0x%x BUSY\n",
59  src_port->name(), pkt->cmdString(), pkt->getAddr());
60  return false;
61  }
62 
63  DPRINTF(HMCController, "recvTimingReq: src %s %s 0x%x\n",
64  src_port->name(), pkt->cmdString(), pkt->getAddr());
65 
66  // store size and command as they might be modified when
67  // forwarding the packet
68  unsigned int pkt_size = pkt->hasData() ? pkt->getSize() : 0;
69  unsigned int pkt_cmd = pkt->cmdToIndex();
70 
71  // store the old header delay so we can restore it if needed
72  Tick old_header_delay = pkt->headerDelay;
73 
74  // a request sees the frontend and forward latency
75  Tick xbar_delay = (frontendLatency + forwardLatency) * clockPeriod();
76 
77  // set the packet header and payload delay
78  calcPacketTiming(pkt, xbar_delay);
79 
80  // determine how long to be layer is busy
81  Tick packetFinishTime = clockEdge(Cycles(1)) + pkt->payloadDelay;
82 
83  // before forwarding the packet (and possibly altering it),
84  // remember if we are expecting a response
85  const bool expect_response = pkt->needsResponse() &&
86  !pkt->cacheResponding();
87 
88  // since it is a normal request, attempt to send the packet
89  bool success = masterPorts[master_port_id]->sendTimingReq(pkt);
90 
91  if (!success) {
92  DPRINTF(HMCController, "recvTimingReq: src %s %s 0x%x RETRY\n",
93  src_port->name(), pkt->cmdString(), pkt->getAddr());
94 
95  // restore the header delay as it is additive
96  pkt->headerDelay = old_header_delay;
97 
98  // occupy until the header is sent
99  reqLayers[master_port_id]->failedTiming(src_port,
100  clockEdge(Cycles(1)));
101 
102  return false;
103  }
104 
105  // remember where to route the response to
106  if (expect_response) {
107  assert(routeTo.find(pkt->req) == routeTo.end());
108  routeTo[pkt->req] = slave_port_id;
109  }
110 
111  reqLayers[master_port_id]->succeededTiming(packetFinishTime);
112 
113  // stats updates
114  pktCount[slave_port_id][master_port_id]++;
115  pktSize[slave_port_id][master_port_id] += pkt_size;
116  transDist[pkt_cmd]++;
117 
118  return true;
119 }
#define DPRINTF(x,...)
Definition: trace.hh:222
bool isExpressSnoop() const
Definition: packet.hh:628
Cycles is a wrapper class for representing cycle counts, i.e.
Definition: types.hh:81
std::vector< ReqLayer * > reqLayers
Declare the layers of this crossbar, one vector for requests and one for responses.
int rotate_counter()
Function for rotating the round robin counter.
HMCController declaration.
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:321
bool cacheResponding() const
Definition: packet.hh:585
A SlavePort is a specialisation of a port.
Definition: port.hh:254
std::vector< bool > gotAddrRanges
Remember for each of the master ports of the crossbar if we got an address range from the connected s...
Definition: xbar.hh:369
Tick clockPeriod() const
virtual bool recvTimingReq(PacketPtr pkt, PortID slave_port_id)
virtual void recvRangeChange(PortID master_port_id)
Function called by the port when the crossbar is recieving a range change.
RequestPtr req
A pointer to the original request.
Definition: packet.hh:321
unsigned getSize() const
Definition: packet.hh:730
bool needsResponse() const
Definition: packet.hh:536
uint32_t headerDelay
The extra delay from seeing the packet until the header is transmitted.
Definition: packet.hh:360
HMC Controller, in general, is responsible for translating the host protocol (AXI for example) to ser...
uint64_t Tick
Tick count type.
Definition: types.hh:61
Stats::Vector transDist
Stats for transaction distribution and data passing through the crossbar.
Definition: xbar.hh:396
Addr getAddr() const
Definition: packet.hh:720
bool hasData() const
Definition: packet.hh:542
void calcPacketTiming(PacketPtr pkt, Tick header_delay)
Calculate the timing parameters for the packet.
Definition: xbar.cc:99
uint32_t payloadDelay
The extra pipelining delay from seeing the packet until the end of payload is transmitted by the comp...
Definition: packet.hh:378
A Packet is used to encapsulate a transfer between two objects in the memory system (e...
Definition: packet.hh:249
const Cycles frontendLatency
Cycles of front-end pipeline including the delay to accept the request and to decode the address...
Definition: xbar.hh:307
Tick clockEdge(Cycles cycles=Cycles(0)) const
Determine the tick when a cycle begins, by default the current one, but the argument also enables the...
HMCController(const HMCControllerParams *p)
bool gotAllAddrRanges
Definition: xbar.hh:370
A non-coherent crossbar connects a number of non-snooping masters and slaves, and routes the request ...
int cmdToIndex() const
Return the index of this command.
Definition: packet.hh:520
std::vector< MasterPort * > masterPorts
Definition: xbar.hh:374
std::vector< QueuedSlavePort * > slavePorts
The master and slave ports of the crossbar.
Definition: xbar.hh:373
const std::string name() const
Return port name (for DPRINTF).
Definition: port.hh:102
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
Definition: types.hh:235
const Cycles forwardLatency
Definition: xbar.hh:308
const std::string & cmdString() const
Return the string name of the cmd field (for debugging and tracing).
Definition: packet.hh:517
Bitfield< 0 > p
Stats::Vector2d pktSize
Definition: xbar.hh:398
virtual void recvRangeChange(PortID master_port_id)
Function called by the port when the crossbar is recieving a range change.
Definition: xbar.cc:358
Stats::Vector2d pktCount
Definition: xbar.hh:397

Generated on Mon Jun 8 2020 15:45:12 for gem5 by doxygen 1.8.13