summaryrefslogtreecommitdiff
path: root/src/systemc/core/module.hh
diff options
context:
space:
mode:
authorGabe Black <gabeblack@google.com>2018-09-28 17:12:46 -0700
committerGabe Black <gabeblack@google.com>2018-10-16 00:40:21 +0000
commit163eb3c56b115e649c72fceff89c8370b6e7306f (patch)
treee66057d1e2107b72aad9e256e4620c287d6cbe37 /src/systemc/core/module.hh
parent3fe6ebb325f3630af32d9210a7121eb5710bf42f (diff)
downloadgem5-163eb3c56b115e649c72fceff89c8370b6e7306f.tar.xz
systemc: Centralize how object parents are chosen.
There's a lot of repeated code for this. Also, the sc_vector type needs to be able to artificially inject a parent for the objects it creates. Change-Id: I76f9b551632cd2cd70e26741b215290b35c382e9 Reviewed-on: https://gem5-review.googlesource.com/c/13194 Reviewed-by: Gabe Black <gabeblack@google.com> Maintainer: Gabe Black <gabeblack@google.com>
Diffstat (limited to 'src/systemc/core/module.hh')
-rw-r--r--src/systemc/core/module.hh29
1 files changed, 26 insertions, 3 deletions
diff --git a/src/systemc/core/module.hh b/src/systemc/core/module.hh
index aa723368a..695f30565 100644
--- a/src/systemc/core/module.hh
+++ b/src/systemc/core/module.hh
@@ -80,10 +80,15 @@ class Module
UniqueNameGen nameGen;
public:
-
Module(const char *name);
~Module();
+ static Module *
+ fromScModule(::sc_core::sc_module *mod)
+ {
+ return mod->_gem5_module;
+ }
+
void finish(Object *this_obj);
const char *name() const { return _name; }
@@ -130,8 +135,26 @@ Module *currentModule();
Module *newModuleChecked();
Module *newModule();
-void callbackModule(Module *m);
-Module *callbackModule();
+static inline Module *
+pickParentModule()
+{
+ ::sc_core::sc_object *obj = pickParentObj();
+ auto mod = dynamic_cast<::sc_core::sc_module *>(obj);
+ if (!mod)
+ return nullptr;
+ return Module::fromScModule(mod);
+}
+static inline void
+pushParentModule(Module *m)
+{
+ pushParentObj(m->obj()->sc_obj());
+}
+static inline void
+popParentModule()
+{
+ assert(pickParentModule());
+ popParentObj();
+}
extern std::list<Module *> allModules;