24.21.2.1. gem5 Packet
Packet
is what goes through ports: a single packet is sent out to the memory system, gets modified when it hits valid data, and then returns with the reply.
Packet
is what CPUs create and send to get memory values. E.g. on gem5 AtomicSimpleCPU
:
void AtomicSimpleCPU::tick() { ... Packet ifetch_pkt = Packet(ifetch_req, MemCmd::ReadReq); ifetch_pkt.dataStatic(&inst); icache_latency = sendPacket(icachePort, &ifetch_pkt); Tick AtomicSimpleCPU::sendPacket(MasterPort &port, const PacketPtr &pkt) { return port.sendAtomic(pkt); }
On TimingSimpleCPU, we note that the packet is dynamically created unlike for the AtomicSimpleCPU, since it must exist across multiple events which happen on separate function calls, unlike atomic memory which is done immediately in a single call:
void TimingSimpleCPU::sendFetch(const Fault &fault, const RequestPtr &req, ThreadContext *tc) { if (fault == NoFault) { DPRINTF(SimpleCPU, "Sending fetch for addr %#x(pa: %#x)\n", req->getVaddr(), req->getPaddr()); ifetch_pkt = new Packet(req, MemCmd::ReadReq); ifetch_pkt->dataStatic(&inst); DPRINTF(SimpleCPU, " -- pkt addr: %#x\n", ifetch_pkt->getAddr()); if (!icachePort.sendTimingReq(ifetch_pkt)) {
It must later delete the return packet that it gets later on, e.g. for the ifetch:
TimingSimpleCPU::completeIfetch(PacketPtr pkt) { if (pkt) { delete pkt; }
The most important properties of a Packet are:
-
PacketDataPtr data;
: the data coming back from a reply packet or being sent via it -
Addr addr;
: the physical address of the data. TODO comment says could be virtual too, when?/// The address of the request. This address could be virtual or /// physical, depending on the system configuration. Addr addr;
-
Flags flags;
: flags describing properties of thePacket
-
MemCmd cmd;
: see gem5MemCmd