systemc: Hook up gem5_getPort to the gem5 getPort mechanism.
Change-Id: I771607c4436f4c1ca9d355d1da52924308cfc3b3
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/17229
Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com>
Maintainer: Gabe Black <gabeblack@google.com>
diff --git a/src/systemc/core/SystemC.py b/src/systemc/core/SystemC.py
index 649d6d3..74b7cec 100644
--- a/src/systemc/core/SystemC.py
+++ b/src/systemc/core/SystemC.py
@@ -25,7 +25,7 @@
#
# Authors: Gabe Black
-from m5.SimObject import SimObject
+from m5.SimObject import SimObject, cxxMethod
# This class represents the systemc kernel. There should be exactly one in the
# simulation. It receives gem5 SimObject lifecycle callbacks (init, regStats,
@@ -62,6 +62,10 @@
cxx_class = 'sc_core::sc_module'
cxx_header = 'systemc/ext/core/sc_module.hh'
+ @cxxMethod(return_value_policy="reference", cxx_name="gem5_getPort")
+ def getPort(self, if_name, iex):
+ return None
+
try:
import _m5
except:
diff --git a/src/systemc/core/sc_module.cc b/src/systemc/core/sc_module.cc
index fc98aa3..ba9c76a 100644
--- a/src/systemc/core/sc_module.cc
+++ b/src/systemc/core/sc_module.cc
@@ -31,6 +31,7 @@
#include <string>
#include <vector>
+#include "base/logging.hh"
#include "systemc/core/event.hh"
#include "systemc/core/kernel.hh"
#include "systemc/core/module.hh"
@@ -114,6 +115,12 @@
const sc_bind_proxy SC_BIND_PROXY_NIL;
+::Port &
+sc_module::gem5_getPort(const std::string &if_name, int idx)
+{
+ fatal("%s does not have any port named %s\n", name(), if_name);
+}
+
sc_module::~sc_module() { delete _gem5_module; }
void
diff --git a/src/systemc/ext/core/sc_module.hh b/src/systemc/ext/core/sc_module.hh
index 0c8bd9f..24a1aea 100644
--- a/src/systemc/ext/core/sc_module.hh
+++ b/src/systemc/ext/core/sc_module.hh
@@ -30,6 +30,7 @@
#ifndef __SYSTEMC_CORE_EXT_SC_MODULE_HH__
#define __SYSTEMC_CORE_EXT_SC_MODULE_HH__
+#include <string>
#include <vector>
#include "sc_object.hh"
@@ -58,6 +59,9 @@
} // namespace sc_gem5
+// Gem5 prototype
+class Port;
+
namespace sc_core
{
@@ -95,6 +99,10 @@
class sc_module : public sc_object
{
public:
+ // Gem5 specific extensions
+ virtual ::Port &gem5_getPort(const std::string &if_name, int idx=-1);
+
+ public:
friend class ::sc_gem5::Kernel;
friend class ::sc_gem5::Module;