diff options
author | Gabe Black <gabeblack@google.com> | 2018-08-07 03:51:18 -0700 |
---|---|---|
committer | Gabe Black <gabeblack@google.com> | 2018-09-20 01:40:14 +0000 |
commit | 33e3365bf9876b09362897a3ad9941090e3aca9c (patch) | |
tree | f8e7848aef052da1366996b8a160f9ed13c32d15 /src/systemc/core/sc_main.cc | |
parent | 049f7b8399a2721fea64274d89d44a8c3a54346b (diff) | |
download | gem5-33e3365bf9876b09362897a3ad9941090e3aca9c.tar.xz |
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 <gabeblack@google.com>
Maintainer: Gabe Black <gabeblack@google.com>
Diffstat (limited to 'src/systemc/core/sc_main.cc')
-rw-r--r-- | src/systemc/core/sc_main.cc | 16 |
1 files changed, 9 insertions, 7 deletions
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; |