From 71b617b647dd83d9b8865c3ae1390c34e0e6abd2 Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Thu, 14 Feb 2019 01:54:20 -0800 Subject: [PATCH] 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 --- src/systemc/core/scheduler.cc | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) 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 -- 2.30.2