namespace
{
+bool scMainDone = false;
bool stopAfterCallbacks = false;
bool startComplete = false;
bool endComplete = false;
bool Kernel::startOfSimulationComplete() { return startComplete; }
bool Kernel::endOfSimulationComplete() { return endComplete; }
+bool Kernel::scMainFinished() { return scMainDone; }
+void Kernel::scMainFinished(bool finished) { scMainDone = finished; }
+
sc_core::sc_status Kernel::status() { return _status; }
void Kernel::status(sc_core::sc_status s) { _status = s; }
void
Kernel::init()
{
+ if (scMainDone)
+ return;
+
status(::sc_core::SC_BEFORE_END_OF_ELABORATION);
for (auto m: sc_gem5::allModules) {
callbackModule(m);
void
Kernel::regStats()
{
+ if (scMainDone)
+ return;
+
for (auto m: sc_gem5::allModules)
for (auto p: m->ports)
p->_gem5Finalize();
void
Kernel::startup()
{
+ if (scMainDone)
+ return;
+
status(::sc_core::SC_START_OF_SIMULATION);
for (auto m: sc_gem5::allModules) {
m->sc_mod()->start_of_simulation();
static bool startOfSimulationComplete();
static bool endOfSimulationComplete();
+ static bool scMainFinished();
+ static void scMainFinished(bool);
+
private:
static void stopWork();
{
if (::sc_main) {
::sc_main(_argc, _argv);
+ // Make sure no systemc events/notifications are scheduled
+ // after sc_main returns.
+ ::sc_gem5::Kernel::scMainFinished(true);
+ ::sc_gem5::scheduler.clear();
} else {
// If python tries to call sc_main but no sc_main was defined...
fatal("sc_main called but not defined.\n");