From 33e3365bf9876b09362897a3ad9941090e3aca9c Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Tue, 7 Aug 2018 03:51:18 -0700 Subject: systemc: Generalize working with the systemc python module from C++. This change pulls the systemc python module creation code out of sc_main and puts it into a more general purpose python.hh and python.cc which can be used by other code to add other entries into that module without having to track that in a central place. This change also adds a mechanism for notifying C++ code that the embedded python interpretter is up and ready to interact with in case it needs to call some python only functionality. An example of that is the code which tracks and then fixes the timescale for the simulator. Change-Id: I9afcd5a089b21d23ebc1b5fdb6f643ae2f7e5f11 Reviewed-on: https://gem5-review.googlesource.com/12069 Reviewed-by: Gabe Black Maintainer: Gabe Black --- src/systemc/core/sc_main.cc | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'src/systemc/core/sc_main.cc') diff --git a/src/systemc/core/sc_main.cc b/src/systemc/core/sc_main.cc index 45ca728c3..446b7377d 100644 --- a/src/systemc/core/sc_main.cc +++ b/src/systemc/core/sc_main.cc @@ -32,11 +32,11 @@ #include "base/fiber.hh" #include "base/logging.hh" #include "base/types.hh" -#include "python/pybind11/pybind.hh" #include "sim/core.hh" #include "sim/eventq.hh" #include "sim/init.hh" #include "systemc/core/kernel.hh" +#include "systemc/core/python.hh" #include "systemc/core/scheduler.hh" #include "systemc/ext/core/sc_main.hh" #include "systemc/ext/utils/sc_report_handler.hh" @@ -113,13 +113,15 @@ sc_main(pybind11::args args) // Make our sc_main wrapper available in the internal _m5 python module under // the systemc submodule. -void -systemc_pybind(pybind11::module &m_internal) + +struct InstallScMain : public ::sc_gem5::PythonInitFunc { - pybind11::module m = m_internal.def_submodule("systemc"); - m.def("sc_main", &sc_main); -} -EmbeddedPyBind embed_("systemc", &systemc_pybind); + void + run(pybind11::module &systemc) override + { + systemc.def("sc_main", &sc_main); + } +} installScMain; sc_stop_mode _stop_mode = SC_STOP_FINISH_DELTA; -- cgit v1.2.3