summaryrefslogtreecommitdiff
path: root/src/systemc/core/module.cc
diff options
context:
space:
mode:
authorGabe Black <gabeblack@google.com>2018-09-07 18:25:10 -0700
committerGabe Black <gabeblack@google.com>2018-10-09 21:44:00 +0000
commita4b82a86115649cbe403315bf04231d5c9512015 (patch)
tree2cd692e0d2f8e179c5b89c3b76ef23415f5d3ac6 /src/systemc/core/module.cc
parent18ca156d81b7399945fdb11a3a8aee34f05bf92c (diff)
downloadgem5-a4b82a86115649cbe403315bf04231d5c9512015.tar.xz
systemc: Centralize module callbacks and report new warnings.
By centralizing module callbacks, the gem5 module class knows when different stages of the simulation are happening and can do it's own extra checks. It also compartmentalizes modules more since the kernel object doesn't have to reach into them to enumerate ports and exports. Change-Id: I55887284af9c05150fe9d054f5b6147cad6092a1 Reviewed-on: https://gem5-review.googlesource.com/c/12610 Reviewed-by: Gabe Black <gabeblack@google.com> Maintainer: Gabe Black <gabeblack@google.com>
Diffstat (limited to 'src/systemc/core/module.cc')
-rw-r--r--src/systemc/core/module.cc59
1 files changed, 58 insertions, 1 deletions
diff --git a/src/systemc/core/module.cc b/src/systemc/core/module.cc
index 78ce2c6fb..dcd6faa53 100644
--- a/src/systemc/core/module.cc
+++ b/src/systemc/core/module.cc
@@ -32,6 +32,7 @@
#include <cassert>
#include "base/logging.hh"
+#include "systemc/ext/core/sc_export.hh"
#include "systemc/ext/core/sc_port.hh"
#include "systemc/ext/utils/sc_report_handler.hh"
@@ -48,7 +49,9 @@ Module *_callbackModule = nullptr;
} // anonymous namespace
-Module::Module(const char *name) : _name(name), _sc_mod(nullptr), _obj(nullptr)
+Module::Module(const char *name) :
+ _name(name), _sc_mod(nullptr), _obj(nullptr), _ended(false),
+ _deprecatedConstructor(false)
{
panic_if(_new_module, "Previous module not finished.\n");
_new_module = this;
@@ -105,6 +108,60 @@ Module::bindPorts(std::vector<const ::sc_core::sc_bind_proxy *> &proxies)
}
}
+void
+Module::beforeEndOfElaboration()
+{
+ callbackModule(this);
+ _sc_mod->before_end_of_elaboration();
+ for (auto p: ports)
+ p->before_end_of_elaboration();
+ for (auto e: exports)
+ e->before_end_of_elaboration();
+ callbackModule(nullptr);
+}
+
+void
+Module::endOfElaboration()
+{
+ if (_deprecatedConstructor && !_ended) {
+ std::string msg = csprintf("module '%s'", name());
+ SC_REPORT_WARNING("(W509) module construction not properly completed: "
+ "did you forget to add a sc_module_name parameter to "
+ "your module constructor?", msg.c_str());
+ }
+ callbackModule(this);
+ _sc_mod->end_of_elaboration();
+ for (auto p: ports)
+ p->end_of_elaboration();
+ for (auto e: exports)
+ e->end_of_elaboration();
+ callbackModule(nullptr);
+}
+
+void
+Module::startOfSimulation()
+{
+ callbackModule(this);
+ _sc_mod->start_of_simulation();
+ for (auto p: ports)
+ p->start_of_simulation();
+ for (auto e: exports)
+ e->start_of_simulation();
+ callbackModule(nullptr);
+}
+
+void
+Module::endOfSimulation()
+{
+ callbackModule(this);
+ _sc_mod->end_of_simulation();
+ for (auto p: ports)
+ p->end_of_simulation();
+ for (auto e: exports)
+ e->end_of_simulation();
+ callbackModule(nullptr);
+}
+
Module *
currentModule()
{