From: Gabe Black Date: Thu, 14 Feb 2019 09:54:20 +0000 (-0800) Subject: systemc: Make sc_(pause|stop) exit to python when not using sc_main. X-Git-Tag: v19.0.0.0~1116 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=71b617b647dd83d9b8865c3ae1390c34e0e6abd2;p=gem5.git systemc: Make sc_(pause|stop) exit to python when not using sc_main. 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 Maintainer: Gabe Black --- diff --git a/src/systemc/core/scheduler.cc b/src/systemc/core/scheduler.cc index da1dd2d03..d06ddfb58 100644 --- a/src/systemc/core/scheduler.cc +++ b/src/systemc/core/scheduler.cc @@ -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