systemc: If sc_main returns, don't do any more systemc stuff.
When sc_main returns, clear out any pending work in the scheduler and also block the systemc kernel from doing actions which correspond with the start of simulation. It's most likely that work like oustanding timeouts might survive past the end of sc_main, especially if it never officially called sc_stop. It's also possible for sc_main to return and never actually call sc_start. In that case, the kernel should not call callbacks of the various objects (which may no longer even exist), or go through the initialization phase. If sc_main is never called at all, then the kernel's actions aren't gated. Change-Id: I49bf094be3283a92d846d2f3da224950bd893a5c Reviewed-on: https://gem5-review.googlesource.com/12249 Reviewed-by: Gabe Black <gabeblack@google.com> Maintainer: Gabe Black <gabeblack@google.com>
This commit is contained in:
@@ -40,6 +40,7 @@ namespace sc_gem5
|
||||
namespace
|
||||
{
|
||||
|
||||
bool scMainDone = false;
|
||||
bool stopAfterCallbacks = false;
|
||||
bool startComplete = false;
|
||||
bool endComplete = false;
|
||||
@@ -51,6 +52,9 @@ sc_core::sc_status _status = sc_core::SC_ELABORATION;
|
||||
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; }
|
||||
|
||||
@@ -64,6 +68,9 @@ Kernel::Kernel(Params *params) :
|
||||
void
|
||||
Kernel::init()
|
||||
{
|
||||
if (scMainDone)
|
||||
return;
|
||||
|
||||
status(::sc_core::SC_BEFORE_END_OF_ELABORATION);
|
||||
for (auto m: sc_gem5::allModules) {
|
||||
callbackModule(m);
|
||||
@@ -84,6 +91,9 @@ Kernel::init()
|
||||
void
|
||||
Kernel::regStats()
|
||||
{
|
||||
if (scMainDone)
|
||||
return;
|
||||
|
||||
for (auto m: sc_gem5::allModules)
|
||||
for (auto p: m->ports)
|
||||
p->_gem5Finalize();
|
||||
@@ -106,6 +116,9 @@ Kernel::regStats()
|
||||
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();
|
||||
|
||||
Reference in New Issue
Block a user