Gabe Black has uploaded this change for review. (
https://gem5-review.googlesource.com/c/public/gem5/+/12076
Change subject: systemc: Track the module in the end_of_elaboration
callback.
......................................................................
systemc: Track the module in the end_of_elaboration callback.
sc_objects constructed during that callback are considered children of
the module the callback belongs to.
Change-Id: I164863a10beef6d0e2c6d9c5e8f2642d80769dca
---
M src/systemc/core/kernel.cc
M src/systemc/core/module.cc
M src/systemc/core/module.hh
M src/systemc/core/object.cc
4 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/src/systemc/core/kernel.cc b/src/systemc/core/kernel.cc
index 3e3bdbd..4eb0bb7 100644
--- a/src/systemc/core/kernel.cc
+++ b/src/systemc/core/kernel.cc
@@ -64,8 +64,11 @@
Kernel::init()
{
status(::sc_core::SC_BEFORE_END_OF_ELABORATION);
- for (auto m: sc_gem5::allModules)
+ for (auto m: sc_gem5::allModules) {
+ callbackModule(m);
m->sc_mod()->before_end_of_elaboration();
+ }
+ callbackModule(nullptr);
if (stopAfterCallbacks)
stopWork();
diff --git a/src/systemc/core/module.cc b/src/systemc/core/module.cc
index e41e932..986ad25 100644
--- a/src/systemc/core/module.cc
+++ b/src/systemc/core/module.cc
@@ -43,6 +43,8 @@
std::list<Module *> _modules;
Module *_new_module;
+Module *_callbackModule = nullptr;
+
} // anonymous namespace
Module::Module(const char *name) : _name(name), _sc_mod(nullptr),
_obj(nullptr)
@@ -90,6 +92,9 @@
return _new_module;
}
+void callbackModule(Module *m) { _callbackModule = m; }
+Module *callbackModule() { return _callbackModule; }
+
std::set<Module *> allModules;
} // namespace sc_gem5
diff --git a/src/systemc/core/module.hh b/src/systemc/core/module.hh
index 8aebff2..7e54e29 100644
--- a/src/systemc/core/module.hh
+++ b/src/systemc/core/module.hh
@@ -106,6 +106,9 @@
Module *currentModule();
Module *newModule();
+void callbackModule(Module *m);
+Module *callbackModule();
+
extern std::set<Module *> allModules;
} // namespace sc_gem5
diff --git a/src/systemc/core/object.cc b/src/systemc/core/object.cc
index 1347661..e066a23 100644
--- a/src/systemc/core/object.cc
+++ b/src/systemc/core/object.cc
@@ -78,6 +78,8 @@
_basename = "object";
Module *p = currentModule();
+ if (!p)
+ p = callbackModule();
Module *n = newModule();
if (n) {
@@ -87,7 +89,7 @@
if (p) {
// We're "within" a parent module, ie we're being created while its
- // constructor is running.
+ // constructor or end_of_elaboration callback is running.
parent = p->obj()->_sc_obj;
addObject(&parent->_gem5_object->children, _sc_obj);
} else if (scheduler.current()) {
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/12076
To unsubscribe, or for help writing mail filters, visit
https://gem5-review.googlesource.com/settings
Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-Change-Id: I164863a10beef6d0e2c6d9c5e8f2642d80769dca
Gerrit-Change-Number: 12076
Gerrit-PatchSet: 1
Gerrit-Owner: Gabe Black <[email protected]>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev