summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Menard <Christian.Menard@tu-dresden.de>2017-02-09 19:15:51 -0500
committerChristian Menard <Christian.Menard@tu-dresden.de>2017-02-09 19:15:51 -0500
commita309c2f343bdebbfde442dcaf1c1812051287fd2 (patch)
tree4ff01ca11c91b9f1d4d98a1662d0c1dd8bb707c0
parent78e4967b6a98e0819e83f000d3a4de8766802bae (diff)
downloadgem5-a309c2f343bdebbfde442dcaf1c1812051287fd2.tar.xz
misc: Clean up and complete the gem5<->SystemC-TLM bridge [10/10]
The current TLM bridge only provides a Slave Port that allows the gem5 world to send request to the SystemC world. This patch series refractors and cleans up the existing code, and adds a Master Port that allows the SystemC world to send requests to the gem5 world. This patch: * Add callbacks for the Gem5SimControl that are called at before and * after simulate() Reviewed at http://reviews.gem5.org/r/3799/ Signed-off-by: Jason Lowe-Power <jason@lowepower.com>
-rw-r--r--util/tlm/sim_control.cc6
-rw-r--r--util/tlm/sim_control.hh16
2 files changed, 22 insertions, 0 deletions
diff --git a/util/tlm/sim_control.cc b/util/tlm/sim_control.cc
index f6a3e4ffe..a96daf2c8 100644
--- a/util/tlm/sim_control.cc
+++ b/util/tlm/sim_control.cc
@@ -152,6 +152,9 @@ Gem5SimControl::end_of_elaboration()
void
Gem5SimControl::run()
{
+ // notify callback
+ beforeSimulate();
+
GlobalSimLoopExitEvent *exit_event = NULL;
if (simulationEnd == 0) {
@@ -165,6 +168,9 @@ Gem5SimControl::run()
getEventQueue(0)->dump();
+ // notify callback
+ afterSimulate();
+
#if TRY_CLEAN_DELETE
config_manager->deleteObjects();
#endif
diff --git a/util/tlm/sim_control.hh b/util/tlm/sim_control.hh
index b411022de..399372c7f 100644
--- a/util/tlm/sim_control.hh
+++ b/util/tlm/sim_control.hh
@@ -77,6 +77,22 @@ class Gem5SimControl : public Module, public Gem5SimControlInterface
/// 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);