gem5  v21.0.1.0
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  numMemSidePorts(p.port_mem_side_ports_connection_count),
10  rr_counter(0)
11 {
12  assert(p.port_cpu_side_ports_connection_count == 1);
13 }
14 
15 // Since this module is a load distributor, all its request ports have the same
16 // range so we should keep only one of the ranges and ignore the others
17 void HMCController::recvRangeChange(PortID mem_side_port_id)
18 {
19  if (mem_side_port_id == 0)
20  {
21  gotAllAddrRanges = true;
22  BaseXBar::recvRangeChange(mem_side_port_id);
23  }
24  else
25  gotAddrRanges[mem_side_port_id] = true;
26 }
27 
29 {
30  int current_value = rr_counter;
31  rr_counter++;
33  rr_counter = 0;
34  return current_value;
35 }
36 
37 bool HMCController::recvTimingReq(PacketPtr pkt, PortID cpu_side_port_id)
38 {
39  // determine the source port based on the id
40  ResponsePort *src_port = cpuSidePorts[cpu_side_port_id];
41 
42  // we should never see express snoops on a non-coherent component
43  assert(!pkt->isExpressSnoop());
44 
45  // For now, this is a simple round robin counter, for distribution the
46  // load among the serial links
47  PortID mem_side_port_id = rotate_counter();
48 
49  // test if the layer should be considered occupied for the current
50  // port
51  if (!reqLayers[mem_side_port_id]->tryTiming(src_port)) {
52  DPRINTF(HMCController, "recvTimingReq: src %s %s 0x%x BUSY\n",
53  src_port->name(), pkt->cmdString(), pkt->getAddr());
54  return false;
55  }
56 
57  DPRINTF(HMCController, "recvTimingReq: src %s %s 0x%x\n",
58  src_port->name(), pkt->cmdString(), pkt->getAddr());
59 
60  // store size and command as they might be modified when
61  // forwarding the packet
62  unsigned int pkt_size = pkt->hasData() ? pkt->getSize() : 0;
63  unsigned int pkt_cmd = pkt->cmdToIndex();
64 
65  // store the old header delay so we can restore it if needed
66  Tick old_header_delay = pkt->headerDelay;
67 
68  // a request sees the frontend and forward latency
69  Tick xbar_delay = (frontendLatency + forwardLatency) * clockPeriod();
70 
71  // set the packet header and payload delay
72  calcPacketTiming(pkt, xbar_delay);
73 
74  // determine how long to be layer is busy
75  Tick packetFinishTime = clockEdge(Cycles(1)) + pkt->payloadDelay;
76 
77  // before forwarding the packet (and possibly altering it),
78  // remember if we are expecting a response
79  const bool expect_response = pkt->needsResponse() &&
80  !pkt->cacheResponding();
81 
82  // since it is a normal request, attempt to send the packet
83  bool success = memSidePorts[mem_side_port_id]->sendTimingReq(pkt);
84 
85  if (!success) {
86  DPRINTF(HMCController, "recvTimingReq: src %s %s 0x%x RETRY\n",
87  src_port->name(), pkt->cmdString(), pkt->getAddr());
88 
89  // restore the header delay as it is additive
90  pkt->headerDelay = old_header_delay;
91 
92  // occupy until the header is sent
93  reqLayers[mem_side_port_id]->failedTiming(src_port,
94  clockEdge(Cycles(1)));
95 
96  return false;
97  }
98 
99  // remember where to route the response to
100  if (expect_response) {
101  assert(routeTo.find(pkt->req) == routeTo.end());
102  routeTo[pkt->req] = cpu_side_port_id;
103  }
104 
105  reqLayers[mem_side_port_id]->succeededTiming(packetFinishTime);
106 
107  // stats updates
108  pktCount[cpu_side_port_id][mem_side_port_id]++;
109  pktSize[cpu_side_port_id][mem_side_port_id] += pkt_size;
110  transDist[pkt_cmd]++;
111 
112  return true;
113 }
BaseXBar::forwardLatency
const Cycles forwardLatency
Definition: xbar.hh:309
HMCController::numMemSidePorts
int numMemSidePorts
Definition: hmc_controller.hh:90
hmc_controller.hh
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::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
Packet::cacheResponding
bool cacheResponding() const
Definition: packet.hh:620
BaseXBar::transDist
Stats::Vector transDist
Stats for transaction distribution and data passing through the crossbar.
Definition: xbar.hh:399
Packet::getAddr
Addr getAddr() const
Definition: packet.hh:755
Packet::isExpressSnoop
bool isExpressSnoop() const
Definition: packet.hh:663
Packet::payloadDelay
uint32_t payloadDelay
The extra pipelining delay from seeing the packet until the end of payload is transmitted by the comp...
Definition: packet.hh:413
random.hh
Tick
uint64_t Tick
Tick count type.
Definition: types.hh:59
PortID
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
Definition: types.hh:243
Packet::req
RequestPtr req
A pointer to the original request.
Definition: packet.hh:341
HMCController::recvTimingReq
virtual bool recvTimingReq(PacketPtr pkt, PortID cpu_side_port_id)
Definition: hmc_controller.cc:37
Packet::getSize
unsigned getSize() const
Definition: packet.hh:765
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
Packet::headerDelay
uint32_t headerDelay
The extra delay from seeing the packet until the header is transmitted.
Definition: packet.hh:395
HMCController::HMCController
HMCController(const HMCControllerParams &p)
Definition: hmc_controller.cc:7
HMCController::recvRangeChange
virtual void recvRangeChange(PortID mem_side_port_id)
Function called by the port when the crossbar is recieving a range change.
Definition: hmc_controller.cc:17
DPRINTF
#define DPRINTF(x,...)
Definition: trace.hh:237
Packet::cmdString
const std::string & cmdString() const
Return the string name of the cmd field (for debugging and tracing).
Definition: packet.hh:552
Packet::needsResponse
bool needsResponse() const
Definition: packet.hh:571
HMCController::rr_counter
int rr_counter
Definition: hmc_controller.hh:93
Clocked::clockEdge
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...
Definition: clocked_object.hh:174
HMCController::rotate_counter
int rotate_counter()
Function for rotating the round robin counter.
Definition: hmc_controller.cc:28
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
BaseXBar::pktSize
Stats::Vector2d pktSize
Definition: xbar.hh:401
Packet::cmdToIndex
int cmdToIndex() const
Return the index of this command.
Definition: packet.hh:555
Port::name
const std::string name() const
Return port name (for DPRINTF).
Definition: port.hh:106
Clocked::clockPeriod
Tick clockPeriod() const
Definition: clocked_object.hh:214
Packet::hasData
bool hasData() const
Definition: packet.hh:577
HMCController
HMC Controller, in general, is responsible for translating the host protocol (AXI for example) to ser...
Definition: hmc_controller.hh:73
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
Packet
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:258
Cycles
Cycles is a wrapper class for representing cycle counts, i.e.
Definition: types.hh:79
trace.hh
BaseXBar::pktCount
Stats::Vector2d pktCount
Definition: xbar.hh:400
MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:323
NoncoherentXBar::reqLayers
std::vector< ReqLayer * > reqLayers
Declare the layers of this crossbar, one vector for requests and one for responses.
Definition: noncoherent_xbar.hh:74
NoncoherentXBar
A non-coherent crossbar connects a number of non-snooping memory-side ports and cpu_sides,...
Definition: noncoherent_xbar.hh:65
BaseXBar::calcPacketTiming
void calcPacketTiming(PacketPtr pkt, Tick header_delay)
Calculate the timing parameters for the packet.
Definition: xbar.cc:101
BaseXBar::memSidePorts
std::vector< RequestPort * > memSidePorts
Definition: xbar.hh:377

Generated on Tue Jun 22 2021 15:28:29 for gem5 by doxygen 1.8.17