39#include "debug/GarnetSyntheticTraffic.hh"
55 tester->completeRequest(pkt);
78 cachePort(
"GarnetSyntheticTraffic",
this),
81 blockSizeBits(
p.block_offset),
82 numDestinations(
p.num_dest),
83 simCycles(
p.sim_cycles),
84 numPacketsMax(
p.num_packets_max),
86 singleSender(
p.single_sender),
87 singleDest(
p.single_dest),
88 trafficType(
p.traffic_type),
91 precision(
p.precision),
92 responseLimit(
p.response_limit),
93 requestorId(
p.system->getRequestorId(
this))
97 schedule(tickEvent, 0);
100 if (trafficStringToEnum.count(trafficType) == 0) {
101 fatal(
"Unknown Traffic Type: %s!\n", traffic);
103 traffic = trafficStringToEnum[trafficType];
106 DPRINTF(GarnetSyntheticTraffic,
"Config Created: Name = %s , and id = %d\n",
113 if (if_name ==
"test")
130 "Completed injection of %s packet for address %x\n",
131 pkt->
isWrite() ?
"write" :
"read\n",
132 pkt->
req->getPaddr());
151 bool sendAllowedThisCycle;
152 double injRange = pow((
double) 10, (
double)
precision);
153 unsigned trySending =
rng->random<
unsigned>(0, (int) injRange);
154 if (trySending <
injRate*injRange)
155 sendAllowedThisCycle =
true;
157 sendAllowedThisCycle =
false;
160 if (sendAllowedThisCycle) {
161 bool senderEnable =
true;
164 senderEnable =
false;
167 senderEnable =
false;
186 int radix = (int) sqrt(num_destinations);
191 int src_x =
id%radix;
192 int src_y =
id/radix;
200 dest_x = radix - src_x - 1;
201 dest_y = radix - src_y - 1;
204 unsigned int straight = source;
205 unsigned int reverse = source & 1;
207 int num_bits = (int) log2(num_destinations);
209 for (
int i = 1;
i < num_bits;
i++)
213 reverse |= (straight & 1);
222 dest_x = (src_x + 1) % radix;
226 if (source < num_destinations/2)
235 dest_x = (src_x + (int) ceil(radix/2) - 1) % radix;
248 unsigned access_size = 1;
284 if (injReqType < 0 || injReqType > 2)
287 injReqType =
rng->random(0, 2);
290 if (injReqType == 0) {
293 req = std::make_shared<Request>(paddr, access_size, flags,
295 }
else if (injReqType == 1) {
299 req = std::make_shared<Request>(
301 req->setPaddr(paddr);
305 req = std::make_shared<Request>(paddr, access_size, flags,
315 "Generated packet with destination %d, embedded in address %x\n",
ClockedObject(const ClockedObjectParams &p)
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...
Cycles is a wrapper class for representing cycle counts, i.e.
virtual bool recvTimingResp(PacketPtr pkt)
Receive a timing response from the peer.
virtual void recvReqRetry()
Called by the peer if sendTimingReq was called on this peer (causing recvTimingReq to be called on th...
GarnetSyntheticTraffic * tester
void sendPkt(PacketPtr pkt)
GarnetSyntheticTrafficParams Params
Port & getPort(const std::string &if_name, PortID idx=InvalidPortID) override
Get a port with a given name and index.
const Cycles responseLimit
EventFunctionWrapper tickEvent
GarnetSyntheticTraffic(const Params &p)
std::map< std::string, TrafficType > trafficStringToEnum
void completeRequest(PacketPtr pkt)
void printAddr(Addr a)
Print state of address in memory system via PrintReq (for debugging).
void init() override
init() is called after all C++ SimObjects have been created and all ports are connected.
Command
List of all commands associated with a packet.
virtual std::string name() const
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
SenderState * senderState
This packet's sender state.
RequestPtr req
A pointer to the original request.
void dataDynamic(T *p)
Set the data pointer to a value that should have delete [] called on it.
Ports are used to interface objects to each other.
@ INST_FETCH
The request was an instruction fetch.
gem5::Flags< FlagsType > Flags
void schedule(Event &event, Tick when)
static const Priority CPU_Tick_Pri
CPU ticks must come after other associated CPU events (such as writebacks).
void set(Type mask)
Set all flag's bits matching the given mask.
#define fatal(...)
This implements a cprintf based fatal() function.
virtual Port & getPort(const std::string &if_name, PortID idx=InvalidPortID)
Get a port with a given name and index.
Copyright (c) 2024 Arm Limited All rights reserved.
std::shared_ptr< Request > RequestPtr
Tick curTick()
The universal simulation clock.
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
void exitSimLoop(const std::string &message, int exit_code, Tick when, Tick repeat, bool serialize)
The "old style" exitSimLoop functions.
Declaration of the Packet class.
Declaration of a request, the overall memory request consisting of the parts of the request that are ...
Declaration of Statistics objects.
const std::string & name()