63 #include "params/TlmToGem5Bridge32.hh" 64 #include "params/TlmToGem5Bridge64.hh" 88 "received transaction with unsupported command");
92 auto req = std::make_shared<Request>(
99 auto pkt =
new Packet(req, cmd);
105 template <
unsigned int BITWIDTH>
112 auto status = socket->nb_transport_bw(trans, phase, delay);
114 "Unexpected status after sending END_REQ");
117 template <
unsigned int BITWIDTH>
126 auto status = socket->nb_transport_bw(trans, phase, delay);
131 responseInProgress =
false;
134 responseInProgress =
true;
136 panic(
"Unexpected status after sending BEGIN_RESP");
140 template <
unsigned int BITWIDTH>
158 if (extension !=
nullptr) {
168 if (bmp.sendTimingReq(pkt)) {
173 pendingRequest = &trans;
178 template <
unsigned int BITWIDTH>
184 responseInProgress =
false;
186 checkTransaction(trans);
188 if (needToSendRetry) {
190 needToSendRetry =
false;
194 template <
unsigned int BITWIDTH>
201 template <
unsigned int BITWIDTH>
206 std::stringstream
ss;
207 ss <<
"Transaction returned with error, response status = " 213 template <
unsigned int BITWIDTH>
217 socket->invalidate_direct_mem_ptr(
218 backdoor.range().start(), backdoor.range().end());
221 template <
unsigned int BITWIDTH>
228 handleBeginReq(trans);
231 handleEndResp(trans);
234 panic(
"unimplemented phase in callback");
238 template <
unsigned int BITWIDTH>
249 if (byteEnable != 0) {
260 peq.notify(trans, phase, delay);
264 template <
unsigned int BITWIDTH>
276 if (extension !=
nullptr) {
284 Tick ticks = bmp.sendAtomicBackdoor(pkt, backdoor);
290 "Packet sending failed!\n");
298 if (extension ==
nullptr)
304 template <
unsigned int BITWIDTH>
313 if (extension !=
nullptr) {
315 bmp.sendFunctional(extension->
getPacket());
319 bmp.sendFunctional(pkt);
327 template <
unsigned int BITWIDTH>
339 if (extension !=
nullptr) {
348 bmp.sendAtomicBackdoor(pkt, backdoor);
366 invalidateDmi(backdoor);
371 if (extension ==
nullptr)
376 return backdoor !=
nullptr;
379 template <
unsigned int BITWIDTH>
385 if (responseInProgress) {
387 needToSendRetry =
true;
406 auto &trans = tlmSenderState->trans;
409 trans.get_extension(extension);
412 delete tlmSenderState;
416 if (extension ==
nullptr)
421 sendBeginResp(trans, delay);
427 template <
unsigned int BITWIDTH>
435 if (bmp.sendTimingReq(pendingPacket)) {
436 waitForRetry =
false;
437 pendingPacket =
nullptr;
439 auto &trans = *pendingRequest;
443 pendingRequest =
nullptr;
447 template <
unsigned int BITWIDTH>
452 "received address range change but ignored it");
455 template <
unsigned int BITWIDTH>
459 if (if_name ==
"gem5")
461 else if (if_name ==
"tlm")
467 template <
unsigned int BITWIDTH>
471 waitForRetry(false), pendingRequest(nullptr), pendingPacket(nullptr),
472 needToSendRetry(false), responseInProgress(false),
473 bmp(
std::string(
name()) +
"master", *this), socket(
"tlm_socket"),
476 masterId(params->
system->getGlobalMasterId(
477 std::string(
"[systemc].") +
name()))
481 template <
unsigned int BITWIDTH>
494 SC_REPORT_INFO(
"TlmToGem5Bridge",
"register non-blocking interface");
495 socket.register_nb_transport_fw(
499 socket.register_b_transport(
501 socket.register_get_direct_mem_ptr(
504 panic(
"gem5 operates neither in Timing nor in Atomic mode");
507 socket.register_transport_dbg(
516 TlmToGem5Bridge32Params::create()
523 TlmToGem5Bridge64Params::create()
void sendEndReq(tlm::tlm_generic_payload &trans)
#define panic(...)
This implements a cprintf based panic() function.
void set_response_status(const tlm_response_status response_status)
void get_extension(T *&ext) const
unsigned int transport_dbg(tlm::tlm_generic_payload &trans)
const std::string & name()
bool recvTimingResp(PacketPtr pkt)
const PortID InvalidPortID
void set_dmi_ptr(unsigned char *p)
bool get_direct_mem_ptr(tlm::tlm_generic_payload &trans, tlm::tlm_dmi &dmi_data)
void set_start_address(sc_dt::uint64 addr)
const char * name() const
void sendBeginResp(tlm::tlm_generic_payload &trans, sc_core::sc_time &delay)
void b_transport(tlm::tlm_generic_payload &trans, sc_core::sc_time &t)
Overload hash function for BasicBlockRange type.
unsigned char * get_byte_enable_ptr() const
#define SC_REPORT_INFO(msg_type, msg)
tlm::tlm_sync_enum nb_transport_fw(tlm::tlm_generic_payload &trans, tlm::tlm_phase &phase, sc_core::sc_time &t)
sc_dt::uint64 get_address() const
#define SC_REPORT_WARNING(msg_type, msg)
void addInvalidationCallback(CbFunction func)
RequestPtr req
A pointer to the original request.
void handleBeginReq(tlm::tlm_generic_payload &trans)
static sc_time from_value(sc_dt::uint64)
bool is_response_error() const
std::string get_response_string() const
void peq_cb(tlm::tlm_generic_payload &trans, const tlm::tlm_phase &phase)
unsigned char * get_data_ptr() const
bool isAtomicMode() const
Is the system in atomic mode?
bool needsResponse() const
uint32_t headerDelay
The extra delay from seeing the packet until the header is transmitted.
TlmToGem5Bridge(Params *p, const sc_core::sc_module_name &mn)
void destroyPacket(PacketPtr pkt)
uint64_t Tick
Tick count type.
unsigned int get_data_length() const
Addr end() const
Get the end address of the range.
::Port & gem5_getPort(const std::string &if_name, int idx=-1) override
void set_granted_access(dmi_access_e a)
const AddrRange & range() const
uint32_t payloadDelay
The extra pipelining delay from seeing the packet until the end of payload is transmitted by the comp...
unsigned int get_streaming_width() const
A Packet is used to encapsulate a transfer between two objects in the memory system (e...
TlmToGem5BridgeBaseParams Params
The request should not cause a memory access.
const sc_time SC_ZERO_TIME
void set_dmi_allowed(bool dmi_allowed)
void checkTransaction(tlm::tlm_generic_payload &trans)
void invalidateDmi(const ::MemBackdoor &backdoor)
tlm_command get_command() const
virtual ::Port & gem5_getPort(const std::string &if_name, int idx=-1)
tlm_utils::simple_target_socket< TlmToGem5Bridge< BITWIDTH >, BITWIDTH > socket
bool isPipeThrough() const
#define SC_REPORT_ERROR(msg_type, msg)
void before_end_of_elaboration() override
void pushSenderState(SenderState *sender_state)
Push a new sender state to the packet and make the current sender state the predecessor of the new on...
Addr start() const
Get the start address of the range.
SenderState * popSenderState()
Pop the top of the state stack and return a pointer to it.
PacketPtr payload2packet(MasterID masterId, tlm::tlm_generic_payload &trans)
#define SC_REPORT_FATAL(msg_type, msg)
void set_end_address(sc_dt::uint64 addr)
bool isTimingMode() const
Is the system in timing mode?
#define panic_if(cond,...)
Conditional panic macro that checks the supplied condition and only panics if the condition is true a...
void handleEndResp(tlm::tlm_generic_payload &trans)
ProbePointArg< PacketInfo > Packet
Packet probe point.
virtual void before_end_of_elaboration()