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

Change subject: systemc: Implement port binding policies.
......................................................................

systemc: Implement port binding policies.

Change-Id: I585e34c4a666103af16ff1675701b61122822b55
Reviewed-on: https://gem5-review.googlesource.com/c/13299
Reviewed-by: Gabe Black <[email protected]>
Maintainer: Gabe Black <[email protected]>
---
M src/systemc/core/port.cc
M src/systemc/ext/core/sc_port.hh
A src/systemc/tests/systemc/communication/sc_port_policy/test03/expected_returncode A src/systemc/tests/systemc/communication/sc_port_policy/test04/expected_returncode
4 files changed, 27 insertions(+), 0 deletions(-)

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



diff --git a/src/systemc/core/port.cc b/src/systemc/core/port.cc
index b7120ef..c1d77d9 100644
--- a/src/systemc/core/port.cc
+++ b/src/systemc/core/port.cc
@@ -29,6 +29,7 @@

 #include "systemc/core/port.hh"

+#include "base/logging.hh"
 #include "systemc/core/process.hh"
 #include "systemc/core/sensitivity.hh"
 #include "systemc/ext/channel/sc_signal_in_if.hh"
@@ -123,6 +124,27 @@
         finalizeReset(r);

     resets.clear();
+
+    switch (portBase->_portPolicy()) {
+      case sc_core::SC_ONE_OR_MORE_BOUND:
+        if (size() == 0)
+            portBase->report_error(
+                    "(E109) complete binding failed", "port not bound");
+        break;
+      case sc_core::SC_ALL_BOUND:
+        if (size() < maxSize() || size() < 1) {
+            std::stringstream ss;
+            ss << size() << " actual binds is less than required " <<
+                maxSize();
+            portBase->report_error(
+                    "(E109) complete binding failed", ss.str().c_str());
+        }
+        break;
+      case sc_core::SC_ZERO_OR_MORE_BOUND:
+        break;
+      default:
+        panic("Unrecognized port policy %d.", portBase->_portPolicy());
+    }
 }

 void
diff --git a/src/systemc/ext/core/sc_port.hh b/src/systemc/ext/core/sc_port.hh
index 915b11f..aa9a322 100644
--- a/src/systemc/ext/core/sc_port.hh
+++ b/src/systemc/ext/core/sc_port.hh
@@ -112,6 +112,7 @@

     ::sc_gem5::Port *_gem5Port;
     virtual const char *_ifTypeName() const = 0;
+    virtual sc_port_policy _portPolicy() const = 0;
 };

 template <class IF>
@@ -299,6 +300,8 @@
     // Disabled
     sc_port(const sc_port<IF, N, P> &) {}
sc_port<IF, N, P> &operator = (const sc_port<IF, N, P> &) { return *this; }
+
+    virtual sc_port_policy _portPolicy() const { return P; }
 };

 } // namespace sc_core
diff --git a/src/systemc/tests/systemc/communication/sc_port_policy/test03/expected_returncode b/src/systemc/tests/systemc/communication/sc_port_policy/test03/expected_returncode
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/src/systemc/tests/systemc/communication/sc_port_policy/test03/expected_returncode
@@ -0,0 +1 @@
+1
diff --git a/src/systemc/tests/systemc/communication/sc_port_policy/test04/expected_returncode b/src/systemc/tests/systemc/communication/sc_port_policy/test04/expected_returncode
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/src/systemc/tests/systemc/communication/sc_port_policy/test04/expected_returncode
@@ -0,0 +1 @@
+1

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/13299
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: I585e34c4a666103af16ff1675701b61122822b55
Gerrit-Change-Number: 13299
Gerrit-PatchSet: 4
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