diff -r 4a4f2963aba7 -r ee5f72396d89 util/tlm/sim_control.hh --- a/util/tlm/sim_control.hh Mon Jan 30 17:49:53 2017 +0100 +++ b/util/tlm/sim_control.hh Tue Jan 31 11:51:10 2017 +0100 @@ -77,6 +77,22 @@ /// Pointer to a previously created instance. static Gem5SimControl* instance; + /** A callback that is called from the run thread before gem5 simulation is + * started. + * + * A derived class may use this to perform any additional initializations + * prior simulation. + */ + virtual void beforeSimulate() {} + + /** A callback that is called from the run thread after gem5 simulation + * completed. + * + * A derived class may use this to perform any additional tasks after gem5 + * exits. For instance, a derived class could use this to call sc_stop(). + */ + virtual void afterSimulate() {} + public: SC_HAS_PROCESS(Gem5SimControl); diff -r 4a4f2963aba7 -r ee5f72396d89 util/tlm/sim_control.cc --- a/util/tlm/sim_control.cc Mon Jan 30 17:49:53 2017 +0100 +++ b/util/tlm/sim_control.cc Tue Jan 31 11:51:10 2017 +0100 @@ -152,6 +152,9 @@ void Gem5SimControl::run() { + // notify callback + beforeSimulate(); + GlobalSimLoopExitEvent *exit_event = NULL; if (simulationEnd == 0) { @@ -165,6 +168,9 @@ getEventQueue(0)->dump(); + // notify callback + afterSimulate(); + #if TRY_CLEAN_DELETE config_manager->deleteObjects(); #endif