fatal("Simulation called sc_stop during elaboration.\n");
status(::sc_core::SC_BEFORE_END_OF_ELABORATION);
- for (auto m: sc_gem5::allModules) {
- callbackModule(m);
- m->sc_mod()->before_end_of_elaboration();
- for (auto p: m->ports)
- p->before_end_of_elaboration();
- for (auto e: m->exports)
- e->before_end_of_elaboration();
- }
- callbackModule(nullptr);
+ for (auto m: sc_gem5::allModules)
+ m->beforeEndOfElaboration();
for (auto c: sc_gem5::allChannels)
c->sc_chan()->before_end_of_elaboration();
}
p->_gem5Finalize();
status(::sc_core::SC_END_OF_ELABORATION);
- for (auto m: sc_gem5::allModules) {
- callbackModule(m);
- m->sc_mod()->end_of_elaboration();
- for (auto p: m->ports)
- p->end_of_elaboration();
- for (auto e: m->exports)
- e->end_of_elaboration();
- }
- callbackModule(nullptr);
+ for (auto m: sc_gem5::allModules)
+ m->endOfElaboration();
for (auto c: sc_gem5::allChannels)
c->sc_chan()->end_of_elaboration();
} catch (...) {
try {
status(::sc_core::SC_START_OF_SIMULATION);
- for (auto m: sc_gem5::allModules) {
- m->sc_mod()->start_of_simulation();
- for (auto p: m->ports)
- p->start_of_simulation();
- for (auto e: m->exports)
- e->start_of_simulation();
- }
- callbackModule(nullptr);
+ for (auto m: sc_gem5::allModules)
+ m->startOfSimulation();
for (auto c: sc_gem5::allChannels)
c->sc_chan()->start_of_simulation();
} catch (...) {
{
status(::sc_core::SC_END_OF_SIMULATION);
try {
- for (auto m: sc_gem5::allModules) {
- m->sc_mod()->end_of_simulation();
- for (auto p: m->ports)
- p->end_of_simulation();
- for (auto e: m->exports)
- e->end_of_simulation();
- }
- callbackModule(nullptr);
+ for (auto m: sc_gem5::allModules)
+ m->endOfSimulation();
for (auto c: sc_gem5::allChannels)
c->sc_chan()->end_of_simulation();
} catch (...) {
#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"
} // 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;
}
}
+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()
{
const char *_name;
sc_core::sc_module *_sc_mod;
Object *_obj;
+ bool _ended;
+ bool _deprecatedConstructor;
UniqueNameGen nameGen;
void finish(Object *this_obj);
const char *name() const { return _name; }
+ void endModule() { _ended = true; }
+ void deprecatedConstructor() { _deprecatedConstructor = true; }
sc_core::sc_module *
sc_mod() const
std::vector<::sc_core::sc_port_base *> ports;
std::vector<::sc_core::sc_export_base *> exports;
+
+ void beforeEndOfElaboration();
+ void endOfElaboration();
+ void startOfSimulation();
+ void endOfSimulation();
};
Module *currentModule();
{}
sc_module::sc_module(const sc_module_name &) : sc_module() {}
-sc_module::sc_module(const char *_name) : sc_module(sc_module_name(_name)) {}
+sc_module::sc_module(const char *_name) : sc_module(sc_module_name(_name))
+{
+ _gem5_module->deprecatedConstructor();
+ SC_REPORT_WARNING("(W569) sc_module(const char*), "
+ "sc_module(const std::string&) have been deprecated, use "
+ "sc_module(const sc_module_name&)", _name);
+}
sc_module::sc_module(const std::string &_name) :
sc_module(sc_module_name(_name.c_str()))
-{}
+{
+ _gem5_module->deprecatedConstructor();
+ SC_REPORT_WARNING("(W569) sc_module(const char*), "
+ "sc_module(const std::string&) have been deprecated, use "
+ "sc_module(const sc_module_name&)", _name.c_str());
+}
+
+void
+sc_module::end_module()
+{
+ _gem5_module->endModule();
+}
void
sc_module::reset_signal_is(const sc_in<bool> &, bool)
virtual const sc_interface *get_interface() const = 0;
protected:
- friend class sc_gem5::Kernel;
+ friend class sc_gem5::Module;
virtual void before_end_of_elaboration() = 0;
virtual void end_of_elaboration() = 0;
{
public:
friend class ::sc_gem5::Kernel;
+ friend class ::sc_gem5::Module;
virtual ~sc_module();
sc_module(const std::string &);
/* Deprecated, but used in the regression tests. */
- void end_module() {}
+ void end_module();
void reset_signal_is(const sc_in<bool> &, bool);
void reset_signal_is(const sc_inout<bool> &, bool);
r'^\nInfo: \(I804\) /IEEE_Std_1666/deprecated: \n' +
r' sc_clock\(const char(.*\n){3}',
warning_filt(540),
- warning_filt(569),
warning_filt(571),
info_filt(804),
in_file_filt,