From: Earl Ou Date: Wed, 11 Nov 2020 06:22:02 +0000 (+0800) Subject: systemc: remove pipe through flag in TLM extension X-Git-Tag: develop-gem5-snapshot~232 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=fa4be29d1749d2fb2fff72ef949d14bf400fd970;p=gem5.git systemc: remove pipe through flag in TLM extension Pipe through flag should be equal to whether we have the extension in TLM payload or not. However, in the current implementation the two are different and cause issues when we have gem5 - SystemC connection. Change-Id: I2c318777d91dca446c1a700d9f7cff356d29ae6d Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/37375 Reviewed-by: Earl Ou Maintainer: Earl Ou Tested-by: kokoro --- diff --git a/src/systemc/tlm_bridge/gem5_to_tlm.cc b/src/systemc/tlm_bridge/gem5_to_tlm.cc index f03548ced..9d108761b 100644 --- a/src/systemc/tlm_bridge/gem5_to_tlm.cc +++ b/src/systemc/tlm_bridge/gem5_to_tlm.cc @@ -167,18 +167,14 @@ Gem5ToTlmBridge::pec( bool need_retry = false; - /* - * If the packet was piped through and needs a response, we don't need - * to touch the packet and can forward it directly as a response. - * Otherwise, we need to make a response and send the transformed - * packet. - */ - if (extension.isPipeThrough()) { - if (packet->isResponse()) { - need_retry = !bridgeResponsePort.sendTimingResp(packet); - } - } else if (packet->needsResponse()) { + // If there is another gem5 model under the receiver side, and already + // make a response packet back, we can simply send it back. Otherwise, + // we make a response packet before sending it back to the initiator + // side gem5 module. + if (packet->needsResponse()) { packet->makeResponse(); + } + if (packet->isResponse()) { need_retry = !bridgeResponsePort.sendTimingResp(packet); } diff --git a/src/systemc/tlm_bridge/sc_ext.cc b/src/systemc/tlm_bridge/sc_ext.cc index ea188c472..194ecbc05 100644 --- a/src/systemc/tlm_bridge/sc_ext.cc +++ b/src/systemc/tlm_bridge/sc_ext.cc @@ -41,7 +41,6 @@ namespace Gem5SystemC Gem5Extension::Gem5Extension(PacketPtr _packet) { packet = _packet; - pipeThrough = false; } Gem5Extension & diff --git a/src/systemc/tlm_bridge/sc_ext.hh b/src/systemc/tlm_bridge/sc_ext.hh index 0d9fc9101..56a19a772 100644 --- a/src/systemc/tlm_bridge/sc_ext.hh +++ b/src/systemc/tlm_bridge/sc_ext.hh @@ -54,12 +54,8 @@ class Gem5Extension: public tlm::tlm_extension const tlm::tlm_generic_payload &payload); PacketPtr getPacket(); - bool isPipeThrough() const { return pipeThrough; } - void setPipeThrough() { pipeThrough = true; } - private: PacketPtr packet; - bool pipeThrough; }; } // namespace Gem5SystemC diff --git a/src/systemc/tlm_bridge/tlm_to_gem5.cc b/src/systemc/tlm_bridge/tlm_to_gem5.cc index a1a8382cd..143eeacae 100644 --- a/src/systemc/tlm_bridge/tlm_to_gem5.cc +++ b/src/systemc/tlm_bridge/tlm_to_gem5.cc @@ -181,7 +181,6 @@ TlmToGem5Bridge::handleBeginReq(tlm::tlm_generic_payload &trans) // world and we can pipe through the original packet. Otherwise, we // generate a new packet based on the transaction. if (extension != nullptr) { - extension->setPipeThrough(); pkt = extension->getPacket(); } else { pkt = payload2packet(_id, trans); @@ -306,7 +305,6 @@ TlmToGem5Bridge::b_transport(tlm::tlm_generic_payload &trans, // If there is an extension, this transaction was initiated by the gem5 // world and we can pipe through the original packet. if (extension != nullptr) { - extension->setPipeThrough(); pkt = extension->getPacket(); } else { pkt = payload2packet(_id, trans); @@ -343,7 +341,6 @@ TlmToGem5Bridge::transport_dbg(tlm::tlm_generic_payload &trans) // If there is an extension, this transaction was initiated by the gem5 // world and we can pipe through the original packet. if (extension != nullptr) { - extension->setPipeThrough(); bmp.sendFunctional(extension->getPacket()); } else { auto pkt = payload2packet(_id, trans); @@ -369,7 +366,6 @@ TlmToGem5Bridge::get_direct_mem_ptr(tlm::tlm_generic_payload &trans, // If there is an extension, this transaction was initiated by the gem5 // world and we can pipe through the original packet. if (extension != nullptr) { - extension->setPipeThrough(); pkt = extension->getPacket(); } else { pkt = payload2packet(_id, trans); @@ -447,8 +443,6 @@ TlmToGem5Bridge::recvTimingResp(PacketPtr pkt) // delete it. The packet travels back with the transaction. if (extension == nullptr) destroyPacket(pkt); - else - sc_assert(extension->isPipeThrough()); sendBeginResp(trans, delay); trans.release(); diff --git a/util/tlm/src/sc_ext.cc b/util/tlm/src/sc_ext.cc index 5e45ed9f6..fb9613fa0 100644 --- a/util/tlm/src/sc_ext.cc +++ b/util/tlm/src/sc_ext.cc @@ -41,7 +41,6 @@ namespace Gem5SystemC Gem5Extension::Gem5Extension(PacketPtr packet) { Packet = packet; - pipeThrough = false; } Gem5Extension& Gem5Extension::getExtension(const tlm_generic_payload *payload) diff --git a/util/tlm/src/sc_ext.hh b/util/tlm/src/sc_ext.hh index 18221de26..b37020899 100644 --- a/util/tlm/src/sc_ext.hh +++ b/util/tlm/src/sc_ext.hh @@ -58,12 +58,8 @@ class Gem5Extension: public tlm::tlm_extension getExtension(const tlm::tlm_generic_payload &payload); PacketPtr getPacket(); - bool isPipeThrough() const { return pipeThrough; } - void setPipeThrough() { pipeThrough = true; } - private: PacketPtr Packet; - bool pipeThrough; }; } diff --git a/util/tlm/src/sc_master_port.cc b/util/tlm/src/sc_master_port.cc index 0008e9bed..7b04921de 100644 --- a/util/tlm/src/sc_master_port.cc +++ b/util/tlm/src/sc_master_port.cc @@ -206,7 +206,6 @@ SCMasterPort::handleBeginReq(tlm::tlm_generic_payload& trans) // world and we can pipe through the original packet. Otherwise, we // generate a new packet based on the transaction. if (extension != nullptr) { - extension->setPipeThrough(); pkt = extension->getPacket(); } else { pkt = generatePacket(trans); @@ -263,7 +262,6 @@ SCMasterPort::b_transport(tlm::tlm_generic_payload& trans, // If there is an extension, this transaction was initiated by the gem5 // world and we can pipe through the original packet. if (extension != nullptr) { - extension->setPipeThrough(); pkt = extension->getPacket(); } else { pkt = generatePacket(trans); @@ -297,7 +295,6 @@ SCMasterPort::transport_dbg(tlm::tlm_generic_payload& trans) // If there is an extension, this transaction was initiated by the gem5 // world and we can pipe through the original packet. if (extension != nullptr) { - extension->setPipeThrough(); sendFunctional(extension->getPacket()); } else { auto pkt = generatePacket(trans); @@ -353,8 +350,6 @@ SCMasterPort::recvTimingResp(PacketPtr pkt) // delete it. The packet travels back with the transaction. if (extension == nullptr) destroyPacket(pkt); - else - sc_assert(extension->isPipeThrough()); sendBeginResp(trans, delay); trans.release(); diff --git a/util/tlm/src/sc_slave_port.cc b/util/tlm/src/sc_slave_port.cc index a3b878349..58b01345b 100644 --- a/util/tlm/src/sc_slave_port.cc +++ b/util/tlm/src/sc_slave_port.cc @@ -293,19 +293,15 @@ SCSlavePort::pec( bool need_retry = false; - /* - * If the packet was piped through and needs a response, we don't need - * to touch the packet and can forward it directly as a response. - * Otherwise, we need to make a response and send the transformed - * packet. - */ - if (extension.isPipeThrough()) { - if (packet->isResponse()) { - need_retry = !sendTimingResp(packet); - } - } else if (packet->needsResponse()) { + // If there is another gem5 model under the receiver side, and already + // make a response packet back, we can simply send it back. Otherwise, + // we make a response packet before sending it back to the initiator + // side gem5 module. + if (packet->needsResponse()) { packet->makeResponse(); - need_retry = !sendTimingResp(packet); + } + if (packet->isResponse()) { + need_retry = !bridgeResponsePort.sendTimingResp(packet); } if (need_retry) {