From 90046bae6f14b4bf94fc450efc617614b9214f92 Mon Sep 17 00:00:00 2001 From: handsomeliu Date: Tue, 8 Nov 2022 15:39:28 +0800 Subject: [PATCH] systemc: Add the stream id entry and its conversion in control extension stream id and substream id are properties of gem5 Request. This CL adds the information into gem5 ControlExtension to manipulate them in SystemC level, and adds the conversion between ControlExtension and Packet. Change-Id: Id13d181561ba496c2012f7237eb800f0a9786d05 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/65371 Maintainer: Bobby Bruce Tested-by: kokoro Reviewed-by: Yu-hsin Wang --- src/systemc/tlm_bridge/sc_ext.cc | 54 +++++++++++++++++++++++++++++++- src/systemc/tlm_bridge/sc_ext.hh | 13 ++++++++ 2 files changed, 66 insertions(+), 1 deletion(-) diff --git a/src/systemc/tlm_bridge/sc_ext.cc b/src/systemc/tlm_bridge/sc_ext.cc index 4d12fb3d9f..6e3cf113d3 100644 --- a/src/systemc/tlm_bridge/sc_ext.cc +++ b/src/systemc/tlm_bridge/sc_ext.cc @@ -33,6 +33,8 @@ #include "systemc/tlm_bridge/sc_ext.hh" +#include + #include "systemc/ext/utils/sc_report_handler.hh" #include "systemc/tlm_bridge/gem5_to_tlm.hh" #include "systemc/tlm_bridge/tlm_to_gem5.hh" @@ -76,6 +78,14 @@ struct ControlConversionRegister } pkt->qosValue(control_ex->getQos()); + + if (control_ex->hasStreamId()) { + pkt->req->setStreamId(control_ex->getStreamId().value()); + } + if (control_ex->hasSubstreamId()) { + pkt->req->setSubstreamId( + control_ex->getSubstreamId().value()); + } }); sc_gem5::addPacketToPayloadConversionStep( [] (PacketPtr pkt, tlm::tlm_generic_payload &trans) @@ -90,6 +100,12 @@ struct ControlConversionRegister control_ex->setSecure(pkt->req->isSecure()); control_ex->setInstruction(pkt->req->isInstFetch()); control_ex->setQos(pkt->qosValue()); + if (pkt->req->hasStreamId()) { + control_ex->setStreamId(pkt->req->streamId()); + } + if (pkt->req->hasSubstreamId()) { + control_ex->setSubstreamId(pkt->req->substreamId()); + } }); } }; @@ -263,4 +279,40 @@ ControlExtension::setQos(uint8_t q) qos = q; } -} // namespace Gem5SystemC +bool +ControlExtension::hasStreamId() const +{ + return stream_id.has_value(); +} + +std::optional +ControlExtension::getStreamId() const +{ + return stream_id; +} + +void +ControlExtension::setStreamId(std::optional s) +{ + stream_id = std::move(s); +} + +bool +ControlExtension::hasSubstreamId() const +{ + return substream_id.has_value(); +} + +std::optional +ControlExtension::getSubstreamId() const +{ + return substream_id; +} + +void +ControlExtension::setSubstreamId(std::optional s) +{ + substream_id = std::move(s); +} + +} // namespace Gem5SystemC diff --git a/src/systemc/tlm_bridge/sc_ext.hh b/src/systemc/tlm_bridge/sc_ext.hh index bb676761ce..f23f3fa54d 100644 --- a/src/systemc/tlm_bridge/sc_ext.hh +++ b/src/systemc/tlm_bridge/sc_ext.hh @@ -36,6 +36,7 @@ #include #include +#include #include "base/amo.hh" #include "mem/packet.hh" @@ -115,6 +116,14 @@ class ControlExtension : public tlm::tlm_extension uint8_t getQos() const; void setQos(uint8_t q); + /* Stream ID and Substream ID */ + bool hasStreamId() const; + std::optional getStreamId() const; + void setStreamId(std::optional s); + bool hasSubstreamId() const; + std::optional getSubstreamId() const; + void setSubstreamId(std::optional s); + private: /* Secure and privileged access */ bool privileged; @@ -123,6 +132,10 @@ class ControlExtension : public tlm::tlm_extension /* Quality of Service (AXI4) */ uint8_t qos; + + /* Stream ID and Substream ID */ + std::optional stream_id; + std::optional substream_id; }; } // namespace Gem5SystemC