60 #include "params/TlmToGem5Bridge32.hh" 61 #include "params/TlmToGem5Bridge64.hh" 85 "received transaction with unsupported command");
89 auto req = std::make_shared<Request>(
96 auto pkt =
new Packet(req, cmd);
102 template <
unsigned int BITWIDTH>
109 auto status = socket->nb_transport_bw(trans, phase, delay);
111 "Unexpected status after sending END_REQ");
114 template <
unsigned int BITWIDTH>
123 auto status = socket->nb_transport_bw(trans, phase, delay);
128 responseInProgress =
false;
131 responseInProgress =
true;
133 panic(
"Unexpected status after sending BEGIN_RESP");
137 template <
unsigned int BITWIDTH>
155 if (extension !=
nullptr) {
165 if (bmp.sendTimingReq(pkt)) {
170 pendingRequest = &trans;
175 template <
unsigned int BITWIDTH>
181 responseInProgress =
false;
183 checkTransaction(trans);
185 if (needToSendRetry) {
187 needToSendRetry =
false;
191 template <
unsigned int BITWIDTH>
198 template <
unsigned int BITWIDTH>
203 std::stringstream
ss;
204 ss <<
"Transaction returned with error, response status = " 210 template <
unsigned int BITWIDTH>
214 socket->invalidate_direct_mem_ptr(
215 backdoor.range().start(), backdoor.range().end());
218 template <
unsigned int BITWIDTH>
225 handleBeginReq(trans);
228 handleEndResp(trans);
231 panic(
"unimplemented phase in callback");
235 template <
unsigned int BITWIDTH>
246 if (byteEnable != 0) {
257 peq.notify(trans, phase, delay);
261 template <
unsigned int BITWIDTH>
273 if (extension !=
nullptr) {
281 Tick ticks = bmp.sendAtomicBackdoor(pkt, backdoor);
287 "Packet sending failed!\n");
295 if (extension ==
nullptr)
301 template <
unsigned int BITWIDTH>
310 if (extension !=
nullptr) {
312 bmp.sendFunctional(extension->
getPacket());
316 bmp.sendFunctional(pkt);
324 template <
unsigned int BITWIDTH>
336 if (extension !=
nullptr) {
345 bmp.sendAtomicBackdoor(pkt, backdoor);
363 invalidateDmi(backdoor);
368 if (extension ==
nullptr)
373 return backdoor !=
nullptr;
376 template <
unsigned int BITWIDTH>
382 if (responseInProgress) {
384 needToSendRetry =
true;
403 auto &trans = tlmSenderState->trans;
406 trans.get_extension(extension);
409 delete tlmSenderState;
413 if (extension ==
nullptr)
418 sendBeginResp(trans, delay);
424 template <
unsigned int BITWIDTH>
432 if (bmp.sendTimingReq(pendingPacket)) {
433 waitForRetry =
false;
434 pendingPacket =
nullptr;
436 auto &trans = *pendingRequest;
440 pendingRequest =
nullptr;
444 template <
unsigned int BITWIDTH>
449 "received address range change but ignored it");
452 template <
unsigned int BITWIDTH>
456 if (if_name ==
"gem5")
458 else if (if_name ==
"tlm")
464 template <
unsigned int BITWIDTH>
468 waitForRetry(false), pendingRequest(nullptr), pendingPacket(nullptr),
469 needToSendRetry(false), responseInProgress(false),
470 bmp(
std::string(
name()) +
"master", *this), socket(
"tlm_socket"),
473 masterId(params->
system->getGlobalMasterId(
474 std::string(
"[systemc].") +
name()))
478 template <
unsigned int BITWIDTH>
491 SC_REPORT_INFO(
"TlmToGem5Bridge",
"register non-blocking interface");
492 socket.register_nb_transport_fw(
496 socket.register_b_transport(
498 socket.register_get_direct_mem_ptr(
501 panic(
"gem5 operates neither in Timing nor in Atomic mode");
504 socket.register_transport_dbg(
513 TlmToGem5Bridge32Params::create()
520 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
const sc_time SC_ZERO_TIME
The request should not cause a memory access.
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()