diff options
author | Andrew Bardsley <Andrew.Bardsley@arm.com> | 2014-12-02 06:08:09 -0500 |
---|---|---|
committer | Andrew Bardsley <Andrew.Bardsley@arm.com> | 2014-12-02 06:08:09 -0500 |
commit | e5e5b80690f736c65c9b51ef96660637210f3938 (patch) | |
tree | 4c2f6422209fd55e2c97bcb48689c5091c000072 /util/systemc/sc_module.hh | |
parent | 05bba75cdc346184da7ff40958673da980a06df2 (diff) | |
download | gem5-e5e5b80690f736c65c9b51ef96660637210f3938.tar.xz |
config: Fix to SystemC example's event handling
This patch fixes checkpoint restore in the SystemC hosting example by handling
early PollEvent events correctly before any EventQueue events are posted.
The SystemC event queue handler (SCEventQueue) reports an error if the event
loop is entered with no Events posted. It is possible for this to happen
after instantiate due to PollEvent events. This patch separates out
`external' events into a different handler in sc_module.cc to prevent the
error from occurring.
This fix also improves the event handling of asynchronous events by:
1) Making asynchronous events 'catch up' gem5 time to SystemC
time to avoid the appearance that events have been lost
while servicing an asynchronous event that schedules an
event loop exit event
2) Add an in_simulate data member to Module to allow the event
loop to check whether events should be processed or deferred
until the next time Module::simulate is entered
3) Cancel pending events around the entry/exit of the event loop
in Module::simulate
4) Moving the state initialisation of the example entirely into
run to correct a problem with early events in checkpoint
restore.
It is still possible to schedule asynchronous events (and talk PollQueue
actions) while simulate is not running. This behaviour may stil cause
some problems.
Diffstat (limited to 'util/systemc/sc_module.hh')
-rw-r--r-- | util/systemc/sc_module.hh | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/util/systemc/sc_module.hh b/util/systemc/sc_module.hh index c9ad94429..b529e2137 100644 --- a/util/systemc/sc_module.hh +++ b/util/systemc/sc_module.hh @@ -99,6 +99,10 @@ class Module : public sc_core::sc_module /** Expected exit time of last eventLoop sleep */ Tick wait_exit_time; + /** Are we in Module::simulate? Used to mask events when not inside + * the simulate loop */ + bool in_simulate; + /** Placeholder base class for a variant event queue if this becomes * useful */ class SCEventQueue : public EventQueue @@ -131,10 +135,18 @@ class Module : public sc_core::sc_module * are created */ static void setupEventQueues(Module &module); + /** Catch gem5 time up with SystemC */ + void catchup(); + /** Notify an externalSchedulingEvent at the given time from the * current SystemC time */ void notify(sc_core::sc_time time_from_now = sc_core::SC_ZERO_TIME); + /** Process an event triggered by externalSchedulingEvent and also + * call eventLoop (to try and mop up any events at this time) if there + * are any scheduled events */ + void serviceExternalEvent(); + /** Process gem5 events up until an exit event or there are no events * left. */ void eventLoop(); |