systemc: Add an error check whether an interface is alread bound to a port.
authorGabe Black <gabeblack@google.com>
Sat, 15 Sep 2018 23:20:27 +0000 (16:20 -0700)
committerGabe Black <gabeblack@google.com>
Tue, 16 Oct 2018 00:23:20 +0000 (00:23 +0000)
Change-Id: I06e3484176c0c06daa28f7be0ed8437b3b15ddb2
Reviewed-on: https://gem5-review.googlesource.com/c/12816
Reviewed-by: Gabe Black <gabeblack@google.com>
Maintainer: Gabe Black <gabeblack@google.com>

src/systemc/core/port.hh
src/systemc/tests/systemc/communication/ports/test05/expected_returncode [new file with mode: 0644]

index 15e7bbed15b4deb9cbaee7c642dfe190e45939f1..217269d8697465d7be09303653322dd8bdf2360b 100644 (file)
@@ -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 @@ class Port
     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 (file)
index 0000000..d00491f
--- /dev/null
@@ -0,0 +1 @@
+1