Gabe Black has submitted this change and it was merged. ( https://gem5-review.googlesource.com/c/public/gem5/+/12804 )

Change subject: systemc: Implement sc_buffer.
......................................................................

systemc: Implement sc_buffer.

This required a small change to sc_signal so that the value change
event and the change stamp for it were accessible.

Change-Id: Ife0545d84f3b25e98da079786c30ffa51025cce7
Reviewed-on: https://gem5-review.googlesource.com/c/12804
Reviewed-by: Gabe Black <[email protected]>
Maintainer: Gabe Black <[email protected]>
---
M src/systemc/ext/channel/sc_buffer.hh
M src/systemc/ext/channel/sc_signal.hh
2 files changed, 42 insertions(+), 18 deletions(-)

Approvals:
  Gabe Black: Looks good to me, approved; Looks good to me, approved



diff --git a/src/systemc/ext/channel/sc_buffer.hh b/src/systemc/ext/channel/sc_buffer.hh
index 2208160..21dc52b 100644
--- a/src/systemc/ext/channel/sc_buffer.hh
+++ b/src/systemc/ext/channel/sc_buffer.hh
@@ -32,7 +32,6 @@

 #include "../core/sc_module.hh" // for sc_gen_unique_name
 #include "sc_signal.hh"
-#include "warn_unimpl.hh" // for warn_unimpl

 namespace sc_core
 {
@@ -49,27 +48,28 @@
     {}

     virtual void
-    write(const T&)
+    write(const T &t)
     {
-        sc_channel_warn_unimpl(__PRETTY_FUNCTION__);
+        this->m_new_val = t;
+        this->request_update();
     }

     sc_buffer<T, WRITER_POLICY> &
-    operator = (const T &)
+    operator = (const T &arg)
     {
-        sc_channel_warn_unimpl(__PRETTY_FUNCTION__);
+        write(arg);
         return *this;
     }
     sc_buffer<T, WRITER_POLICY> &
-    operator = (const sc_signal<T, WRITER_POLICY> &)
+    operator = (const sc_signal<T, WRITER_POLICY> &arg)
     {
-        sc_channel_warn_unimpl(__PRETTY_FUNCTION__);
+        write(arg.read());
         return *this;
     }
     sc_buffer<T, WRITER_POLICY> &
-    operator = (const sc_buffer<T, WRITER_POLICY> &)
+    operator = (const sc_buffer<T, WRITER_POLICY> &arg)
     {
-        sc_channel_warn_unimpl(__PRETTY_FUNCTION__);
+        write(arg.read());
         return *this;
     }

@@ -79,7 +79,8 @@
     virtual void
     update()
     {
-        sc_channel_warn_unimpl(__PRETTY_FUNCTION__);
+        this->m_cur_val = this->m_new_val;
+        this->_signalChange();
     }

   private:
diff --git a/src/systemc/ext/channel/sc_signal.hh b/src/systemc/ext/channel/sc_signal.hh
index 022bd33..bbe2d01 100644
--- a/src/systemc/ext/channel/sc_signal.hh
+++ b/src/systemc/ext/channel/sc_signal.hh
@@ -151,6 +151,14 @@
             return;

         m_cur_val = m_new_val;
+        _signalChange();
+        _changeStamp = ::sc_gem5::getChangeStamp();
+        _valueChangedEvent.notify(SC_ZERO_TIME);
+    }
+
+    void
+    _signalChange()
+    {
         _changeStamp = ::sc_gem5::getChangeStamp();
         _valueChangedEvent.notify(SC_ZERO_TIME);
     }
@@ -293,18 +301,23 @@
             return;

         m_cur_val = m_new_val;
-        uint64_t change_stamp = ::sc_gem5::getChangeStamp();
-        _changeStamp = change_stamp;
-        _valueChangedEvent.notify(SC_ZERO_TIME);
+        _signalChange();
         if (m_cur_val) {
-            _posStamp = change_stamp;
+            _posStamp = ::sc_gem5::getChangeStamp();
             _posedgeEvent.notify(SC_ZERO_TIME);
         } else {
-            _negStamp = change_stamp;
+            _negStamp = ::sc_gem5::getChangeStamp();
             _negedgeEvent.notify(SC_ZERO_TIME);
         }
     }

+    void
+    _signalChange()
+    {
+        _changeStamp = ::sc_gem5::getChangeStamp();
+        _valueChangedEvent.notify(SC_ZERO_TIME);
+    }
+
     bool m_cur_val;
     bool m_new_val;

@@ -438,11 +451,21 @@
             return;

         m_cur_val = m_new_val;
-        _valueChangedEvent.notify(SC_ZERO_TIME);
-        if (m_cur_val == sc_dt::SC_LOGIC_1)
+        _signalChange();
+        if (m_cur_val == sc_dt::SC_LOGIC_1) {
+            _posStamp = ::sc_gem5::getChangeStamp();
             _posedgeEvent.notify(SC_ZERO_TIME);
-        else if (m_cur_val == sc_dt::SC_LOGIC_0)
+        } else if (m_cur_val == sc_dt::SC_LOGIC_0) {
+            _negStamp = ::sc_gem5::getChangeStamp();
             _negedgeEvent.notify(SC_ZERO_TIME);
+        }
+    }
+
+    void
+    _signalChange()
+    {
+        _changeStamp = ::sc_gem5::getChangeStamp();
+        _valueChangedEvent.notify(SC_ZERO_TIME);
     }

     sc_dt::sc_logic m_cur_val;

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

Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-Change-Id: Ife0545d84f3b25e98da079786c30ffa51025cce7
Gerrit-Change-Number: 12804
Gerrit-PatchSet: 6
Gerrit-Owner: Gabe Black <[email protected]>
Gerrit-Reviewer: Andreas Sandberg <[email protected]>
Gerrit-Reviewer: Gabe Black <[email protected]>
Gerrit-Reviewer: Giacomo Travaglini <[email protected]>
Gerrit-Reviewer: Jason Lowe-Power <[email protected]>
Gerrit-Reviewer: Matthias Jung <[email protected]>
Gerrit-MessageType: merged
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to