Yu-hsin Wang has uploaded this change for review. ( 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
---
M src/systemc/tlm_bridge/sc_ext.cc
M src/systemc/tlm_bridge/sc_ext.hh
2 files changed, 71 insertions(+), 0 deletions(-)



diff --git a/src/systemc/tlm_bridge/sc_ext.cc b/src/systemc/tlm_bridge/sc_ext.cc
index 194ecbc..55e303b 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)
+  : amo_op(_amo_op), need_return(_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 &cpyFrom = static_cast<const AtomicExtension &>(ext);
+    *this = cpyFrom;
+}
+
+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 need_return;
+}
+
+AtomicOpFunctor*
+AtomicExtension::getAtomicOpFunctor() const
+{
+    return amo_op.get();
+}
+
 } // namespace Gem5SystemC
diff --git a/src/systemc/tlm_bridge/sc_ext.hh b/src/systemc/tlm_bridge/sc_ext.hh
index 56a19a77..aea14ae 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> amo_op;
+    bool need_return;
+};
+
 } // namespace Gem5SystemC

 #endif // __SYSTEMC_TLM_BRIDGE_SC_EXT_HH__

--
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: 1
Gerrit-Owner: Yu-hsin Wang <[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