From e5e5b80690f736c65c9b51ef96660637210f3938 Mon Sep 17 00:00:00 2001 From: Andrew Bardsley Date: Tue, 2 Dec 2014 06:08:09 -0500 Subject: 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. --- util/systemc/sc_gem5_control.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'util/systemc/sc_gem5_control.cc') diff --git a/util/systemc/sc_gem5_control.cc b/util/systemc/sc_gem5_control.cc index ec46a7dc9..5dd3b1ed5 100644 --- a/util/systemc/sc_gem5_control.cc +++ b/util/systemc/sc_gem5_control.cc @@ -228,8 +228,11 @@ Gem5TopLevelModule::Gem5TopLevelModule(sc_core::sc_module_name name, * sole top level gem5 EventQueue */ Gem5SystemC::Module::setupEventQueues(*this); - if (sc_core::sc_get_time_resolution() != sc_core::sc_time(1, sc_core::SC_PS)) + if (sc_core::sc_get_time_resolution() != + sc_core::sc_time(1, sc_core::SC_PS)) + { fatal("Time resolution must be set to 1 ps for gem5 to work"); + } /* Enable keyboard interrupt, async I/O etc. */ initSignals(); -- cgit v1.2.3