summaryrefslogtreecommitdiff
path: root/src/systemc/core/kernel.cc
diff options
context:
space:
mode:
authorGabe Black <gabeblack@google.com>2018-07-20 19:23:58 -0700
committerGabe Black <gabeblack@google.com>2018-09-11 21:44:35 +0000
commit3224bc355464bfa6bac924e6fa6d6d507700e3ff (patch)
treef35c31b2748ea0cebb4ff303e642371f76e14ede /src/systemc/core/kernel.cc
parent81b6ef4478c014a77bd0253d316ab3d349ad8ac8 (diff)
downloadgem5-3224bc355464bfa6bac924e6fa6d6d507700e3ff.tar.xz
systemc: Make some functions of the kernel static.
This makes it possible to call them without having to have a kernel instance available. The kernel is a singleton anyway, so there should only ever be a single instance of any of these values. Change-Id: I3610d60cc72e9f3114997fe63db94b96ccaac3cd Reviewed-on: https://gem5-review.googlesource.com/12041 Reviewed-by: Gabe Black <gabeblack@google.com> Maintainer: Gabe Black <gabeblack@google.com>
Diffstat (limited to 'src/systemc/core/kernel.cc')
-rw-r--r--src/systemc/core/kernel.cc46
1 files changed, 30 insertions, 16 deletions
diff --git a/src/systemc/core/kernel.cc b/src/systemc/core/kernel.cc
index dac2229e2..9eed325ec 100644
--- a/src/systemc/core/kernel.cc
+++ b/src/systemc/core/kernel.cc
@@ -36,44 +36,58 @@
namespace sc_gem5
{
+namespace
+{
+
+bool stopAfterCallbacks = false;
+bool startComplete = false;
+bool endComplete = false;
+
+sc_core::sc_status _status = sc_core::SC_ELABORATION;
+
+} // anonymous namespace
+
+bool Kernel::startOfSimulationComplete() { return startComplete; }
+bool Kernel::endOfSimulationComplete() { return endComplete; }
+
+sc_core::sc_status Kernel::status() { return _status; }
+void Kernel::status(sc_core::sc_status s) { _status = s; }
+
Kernel::Kernel(Params *params) :
- SimObject(params), _stopAfterCallbacks(false),
- _startComplete(false), _endComplete(false),
- _status(sc_core::SC_ELABORATION),
- t0Event(this, false, EventBase::Default_Pri - 1) {}
+ SimObject(params), t0Event(this, false, EventBase::Default_Pri - 1) {}
void
Kernel::init()
{
- kernel->status(::sc_core::SC_BEFORE_END_OF_ELABORATION);
+ status(::sc_core::SC_BEFORE_END_OF_ELABORATION);
for (auto m: sc_gem5::allModules)
m->sc_mod()->before_end_of_elaboration();
- if (_stopAfterCallbacks)
+ if (stopAfterCallbacks)
stopWork();
}
void
Kernel::regStats()
{
- kernel->status(::sc_core::SC_END_OF_ELABORATION);
+ status(::sc_core::SC_END_OF_ELABORATION);
for (auto m: sc_gem5::allModules)
m->sc_mod()->end_of_elaboration();
- if (_stopAfterCallbacks)
+ if (stopAfterCallbacks)
stopWork();
}
void
Kernel::startup()
{
- kernel->status(::sc_core::SC_START_OF_SIMULATION);
+ status(::sc_core::SC_START_OF_SIMULATION);
for (auto m: sc_gem5::allModules)
m->sc_mod()->start_of_simulation();
- _startComplete = true;
+ startComplete = true;
- if (_stopAfterCallbacks)
+ if (stopAfterCallbacks)
stopWork();
kernel->status(::sc_core::SC_RUNNING);
@@ -89,7 +103,7 @@ void
Kernel::stop()
{
if (status() < ::sc_core::SC_RUNNING)
- _stopAfterCallbacks = true;
+ stopAfterCallbacks = true;
else
stopWork();
}
@@ -97,15 +111,15 @@ Kernel::stop()
void
Kernel::stopWork()
{
- kernel->status(::sc_core::SC_END_OF_SIMULATION);
+ status(::sc_core::SC_END_OF_SIMULATION);
for (auto m: sc_gem5::allModules)
m->sc_mod()->end_of_simulation();
- _endComplete = true;
+ endComplete = true;
- kernel->status(::sc_core::SC_STOPPED);
+ status(::sc_core::SC_STOPPED);
- if (_stopAfterCallbacks)
+ if (stopAfterCallbacks)
fatal("Simulation called sc_stop during elaboration.\n");
}