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

Change subject: systemc: Add an error check whether an interface is alread bound to a port.
......................................................................

systemc: Add an error check whether an interface is alread bound to a port.

Change-Id: I06e3484176c0c06daa28f7be0ed8437b3b15ddb2
Reviewed-on: https://gem5-review.googlesource.com/c/12816
Reviewed-by: Gabe Black <[email protected]>
Maintainer: Gabe Black <[email protected]>
---
M src/systemc/core/port.hh
A src/systemc/tests/systemc/communication/ports/test05/expected_returncode
2 files changed, 13 insertions(+), 2 deletions(-)

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



diff --git a/src/systemc/core/port.hh b/src/systemc/core/port.hh
index 15e7bbe..217269d 100644
--- a/src/systemc/core/port.hh
+++ b/src/systemc/core/port.hh
@@ -33,6 +33,7 @@
 #include <list>
 #include <vector>

+#include "base/cprintf.hh"
 #include "systemc/ext/core/sc_interface.hh"
 #include "systemc/ext/core/sc_port.hh"

@@ -59,10 +60,19 @@
     void finalizeFinder(StaticSensitivityFinder *finder);

     void
-    addInterface(::sc_core::sc_interface *i)
+    addInterface(::sc_core::sc_interface *iface)
     {
+        for (int i = 0; i < _size; i++) {
+            if (getInterface(i) == iface) {
+                std::string msg =
+ csprintf("interface already bound to port: port '%s' (%s)",
+                        portBase->name(), portBase->kind());
+                SC_REPORT_ERROR("(E107) bind interface to port failed",
+                        msg.c_str());
+            }
+        }
         _size++;
-        portBase->_gem5AddInterface(i);
+        portBase->_gem5AddInterface(iface);
     }

     void
diff --git a/src/systemc/tests/systemc/communication/ports/test05/expected_returncode b/src/systemc/tests/systemc/communication/ports/test05/expected_returncode
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/src/systemc/tests/systemc/communication/ports/test05/expected_returncode
@@ -0,0 +1 @@
+1

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