Jui-min Lee has uploaded this change for review. ( https://gem5-review.googlesource.com/c/public/gem5/+/44305 )

Change subject: systemc: Use peq in Gem5ToTlmBridge
......................................................................

systemc: Use peq in Gem5ToTlmBridge

Old implementation utilize gem5's scheduling function to handle tlm2
transaction delay; however, the behavior of gem5 event queue is slightly
different from the SystemC peq and will cause error in extreme case.
i.e. when END_REQ and BEGIN_RESP occurs at the same time.

In this CL we add a peq into the bridge and use it to properly handle
the phase change and delay of tlm2 transaction.

Change-Id: Ic33a92162c8c53af3887c7b04090115a38f96866
---
M src/systemc/tlm_bridge/gem5_to_tlm.cc
M src/systemc/tlm_bridge/gem5_to_tlm.hh
2 files changed, 7 insertions(+), 7 deletions(-)



diff --git a/src/systemc/tlm_bridge/gem5_to_tlm.cc b/src/systemc/tlm_bridge/gem5_to_tlm.cc
index b80a083..e66534e 100644
--- a/src/systemc/tlm_bridge/gem5_to_tlm.cc
+++ b/src/systemc/tlm_bridge/gem5_to_tlm.cc
@@ -366,9 +366,7 @@
         sc_assert(phase == tlm::END_REQ || phase == tlm::BEGIN_RESP);
         // Accepted but is now blocking until END_REQ (exclusion rule).
         blockingRequest = trans;
-        auto cb = [this, trans, phase]() { pec(*trans, phase); };
-        system->schedule(new EventFunctionWrapper(cb, "pec", true),
-                         curTick() + delay.value());
+        peq.notify(*trans, phase, delay);
     } else if (status == tlm::TLM_COMPLETED) {
         // Transaction is over nothing has do be done.
         sc_assert(phase == tlm::END_RESP);
@@ -441,9 +439,7 @@
 Gem5ToTlmBridge<BITWIDTH>::nb_transport_bw(tlm::tlm_generic_payload &trans,
     tlm::tlm_phase &phase, sc_core::sc_time &delay)
 {
-    auto cb = [this, &trans, phase]() { pec(trans, phase); };
-    system->schedule(new EventFunctionWrapper(cb, "pec", true),
-                     curTick() + delay.value());
+    peq.notify(trans, phase, delay);
     return tlm::TLM_ACCEPTED;
 }

@@ -472,7 +468,9 @@
     bridgeResponsePort(std::string(name()) + ".gem5", *this),
     socket("tlm_socket"),
     wrapper(socket, std::string(name()) + ".tlm", InvalidPortID),
-    system(params.system), blockingRequest(nullptr),
+    system(params.system),
+    peq(this, &Gem5ToTlmBridge::pec),
+    blockingRequest(nullptr),
     needToSendRequestRetry(false), blockingResponse(nullptr),
     addrRanges(params.addr_ranges.begin(), params.addr_ranges.end())
 {
diff --git a/src/systemc/tlm_bridge/gem5_to_tlm.hh b/src/systemc/tlm_bridge/gem5_to_tlm.hh
index d29bfd7..10a7253 100644
--- a/src/systemc/tlm_bridge/gem5_to_tlm.hh
+++ b/src/systemc/tlm_bridge/gem5_to_tlm.hh
@@ -68,6 +68,7 @@
 #include "systemc/ext/core/sc_module.hh"
 #include "systemc/ext/core/sc_module_name.hh"
 #include "systemc/ext/tlm_core/2/generic_payload/gp.hh"
+#include "systemc/ext/tlm_utils/peq_with_cb_and_phase.h"
 #include "systemc/ext/tlm_utils/simple_initiator_socket.h"
 #include "systemc/tlm_port_wrapper.hh"

@@ -146,6 +147,7 @@
     sc_gem5::TlmInitiatorWrapper<BITWIDTH> wrapper;

     System *system;
+    tlm_utils::peq_with_cb_and_phase<Gem5ToTlmBridge<BITWIDTH>> peq;

     /**
* A transaction after BEGIN_REQ has been sent but before END_REQ, which

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/44305
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: Ic33a92162c8c53af3887c7b04090115a38f96866
Gerrit-Change-Number: 44305
Gerrit-PatchSet: 1
Gerrit-Owner: Jui-min Lee <[email protected]>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

Reply via email to