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 socket->invalidate_direct_mem_ptr(
311template <
unsigned int BITWIDTH>
318 handleBeginReq(trans);
321 handleEndResp(trans);
324 panic(
"unimplemented phase in callback");
328template <
unsigned int BITWIDTH>
339 if (byteEnable != 0) {
350 peq.notify(trans, phase, delay);
354template <
unsigned int BITWIDTH>
363 Tick ticks = bmp.sendAtomicBackdoor(pkt, backdoor);
368 panic_if(pkt->needsResponse() && !pkt->isResponse(),
369 "Packet sending failed!\n");
391template <
unsigned int BITWIDTH>
396 if (pkt !=
nullptr) {
399 bmp.sendFunctional(pkt);
415template <
unsigned int BITWIDTH>
429 panic(
"TlmToGem5Bridge: "
430 "received transaction with unsupported command");
438 bmp.sendMemBackdoorReq(req, backdoor);
448 if (backdoor->readable())
450 if (backdoor->writeable())
455 if (requestedBackdoors.find(backdoor) == requestedBackdoors.end()) {
456 backdoor->addInvalidationCallback(
459 invalidateDmi(backdoor);
462 requestedBackdoors.emplace(backdoor);
468 return backdoor !=
nullptr;
471template <
unsigned int BITWIDTH>
477 if (responseInProgress) {
479 needToSendRetry =
true;
495 auto *tlmSenderState =
499 auto &trans = tlmSenderState->trans;
501 sendBeginResp(trans, delay);
504 trans.get_extension(extension);
507 delete tlmSenderState;
511 if (extension ==
nullptr)
519template <
unsigned int BITWIDTH>
529 bool needsResponse = pendingPacket->needsResponse();
530 if (bmp.sendTimingReq(pendingPacket)) {
531 waitForRetry =
false;
533 auto &trans = *pendingRequest;
535 if (!needsResponse) {
538 sendBeginResp(trans, delay);
542 pendingRequest =
nullptr;
546template <
unsigned int BITWIDTH>
551 "received address range change but ignored it");
554template <
unsigned int BITWIDTH>
558 if (if_name ==
"gem5")
560 else if (if_name ==
"tlm")
566template <
unsigned int BITWIDTH>
570 waitForRetry(false), pendingRequest(nullptr), pendingPacket(nullptr),
571 needToSendRetry(false), responseInProgress(false),
572 bmp(
std::string(
name()) +
"master", *this), socket(
"tlm_socket"),
575 _id(params.
system->getGlobalRequestorId(
576 std::string(
"[systemc].") +
name()))
580template <
unsigned int BITWIDTH>
592 if (
system->isTimingMode()) {
593 DPRINTF(TlmBridge,
"register non-blocking interface");
594 socket.register_nb_transport_fw(
596 }
else if (
system->isAtomicMode()) {
597 DPRINTF(TlmBridge,
"register blocking interface");
598 socket.register_b_transport(
601 panic(
"gem5 operates neither in Timing nor in Atomic mode");
604 socket.register_get_direct_mem_ptr(
606 socket.register_transport_dbg(
615gem5::TlmToGem5Bridge32Params::create()
const
622gem5::TlmToGem5Bridge64Params::create()
const
629gem5::TlmToGem5Bridge128Params::create()
const
636gem5::TlmToGem5Bridge256Params::create()
const
643gem5::TlmToGem5Bridge512Params::create()
const
bool isReturnRequired() const
gem5::AtomicOpFunctor * getAtomicOpFunctor() const
gem5::PacketPtr getPacket()
const AddrRange & range() const
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)
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...
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
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()