systemc: Make sc_(pause|stop) exit to python when not using sc_main.
authorGabe Black <gabeblack@google.com>
Thu, 14 Feb 2019 09:54:20 +0000 (01:54 -0800)
committerGabe Black <gabeblack@google.com>
Thu, 21 Feb 2019 22:35:23 +0000 (22:35 +0000)
In those cases, there's no sc_main to return control to. The python
config script is serving more or less the same purpose, so we can
return control to there instead.

Change-Id: I3cf0623ae51d989b883fb8556ebbf44651bbec99
Reviewed-on: https://gem5-review.googlesource.com/c/16445
Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com>
Maintainer: Gabe Black <gabeblack@google.com>

src/systemc/core/scheduler.cc

index da1dd2d0398ad7706c27c7a16b3b002829e51f0a..d06ddfb582ad27cb6e4f05309ad7406dd416069d 100644 (file)
@@ -32,6 +32,7 @@
 #include "base/fiber.hh"
 #include "base/logging.hh"
 #include "sim/eventq.hh"
+#include "sim/sim_exit.hh"
 #include "systemc/core/kernel.hh"
 #include "systemc/core/sc_main_fiber.hh"
 #include "systemc/ext/core/messages.hh"
@@ -352,8 +353,15 @@ Scheduler::pause()
     status(StatusPaused);
     kernel->status(::sc_core::SC_PAUSED);
     runOnce = false;
-    if (scMainFiber.called() && !scMainFiber.finished())
-        scMainFiber.run();
+    if (scMainFiber.called()) {
+        if (!scMainFiber.finished())
+            scMainFiber.run();
+    } else {
+        if (scMainFiber.finished())
+            fatal("Pausing systemc after sc_main completed.");
+        else
+            exitSimLoopNow("systemc pause");
+    }
 }
 
 void
@@ -365,8 +373,15 @@ Scheduler::stop()
     clear();
 
     runOnce = false;
-    if (scMainFiber.called() && !scMainFiber.finished())
-        scMainFiber.run();
+    if (scMainFiber.called()) {
+        if (!scMainFiber.finished())
+            scMainFiber.run();
+    } else {
+        if (scMainFiber.finished())
+            fatal("Stopping systemc after sc_main completed.");
+        else
+            exitSimLoopNow("systemc stop");
+    }
 }
 
 void