63#include "debug/TlmBridge.hh"
64#include "params/TlmToGem5Bridge128.hh"
65#include "params/TlmToGem5Bridge256.hh"
66#include "params/TlmToGem5Bridge32.hh"
67#include "params/TlmToGem5Bridge512.hh"
68#include "params/TlmToGem5Bridge64.hh"
98 extraPayloadToPacketSteps.push_back(std::move(step));
117 if (extension !=
nullptr) {
122 for (
auto &step : extraPayloadToPacketSteps) {
125 return std::make_pair(pkt,
false);
141 req = std::make_shared<Request>(
143 0, 0, std::move(amo_op));
154 return std::make_pair(
nullptr,
false);
157 "received transaction with unsupported "
161 req = std::make_shared<Request>(
170 auto pkt =
new Packet(req, cmd);
174 for (
auto &step : extraPayloadToPacketSteps) {
178 return std::make_pair(pkt,
true);
193template <
unsigned int BITWIDTH>
200 auto status = socket->nb_transport_bw(trans, phase, delay);
202 "Unexpected status after sending END_REQ");
205template <
unsigned int BITWIDTH>
219 panic(
"TlmToGem5Bridge: "
220 "received transaction with unsupported command");
228 bmp.sendMemBackdoorReq(req, backdoor);
235 auto status = socket->nb_transport_bw(trans, phase, delay);
240 responseInProgress =
false;
243 responseInProgress =
true;
245 panic(
"Unexpected status after sending BEGIN_RESP");
249template <
unsigned int BITWIDTH>
260 auto pkt = res.first;
265 bool needsResponse = pkt->needsResponse();
266 if (bmp.sendTimingReq(pkt)) {
268 if (!needsResponse) {
271 sendBeginResp(trans, delay);
276 pendingRequest = &trans;
281template <
unsigned int BITWIDTH>
287 responseInProgress =
false;
289 if (needToSendRetry) {
291 needToSendRetry =
false;
295template <
unsigned int BITWIDTH>
302template <
unsigned int BITWIDTH>
306 if (backdoor ==
nullptr)
return;
309 if (requestedBackdoors.find(backdoor) == requestedBackdoors.end()) {
313 invalidateDmi(backdoor);
316 requestedBackdoors.emplace(backdoor);
320template <
unsigned int BITWIDTH>
324 socket->invalidate_direct_mem_ptr(
329template <
unsigned int BITWIDTH>
336 handleBeginReq(trans);
339 handleEndResp(trans);
342 panic(
"unimplemented phase in callback");
346template <
unsigned int BITWIDTH>
357 if (byteEnable != 0) {
368 peq.notify(trans, phase, delay);
372template <
unsigned int BITWIDTH>
385 for (
auto&
b : requestedBackdoors) {
386 if (pkt->getAddrRange().isSubset(
b->range()) &&
387 ((!pkt->isWrite() &&
b->readable()) ||
388 (pkt->isWrite() &&
b->writeable()))) {
394 ticks = bmp.sendAtomic(pkt);
396 ticks = bmp.sendAtomicBackdoor(pkt, backdoor);
402 cacheBackdoor(backdoor);
406 panic_if(pkt->needsResponse() && !pkt->isResponse(),
407 "Packet sending failed!\n");
429template <
unsigned int BITWIDTH>
434 if (pkt !=
nullptr) {
437 bmp.sendFunctional(pkt);
453template <
unsigned int BITWIDTH>
467 panic(
"TlmToGem5Bridge: "
468 "received transaction with unsupported command");
476 bmp.sendMemBackdoorReq(req, backdoor);
486 if (backdoor->readable())
488 if (backdoor->writeable())
491 cacheBackdoor(backdoor);
496 return backdoor !=
nullptr;
499template <
unsigned int BITWIDTH>
505 if (responseInProgress) {
507 needToSendRetry =
true;
523 auto *tlmSenderState =
527 auto &trans = tlmSenderState->trans;
529 sendBeginResp(trans, delay);
532 trans.get_extension(extension);
535 delete tlmSenderState;
539 if (extension ==
nullptr)
547template <
unsigned int BITWIDTH>
557 bool needsResponse = pendingPacket->needsResponse();
558 if (bmp.sendTimingReq(pendingPacket)) {
559 waitForRetry =
false;
561 auto &trans = *pendingRequest;
563 if (!needsResponse) {
566 sendBeginResp(trans, delay);
570 pendingRequest =
nullptr;
571 pendingPacket =
nullptr;
575template <
unsigned int BITWIDTH>
580 "received address range change but ignored it");
583template <
unsigned int BITWIDTH>
587 if (if_name ==
"gem5")
589 else if (if_name ==
"tlm")
595template <
unsigned int BITWIDTH>
599 waitForRetry(false), pendingRequest(nullptr), pendingPacket(nullptr),
600 needToSendRetry(false), responseInProgress(false),
601 bmp(
std::string(
name()) +
"master", *this), socket(
"tlm_socket"),
604 _id(params.
system->getGlobalRequestorId(
605 std::string(
"[systemc].") +
name()))
609template <
unsigned int BITWIDTH>
621 if (
system->isTimingMode()) {
622 DPRINTF(TlmBridge,
"register non-blocking interface");
623 socket.register_nb_transport_fw(
625 }
else if (
system->isAtomicMode()) {
626 DPRINTF(TlmBridge,
"register blocking interface");
627 socket.register_b_transport(
630 panic(
"gem5 operates neither in Timing nor in Atomic mode");
633 socket.register_get_direct_mem_ptr(
635 socket.register_transport_dbg(
644gem5::TlmToGem5Bridge32Params::create()
const
651gem5::TlmToGem5Bridge64Params::create()
const
658gem5::TlmToGem5Bridge128Params::create()
const
665gem5::TlmToGem5Bridge256Params::create()
const
672gem5::TlmToGem5Bridge512Params::create()
const
bool isReturnRequired() const
gem5::AtomicOpFunctor * getAtomicOpFunctor() const
gem5::PacketPtr getPacket()
const AddrRange & range() const
void addInvalidationCallback(CbFunction func)
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
void setAddr(Addr _addr)
Update the address of this packet mid-transaction.
uint32_t payloadDelay
The extra pipelining delay from seeing the packet until the end of payload is transmitted by the comp...
uint32_t headerDelay
The extra delay from seeing the packet until the header is transmitted.
SenderState * popSenderState()
Pop the top of the state stack and return a pointer to it.
Ports are used to interface objects to each other.
@ ATOMIC_RETURN_OP
The request is an atomic that returns data.
@ ATOMIC_NO_RETURN_OP
The request is an atomic that does not return data.
virtual void before_end_of_elaboration()
virtual gem5::Port & gem5_getPort(const std::string &if_name, int idx=-1)
static sc_time from_value(sc_dt::uint64)
void destroyPacket(gem5::PacketPtr pkt)
void handleEndResp(tlm::tlm_generic_payload &trans)
bool get_direct_mem_ptr(tlm::tlm_generic_payload &trans, tlm::tlm_dmi &dmi_data)
void sendBeginResp(tlm::tlm_generic_payload &trans, sc_core::sc_time &delay)
void invalidateDmi(const gem5::MemBackdoor &backdoor)
void b_transport(tlm::tlm_generic_payload &trans, sc_core::sc_time &t)
tlm::tlm_sync_enum nb_transport_fw(tlm::tlm_generic_payload &trans, tlm::tlm_phase &phase, sc_core::sc_time &t)
void cacheBackdoor(gem5::MemBackdoorPtr backdoor)
unsigned int transport_dbg(tlm::tlm_generic_payload &trans)
void sendEndReq(tlm::tlm_generic_payload &trans)
void handleBeginReq(tlm::tlm_generic_payload &trans)
gem5::Port & gem5_getPort(const std::string &if_name, int idx=-1) override
void peq_cb(tlm::tlm_generic_payload &trans, const tlm::tlm_phase &phase)
TlmToGem5Bridge(const Params &p, const sc_core::sc_module_name &mn)
void before_end_of_elaboration() override
bool recvTimingResp(gem5::PacketPtr pkt)
gem5::TlmToGem5BridgeBaseParams Params
void set_granted_access(dmi_access_e a)
void set_dmi_ptr(unsigned char *p)
void set_start_address(sc_dt::uint64 addr)
void set_end_address(sc_dt::uint64 addr)
unsigned char * get_data_ptr() const
void set_dmi_allowed(bool dmi_allowed)
void set_response_status(const tlm_response_status response_status)
unsigned char * get_byte_enable_ptr() const
sc_dt::uint64 get_address() const
void get_extension(T *&ext) const
unsigned int get_streaming_width() const
unsigned int get_data_length() const
tlm_command get_command() const
Addr end() const
Get the end address of the range.
Addr start() const
Get the start address of the range.
virtual AtomicOpFunctor * clone()=0
std::unique_ptr< AtomicOpFunctor > AtomicOpFunctorPtr
#define panic(...)
This implements a cprintf based panic() function.
#define panic_if(cond,...)
Conditional panic macro that checks the supplied condition and only panics if the condition is true a...
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
std::shared_ptr< Request > RequestPtr
const PortID InvalidPortID
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
uint64_t Tick
Tick count type.
const sc_time SC_ZERO_TIME
void addPayloadToPacketConversionStep(PayloadToPacketConversionStep step)
Notify the Tlm2Gem5 bridge that we need an extra step to properly convert a tlm payload to gem5 packe...
void setPayloadResponse(tlm::tlm_generic_payload &trans, PacketPtr pkt)
std::function< void(gem5::PacketPtr pkt, tlm::tlm_generic_payload &trans)> PayloadToPacketConversionStep
std::pair< PacketPtr, bool > payload2packet(RequestorID _id, tlm::tlm_generic_payload &trans)
Convert a TLM payload to gem5 packet by copying all the relevant information to new packet.
Overload hash function for BasicBlockRange type.
@ TLM_ADDRESS_ERROR_RESPONSE
@ TLM_BURST_ERROR_RESPONSE
@ TLM_BYTE_ENABLE_ERROR_RESPONSE
@ TLM_COMMAND_ERROR_RESPONSE
#define SC_REPORT_FATAL(msg_type, msg)
A virtual base opaque structure used to hold state associated with the packet (e.g....
const std::string & name()