systemc: Fix where we checked if sc_stop was called durig elaboration.
authorGabe Black <gabeblack@google.com>
Sun, 26 Aug 2018 21:54:20 +0000 (14:54 -0700)
committerGabe Black <gabeblack@google.com>
Wed, 26 Sep 2018 00:02:16 +0000 (00:02 +0000)
If sc_stop is called during one of the various callbacks, that has
defined behavior and will cause the simulation to stop after the
current batch of callbacks. We were checking whether sc_stop had been
called during one of those batches and killing the system, erroneously
assuming that meant it had called during elaboration.

This change moves the check to before the callbacks which actually
does mean that sc_stop was called during elaboration.

Change-Id: I6876305450e52a407acffb9a2f45ee2ae24a9adf
Reviewed-on: https://gem5-review.googlesource.com/12266
Reviewed-by: Gabe Black <gabeblack@google.com>
Maintainer: Gabe Black <gabeblack@google.com>

src/systemc/core/kernel.cc

index 545901a84a6e4bf96668197943afbc3dd7252f5b..24d9f22b2d8ee851d1a4b107a122a296012f3251 100644 (file)
@@ -71,6 +71,9 @@ Kernel::init()
     if (scMainDone)
         return;
 
+    if (stopAfterCallbacks)
+        fatal("Simulation called sc_stop during elaboration.\n");
+
     status(::sc_core::SC_BEFORE_END_OF_ELABORATION);
     for (auto m: sc_gem5::allModules) {
         callbackModule(m);
@@ -168,9 +171,6 @@ Kernel::stopWork()
     endComplete = true;
 
     status(::sc_core::SC_STOPPED);
-
-    if (stopAfterCallbacks)
-        fatal("Simulation called sc_stop during elaboration.\n");
 }
 
 void