gem5 v24.0.0.0
Loading...
Searching...
No Matches
hmc_controller.cc
Go to the documentation of this file.
2
3#include "base/random.hh"
4#include "base/trace.hh"
5#include "debug/HMCController.hh"
6
7namespace gem5
8{
9
10HMCController::HMCController(const HMCControllerParams &p) :
12 numMemSidePorts(p.port_mem_side_ports_connection_count),
13 rr_counter(0)
14{
15 assert(p.port_cpu_side_ports_connection_count == 1);
16}
17
18// Since this module is a load distributor, all its request ports have the same
19// range so we should keep only one of the ranges and ignore the others
21{
22 if (mem_side_port_id == 0)
23 {
24 gotAllAddrRanges = true;
25 BaseXBar::recvRangeChange(mem_side_port_id);
26 }
27 else
28 gotAddrRanges[mem_side_port_id] = true;
29}
30
32{
33 int current_value = rr_counter;
34 rr_counter++;
36 rr_counter = 0;
37 return current_value;
38}
39
41{
42 // determine the source port based on the id
43 ResponsePort *src_port = cpuSidePorts[cpu_side_port_id];
44
45 // we should never see express snoops on a non-coherent component
46 assert(!pkt->isExpressSnoop());
47
48 // For now, this is a simple round robin counter, for distribution the
49 // load among the serial links
50 PortID mem_side_port_id = rotate_counter();
51
52 // test if the layer should be considered occupied for the current
53 // port
54 if (!reqLayers[mem_side_port_id]->tryTiming(src_port)) {
55 DPRINTF(HMCController, "recvTimingReq: src %s %s 0x%x BUSY\n",
56 src_port->name(), pkt->cmdString(), pkt->getAddr());
57 return false;
58 }
59
60 DPRINTF(HMCController, "recvTimingReq: src %s %s 0x%x\n",
61 src_port->name(), pkt->cmdString(), pkt->getAddr());
62
63 // store size and command as they might be modified when
64 // forwarding the packet
65 unsigned int pkt_size = pkt->hasData() ? pkt->getSize() : 0;
66 unsigned int pkt_cmd = pkt->cmdToIndex();
67
68 // store the old header delay so we can restore it if needed
69 Tick old_header_delay = pkt->headerDelay;
70
71 // a request sees the frontend and forward latency
73
74 // set the packet header and payload delay
75 calcPacketTiming(pkt, xbar_delay);
76
77 // determine how long to be layer is busy
78 Tick packetFinishTime = clockEdge(Cycles(1)) + pkt->payloadDelay;
79
80 // before forwarding the packet (and possibly altering it),
81 // remember if we are expecting a response
82 const bool expect_response = pkt->needsResponse() &&
83 !pkt->cacheResponding();
84
85 // since it is a normal request, attempt to send the packet
86 bool success = memSidePorts[mem_side_port_id]->sendTimingReq(pkt);
87
88 if (!success) {
89 DPRINTF(HMCController, "recvTimingReq: src %s %s 0x%x RETRY\n",
90 src_port->name(), pkt->cmdString(), pkt->getAddr());
91
92 // restore the header delay as it is additive
93 pkt->headerDelay = old_header_delay;
94
95 // occupy until the header is sent
96 reqLayers[mem_side_port_id]->failedTiming(src_port,
97 clockEdge(Cycles(1)));
98
99 return false;
100 }
101
102 // remember where to route the response to
103 if (expect_response) {
104 assert(routeTo.find(pkt->req) == routeTo.end());
105 routeTo[pkt->req] = cpu_side_port_id;
106 }
107
108 reqLayers[mem_side_port_id]->succeededTiming(packetFinishTime);
109
110 // stats updates
111 pktCount[cpu_side_port_id][mem_side_port_id]++;
112 pktSize[cpu_side_port_id][mem_side_port_id] += pkt_size;
113 transDist[pkt_cmd]++;
114
115 return true;
116}
117
118} // namespace gem5
#define DPRINTF(x,...)
Definition trace.hh:210
bool gotAllAddrRanges
Definition xbar.hh:383
std::vector< RequestPort * > memSidePorts
Definition xbar.hh:387
const Cycles frontendLatency
Cycles of front-end pipeline including the delay to accept the request and to decode the address.
Definition xbar.hh:311
statistics::Vector transDist
Stats for transaction distribution and data passing through the crossbar.
Definition xbar.hh:409
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
statistics::Vector2d pktCount
Definition xbar.hh:410
std::vector< QueuedResponsePort * > cpuSidePorts
The memory-side ports and CPU-side ports of the crossbar.
Definition xbar.hh:386
const Cycles forwardLatency
Definition xbar.hh:312
statistics::Vector2d pktSize
Definition xbar.hh:411
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:382
virtual void recvRangeChange(PortID mem_side_port_id)
Function called by the port when the crossbar is recieving a range change.
Definition xbar.cc:374
void calcPacketTiming(PacketPtr pkt, Tick header_delay)
Calculate the timing parameters for the packet.
Definition xbar.cc:108
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...
Tick clockPeriod() const
Cycles is a wrapper class for representing cycle counts, i.e.
Definition types.hh:79
HMC Controller, in general, is responsible for translating the host protocol (AXI for example) to ser...
HMCController(const HMCControllerParams &p)
virtual bool recvTimingReq(PacketPtr pkt, PortID cpu_side_port_id)
virtual void recvRangeChange(PortID mem_side_port_id)
Function called by the port when the crossbar is recieving a range change.
int rotate_counter()
Function for rotating the round robin counter.
A non-coherent crossbar connects a number of non-snooping memory-side ports and cpu_sides,...
std::vector< ReqLayer * > reqLayers
Declare the layers of this crossbar, one vector for requests and one for responses.
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition packet.hh:295
Addr getAddr() const
Definition packet.hh:807
const std::string & cmdString() const
Return the string name of the cmd field (for debugging and tracing).
Definition packet.hh:588
bool needsResponse() const
Definition packet.hh:608
uint32_t payloadDelay
The extra pipelining delay from seeing the packet until the end of payload is transmitted by the comp...
Definition packet.hh:449
uint32_t headerDelay
The extra delay from seeing the packet until the header is transmitted.
Definition packet.hh:431
int cmdToIndex() const
Return the index of this command.
Definition packet.hh:591
bool hasData() const
Definition packet.hh:614
RequestPtr req
A pointer to the original request.
Definition packet.hh:377
unsigned getSize() const
Definition packet.hh:817
bool isExpressSnoop() const
Definition packet.hh:702
bool cacheResponding() const
Definition packet.hh:659
const std::string name() const
Return port name (for DPRINTF).
Definition port.hh:111
A ResponsePort is a specialization of a port.
Definition port.hh:349
HMCController declaration.
Bitfield< 0 > p
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
Definition binary32.hh:36
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
Definition types.hh:245
uint64_t Tick
Tick count type.
Definition types.hh:58

Generated on Tue Jun 18 2024 16:24:05 for gem5 by doxygen 1.11.0