summaryrefslogtreecommitdiff
path: root/src/systemc
diff options
context:
space:
mode:
authorGabe Black <gabeblack@google.com>2018-09-22 06:28:32 -0700
committerGabe Black <gabeblack@google.com>2018-10-16 00:28:28 +0000
commit2ede803d7c29065c1e42442b495f773c03c68270 (patch)
tree9565fcbfdaebddf9438f1fc910260dd3d27e1102 /src/systemc
parent0f6961d200e6334ca676f16f81280fbdec62b942 (diff)
downloadgem5-2ede803d7c29065c1e42442b495f773c03c68270.tar.xz
systemc: Make sure the right type process is running when calling wait.
That function is only allowed when running a thread or cthread. Change-Id: Idf98b70018169d4f724aa8168f3c4e8161f0b83d Reviewed-on: https://gem5-review.googlesource.com/c/12967 Reviewed-by: Gabe Black <gabeblack@google.com> Maintainer: Gabe Black <gabeblack@google.com>
Diffstat (limited to 'src/systemc')
-rw-r--r--src/systemc/core/sc_module.cc33
-rw-r--r--src/systemc/tests/systemc/kernel/dynamic_processes/test03/expected_returncode1
2 files changed, 34 insertions, 0 deletions
diff --git a/src/systemc/core/sc_module.cc b/src/systemc/core/sc_module.cc
index 32d1c979a..dfd89790c 100644
--- a/src/systemc/core/sc_module.cc
+++ b/src/systemc/core/sc_module.cc
@@ -591,10 +591,29 @@ timed_out()
}
+namespace
+{
+
+bool
+waitErrorCheck(sc_gem5::Process *p)
+{
+ if (p->procKind() == SC_METHOD_PROC_) {
+ SC_REPORT_ERROR(
+ "(E519) wait() is only allowed in SC_THREADs and SC_CTHREADs",
+ "\n in SC_METHODs use next_trigger() instead");
+ return true;
+ }
+ return false;
+}
+
+} // anonymous namespace
+
void
wait()
{
sc_gem5::Process *p = sc_gem5::scheduler.current();
+ if (waitErrorCheck(p))
+ return;
p->cancelTimeout();
p->clearDynamic();
sc_gem5::scheduler.yield();
@@ -615,6 +634,8 @@ void
wait(const sc_event &e)
{
sc_gem5::Process *p = sc_gem5::scheduler.current();
+ if (waitErrorCheck(p))
+ return;
p->cancelTimeout();
::sc_gem5::newDynamicSensitivityEvent(p, &e);
sc_gem5::scheduler.yield();
@@ -624,6 +645,8 @@ void
wait(const sc_event_or_list &eol)
{
sc_gem5::Process *p = sc_gem5::scheduler.current();
+ if (waitErrorCheck(p))
+ return;
p->cancelTimeout();
::sc_gem5::newDynamicSensitivityEventOrList(p, &eol);
sc_gem5::scheduler.yield();
@@ -633,6 +656,8 @@ void
wait(const sc_event_and_list &eal)
{
sc_gem5::Process *p = sc_gem5::scheduler.current();
+ if (waitErrorCheck(p))
+ return;
p->cancelTimeout();
::sc_gem5::newDynamicSensitivityEventAndList(p, &eal);
sc_gem5::scheduler.yield();
@@ -642,6 +667,8 @@ void
wait(const sc_time &t)
{
sc_gem5::Process *p = sc_gem5::scheduler.current();
+ if (waitErrorCheck(p))
+ return;
p->setTimeout(t);
p->clearDynamic();
sc_gem5::scheduler.yield();
@@ -657,6 +684,8 @@ void
wait(const sc_time &t, const sc_event &e)
{
sc_gem5::Process *p = sc_gem5::scheduler.current();
+ if (waitErrorCheck(p))
+ return;
p->setTimeout(t);
::sc_gem5::newDynamicSensitivityEvent(p, &e);
sc_gem5::scheduler.yield();
@@ -672,6 +701,8 @@ void
wait(const sc_time &t, const sc_event_or_list &eol)
{
sc_gem5::Process *p = sc_gem5::scheduler.current();
+ if (waitErrorCheck(p))
+ return;
p->setTimeout(t);
::sc_gem5::newDynamicSensitivityEventOrList(p, &eol);
sc_gem5::scheduler.yield();
@@ -687,6 +718,8 @@ void
wait(const sc_time &t, const sc_event_and_list &eal)
{
sc_gem5::Process *p = sc_gem5::scheduler.current();
+ if (waitErrorCheck(p))
+ return;
p->setTimeout(t);
::sc_gem5::newDynamicSensitivityEventAndList(p, &eal);
sc_gem5::scheduler.yield();
diff --git a/src/systemc/tests/systemc/kernel/dynamic_processes/test03/expected_returncode b/src/systemc/tests/systemc/kernel/dynamic_processes/test03/expected_returncode
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/src/systemc/tests/systemc/kernel/dynamic_processes/test03/expected_returncode
@@ -0,0 +1 @@
+1