From: Gabe Black Date: Tue, 12 Mar 2019 07:33:52 +0000 (-0700) Subject: systemc: Hook up gem5_getPort to the gem5 getPort mechanism. X-Git-Tag: v19.0.0.0~1034 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=dee6fe7b6a4ce4f2d1e08af9250b6d1d6ce96836;p=gem5.git 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 Maintainer: Gabe Black --- diff --git a/src/systemc/core/SystemC.py b/src/systemc/core/SystemC.py index 649d6d367..74b7cec14 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 @@ class SystemC_ScModule(SystemC_ScObject): 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 fc98aa3a0..ba9c76a0e 100644 --- a/src/systemc/core/sc_module.cc +++ b/src/systemc/core/sc_module.cc @@ -31,6 +31,7 @@ #include #include +#include "base/logging.hh" #include "systemc/core/event.hh" #include "systemc/core/kernel.hh" #include "systemc/core/module.hh" @@ -114,6 +115,12 @@ sc_bind_proxy::sc_bind_proxy(sc_port_base &_port) : 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 0c8bd9f6c..24a1aea04 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 #include #include "sc_object.hh" @@ -58,6 +59,9 @@ Process *newCThreadProcess(const char *name, ProcessFuncWrapper *func); } // namespace sc_gem5 +// Gem5 prototype +class Port; + namespace sc_core { @@ -94,6 +98,10 @@ extern const sc_bind_proxy SC_BIND_PROXY_NIL; 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;