diff options
author | Gabe Black <gabeblack@google.com> | 2018-07-17 00:09:59 -0700 |
---|---|---|
committer | Gabe Black <gabeblack@google.com> | 2018-09-05 06:08:22 +0000 |
commit | 91a6b128198515a7a29ee766715c9a1fe1bf7b0c (patch) | |
tree | 22980516f87d12af1df372ddfabe57e45f4acc5a /src/systemc/core/sc_main.cc | |
parent | 746c1eaa72dbce46899459f988336485190897c2 (diff) | |
download | gem5-91a6b128198515a7a29ee766715c9a1fe1bf7b0c.tar.xz |
systemc: Implement sc_pause, sc_stop, and re-sc_start-ing.
This change further modifies the scheduler to implement the sc_pause
and sc_stop functions, and to ensure that calling sc_start again works.
Also, some small changes were made to how processes and contexts are
hooked up. Now, rather than checking whether a process is running to
determine wether it started on its own or needs to be started manually,
there's a bool which explicitly tracks whether it needs this step. The
problem was that once a thread finished, it wasn't considered running
any more. In that case it had run but finished, but that was
indistinguishable from it needing to run but not having been started.
Change-Id: I3aefb5493f91d9efa1a1382586196339b67925fe
Reviewed-on: https://gem5-review.googlesource.com/12031
Reviewed-by: Gabe Black <gabeblack@google.com>
Maintainer: Gabe Black <gabeblack@google.com>
Diffstat (limited to 'src/systemc/core/sc_main.cc')
-rw-r--r-- | src/systemc/core/sc_main.cc | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/src/systemc/core/sc_main.cc b/src/systemc/core/sc_main.cc index 0b385e9a0..120bbf9ae 100644 --- a/src/systemc/core/sc_main.cc +++ b/src/systemc/core/sc_main.cc @@ -123,9 +123,6 @@ EmbeddedPyBind embed_("systemc", &systemc_pybind); sc_stop_mode _stop_mode = SC_STOP_FINISH_DELTA; sc_status _status = SC_ELABORATION; -Tick _max_tick = MaxTick; -sc_starvation_policy _starvation = SC_EXIT_ON_STARVATION; - } // anonymous namespace int @@ -143,28 +140,29 @@ sc_argv() void sc_start() { - _max_tick = MaxTick; - _starvation = SC_EXIT_ON_STARVATION; - - // Switch back gem5. - Fiber::primaryFiber()->run(); + Tick now = curEventQueue() ? curEventQueue()->getCurTick() : 0; + sc_start(sc_time::from_value(MaxTick - now), SC_EXIT_ON_STARVATION); } void sc_pause() { - warn("%s not implemented.\n", __PRETTY_FUNCTION__); + if (_status == SC_RUNNING) + ::sc_gem5::scheduler.schedulePause(); } void sc_start(const sc_time &time, sc_starvation_policy p) { + _status = SC_RUNNING; + Tick now = curEventQueue() ? curEventQueue()->getCurTick() : 0; - _max_tick = now + time.value(); - _starvation = p; + ::sc_gem5::scheduler.start(now + time.value(), p == SC_RUN_TO_TIME); - // Switch back to gem5. - Fiber::primaryFiber()->run(); + if (::sc_gem5::scheduler.paused()) + _status = SC_PAUSED; + else if (::sc_gem5::scheduler.stopped()) + _status = SC_STOPPED; } void @@ -187,7 +185,15 @@ sc_get_stop_mode() void sc_stop() { - warn("%s not implemented.\n", __PRETTY_FUNCTION__); + if (_status == SC_STOPPED) + return; + + if (sc_is_running()) { + bool finish_delta = (_stop_mode == SC_STOP_FINISH_DELTA); + ::sc_gem5::scheduler.scheduleStop(finish_delta); + } else { + //XXX Should stop if in one of the various elaboration callbacks. + } } const sc_time & |