sc_objects constructed during that callback are considered children of
the module the callback belongs to.
Change-Id: I164863a10beef6d0e2c6d9c5e8f2642d80769dca
Reviewed-on: https://gem5-review.googlesource.com/12076
Reviewed-by: Gabe Black <gabeblack@google.com>
Maintainer: Gabe Black <gabeblack@google.com>
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();
std::list<Module *> _modules;
Module *_new_module;
+Module *_callbackModule = nullptr;
+
} // anonymous namespace
Module::Module(const char *name) : _name(name), _sc_mod(nullptr), _obj(nullptr)
return _new_module;
}
+void callbackModule(Module *m) { _callbackModule = m; }
+Module *callbackModule() { return _callbackModule; }
+
std::set<Module *> allModules;
} // namespace sc_gem5
Module *currentModule();
Module *newModule();
+void callbackModule(Module *m);
+Module *callbackModule();
+
extern std::set<Module *> allModules;
} // namespace sc_gem5
_basename = "object";
Module *p = currentModule();
+ if (!p)
+ p = callbackModule();
Module *n = newModule();
if (n) {
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()) {