Gabe Black has uploaded this change for review. ( https://gem5-review.googlesource.com/c/public/gem5/+/12468

Change subject: systemc: Ensure sc_stop during callbacks actually stops.
......................................................................

systemc: Ensure sc_stop during callbacks actually stops.

Make sure calling sc_stop during the appropriate callbacks will
actually skip future action by skipping later callbacks, by flushing
the scheduler before running init (so it doesn't really do anything
but record that it's in running mode now), and schedule the stop event.

Change-Id: I5edfbceda457df88d15bfcac4d97e8578205ec5b
---
M src/systemc/core/kernel.cc
1 file changed, 14 insertions(+), 11 deletions(-)



diff --git a/src/systemc/core/kernel.cc b/src/systemc/core/kernel.cc
index fd51b4c..cc65fcc 100644
--- a/src/systemc/core/kernel.cc
+++ b/src/systemc/core/kernel.cc
@@ -86,15 +86,12 @@
     callbackModule(nullptr);
     for (auto c: sc_gem5::allChannels)
         c->sc_chan()->before_end_of_elaboration();
-
-    if (stopAfterCallbacks)
-        stopWork();
 }

 void
 Kernel::regStats()
 {
-    if (scMainDone)
+    if (scMainDone || stopAfterCallbacks)
         return;

     for (auto m: sc_gem5::allModules)
@@ -113,9 +110,6 @@
     callbackModule(nullptr);
     for (auto c: sc_gem5::allChannels)
         c->sc_chan()->end_of_elaboration();
-
-    if (stopAfterCallbacks)
-        stopWork();
 }

 void
@@ -124,6 +118,11 @@
     if (scMainDone)
         return;

+    schedule(t0Event, curTick());
+
+    if (stopAfterCallbacks)
+        return;
+
     status(::sc_core::SC_START_OF_SIMULATION);
     for (auto m: sc_gem5::allModules) {
         m->sc_mod()->start_of_simulation();
@@ -142,7 +141,6 @@

     kernel->status(::sc_core::SC_RUNNING);

-    schedule(t0Event, curTick());
     // Run update once before the event queue starts.
     ::sc_gem5::scheduler.update();
 }
@@ -178,9 +176,14 @@
 void
 Kernel::t0Handler()
 {
-    ::sc_gem5::scheduler.initPhase();
-
-    status(::sc_core::SC_RUNNING);
+    if (stopAfterCallbacks) {
+        scheduler.clear();
+        ::sc_gem5::scheduler.initPhase();
+        scheduler.scheduleStop(false);
+    } else {
+        ::sc_gem5::scheduler.initPhase();
+        status(::sc_core::SC_RUNNING);
+    }
 }

 Kernel *kernel;

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/12468
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-Change-Id: I5edfbceda457df88d15bfcac4d97e8578205ec5b
Gerrit-Change-Number: 12468
Gerrit-PatchSet: 1
Gerrit-Owner: Gabe Black <[email protected]>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to