gem5  v20.1.0.0
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 
16 HMCControllerParams::create()
17 {
18  return new HMCController(this);
19 }
20 
21 // Since this module is a load distributor, all its request ports have the same
22 // range so we should keep only one of the ranges and ignore the others
23 void HMCController::recvRangeChange(PortID mem_side_port_id)
24 {
25  if (mem_side_port_id == 0)
26  {
27  gotAllAddrRanges = true;
28  BaseXBar::recvRangeChange(mem_side_port_id);
29  }
30  else
31  gotAddrRanges[mem_side_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 
43 bool HMCController::recvTimingReq(PacketPtr pkt, PortID cpu_side_port_id)
44 {
45  // determine the source port based on the id
46  ResponsePort *src_port = cpuSidePorts[cpu_side_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 mem_side_port_id = rotate_counter();
54 
55  // test if the layer should be considered occupied for the current
56  // port
57  if (!reqLayers[mem_side_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 = memSidePorts[mem_side_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[mem_side_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] = cpu_side_port_id;
109  }
110 
111  reqLayers[mem_side_port_id]->succeededTiming(packetFinishTime);
112 
113  // stats updates
114  pktCount[cpu_side_port_id][mem_side_port_id]++;
115  pktSize[cpu_side_port_id][mem_side_port_id] += pkt_size;
116  transDist[pkt_cmd]++;
117 
118  return true;
119 }
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:619
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:754
Packet::isExpressSnoop
bool isExpressSnoop() const
Definition: packet.hh:662
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:412
random.hh
Tick
uint64_t Tick
Tick count type.
Definition: types.hh:63
PortID
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
Definition: types.hh:237
Packet::req
RequestPtr req
A pointer to the original request.
Definition: packet.hh:340
HMCController::recvTimingReq
virtual bool recvTimingReq(PacketPtr pkt, PortID cpu_side_port_id)
Definition: hmc_controller.cc:43
Packet::getSize
unsigned getSize() const
Definition: packet.hh:764
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:394
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:23
HMCController::HMCController
HMCController(const HMCControllerParams *p)
Definition: hmc_controller.cc:7
DPRINTF
#define DPRINTF(x,...)
Definition: trace.hh:234
Packet::cmdString
const std::string & cmdString() const
Return the string name of the cmd field (for debugging and tracing).
Definition: packet.hh:551
Packet::needsResponse
bool needsResponse() const
Definition: packet.hh:570
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:34
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:554
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:576
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:257
Cycles
Cycles is a wrapper class for representing cycle counts, i.e.
Definition: types.hh:83
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 Wed Sep 30 2020 14:02:13 for gem5 by doxygen 1.8.17