Yu-hsin Wang has submitted this change. ( https://gem5-review.googlesource.com/c/public/gem5/+/44525 )

Change subject: systemc: define atomic extension
......................................................................

systemc: define atomic extension

Gem5 defines several types of memory access including normal read,
normal write, atomic operations. For now we only support normal read
and normal write converting from SystemC via TLM2. To support atomic
operations from SystemC, we add an atomic extension. A SystemC model can
fire a atomic request with the extension.

The extension mainly has two attributes. One is a AtomicOpFunctor which
is the implementation of the atomic operation. The other one is bool
which indicates the gem5 request flag should be ATOMIC_RETURN_OP or
ATOMIC_NO_RETURN_OP.

Change-Id: I817727dd4b2d357667f928063210c58a44c81afb
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/44525
Tested-by: kokoro <[email protected]>
Reviewed-by: Gabe Black <[email protected]>
Maintainer: Gabe Black <[email protected]>
---
M src/systemc/tlm_bridge/sc_ext.cc
M src/systemc/tlm_bridge/sc_ext.hh
2 files changed, 71 insertions(+), 0 deletions(-)

Approvals:
  Gabe Black: Looks good to me, approved; Looks good to me, approved
  kokoro: Regressions pass



diff --git a/src/systemc/tlm_bridge/sc_ext.cc b/src/systemc/tlm_bridge/sc_ext.cc
index 194ecbc..18591d5 100644
--- a/src/systemc/tlm_bridge/sc_ext.cc
+++ b/src/systemc/tlm_bridge/sc_ext.cc
@@ -77,4 +77,50 @@
     packet = cpyFrom.packet;
 }

+AtomicExtension::AtomicExtension(
+    std::shared_ptr<AtomicOpFunctor> amo_op, bool need_return)
+  : _op(amo_op), _needReturn(need_return)
+{
+}
+
+tlm::tlm_extension_base *
+AtomicExtension::clone() const
+{
+    return new AtomicExtension(*this);
+}
+
+void
+AtomicExtension::copy_from(const tlm::tlm_extension_base &ext)
+{
+ const AtomicExtension &from = static_cast<const AtomicExtension &>(ext);
+    *this = from;
+}
+
+AtomicExtension &
+AtomicExtension::getExtension(const tlm::tlm_generic_payload &payload)
+{
+    return AtomicExtension::getExtension(&payload);
+}
+
+AtomicExtension &
+AtomicExtension::getExtension(const tlm::tlm_generic_payload *payload)
+{
+    AtomicExtension *result = nullptr;
+    payload->get_extension(result);
+    sc_assert(result);
+    return *result;
+}
+
+bool
+AtomicExtension::needReturn() const
+{
+    return _needReturn;
+}
+
+AtomicOpFunctor*
+AtomicExtension::getAtomicOpFunctor() const
+{
+    return _op.get();
+}
+
 } // namespace Gem5SystemC
diff --git a/src/systemc/tlm_bridge/sc_ext.hh b/src/systemc/tlm_bridge/sc_ext.hh
index 56a19a77..0cdf195 100644
--- a/src/systemc/tlm_bridge/sc_ext.hh
+++ b/src/systemc/tlm_bridge/sc_ext.hh
@@ -34,6 +34,9 @@
 #ifndef __SYSTEMC_TLM_BRIDGE_SC_EXT_HH__
 #define __SYSTEMC_TLM_BRIDGE_SC_EXT_HH__

+#include <memory>
+
+#include "base/amo.hh"
 #include "mem/packet.hh"
 #include "systemc/ext/tlm_core/2/generic_payload/gp.hh"

@@ -58,6 +61,28 @@
     PacketPtr packet;
 };

+class AtomicExtension: public tlm::tlm_extension<AtomicExtension>
+{
+  public:
+    AtomicExtension(
+        std::shared_ptr<AtomicOpFunctor> amo_op, bool need_return);
+
+    virtual tlm_extension_base *clone() const;
+    virtual void copy_from(const tlm_extension_base &ext);
+
+    static AtomicExtension &getExtension(
+            const tlm::tlm_generic_payload *payload);
+    static AtomicExtension &getExtension(
+            const tlm::tlm_generic_payload &payload);
+
+    bool needReturn() const;
+    AtomicOpFunctor* getAtomicOpFunctor() const;
+
+  private:
+    std::shared_ptr<AtomicOpFunctor> _op;
+    bool _needReturn;
+};
+
 } // namespace Gem5SystemC

 #endif // __SYSTEMC_TLM_BRIDGE_SC_EXT_HH__



4 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the submitted one.
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/44525
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: I817727dd4b2d357667f928063210c58a44c81afb
Gerrit-Change-Number: 44525
Gerrit-PatchSet: 6
Gerrit-Owner: Yu-hsin Wang <[email protected]>
Gerrit-Reviewer: Earl Ou <[email protected]>
Gerrit-Reviewer: Gabe Black <[email protected]>
Gerrit-Reviewer: Gabe Black <[email protected]>
Gerrit-Reviewer: Yu-hsin Wang <[email protected]>
Gerrit-Reviewer: kokoro <[email protected]>
Gerrit-CC: Philip Metzler <[email protected]>
Gerrit-MessageType: merged
_______________________________________________
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