summaryrefslogtreecommitdiff
path: root/src/systemc/tests/systemc/kernel/process_control
diff options
context:
space:
mode:
Diffstat (limited to 'src/systemc/tests/systemc/kernel/process_control')
-rw-r--r--src/systemc/tests/systemc/kernel/process_control/disable_enable/test1/golden/test1.log29
-rw-r--r--src/systemc/tests/systemc/kernel/process_control/disable_enable/test1/test1.cpp201
-rw-r--r--src/systemc/tests/systemc/kernel/process_control/disable_enable/test2/golden/test2.log84
-rw-r--r--src/systemc/tests/systemc/kernel/process_control/disable_enable/test2/test2.cpp222
-rw-r--r--src/systemc/tests/systemc/kernel/process_control/reset/method_reset_throw/golden/sc_method_reset_throw.log7
-rw-r--r--src/systemc/tests/systemc/kernel/process_control/reset/method_reset_throw/sc_method_reset_throw.cpp100
-rw-r--r--src/systemc/tests/systemc/kernel/process_control/reset/method_self_reset/golden/method_self_reset.log14
-rw-r--r--src/systemc/tests/systemc/kernel/process_control/reset/method_self_reset/method_self_reset.cpp82
-rw-r--r--src/systemc/tests/systemc/kernel/process_control/suspend_resume/test1/golden/test1.log30
-rw-r--r--src/systemc/tests/systemc/kernel/process_control/suspend_resume/test1/test1.cpp216
-rw-r--r--src/systemc/tests/systemc/kernel/process_control/suspend_resume/test2/golden/test2.log90
-rw-r--r--src/systemc/tests/systemc/kernel/process_control/suspend_resume/test2/test2.cpp237
-rw-r--r--src/systemc/tests/systemc/kernel/process_control/test01/golden/test01.log76
-rw-r--r--src/systemc/tests/systemc/kernel/process_control/test01/test01.cpp260
-rw-r--r--src/systemc/tests/systemc/kernel/process_control/test02/golden/test02.log24
-rw-r--r--src/systemc/tests/systemc/kernel/process_control/test02/test02.cpp237
-rw-r--r--src/systemc/tests/systemc/kernel/process_control/test03/golden/test03.log73
-rw-r--r--src/systemc/tests/systemc/kernel/process_control/test03/test03.cpp385
-rw-r--r--src/systemc/tests/systemc/kernel/process_control/test04/golden/test04.log20
-rw-r--r--src/systemc/tests/systemc/kernel/process_control/test04/test04.cpp137
-rw-r--r--src/systemc/tests/systemc/kernel/process_control/test05/golden/test05.log10
-rw-r--r--src/systemc/tests/systemc/kernel/process_control/test05/test05.cpp112
-rw-r--r--src/systemc/tests/systemc/kernel/process_control/test06/golden/test06.log21
-rw-r--r--src/systemc/tests/systemc/kernel/process_control/test06/test06.cpp130
-rw-r--r--src/systemc/tests/systemc/kernel/process_control/test07/golden/test07.log90
-rw-r--r--src/systemc/tests/systemc/kernel/process_control/test07/test07.cpp204
-rw-r--r--src/systemc/tests/systemc/kernel/process_control/test08/golden/test08.log16
-rw-r--r--src/systemc/tests/systemc/kernel/process_control/test08/test08.cpp127
-rw-r--r--src/systemc/tests/systemc/kernel/process_control/throw_it/test1/golden/test1.log5
-rw-r--r--src/systemc/tests/systemc/kernel/process_control/throw_it/test1/test1.cpp57
30 files changed, 3296 insertions, 0 deletions
diff --git a/src/systemc/tests/systemc/kernel/process_control/disable_enable/test1/golden/test1.log b/src/systemc/tests/systemc/kernel/process_control/disable_enable/test1/golden/test1.log
new file mode 100644
index 000000000..a5d597234
--- /dev/null
+++ b/src/systemc/tests/systemc/kernel/process_control/disable_enable/test1/golden/test1.log
@@ -0,0 +1,29 @@
+SystemC Simulation
+0 s[0]: target_method0: starting
+0 s[0]: target_method0: issuing self disable
+0 s[0]: target_method0: after issuing self disable
+
+0 s[0]: target_thread0: starting
+0 s[0]: target_thread0: issuing self disable
+0 s[0]: target_thread0: after issuing self disable
+
+0 s[1]: target_cthread0: starting
+0 s[1]: target_cthread0: issuing self disable
+0 s[1]: target_cthread0: after issuing self disable
+
+
+10 ns[21]: stimulator: enabling target_cthread0
+
+
+20 ns[51]: stimulator: enabling target_method0
+
+
+30 ns[81]: stimulator: enabling target_thread0
+
+80 ns[231]: target_thread0: terminating
+109 ns[319]: target_cthread0: terminating
+118 ns[346]: target_method0: terminating
+
+1030 ns[3081]: stimulator: terminating
+
+Info: /OSCI/SystemC: Simulation stopped by user.
diff --git a/src/systemc/tests/systemc/kernel/process_control/disable_enable/test1/test1.cpp b/src/systemc/tests/systemc/kernel/process_control/disable_enable/test1/test1.cpp
new file mode 100644
index 000000000..62a88b763
--- /dev/null
+++ b/src/systemc/tests/systemc/kernel/process_control/disable_enable/test1/test1.cpp
@@ -0,0 +1,201 @@
+/*****************************************************************************
+
+ Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
+ more contributor license agreements. See the NOTICE file distributed
+ with this work for additional information regarding copyright ownership.
+ Accellera licenses this file to you under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with the
+ License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied. See the License for the specific language governing
+ permissions and limitations under the License.
+
+ *****************************************************************************/
+
+//*****************************************************************************
+//
+// test01.cpp -- test self disables on processes
+//
+// Original Author: Andy Goodrich, Forte Design Systems, Inc.
+//
+// CVS MODIFICATION LOG - modifiers, enter your name, affiliation, date and
+// changes you are making here.
+//
+// $Log: test1.cpp,v $
+// Revision 1.2 2009/07/28 01:09:48 acg
+// Andy Goodrich: replacement test using standardized environment.
+//
+//*****************************************************************************
+
+#define SC_INCLUDE_DYNAMIC_PROCESSES
+#include "systemc.h"
+
+enum my_process_states {
+ ST_DISABLED,
+ ST_NORMAL,
+ ST_SUSPENDED
+};
+
+inline ostream& time_stamp( ostream& os )
+{
+ os << dec << sc_time_stamp() << "[" << sc_delta_count() << "]: ";
+ return os;
+}
+
+SC_MODULE(top) {
+ // constructor:
+
+ SC_CTOR(top) :
+ m_state_cthread0(ST_NORMAL),
+ m_state_method0(ST_NORMAL),
+ m_state_thread0(ST_NORMAL)
+ {
+ SC_THREAD(stimulator0);
+
+ SC_CTHREAD( target_cthread0, m_clk.pos() );
+ m_target_cthread0 = sc_get_current_process_handle();
+
+ SC_METHOD(target_method0);
+ sensitive << m_clk.pos();
+ m_target_method0 = sc_get_current_process_handle();
+
+ SC_THREAD(target_thread0);
+ m_target_thread0 = sc_get_current_process_handle();
+ }
+
+ // processes:
+
+ void stimulator0();
+ void target_cthread0();
+ void target_method0();
+ void target_thread0();
+
+ // Storage:
+
+ sc_in<bool> m_clk;
+ int m_state_cthread0;
+ int m_state_method0;
+ int m_state_thread0;
+ sc_process_handle m_target_cthread0;
+ sc_process_handle m_target_method0;
+ sc_process_handle m_target_thread0;
+};
+
+void top::stimulator0()
+{
+ const char* name = "stimulator";
+ wait(10, SC_NS);
+ cout << endl;
+ time_stamp(cout) << name << ": enabling target_cthread0" << endl;
+ cout << endl;
+ m_state_cthread0 = ST_NORMAL;
+ m_target_cthread0.enable();
+ wait(10, SC_NS);
+
+ cout << endl;
+ time_stamp(cout) << name << ": enabling target_method0" << endl;
+ cout << endl;
+ m_state_method0 = ST_NORMAL;
+ m_target_method0.enable();
+ wait(10, SC_NS);
+
+ cout << endl;
+ time_stamp(cout) << name << ": enabling target_thread0" << endl;
+ cout << endl;
+ m_state_thread0 = ST_NORMAL;
+ m_target_thread0.enable();
+ ::sc_core::wait(1000, SC_NS);
+
+ cout << endl;
+ time_stamp(cout) << name << ": terminating" << endl;
+ sc_stop();
+}
+
+void top::target_cthread0()
+{
+ int i;
+ const char* name = "target_cthread0";
+
+ time_stamp(cout) << name << ": starting" << endl;
+ time_stamp(cout) << name << ": issuing self disable" << endl;
+ m_state_cthread0 = ST_DISABLED;
+ m_target_cthread0.disable();
+ time_stamp(cout) << name << ": after issuing self disable" << endl;
+ cout << endl;
+ for ( i = 0; i < 100; i++ )
+ {
+ wait();
+ if ( m_state_cthread0 == ST_DISABLED )
+ {
+ time_stamp(cout) << name << ": ERROR should not see this" << endl;
+ }
+ }
+ time_stamp(cout) << name << ": terminating" << endl;
+}
+
+void top::target_method0()
+{
+ const char* name = "target_method0";
+ static int state = 0;
+ switch( state )
+ {
+ case 0:
+ time_stamp(cout) << name << ": starting" << endl;
+ time_stamp(cout) << name << ": issuing self disable" << endl;
+ m_state_method0 = ST_DISABLED;
+ m_target_method0.disable();
+ time_stamp(cout) << name << ": after issuing self disable" << endl;
+ cout << endl;
+ break;
+ default:
+ if ( m_state_method0 == ST_DISABLED )
+ {
+ time_stamp(cout) << name << ": ERROR should not see this" << endl;
+ }
+ break;
+ case 99:
+ time_stamp(cout) << name << ": terminating" << endl;
+ break;
+ }
+ state++;
+}
+
+void top::target_thread0()
+{
+ const char* name = "target_thread0";
+
+ time_stamp(cout) << name << ": starting" << endl;
+ time_stamp(cout) << name << ": issuing self disable" << endl;
+ m_state_thread0 = ST_DISABLED;
+ m_target_thread0.disable();
+ time_stamp(cout) << name << ": after issuing self disable" << endl;
+ cout << endl;
+
+ // We wait a long enough time that our event will not occur until
+ // after we are re-enabled. Otherwise this thread will just go away
+ // quietly when the disable cancels the event.
+
+ ::sc_core::wait(80, SC_NS);
+ if ( m_state_thread0 == ST_DISABLED )
+ {
+ time_stamp(cout) << name << ": ERROR should not see this" << endl;
+ }
+ time_stamp(cout) << name << ": terminating" << endl;
+}
+
+int sc_main (int argc, char *argv[])
+{
+ sc_clock clock( "clock", 1.0, SC_NS );
+
+ top* top_p = new top("top");
+ top_p->m_clk(clock);
+
+ sc_start();
+ return 0;
+}
+
diff --git a/src/systemc/tests/systemc/kernel/process_control/disable_enable/test2/golden/test2.log b/src/systemc/tests/systemc/kernel/process_control/disable_enable/test2/golden/test2.log
new file mode 100644
index 000000000..6a5b9bd77
--- /dev/null
+++ b/src/systemc/tests/systemc/kernel/process_control/disable_enable/test2/golden/test2.log
@@ -0,0 +1,84 @@
+SystemC Simulation
+0 s[0]: target_method0: starting
+0 s[0]: target_thread0: starting
+0 s[1]: target_method0: active
+0 s[1]: target_cthread0: starting
+1 ns[3]: target_thread0: active
+
+2 ns[4]: stimulator: disabling target_cthread0
+
+2 ns[5]: target_method0: active
+3 ns[7]: target_thread0: active
+4 ns[9]: target_method0: active
+
+5 ns[10]: stimulator: disabling target_method0
+
+5 ns[11]: target_thread0: active
+7 ns[14]: target_thread0: active
+
+8 ns[15]: stimulator: disabling target_thread0
+
+
+11 ns[18]: stimulator: enabling target_cthread0
+
+12 ns[20]: target_cthread0: active
+
+14 ns[22]: stimulator: enabling target_method0
+
+14 ns[23]: target_method0: active
+14 ns[23]: target_cthread0: active
+16 ns[26]: target_method0: active
+16 ns[26]: target_cthread0: active
+
+17 ns[27]: stimulator: enabling target_thread0
+
+17 ns[28]: target_thread0: active
+18 ns[30]: target_method0: active
+18 ns[30]: target_cthread0: active
+19 ns[32]: target_thread0: active
+
+20 ns[33]: stimulator: disabling target_cthread0
+
+20 ns[34]: target_method0: active
+21 ns[36]: target_thread0: active
+22 ns[38]: target_method0: active
+
+23 ns[39]: stimulator: disabling target_method0
+
+23 ns[40]: target_thread0: active
+25 ns[43]: target_thread0: active
+
+26 ns[44]: stimulator: disabling target_thread0
+
+
+29 ns[47]: stimulator: enabling target_cthread0
+
+30 ns[49]: target_cthread0: active
+
+32 ns[51]: stimulator: enabling target_method0
+
+32 ns[52]: target_method0: active
+32 ns[52]: target_cthread0: active
+34 ns[55]: target_method0: active
+34 ns[55]: target_cthread0: active
+
+35 ns[56]: stimulator: enabling target_thread0
+
+35 ns[57]: target_thread0: active
+35 ns[57]: target_thread0: terminating
+36 ns[59]: target_method0: active
+36 ns[59]: target_cthread0: active
+38 ns[62]: target_method0: active
+38 ns[62]: target_cthread0: active
+40 ns[65]: target_method0: active
+40 ns[65]: target_cthread0: active
+40 ns[65]: target_cthread0: terminating
+42 ns[68]: target_method0: active
+44 ns[71]: target_method0: active
+46 ns[74]: target_method0: active
+48 ns[77]: target_method0: active
+52 ns[83]: target_method0: terminating
+
+1038 ns[1561]: stimulator: terminating
+
+Info: /OSCI/SystemC: Simulation stopped by user.
diff --git a/src/systemc/tests/systemc/kernel/process_control/disable_enable/test2/test2.cpp b/src/systemc/tests/systemc/kernel/process_control/disable_enable/test2/test2.cpp
new file mode 100644
index 000000000..f42d9bc98
--- /dev/null
+++ b/src/systemc/tests/systemc/kernel/process_control/disable_enable/test2/test2.cpp
@@ -0,0 +1,222 @@
+/*****************************************************************************
+
+ Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
+ more contributor license agreements. See the NOTICE file distributed
+ with this work for additional information regarding copyright ownership.
+ Accellera licenses this file to you under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with the
+ License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied. See the License for the specific language governing
+ permissions and limitations under the License.
+
+ *****************************************************************************/
+
+//*****************************************************************************
+//
+// test02.cpp -- test that disabled processes with static sensitivity
+// wake up when enabled.
+//
+// Original Author: Andy Goodrich, Forte Design Systems, Inc.
+//
+// CVS MODIFICATION LOG - modifiers, enter your name, affiliation, date and
+// changes you are making here.
+//
+// $Log: test2.cpp,v $
+// Revision 1.2 2009/07/28 01:10:19 acg
+// Andy Goodrich: replacement test using standardized test bench.
+//
+//*****************************************************************************
+
+#define SC_INCLUDE_DYNAMIC_PROCESSES
+#include "systemc.h"
+
+enum my_process_states {
+ ST_DISABLED,
+ ST_NORMAL,
+ ST_SUSPENDED
+};
+
+inline ostream& time_stamp( ostream& os )
+{
+ os << dec << sc_time_stamp() << "[" << sc_delta_count() << "]: ";
+ return os;
+}
+
+SC_MODULE(top) {
+ // constructor:
+
+ SC_CTOR(top)
+ {
+ m_state_cthread0 = ST_NORMAL;
+ m_state_method0 = ST_NORMAL;
+ m_state_thread0 = ST_NORMAL;
+
+ SC_THREAD(stimulator0);
+
+ SC_CTHREAD( target_cthread0, m_clk.pos() );
+ m_target_cthread0 = sc_get_current_process_handle();
+
+ SC_METHOD(target_method0);
+ sensitive << m_clk.pos();
+ m_target_method0 = sc_get_current_process_handle();
+
+ SC_THREAD(target_thread0);
+ sensitive << m_clk.neg();
+ m_target_thread0 = sc_get_current_process_handle();
+ }
+
+ // processes:
+
+ void stimulator0();
+ void target_cthread0();
+ void target_method0();
+ void target_thread0();
+
+ // Storage:
+
+ sc_in<bool> m_clk;
+ sc_signal<int> m_state_cthread0;
+ sc_signal<int> m_state_method0;
+ sc_signal<int> m_state_thread0;
+ sc_process_handle m_target_cthread0;
+ sc_process_handle m_target_method0;
+ sc_process_handle m_target_thread0;
+};
+
+#define DISABLE(TARGET) \
+ cout << endl; \
+ time_stamp(cout) << name << ": disabling target_" << #TARGET << endl; \
+ m_state_##TARGET = ST_DISABLED; \
+ m_target_##TARGET.disable(); \
+ cout << endl;
+
+#define ENABLE(TARGET) \
+ cout << endl; \
+ time_stamp(cout) << name << ": enabling target_" << #TARGET << endl; \
+ m_state_##TARGET = ST_NORMAL; \
+ m_target_##TARGET.enable(); \
+ cout << endl;
+
+void top::stimulator0()
+{
+ const char* name = "stimulator";
+
+ wait(2, SC_NS);
+
+ DISABLE(cthread0)
+ wait(3, SC_NS);
+ DISABLE(method0)
+ wait(3, SC_NS);
+ DISABLE(thread0)
+ wait(3, SC_NS);
+
+ ENABLE(cthread0)
+ wait(3, SC_NS);
+ ENABLE(method0)
+ wait(3, SC_NS);
+ ENABLE(thread0)
+ wait(3, SC_NS);
+
+ DISABLE(cthread0)
+ wait(3, SC_NS);
+ DISABLE(method0)
+ wait(3, SC_NS);
+ DISABLE(thread0)
+ wait(3, SC_NS);
+
+ ENABLE(cthread0)
+ wait(3, SC_NS);
+ ENABLE(method0)
+ wait(3, SC_NS);
+ ENABLE(thread0)
+ wait(3, SC_NS);
+
+ ::sc_core::wait(1000, SC_NS);
+ cout << endl;
+ time_stamp(cout) << name << ": terminating" << endl;
+ sc_stop();
+}
+
+void top::target_cthread0()
+{
+ const char* name = "target_cthread0";
+
+ time_stamp(cout) << name << ": starting" << endl;
+ for (int i = 0; i < 10; i++)
+ {
+ wait();
+ if ( m_state_cthread0 == ST_DISABLED )
+ {
+ time_stamp(cout) << name << ": ERROR should not see this" << endl;
+ }
+ else
+ {
+ time_stamp(cout) << name << ": active" << endl;
+ }
+ }
+ time_stamp(cout) << name << ": terminating" << endl;
+}
+
+void top::target_method0()
+{
+ const char* name = "target_method0";
+ static int state = 0;
+ switch( state )
+ {
+ case 0:
+ time_stamp(cout) << name << ": starting" << endl;
+ break;
+ default:
+ if ( m_state_method0 == ST_DISABLED )
+ {
+ time_stamp(cout) << name << ": ERROR should not see this" << endl;
+ }
+ else if ( state < 18 )
+ {
+ time_stamp(cout) << name << ": active" << endl;
+ }
+ break;
+ case 19:
+ time_stamp(cout) << name << ": terminating" << endl;
+ break;
+ }
+ state++;
+}
+
+void top::target_thread0()
+{
+ const char* name = "target_thread0";
+
+ time_stamp(cout) << name << ": starting" << endl;
+ for (int i = 0; i < 10; i++)
+ {
+ wait();
+ if ( m_state_thread0 == ST_DISABLED )
+ {
+ time_stamp(cout) << name << ": ERROR should not see this" << endl;
+ }
+ else
+ {
+ time_stamp(cout) << name << ": active" << endl;
+ }
+ }
+ time_stamp(cout) << name << ": terminating" << endl;
+}
+
+int sc_main (int argc, char *argv[])
+{
+ sc_clock clock( "clock", 2.0, SC_NS );
+
+ top* top_p = new top("top");
+ top_p->m_clk(clock);
+
+ sc_start();
+ return 0;
+}
+
diff --git a/src/systemc/tests/systemc/kernel/process_control/reset/method_reset_throw/golden/sc_method_reset_throw.log b/src/systemc/tests/systemc/kernel/process_control/reset/method_reset_throw/golden/sc_method_reset_throw.log
new file mode 100644
index 000000000..31efd2c64
--- /dev/null
+++ b/src/systemc/tests/systemc/kernel/process_control/reset/method_reset_throw/golden/sc_method_reset_throw.log
@@ -0,0 +1,7 @@
+SystemC Simulation
+5 ns: reset method m1
+5 ns: in m1
+5 ns: in m1() throwing exception in throwee1
+5 ns: in throwee1, caught exception
+5 ns: in m1() after throwing exception in throwee1
+5 ns: after reset of method m1
diff --git a/src/systemc/tests/systemc/kernel/process_control/reset/method_reset_throw/sc_method_reset_throw.cpp b/src/systemc/tests/systemc/kernel/process_control/reset/method_reset_throw/sc_method_reset_throw.cpp
new file mode 100644
index 000000000..c6596f0c7
--- /dev/null
+++ b/src/systemc/tests/systemc/kernel/process_control/reset/method_reset_throw/sc_method_reset_throw.cpp
@@ -0,0 +1,100 @@
+
+/*****************************************************************************
+
+ The following code is derived, directly or indirectly, from the SystemC
+ source code Copyright (c) 1996-2014 by all Contributors.
+ All Rights reserved.
+
+ The contents of this file are subject to the restrictions and limitations
+ set forth in the SystemC Open Source License (the "License");
+ You may not use this file except in compliance with such restrictions and
+ limitations. You may obtain instructions on how to receive a copy of the
+ License at http://www.accellera.org/. Software distributed by Contributors
+ under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
+ ANY KIND, either express or implied. See the License for the specific
+ language governing rights and limitations under the License.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ sc_method_reset_throw.cpp --
+
+ Original Author: Bishnupriya Bhattacharya, Cadence Design Systems, 2012-08-07
+
+ *****************************************************************************/
+
+#define SC_INCLUDE_DYNAMIC_PROCESSES
+#include <systemc.h>
+
+class my_exception
+{
+public:
+ explicit my_exception(const char* s) : s_(s) { }
+ const char* message() const { return s_.c_str(); }
+protected:
+ std::string s_;
+};
+
+SC_MODULE(sctop)
+{
+public:
+ SC_CTOR(sctop)
+ {
+ SC_THREAD(run);
+ SC_METHOD(m1); dont_initialize();
+ method_handle = sc_get_current_process_handle();
+ SC_THREAD(throwee1);
+ throwee1_h = sc_get_current_process_handle();
+ }
+
+ void run() {
+ wait (5, SC_NS);
+ cout << sc_time_stamp() << ": reset method m1" << endl;
+ method_handle.reset();
+ cout << sc_time_stamp() << ": after reset of method m1" << endl;
+ }
+
+ void m1()
+ {
+ cout << sc_time_stamp() << ": in m1" << endl;
+ cout << sc_time_stamp() << ": in m1() "
+ << "throwing exception in throwee1" << endl;
+
+ throwee1_h.throw_it(
+ my_exception("thrown in throwee1 from m1()")
+ );
+
+ cout << sc_time_stamp() << ": in m1() "
+ << "after throwing exception in throwee1" << endl;
+ }
+
+ void throwee1()
+ {
+ // catch exception and exit
+ while (1) {
+ try {
+ wait(50, SC_NS);
+ cerr << sc_time_stamp() << ": in throwee1, normal flow" << endl;
+ }
+ catch (my_exception const & x) {
+ cerr << sc_time_stamp() << ": in throwee1, caught exception "
+ << endl;
+ return;
+ }
+ }
+ }
+
+protected:
+ sc_process_handle method_handle;
+ sc_process_handle throwee1_h;
+};
+
+
+int sc_main (int, char*[])
+{
+ sc_report_handler::set_actions( SC_ID_DISABLE_WILL_ORPHAN_PROCESS_, SC_DO_NOTHING );
+ sctop top1("Top1");
+ sc_start(10, SC_NS);
+ return 0;
+}
diff --git a/src/systemc/tests/systemc/kernel/process_control/reset/method_self_reset/golden/method_self_reset.log b/src/systemc/tests/systemc/kernel/process_control/reset/method_self_reset/golden/method_self_reset.log
new file mode 100644
index 000000000..f5f0d3ebe
--- /dev/null
+++ b/src/systemc/tests/systemc/kernel/process_control/reset/method_self_reset/golden/method_self_reset.log
@@ -0,0 +1,14 @@
+SystemC Simulation
+Entry
+Issuing self reset
+Entry
+Exit
+Entry
+Exit
+Entry
+Issuing self reset
+Entry
+Exit
+Entry
+Exit
+Program completed
diff --git a/src/systemc/tests/systemc/kernel/process_control/reset/method_self_reset/method_self_reset.cpp b/src/systemc/tests/systemc/kernel/process_control/reset/method_self_reset/method_self_reset.cpp
new file mode 100644
index 000000000..8b5da09b4
--- /dev/null
+++ b/src/systemc/tests/systemc/kernel/process_control/reset/method_self_reset/method_self_reset.cpp
@@ -0,0 +1,82 @@
+/*****************************************************************************
+
+ Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
+ more contributor license agreements. See the NOTICE file distributed
+ with this work for additional information regarding copyright ownership.
+ Accellera licenses this file to you under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with the
+ License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied. See the License for the specific language governing
+ permissions and limitations under the License.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ method_self_reset.cpp -- Test of method self reset.
+
+ Original Author: Andy Goodrich
+
+ *****************************************************************************/
+// $Log: method_self_reset.cpp,v $
+// Revision 1.4 2011/07/24 15:59:53 acg
+// Andy Goodrich: add statement I missed installing Philipp's patch.
+//
+// Revision 1.3 2011/07/24 15:58:39 acg
+// Philipp A. Hartmann: convert first time toggle to counter since need 3
+// states.
+//
+// Revision 1.2 2011/02/04 15:26:33 acg
+// Andy Goodrich: regolden for proper process control semantics.
+//
+// Revision 1.1 2011/01/28 19:48:36 acg
+// Andy Goodrich: first check in.
+//
+
+#include "systemc.h"
+
+SC_MODULE(DUT)
+{
+ SC_CTOR(DUT)
+ {
+ SC_METHOD(method);
+ sensitive << m_clk.pos();
+ }
+ void method()
+ {
+ static int trigger = 0;
+ cout << "Entry " << endl;
+ switch( trigger++ )
+ {
+ case 0:
+ cout << "Issuing self reset " << endl;
+ sc_get_current_process_handle().reset();
+ sc_assert( false );
+ case 1:
+ break;
+ default:
+ trigger = 0;
+ }
+ cout << "Exit " << endl;
+ }
+ sc_in<bool> m_clk;
+};
+
+int sc_main(int argc, char* argv[])
+{
+ sc_clock clock;
+ DUT dut("dut");
+
+ dut.m_clk(clock);
+
+ sc_start(3, SC_NS);
+
+ cout << "Program completed" << endl;
+ return 0;
+}
diff --git a/src/systemc/tests/systemc/kernel/process_control/suspend_resume/test1/golden/test1.log b/src/systemc/tests/systemc/kernel/process_control/suspend_resume/test1/golden/test1.log
new file mode 100644
index 000000000..f32038842
--- /dev/null
+++ b/src/systemc/tests/systemc/kernel/process_control/suspend_resume/test1/golden/test1.log
@@ -0,0 +1,30 @@
+SystemC Simulation
+0 s[0]: target_method0: starting
+0 s[0]: target_method0: issuing self suspend
+0 s[0]: target_method0: after issuing self suspend
+
+0 s[0]: target_thread0: starting
+0 s[0]: target_thread0: issuing self suspend
+
+0 s[1]: target_cthread0: starting
+0 s[1]: target_cthread0: issuing self suspend
+
+
+10 ns[21]: stimulator: resuming target_cthread0
+
+10 ns[21]: target_cthread0: back from self suspend
+
+20 ns[51]: stimulator: resuming target_method0
+
+20 ns[51]: target_method0: back from self suspend
+
+30 ns[81]: stimulator: resuming target_thread0
+
+30 ns[81]: target_thread0: back from self suspend
+109 ns[319]: target_cthread0: terminating
+110 ns[321]: target_thread0: terminating
+117 ns[343]: target_method0: terminating
+
+1030 ns[3081]: stimulator: terminating
+
+Info: /OSCI/SystemC: Simulation stopped by user.
diff --git a/src/systemc/tests/systemc/kernel/process_control/suspend_resume/test1/test1.cpp b/src/systemc/tests/systemc/kernel/process_control/suspend_resume/test1/test1.cpp
new file mode 100644
index 000000000..af361436b
--- /dev/null
+++ b/src/systemc/tests/systemc/kernel/process_control/suspend_resume/test1/test1.cpp
@@ -0,0 +1,216 @@
+/*****************************************************************************
+
+ Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
+ more contributor license agreements. See the NOTICE file distributed
+ with this work for additional information regarding copyright ownership.
+ Accellera licenses this file to you under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with the
+ License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied. See the License for the specific language governing
+ permissions and limitations under the License.
+
+ *****************************************************************************/
+
+//*****************************************************************************
+//
+// test01.cpp -- test self suspends on processes
+//
+// Original Author: Andy Goodrich, Forte Design Systems, Inc.
+//
+// CVS MODIFICATION LOG - modifiers, enter your name, affiliation, date and
+// changes you are making here.
+//
+// $Log: test1.cpp,v $
+// Revision 1.4 2011/04/02 00:07:44 acg
+// Andy Goodrich: new message format.
+//
+// Revision 1.3 2011/03/07 19:32:07 acg
+// Andy Goodrich: addition to set sc_core::sc_allow_process_control_corners
+// to true so that this test avoids corner case error messages.
+//
+// Revision 1.2 2009/07/28 18:43:50 acg
+// Andy Goodrich: new standard test bench version of this test.
+//
+// Revision 1.2 2009/07/28 01:09:48 acg
+// Andy Goodrich: replacement test using standardized environment.
+//
+//*****************************************************************************
+
+#define SC_INCLUDE_DYNAMIC_PROCESSES
+#include "systemc.h"
+
+enum my_process_states {
+ ST_DISABLED,
+ ST_NORMAL,
+ ST_SUSPENDED
+};
+
+inline ostream& time_stamp( ostream& os )
+{
+ os << dec << sc_time_stamp() << "[" << sc_delta_count() << "]: ";
+ return os;
+}
+
+SC_MODULE(top) {
+ // constructor:
+
+ SC_CTOR(top) :
+ m_state_cthread0(ST_NORMAL),
+ m_state_method0(ST_NORMAL),
+ m_state_thread0(ST_NORMAL)
+ {
+ SC_THREAD(stimulator0);
+
+ SC_CTHREAD( target_cthread0, m_clk.pos() );
+ m_target_cthread0 = sc_get_current_process_handle();
+
+ SC_METHOD(target_method0);
+ sensitive << m_clk.pos();
+ m_target_method0 = sc_get_current_process_handle();
+
+ SC_THREAD(target_thread0);
+ m_target_thread0 = sc_get_current_process_handle();
+ }
+
+ // processes:
+
+ void stimulator0();
+ void target_cthread0();
+ void target_method0();
+ void target_thread0();
+
+ // Storage:
+
+ sc_in<bool> m_clk;
+ int m_state_cthread0;
+ int m_state_method0;
+ int m_state_thread0;
+ sc_process_handle m_target_cthread0;
+ sc_process_handle m_target_method0;
+ sc_process_handle m_target_thread0;
+};
+
+void top::stimulator0()
+{
+ const char* name = "stimulator";
+ wait(10, SC_NS);
+ cout << endl;
+ time_stamp(cout) << name << ": resuming target_cthread0" << endl;
+ cout << endl;
+ m_state_cthread0 = ST_NORMAL;
+ m_target_cthread0.resume();
+ wait(10, SC_NS);
+
+ cout << endl;
+ time_stamp(cout) << name << ": resuming target_method0" << endl;
+ cout << endl;
+ m_state_method0 = ST_NORMAL;
+ m_target_method0.resume();
+ wait(10, SC_NS);
+
+ cout << endl;
+ time_stamp(cout) << name << ": resuming target_thread0" << endl;
+ cout << endl;
+ m_state_thread0 = ST_NORMAL;
+ m_target_thread0.resume();
+ ::sc_core::wait(1000, SC_NS);
+
+ cout << endl;
+ time_stamp(cout) << name << ": terminating" << endl;
+ sc_stop();
+}
+
+void top::target_cthread0()
+{
+ int i;
+ const char* name = "target_cthread0";
+
+ time_stamp(cout) << name << ": starting" << endl;
+ time_stamp(cout) << name << ": issuing self suspend" << endl;
+ cout << endl;
+ m_state_cthread0 = ST_SUSPENDED;
+ m_target_cthread0.suspend();
+ time_stamp(cout) << name << ": back from self suspend" << endl;
+ for ( i = 0; i < 100; i++ )
+ {
+ if ( m_state_cthread0 == ST_SUSPENDED )
+ {
+ time_stamp(cout) << name << ": ERROR should not see this" << endl;
+ }
+ wait();
+ }
+ time_stamp(cout) << name << ": terminating" << endl;
+}
+
+void top::target_method0()
+{
+ const char* name = "target_method0";
+ static int state = 0;
+ switch( state )
+ {
+ case 0:
+ time_stamp(cout) << name << ": starting" << endl;
+ time_stamp(cout) << name << ": issuing self suspend" << endl;
+ m_state_method0 = ST_SUSPENDED;
+ m_target_method0.suspend();
+ time_stamp(cout) << name << ": after issuing self suspend" << endl;
+ cout << endl;
+ break;
+ case 1:
+ time_stamp(cout) << name << ": back from self suspend" << endl;
+ // fall through
+ default:
+ if ( m_state_method0 == ST_SUSPENDED )
+ {
+ time_stamp(cout) << name << ": ERROR should not see this" << endl;
+ }
+ break;
+ case 99:
+ time_stamp(cout) << name << ": terminating" << endl;
+ break;
+ }
+ state++;
+}
+
+void top::target_thread0()
+{
+ const char* name = "target_thread0";
+
+ time_stamp(cout) << name << ": starting" << endl;
+ time_stamp(cout) << name << ": issuing self suspend" << endl;
+ cout << endl;
+ m_state_thread0 = ST_SUSPENDED;
+ m_target_thread0.suspend();
+ time_stamp(cout) << name << ": back from self suspend" << endl;
+
+ // We wait a long enough time that our event will not occur until
+ // after we are resumed. Otherwise this thread will just go away
+ // quietly when the suspend cancels the event.
+
+ ::sc_core::wait(80, SC_NS);
+ if ( m_state_thread0 == ST_SUSPENDED )
+ {
+ time_stamp(cout) << name << ": ERROR should not see this" << endl;
+ }
+ time_stamp(cout) << name << ": terminating" << endl;
+}
+
+int sc_main (int argc, char *argv[])
+{
+ sc_core::sc_allow_process_control_corners = true;
+ sc_clock clock( "clock", 1.0, SC_NS );
+
+ top* top_p = new top("top");
+ top_p->m_clk(clock);
+
+ sc_core::sc_allow_process_control_corners = true;
+ sc_start();
+ return 0;
+}
+
diff --git a/src/systemc/tests/systemc/kernel/process_control/suspend_resume/test2/golden/test2.log b/src/systemc/tests/systemc/kernel/process_control/suspend_resume/test2/golden/test2.log
new file mode 100644
index 000000000..64627e16a
--- /dev/null
+++ b/src/systemc/tests/systemc/kernel/process_control/suspend_resume/test2/golden/test2.log
@@ -0,0 +1,90 @@
+SystemC Simulation
+0 s[0]: target_method0: starting
+0 s[0]: target_thread0: starting
+0 s[1]: target_method0: active
+0 s[1]: target_cthread0: starting
+1 ns[3]: target_thread0: active
+
+2 ns[4]: stimulator: suspending target_cthread0
+
+2 ns[5]: target_method0: active
+3 ns[7]: target_thread0: active
+4 ns[9]: target_method0: active
+
+5 ns[10]: stimulator: suspending target_method0
+
+5 ns[11]: target_thread0: active
+7 ns[14]: target_thread0: active
+
+8 ns[15]: stimulator: suspending target_thread0
+
+
+11 ns[18]: stimulator: resuming target_cthread0
+
+11 ns[18]: target_cthread0: active
+12 ns[20]: target_cthread0: active
+
+14 ns[22]: stimulator: resuming target_method0
+
+14 ns[22]: target_method0: active
+14 ns[23]: target_method0: active
+14 ns[23]: target_cthread0: active
+16 ns[26]: target_method0: active
+16 ns[26]: target_cthread0: active
+
+17 ns[27]: stimulator: resuming target_thread0
+
+17 ns[27]: target_thread0: active
+17 ns[28]: target_thread0: active
+18 ns[30]: target_method0: active
+18 ns[30]: target_cthread0: active
+19 ns[32]: target_thread0: active
+
+20 ns[33]: stimulator: suspending target_cthread0
+
+20 ns[34]: target_method0: active
+21 ns[36]: target_thread0: active
+22 ns[38]: target_method0: active
+
+23 ns[39]: stimulator: suspending target_method0
+
+23 ns[40]: target_thread0: active
+25 ns[43]: target_thread0: active
+
+26 ns[44]: stimulator: suspending target_thread0
+
+
+29 ns[47]: stimulator: resuming target_cthread0
+
+29 ns[47]: target_cthread0: active
+30 ns[49]: target_cthread0: active
+
+32 ns[51]: stimulator: resuming target_method0
+
+32 ns[51]: target_method0: active
+32 ns[52]: target_method0: active
+32 ns[52]: target_cthread0: active
+34 ns[55]: target_method0: active
+34 ns[55]: target_cthread0: active
+
+35 ns[56]: stimulator: resuming target_thread0
+
+35 ns[56]: target_thread0: active
+35 ns[57]: target_thread0: active
+35 ns[57]: target_thread0: terminating
+36 ns[59]: target_method0: active
+36 ns[59]: target_cthread0: active
+38 ns[62]: target_method0: active
+38 ns[62]: target_cthread0: active
+40 ns[65]: target_method0: active
+40 ns[65]: target_cthread0: active
+40 ns[65]: target_cthread0: terminating
+42 ns[68]: target_method0: active
+44 ns[71]: target_method0: active
+46 ns[74]: target_method0: active
+48 ns[77]: target_method0: active
+52 ns[83]: target_method0: terminating
+
+1038 ns[1561]: stimulator: terminating
+
+Info: /OSCI/SystemC: Simulation stopped by user.
diff --git a/src/systemc/tests/systemc/kernel/process_control/suspend_resume/test2/test2.cpp b/src/systemc/tests/systemc/kernel/process_control/suspend_resume/test2/test2.cpp
new file mode 100644
index 000000000..2e4f8997b
--- /dev/null
+++ b/src/systemc/tests/systemc/kernel/process_control/suspend_resume/test2/test2.cpp
@@ -0,0 +1,237 @@
+/*****************************************************************************
+
+ Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
+ more contributor license agreements. See the NOTICE file distributed
+ with this work for additional information regarding copyright ownership.
+ Accellera licenses this file to you under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with the
+ License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied. See the License for the specific language governing
+ permissions and limitations under the License.
+
+ *****************************************************************************/
+
+//*****************************************************************************
+//
+// test02.cpp -- test that suspended processes with static sensitivity
+// wake up when resumed.
+//
+// Original Author: Andy Goodrich, Forte Design Systems, Inc.
+//
+// CVS MODIFICATION LOG - modifiers, enter your name, affiliation, date and
+// changes you are making here.
+//
+// $Log: test2.cpp,v $
+// Revision 1.5 2011/04/02 00:08:19 acg
+// Andy Goodrich: turn off corner case error checking.
+//
+// Revision 1.4 2011/03/07 19:32:09 acg
+// Andy Goodrich: addition to set sc_core::sc_allow_process_control_corners
+// to true so that this test avoids corner case error messages.
+//
+// Revision 1.3 2011/02/20 13:43:49 acg
+// Andy Goodrich: updates for IEEE 1666 2011.
+//
+// Revision 1.2 2011/02/04 15:26:52 acg
+// Andy Goodrich: changes for process control semantics.
+//
+// Revision 1.1 2009/07/28 18:43:55 acg
+// Andy Goodrich: new standard test bench version of this test.
+//
+//*****************************************************************************
+
+#define SC_INCLUDE_DYNAMIC_PROCESSES
+#include "systemc.h"
+
+enum my_process_states {
+ ST_SUSPENDD,
+ ST_NORMAL,
+ ST_SUSPENDED
+};
+
+inline ostream& time_stamp( ostream& os )
+{
+ os << dec << sc_time_stamp() << "[" << sc_delta_count() << "]: ";
+ return os;
+}
+
+SC_MODULE(top) {
+ // constructor:
+
+ SC_CTOR(top)
+ {
+ m_state_cthread0 = ST_NORMAL;
+ m_state_method0 = ST_NORMAL;
+ m_state_thread0 = ST_NORMAL;
+
+ SC_THREAD(stimulator0);
+
+ SC_CTHREAD( target_cthread0, m_clk.pos() );
+ m_target_cthread0 = sc_get_current_process_handle();
+
+ SC_METHOD(target_method0);
+ sensitive << m_clk.pos();
+ m_target_method0 = sc_get_current_process_handle();
+
+ SC_THREAD(target_thread0);
+ sensitive << m_clk.neg();
+ m_target_thread0 = sc_get_current_process_handle();
+ }
+
+ // processes:
+
+ void stimulator0();
+ void target_cthread0();
+ void target_method0();
+ void target_thread0();
+
+ // Storage:
+
+ sc_in<bool> m_clk;
+ int m_state_cthread0;
+ int m_state_method0;
+ int m_state_thread0;
+ sc_process_handle m_target_cthread0;
+ sc_process_handle m_target_method0;
+ sc_process_handle m_target_thread0;
+};
+
+#define SUSPEND(TARGET) \
+ cout << endl; \
+ time_stamp(cout) << name << ": suspending target_" << #TARGET << endl; \
+ m_state_##TARGET = ST_SUSPENDD; \
+ m_target_##TARGET.suspend(); \
+ cout << endl;
+
+#define RESUME(TARGET) \
+ cout << endl; \
+ time_stamp(cout) << name << ": resuming target_" << #TARGET << endl; \
+ m_state_##TARGET = ST_NORMAL; \
+ m_target_##TARGET.resume(); \
+ cout << endl;
+
+void top::stimulator0()
+{
+ const char* name = "stimulator";
+
+ wait(2, SC_NS);
+
+ SUSPEND(cthread0)
+ wait(3, SC_NS);
+ SUSPEND(method0)
+ wait(3, SC_NS);
+ SUSPEND(thread0)
+ wait(3, SC_NS);
+
+ RESUME(cthread0)
+ wait(3, SC_NS);
+ RESUME(method0)
+ wait(3, SC_NS);
+ RESUME(thread0)
+ wait(3, SC_NS);
+
+ SUSPEND(cthread0)
+ wait(3, SC_NS);
+ SUSPEND(method0)
+ wait(3, SC_NS);
+ SUSPEND(thread0)
+ wait(3, SC_NS);
+
+ RESUME(cthread0)
+ wait(3, SC_NS);
+ RESUME(method0)
+ wait(3, SC_NS);
+ RESUME(thread0)
+ wait(3, SC_NS);
+
+ ::sc_core::wait(1000, SC_NS);
+ cout << endl;
+ time_stamp(cout) << name << ": terminating" << endl;
+ sc_stop();
+}
+
+void top::target_cthread0()
+{
+ const char* name = "target_cthread0";
+
+ time_stamp(cout) << name << ": starting" << endl;
+ for (int i = 0; i < 12; i++)
+ {
+ wait();
+ if ( m_state_cthread0 == ST_SUSPENDD )
+ {
+ time_stamp(cout) << name << ": ERROR should not see this" << endl;
+ }
+ else
+ {
+ time_stamp(cout) << name << ": active" << endl;
+ }
+ }
+ time_stamp(cout) << name << ": terminating" << endl;
+}
+
+void top::target_method0()
+{
+ const char* name = "target_method0";
+ static int state = 0;
+ switch( state )
+ {
+ case 0:
+ time_stamp(cout) << name << ": starting" << endl;
+ break;
+ default:
+ if ( m_state_method0 == ST_SUSPENDD )
+ {
+ time_stamp(cout) << name << ": ERROR should not see this" << endl;
+ }
+ else if ( state < 20 )
+ {
+ time_stamp(cout) << name << ": active" << endl;
+ }
+ break;
+ case 21:
+ time_stamp(cout) << name << ": terminating" << endl;
+ break;
+ }
+ state++;
+}
+
+void top::target_thread0()
+{
+ const char* name = "target_thread0";
+
+ time_stamp(cout) << name << ": starting" << endl;
+ for (int i = 0; i < 12; i++)
+ {
+ wait();
+ if ( m_state_thread0 == ST_SUSPENDD )
+ {
+ time_stamp(cout) << name << ": ERROR should not see this" << endl;
+ }
+ else
+ {
+ time_stamp(cout) << name << ": active" << endl;
+ }
+ }
+ time_stamp(cout) << name << ": terminating" << endl;
+}
+
+int sc_main (int argc, char *argv[])
+{
+ sc_core::sc_allow_process_control_corners = true;
+ sc_clock clock( "clock", 2.0, SC_NS );
+
+ top* top_p = new top("top");
+ top_p->m_clk(clock);
+
+ sc_core::sc_allow_process_control_corners = true;
+ sc_start();
+ return 0;
+}
+
diff --git a/src/systemc/tests/systemc/kernel/process_control/test01/golden/test01.log b/src/systemc/tests/systemc/kernel/process_control/test01/golden/test01.log
new file mode 100644
index 000000000..824523a11
--- /dev/null
+++ b/src/systemc/tests/systemc/kernel/process_control/test01/golden/test01.log
@@ -0,0 +1,76 @@
+SystemC Simulation
+0 s: dynamic method (75,0) initialization call
+0 s: static method (136)
+0 s: dynamic thread (114) initialization call
+0 s: static method (136)
+0 s: dynamic method (80,1) after wait on m_clk.posedge_event()
+0 s: static thread (145)
+0 s: dynamic thread (119) after wait on m_clk.posedge_event()
+1 ns: static method (136)
+1 ns: dynamic method (86,2) after wait on m_clk.posedge_event()
+1 ns: static thread (145)
+1 ns: cthread (63)
+1 ns: dynamic thread (122) after wait on m_clk.posedge_event()
+1500 ps: dynamic method (92,3) after wait on m_clk.negedge()
+1500 ps: dynamic thread (125) after wait on m_clk.negedge_event()
+2 ns: static method (136)
+2 ns: stimulus (156) - suspending all processes
+
+5 ns: stimulus (171) - resuming all processes
+5 ns: static method (136)
+5 ns: cthread (63)
+5 ns: static thread (145)
+6 ns: static method (136)
+6 ns: stimulus (174) - suspending all processes
+7 ns: stimulus (183) - firing event1
+
+8 ns: stimulus (191) - resuming all processes
+8 ns: static method (136)
+8 ns: cthread (63)
+8 ns: static thread (145)
+9 ns: static method (136)
+9 ns: stimulus (195) - firing event2
+9 ns: static thread (145)
+9 ns: cthread (63)
+9 ns: dynamic method (97,4) after wait on m_event1 & m_event2
+9 ns: dynamic thread (128) after wait on m_event1 & m_event2
+10 ns: static method (136)
+10 ns: dynamic method (80,1) after wait on m_clk.posedge_event()
+10 ns: static thread (145)
+10 ns: cthread (63)
+10 ns: dynamic thread (119) after wait on m_clk.posedge_event()
+11 ns: static method (136)
+11 ns: dynamic method (86,2) after wait on m_clk.posedge_event()
+11 ns: static thread (145)
+11 ns: cthread (63)
+11 ns: dynamic thread (122) after wait on m_clk.posedge_event()
+11500 ps: dynamic method (92,3) after wait on m_clk.negedge()
+11500 ps: dynamic thread (125) after wait on m_clk.negedge_event()
+12 ns: static method (136)
+12 ns: static thread (145)
+12 ns: cthread (63)
+13 ns: static method (136)
+13 ns: static thread (145)
+13 ns: cthread (63)
+14 ns: static method (136)
+14 ns: stimulus (156) - suspending all processes
+
+17 ns: stimulus (171) - resuming all processes
+17 ns: static method (136)
+17 ns: cthread (63)
+17 ns: static thread (145)
+18 ns: static method (136)
+18 ns: stimulus (174) - suspending all processes
+19 ns: stimulus (183) - firing event1
+
+20 ns: stimulus (191) - resuming all processes
+20 ns: static method (136)
+20 ns: cthread (63)
+20 ns: static thread (145)
+21 ns: static method (136)
+21 ns: stimulus (195) - firing event2
+21 ns: static thread (145)
+21 ns: cthread (63)
+21 ns: dynamic method (97,4) after wait on m_event1 & m_event2
+21 ns: dynamic thread (128) after wait on m_event1 & m_event2
+Program completed
diff --git a/src/systemc/tests/systemc/kernel/process_control/test01/test01.cpp b/src/systemc/tests/systemc/kernel/process_control/test01/test01.cpp
new file mode 100644
index 000000000..f391bb75e
--- /dev/null
+++ b/src/systemc/tests/systemc/kernel/process_control/test01/test01.cpp
@@ -0,0 +1,260 @@
+/*****************************************************************************
+
+ Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
+ more contributor license agreements. See the NOTICE file distributed
+ with this work for additional information regarding copyright ownership.
+ Accellera licenses this file to you under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with the
+ License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied. See the License for the specific language governing
+ permissions and limitations under the License.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ test01.cpp -- Test of suspend resume on processes
+
+ Original Author: Andy Goodrich
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ MODIFICATION LOG - modifiers, enter your name, affiliation, date and
+ changes you are making here.
+
+ Name, Affiliation, Date:
+ Description of Modification:
+
+ Revision log at end of the file to let __LINE__ give the same results
+ after a check-in.
+ *****************************************************************************/
+
+
+#include "systemc.h"
+
+SC_MODULE(DUT)
+{
+ SC_CTOR(DUT)
+ {
+ SC_CTHREAD(cthread,m_clk.pos());
+ SC_METHOD(dynamic_method);
+ SC_THREAD(dynamic_thread);
+ SC_METHOD(static_method);
+ sensitive << m_clk.pos();
+ SC_THREAD(static_thread);
+ sensitive << m_clk.pos();
+ SC_CTHREAD(stimulus,m_clk.pos());
+ reset_signal_is(m_reset, true);
+ }
+ void cthread()
+ {
+ m_cthread = sc_get_current_process_handle();
+ for (;;)
+ {
+ wait();
+ cout << sc_time_stamp() << ": cthread (" << __LINE__ << ")"
+ << endl;
+ }
+ }
+ void dynamic_method()
+ {
+ static int state = 0;
+ switch ( state )
+ {
+ case 0:
+ m_dynamic_method = sc_get_current_process_handle();
+ next_trigger( m_clk.posedge_event() );
+ cout << sc_time_stamp() << ": dynamic method (" << __LINE__
+ << "," << state << ") initialization call " << endl;
+ break;
+ case 1:
+ next_trigger( m_clk.posedge_event() );
+ cout << sc_time_stamp() << ": dynamic method (" << __LINE__
+ << "," << state << ") after wait on m_clk.posedge_event() "
+ << endl;
+ break;
+ case 2:
+ next_trigger( m_clk.negedge_event() );
+ cout << sc_time_stamp() << ": dynamic method (" << __LINE__
+ << "," << state << ") after wait on m_clk.posedge_event() "
+ << endl;
+ break;
+ case 3:
+ next_trigger( m_event1 & m_event2 );
+ cout << sc_time_stamp() << ": dynamic method (" << __LINE__
+ << "," << state << ") after wait on m_clk.negedge() " << endl;
+ break;
+ case 4:
+ next_trigger( m_clk.posedge_event() );
+ cout << sc_time_stamp() << ": dynamic method (" << __LINE__
+ << "," << state << ") after wait on m_event1 & m_event2 "
+ << endl;
+ break;
+ default:
+ next_trigger( m_clk.posedge_event() );
+ cout << sc_time_stamp() << ": dynamic method (" << __LINE__
+ << "," << state << ") after wait on m_clk.posedge_event() "
+ << endl;
+ break;
+ }
+ state = state + 1;
+ if ( state == 5 ) state = 1;
+ }
+ void dynamic_thread()
+ {
+ m_dynamic_thread = sc_get_current_process_handle();
+ cout << sc_time_stamp() << ": dynamic thread (" << __LINE__ << ")"
+ << " initialization call " << endl;
+ wait(m_clk.posedge_event());
+ for (;;)
+ {
+ cout << sc_time_stamp() << ": dynamic thread (" << __LINE__
+ << ") after wait on m_clk.posedge_event() " << endl;
+ wait(m_clk.posedge_event());
+ cout << sc_time_stamp() << ": dynamic thread (" << __LINE__
+ << ") after wait on m_clk.posedge_event() " << endl;
+ wait(m_clk.negedge_event());
+ cout << sc_time_stamp() << ": dynamic thread (" << __LINE__
+ << ") after wait on m_clk.negedge_event() " << endl;
+ wait(m_event1 & m_event2 );
+ cout << sc_time_stamp() << ": dynamic thread (" << __LINE__
+ << ") after wait on m_event1 & m_event2 " << endl;
+ wait(m_clk.posedge_event());
+ }
+ }
+ void static_method()
+ {
+ m_static_method = sc_get_current_process_handle();
+ cout << sc_time_stamp() << ": static method (" << __LINE__ << ")"
+ << endl;
+ }
+ void static_thread()
+ {
+ m_static_thread = sc_get_current_process_handle();
+ for (;;)
+ {
+ wait();
+ cout << sc_time_stamp() << ": static thread (" << __LINE__
+ << ")" << endl;
+ }
+ }
+ void stimulus()
+ {
+ for (;;)
+ {
+ wait();
+ wait();
+ cout << sc_time_stamp() << ": stimulus ("
+ << __LINE__ << ") - suspending all processes" << endl;
+ m_cthread.suspend();
+ m_dynamic_method.suspend();
+ m_dynamic_thread.suspend();
+ m_static_method.suspend();
+ m_static_thread.suspend();
+ wait();
+ wait();
+ wait();
+ m_cthread.resume();
+ m_dynamic_method.resume();
+ m_dynamic_thread.resume();
+ m_static_method.resume();
+ m_static_thread.resume();
+ cout << endl << sc_time_stamp() << ": stimulus ("
+ << __LINE__ << ") - resuming all processes" << endl;
+ wait();
+ cout << sc_time_stamp() << ": stimulus ("
+ << __LINE__ << ") - suspending all processes" << endl;
+ m_cthread.suspend();
+ m_dynamic_method.suspend();
+ m_dynamic_thread.suspend();
+ m_static_method.suspend();
+ m_static_thread.suspend();
+ wait();
+ m_event1.notify(SC_ZERO_TIME);
+ cout << sc_time_stamp() << ": stimulus ("
+ << __LINE__ << ") - firing event1 " << endl;
+ wait();
+ m_cthread.resume();
+ m_dynamic_method.resume();
+ m_dynamic_thread.resume();
+ m_static_method.resume();
+ m_static_thread.resume();
+ cout << endl << sc_time_stamp() << ": stimulus ("
+ << __LINE__ << ") - resuming all processes" << endl;
+ wait();
+ m_event2.notify(SC_ZERO_TIME);
+ cout << sc_time_stamp() << ": stimulus ("
+ << __LINE__ << ") - firing event2 " << endl;
+ wait();
+ wait();
+ wait();
+ }
+ }
+ sc_in<bool> m_clk;
+ sc_process_handle m_cthread;
+ sc_process_handle m_dynamic_method;
+ sc_process_handle m_dynamic_thread;
+ sc_event m_event1;
+ sc_event m_event2;
+ sc_event m_event3;
+ sc_event m_event4;
+ sc_in<bool> m_reset;
+ sc_process_handle m_static_method;
+ sc_process_handle m_static_thread;
+};
+
+int sc_main(int argc, char* argv[])
+{
+ sc_core::sc_allow_process_control_corners = true;
+ sc_clock clock;
+ DUT dut("dut");
+ sc_signal<bool> reset;
+
+ dut.m_clk(clock);
+ dut.m_reset(reset);
+
+ sc_core::sc_allow_process_control_corners = true;
+ reset = true;
+ sc_start(1, SC_NS);
+ reset = false;
+ sc_start(21, SC_NS);
+
+ cout << "Program completed" << endl;
+ return 0;
+}
+
+// $Log: test01.cpp,v $
+// Revision 1.5 2011/04/02 00:08:23 acg
+// Andy Goodrich: turn off corner case error checking.
+//
+// Revision 1.4 2011/03/07 19:32:10 acg
+// Andy Goodrich: addition to set sc_core::sc_allow_process_control_corners
+// to true so that this test avoids corner case error messages.
+//
+// Revision 1.3 2011/02/20 13:43:54 acg
+// Andy Goodrich: updates for IEEE 1666 2011.
+//
+// Revision 1.2 2011/02/14 16:59:58 acg
+// Andy Goodrich: updated copyright and added cvs logging information inline.
+//
+// Revision 1.1.1.1 2006/12/15 20:26:03 acg
+// systemc_tests-2.3
+//
+// Revision 1.1 2006/12/14 21:39:59 acg
+// Andy Goodrich: moving test to new directory.
+//
+// Revision 1.2 2006/04/20 19:43:31 acg
+// Andy Goodrich: moved CVS log to end of file so that __LINE__ does not
+// change when a checkin is done.
+//
+// Revision 1.1 2006/04/17 20:10:55 acg
+// Andy Goodrich: First inclusion of test for suspend and resume support.
+//
diff --git a/src/systemc/tests/systemc/kernel/process_control/test02/golden/test02.log b/src/systemc/tests/systemc/kernel/process_control/test02/golden/test02.log
new file mode 100644
index 000000000..c24196a29
--- /dev/null
+++ b/src/systemc/tests/systemc/kernel/process_control/test02/golden/test02.log
@@ -0,0 +1,24 @@
+SystemC Simulation
+0 s: dynamic method (83,0) initialization call
+0 s: static method (115) initialization call
+0 s: dynamic thread (97) initialization call
+0 s: static thread (126) initialization call
+0 s: dynamic method (90,1) after wait on m_clk.posedge()
+0 s: dynamic thread (100) after wait on m_clk.posedge_event()
+1 ns: clocked thread (72) after wait on m_clk.pos()
+2 ns: stimulus (143) - suspending all processes
+3 ns: stimulus (153) - firing event1
+4 ns: stimulus (157) - firing event2
+
+6 ns: stimulus (167) - resuming all processes
+6 ns: dynamic method (90,1) after wait on m_clk.posedge()
+6 ns: static method (120) after wait on m_event1 | m_event2
+6 ns: clocked thread (72) after wait on m_clk.pos()
+6 ns: dynamic thread (105) after wait on m_event1 & m_event2
+6 ns: static thread (131) after wait on m_event1 | m_event2
+7 ns: clocked thread (72) after wait on m_clk.pos()
+8 ns: clocked thread (72) after wait on m_clk.pos()
+9 ns: clocked thread (72) after wait on m_clk.pos()
+
+Info: /OSCI/SystemC: Simulation stopped by user.
+Program completed
diff --git a/src/systemc/tests/systemc/kernel/process_control/test02/test02.cpp b/src/systemc/tests/systemc/kernel/process_control/test02/test02.cpp
new file mode 100644
index 000000000..d770e43a4
--- /dev/null
+++ b/src/systemc/tests/systemc/kernel/process_control/test02/test02.cpp
@@ -0,0 +1,237 @@
+/*****************************************************************************
+
+ Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
+ more contributor license agreements. See the NOTICE file distributed
+ with this work for additional information regarding copyright ownership.
+ Accellera licenses this file to you under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with the
+ License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied. See the License for the specific language governing
+ permissions and limitations under the License.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ test02.cpp -- Test of resume after dynamic event completion
+
+ Original Author: Andy Goodrich
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ MODIFICATION LOG - modifiers, enter your name, affiliation, date and
+ changes you are making here.
+
+ Name, Affiliation, Date:
+ Description of Modification:
+
+ Revision log at end of the file to let __LINE__ give the same results
+ after a check-in.
+ *****************************************************************************/
+
+#include "systemc.h"
+
+SC_MODULE(DUT)
+{
+ SC_CTOR(DUT)
+ {
+ SC_CTHREAD(cthread,m_clk.pos());
+ reset_signal_is(m_reset, true);
+ m_cthread = sc_get_current_process_handle();
+
+ SC_METHOD(dynamic_method);
+ m_dynamic_method = sc_get_current_process_handle();
+
+ SC_THREAD(dynamic_thread);
+ m_dynamic_thread = sc_get_current_process_handle();
+
+ SC_METHOD(static_method);
+ sensitive << m_event1 << m_event2;
+ m_static_method = sc_get_current_process_handle();
+
+ SC_THREAD(static_thread);
+ sensitive << m_event1 << m_event2;
+ m_static_thread = sc_get_current_process_handle();
+
+ SC_CTHREAD(stimulus,m_clk.pos());
+ reset_signal_is(m_reset, true);
+ }
+ void cthread()
+ {
+ for (;;)
+ {
+ wait();
+ cout << sc_time_stamp() << ": clocked thread (" << __LINE__
+ << ") after wait on m_clk.pos() " << endl;
+ }
+ }
+ void dynamic_method()
+ {
+ static int state = 0;
+ switch ( state )
+ {
+ case 0:
+ next_trigger( m_clk.posedge_event() );
+ cout << sc_time_stamp() << ": dynamic method (" << __LINE__
+ << "," << state << ") initialization call " << endl;
+ state = 1;
+ break;
+ default:
+ case 1:
+ next_trigger( m_event1 & m_event2 );
+ cout << sc_time_stamp() << ": dynamic method (" << __LINE__
+ << "," << state << ") after wait on m_clk.posedge() " << endl;
+ break;
+ }
+ }
+ void dynamic_thread()
+ {
+ cout << sc_time_stamp() << ": dynamic thread (" << __LINE__ << ")"
+ << " initialization call " << endl;
+ wait(m_clk.posedge_event());
+ cout << sc_time_stamp() << ": dynamic thread (" << __LINE__
+ << ") after wait on m_clk.posedge_event() " << endl;
+ for (;;)
+ {
+ wait(m_event1 & m_event2 );
+ cout << sc_time_stamp() << ": dynamic thread (" << __LINE__
+ << ") after wait on m_event1 & m_event2 " << endl;
+ }
+ }
+ void static_method()
+ {
+ static bool initialized = false;
+ if ( !initialized )
+ {
+ initialized = true;
+ cout << sc_time_stamp() << ": static method (" << __LINE__
+ << ")" << " initialization call " << endl;
+ }
+ else
+ {
+ cout << sc_time_stamp() << ": static method (" << __LINE__
+ << ") after wait on m_event1 | m_event2 " << endl;
+ }
+ }
+ void static_thread()
+ {
+ cout << sc_time_stamp() << ": static thread (" << __LINE__ << ")"
+ << " initialization call " << endl;
+ for (;;)
+ {
+ wait();
+ cout << sc_time_stamp() << ": static thread (" << __LINE__
+ << ") after wait on m_event1 | m_event2 " << endl;
+ }
+
+ }
+ void stimulus()
+ {
+ for (;;)
+ {
+ wait();
+ wait();
+ cout << sc_time_stamp() << ": stimulus ("
+ << __LINE__ << ") - suspending all processes" << endl;
+ m_cthread.suspend();
+ m_dynamic_method.suspend();
+ m_dynamic_thread.suspend();
+ m_static_method.suspend();
+ m_static_thread.suspend();
+ wait();
+
+ m_event1.notify(SC_ZERO_TIME);
+ cout << sc_time_stamp() << ": stimulus ("
+ << __LINE__ << ") - firing event1 " << endl;
+ wait();
+ m_event2.notify(SC_ZERO_TIME);
+ cout << sc_time_stamp() << ": stimulus ("
+ << __LINE__ << ") - firing event2 " << endl;
+ wait();
+ wait();
+
+ m_cthread.resume();
+ m_dynamic_method.resume();
+ m_dynamic_thread.resume();
+ m_static_method.resume();
+ m_static_thread.resume();
+ cout << endl << sc_time_stamp() << ": stimulus ("
+ << __LINE__ << ") - resuming all processes" << endl;
+ wait();
+ wait();
+ wait();
+ sc_stop();
+ }
+ }
+ sc_in<bool> m_clk;
+ sc_process_handle m_cthread;
+ sc_process_handle m_dynamic_method;
+ sc_process_handle m_dynamic_thread;
+ sc_event m_event1;
+ sc_event m_event2;
+ sc_event m_event3;
+ sc_event m_event4;
+ sc_in<bool> m_reset;
+ sc_process_handle m_static_method;
+ sc_process_handle m_static_thread;
+};
+
+int sc_main(int argc, char* argv[])
+{
+ sc_core::sc_allow_process_control_corners = true;
+ sc_clock clock;
+ DUT dut("dut");
+ sc_signal<bool> reset;
+
+ dut.m_clk(clock);
+ dut.m_reset(reset);
+
+ sc_core::sc_allow_process_control_corners = true;
+ reset = true;
+ sc_start(1, SC_NS);
+ reset = false;
+ sc_start(21, SC_NS);
+
+ cout << "Program completed" << endl;
+ return 0;
+}
+
+// $Log: test02.cpp,v $
+// Revision 1.6 2011/04/02 00:08:27 acg
+// Andy Goodrich: turn off corner case error checking.
+//
+// Revision 1.5 2011/03/07 19:32:11 acg
+// Andy Goodrich: addition to set sc_core::sc_allow_process_control_corners
+// to true so that this test avoids corner case error messages.
+//
+// Revision 1.4 2011/02/20 13:43:58 acg
+// Andy Goodrich: updates for IEEE 1666 2011.
+//
+// Revision 1.3 2011/02/14 17:00:00 acg
+// Andy Goodrich: updated copyright and added cvs logging information inline.
+//
+// Revision 1.2 2011/01/20 16:55:23 acg
+// Andy Goodrich: changes for IEEE 1666 2011.
+//
+// Revision 1.1.1.1 2006/12/15 20:26:03 acg
+// systemc_tests-2.3
+//
+// Revision 1.1 2006/12/14 21:40:06 acg
+// Andy Goodrich: moving test to new directory.
+//
+// Revision 1.2 2006/04/20 19:43:34 acg
+// Andy Goodrich: moved CVS log to end of file so that __LINE__ does not
+// change when a checkin is done.
+//
+// Revision 1.1 2006/04/17 20:11:02 acg
+// Andy Goodrich: First inclusion of test for suspend and resume support.
+//
+
diff --git a/src/systemc/tests/systemc/kernel/process_control/test03/golden/test03.log b/src/systemc/tests/systemc/kernel/process_control/test03/golden/test03.log
new file mode 100644
index 000000000..9bb03d038
--- /dev/null
+++ b/src/systemc/tests/systemc/kernel/process_control/test03/golden/test03.log
@@ -0,0 +1,73 @@
+SystemC Simulation
+Status before sc_start(1,SC_NS) = SC_ELABORATION
+0 s dynamic_method_and_events: initialization call
+0 s dynamic_method_negedge: initialization call
+0 s dynamic_method_posedge: initialization call
+Status during sc_start(1,SC_NS) = SC_RUNNING
+0 s: stimulus (205) - disabling all processes
+0 s dynamic_thread_and_events: initialization call
+0 s dynamic_thread_negedge: initialization call
+0 s dynamic_thread_posedge: initialization call
+Status after sc_start(1,SC_NS) = SC_PAUSED
+
+3 ns: stimulus (238) - enabling all processes
+3500 ps dynamic_method_negedge: awakened
+3500 ps dynamic_thread_negedge: awakened
+4 ns: static method awakened
+4 ns dynamic_method_posedge: awakened
+
+4 ns: stimulus (244) - disabling all processes
+4 ns: static thread awakened
+4 ns dynamic_thread_posedge: awakened
+
+5 ns: stimulus (259) - enabling all processes
+5500 ps dynamic_method_negedge: awakened
+5500 ps dynamic_thread_negedge: awakened
+6 ns: static method awakened
+6 ns dynamic_method_posedge: awakened
+
+6 ns: stimulus (273) - firing event1
+6 ns: static thread awakened
+6 ns: cthread awakened
+6 ns dynamic_thread_posedge: awakened
+6500 ps dynamic_method_negedge: awakened
+6500 ps dynamic_thread_negedge: awakened
+7 ns: static method awakened
+7 ns dynamic_method_posedge: awakened
+
+7 ns: stimulus (278) - disabling all processes
+7 ns: static thread awakened
+7 ns: cthread awakened
+7 ns dynamic_thread_posedge: awakened
+
+8 ns: stimulus (295) - firing event2
+
+11 ns: stimulus (303) - enabling all processes
+11500 ps dynamic_method_negedge: awakened
+11500 ps dynamic_thread_negedge: awakened
+12 ns: static method awakened
+12 ns dynamic_method_posedge: awakened
+
+12 ns: stimulus (317) - firing event2
+12 ns: static thread awakened
+12 ns: cthread awakened
+12 ns dynamic_thread_posedge: awakened
+12 ns dynamic_method_and_events: awakened
+12 ns dynamic_thread_and_events: awakened
+12500 ps dynamic_method_negedge: awakened
+12500 ps dynamic_thread_negedge: awakened
+13 ns: static method awakened
+13 ns dynamic_method_posedge: awakened
+13 ns: static thread awakened
+13 ns: cthread awakened
+13 ns dynamic_thread_posedge: awakened
+13500 ps dynamic_method_negedge: awakened
+13500 ps dynamic_thread_negedge: awakened
+14 ns: static method awakened
+14 ns dynamic_method_posedge: awakened
+14 ns: static thread awakened
+14 ns: cthread awakened
+14 ns dynamic_thread_posedge: awakened
+
+Info: /OSCI/SystemC: Simulation stopped by user.
+Program completed
diff --git a/src/systemc/tests/systemc/kernel/process_control/test03/test03.cpp b/src/systemc/tests/systemc/kernel/process_control/test03/test03.cpp
new file mode 100644
index 000000000..45e84c828
--- /dev/null
+++ b/src/systemc/tests/systemc/kernel/process_control/test03/test03.cpp
@@ -0,0 +1,385 @@
+/*****************************************************************************
+
+ Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
+ more contributor license agreements. See the NOTICE file distributed
+ with this work for additional information regarding copyright ownership.
+ Accellera licenses this file to you under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with the
+ License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied. See the License for the specific language governing
+ permissions and limitations under the License.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ test03.cpp -- Test of disable enable on processes
+
+ Original Author: Andy Goodrich
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ MODIFICATION LOG - modifiers, enter your name, affiliation, date and
+ changes you are making here.
+
+ Name, Affiliation, Date:
+ Description of Modification:
+
+ Revision log at end of the file to let __LINE__ give the same results
+ after a check-in.
+ *****************************************************************************/
+
+
+#include "systemc.h"
+
+SC_MODULE(DUT)
+{
+ SC_CTOR(DUT)
+ {
+ SC_CTHREAD(cthread,m_clk.pos());
+ m_cthread = sc_get_current_process_handle();
+ SC_METHOD(dynamic_method_and_events);
+
+ m_dynamic_method_and_events = sc_get_current_process_handle();
+ SC_METHOD(dynamic_method_negedge);
+ m_dynamic_method_negedge = sc_get_current_process_handle();
+ SC_METHOD(dynamic_method_posedge);
+ m_dynamic_method_posedge = sc_get_current_process_handle();
+
+ SC_THREAD(dynamic_thread_and_events);
+ m_dynamic_thread_and_events = sc_get_current_process_handle();
+ SC_THREAD(dynamic_thread_negedge);
+ m_dynamic_thread_negedge = sc_get_current_process_handle();
+ SC_THREAD(dynamic_thread_posedge);
+ m_dynamic_thread_posedge = sc_get_current_process_handle();
+
+ SC_METHOD(static_method);
+ sensitive << m_clk.pos();
+ dont_initialize();
+ m_static_method = sc_get_current_process_handle();
+ SC_THREAD(static_thread);
+ sensitive << m_clk.pos();
+ m_static_thread = sc_get_current_process_handle();
+ SC_METHOD(stimulus_method);
+
+ SC_CTHREAD(stimulus,m_clk.pos());
+ reset_signal_is(m_reset, true);
+ }
+
+ void cthread()
+ {
+ for (;;)
+ {
+ wait();
+ cout << sc_time_stamp() << ": cthread awakened" << endl;
+ }
+ }
+
+ // dynamic_method_and_events - dynamic method waiting on the and of
+ // two events:
+
+ void dynamic_method_and_events()
+ {
+ static int state = 0;
+ switch( state )
+ {
+ case 0:
+ cout << sc_time_stamp()
+ << " dynamic_method_and_events: initialization call" << endl;
+ break;
+ case 1:
+ cout << sc_time_stamp() << " dynamic_method_and_events: awakened"
+ << endl;
+ break;
+ }
+ next_trigger( m_event1 & m_event2 );
+ state = 1;
+ }
+
+ // dynamic_method_negedge - dynamic method waiting on negedge events:
+
+ void dynamic_method_negedge()
+ {
+ static int state = 0;
+ switch( state )
+ {
+ case 0:
+ cout << sc_time_stamp()
+ << " dynamic_method_negedge: initialization call" << endl;
+ break;
+ case 1:
+ cout << sc_time_stamp() << " dynamic_method_negedge: awakened"
+ << endl;
+ break;
+ }
+ next_trigger( m_clk.negedge_event() );
+ state = 1;
+ }
+
+ // dynamic_method_posedge - dynamic method waiting on posedge events:
+
+ void dynamic_method_posedge()
+ {
+ static int state = 0;
+ switch( state )
+ {
+ case 0:
+ cout << sc_time_stamp()
+ << " dynamic_method_posedge: initialization call" << endl;
+ break;
+ default:
+ cout << sc_time_stamp() << " dynamic_method_posedge: awakened"
+ << endl;
+ }
+ next_trigger( m_clk.posedge_event() );
+ state = 1;
+ }
+
+ // dynamic_thread_and_events - dynamic thread waiting on the and of
+ // two events:
+
+ void dynamic_thread_and_events()
+ {
+ cout << sc_time_stamp()
+ << " dynamic_thread_and_events: initialization call" << endl;
+ for (;;)
+ {
+ wait( m_event1 & m_event2 );
+ cout << sc_time_stamp() << " dynamic_thread_and_events: awakened"
+ << endl;
+ }
+ }
+
+ // dynamic_thread_negedge - dynamic thread waiting on negedge events:
+
+ void dynamic_thread_negedge()
+ {
+ cout << sc_time_stamp()
+ << " dynamic_thread_negedge: initialization call" << endl;
+ for (;;)
+ {
+ wait( m_clk.negedge_event() );
+ cout << sc_time_stamp() << " dynamic_thread_negedge: awakened"
+ << endl;
+ }
+ }
+
+ // dynamic_thread_posedge - dynamic thread waiting on posedge events:
+
+ void dynamic_thread_posedge()
+ {
+ cout << sc_time_stamp()
+ << " dynamic_thread_posedge: initialization call" << endl;
+ for (;;)
+ {
+ wait( m_clk.posedge_event() );
+ cout << sc_time_stamp() << " dynamic_thread_posedge: awakened"
+ << endl;
+ }
+ }
+
+ void static_method()
+ {
+ cout << sc_time_stamp() << ": static method awakened" << endl;
+ }
+ void static_thread()
+ {
+ for (;;)
+ {
+ wait();
+ cout << sc_time_stamp() << ": static thread awakened" << endl;
+ }
+ }
+ void stimulus_method()
+ {
+ cout << "Status during sc_start(1,SC_NS) = " << sc_get_status() << endl;
+ cout << sc_time_stamp() << ": stimulus ("
+ << __LINE__ << ") - disabling all processes" << endl;
+ m_cthread.disable();
+ m_dynamic_method_and_events.disable();
+ m_dynamic_method_negedge.disable();
+ m_dynamic_method_posedge.disable();
+ m_dynamic_thread_and_events.disable();
+ m_dynamic_thread_negedge.disable();
+ m_dynamic_thread_posedge.disable();
+ m_static_method.disable();
+ m_static_thread.disable();
+ }
+ void stimulus()
+ {
+ for (;;)
+ {
+ // START OUT BY WAITING ON THE DISABLE FROM THE stimulus_method.
+
+ wait();
+ wait();
+ wait();
+
+ // PROCEED WITH AN ENABLE ON EVERYONE - EXPECTING posedge WAKES:
+
+ m_cthread.enable();
+ m_dynamic_method_and_events.enable();
+ m_dynamic_method_negedge.enable();
+ m_dynamic_method_posedge.enable();
+ m_dynamic_thread_and_events.enable();
+ m_dynamic_thread_negedge.enable();
+ m_dynamic_thread_posedge.enable();
+ m_static_method.enable();
+ m_static_thread.enable();
+ cout << endl << sc_time_stamp() << ": stimulus ("
+ << __LINE__ << ") - enabling all processes" << endl;
+ wait();
+
+ // DISABLE EVERYONE AGAIN:
+
+ cout << endl << sc_time_stamp() << ": stimulus ("
+ << __LINE__ << ") - disabling all processes" << endl;
+ m_cthread.disable();
+ m_dynamic_method_and_events.disable();
+ m_dynamic_method_negedge.disable();
+ m_dynamic_method_posedge.disable();
+ m_dynamic_thread_and_events.disable();
+ m_dynamic_thread_negedge.disable();
+ m_dynamic_thread_posedge.disable();
+ m_static_method.disable();
+ m_static_thread.disable();
+ wait();
+
+ // PROCEED WITH AN ENABLE ON EVERYONE - EXPECTING negedge WAKES:
+
+ cout << endl << sc_time_stamp() << ": stimulus ("
+ << __LINE__ << ") - enabling all processes" << endl;
+ m_cthread.enable();
+ m_dynamic_method_and_events.enable();
+ m_dynamic_method_negedge.enable();
+ m_dynamic_method_posedge.enable();
+ m_dynamic_thread_and_events.enable();
+ m_dynamic_thread_negedge.enable();
+ m_dynamic_thread_posedge.enable();
+ m_static_method.enable();
+ m_static_thread.enable();
+ wait();
+
+ // FIRE OFF EVENT 1:
+ cout << endl << sc_time_stamp() << ": stimulus ("
+ << __LINE__ << ") - firing event1 " << endl;
+ m_event1.notify(SC_ZERO_TIME);
+ wait();
+
+ cout << endl << sc_time_stamp() << ": stimulus ("
+ << __LINE__ << ") - disabling all processes" << endl;
+ m_cthread.disable();
+ m_dynamic_method_and_events.disable();
+ m_dynamic_method_negedge.disable();
+ m_dynamic_method_posedge.disable();
+ m_dynamic_thread_and_events.disable();
+ m_dynamic_thread_negedge.disable();
+ m_dynamic_thread_posedge.disable();
+ m_static_method.disable();
+ m_static_thread.disable();
+ wait();
+
+
+ // FIRE OFF EVENT 2: WITH EVERYONE DISABLED:
+
+ m_event2.notify(SC_ZERO_TIME);
+ cout << endl << sc_time_stamp() << ": stimulus ("
+ << __LINE__ << ") - firing event2 " << endl;
+ wait();
+ wait();
+ wait();
+
+ // FIRE OFF EVENT 2: WITH EVERYONE ENABLED:
+
+ cout << endl << sc_time_stamp() << ": stimulus ("
+ << __LINE__ << ") - enabling all processes" << endl;
+ m_cthread.enable();
+ m_dynamic_method_and_events.enable();
+ m_dynamic_method_negedge.enable();
+ m_dynamic_method_posedge.enable();
+ m_dynamic_thread_and_events.enable();
+ m_dynamic_thread_negedge.enable();
+ m_dynamic_thread_posedge.enable();
+ m_static_method.enable();
+ m_static_thread.enable();
+ wait();
+
+ m_event2.notify(SC_ZERO_TIME);
+ cout << endl << sc_time_stamp() << ": stimulus ("
+ << __LINE__ << ") - firing event2 " << endl;
+ wait();
+ wait();
+ sc_stop();
+ }
+ }
+ sc_in<bool> m_clk;
+ sc_process_handle m_cthread;
+ sc_process_handle m_dynamic_method_and_events;
+ sc_process_handle m_dynamic_method_negedge;
+ sc_process_handle m_dynamic_method_posedge;
+ sc_process_handle m_dynamic_thread_and_events;
+ sc_process_handle m_dynamic_thread_negedge;
+ sc_process_handle m_dynamic_thread_posedge;
+ sc_event m_event1;
+ sc_event m_event2;
+ sc_event m_event3;
+ sc_event m_event4;
+ sc_in<bool> m_reset;
+ sc_process_handle m_static_method;
+ sc_process_handle m_static_thread;
+};
+
+int sc_main(int argc, char* argv[])
+{
+ sc_clock clock;
+ DUT dut("dut");
+ sc_signal<bool> reset;
+
+ dut.m_clk(clock);
+ dut.m_reset(reset);
+
+ reset = true;
+ cout << "Status before sc_start(1,SC_NS) = " << sc_get_status() << endl;
+ sc_start(1, SC_NS);
+ cout << "Status after sc_start(1,SC_NS) = " << sc_get_status() << endl;
+ reset = false;
+ sc_start();
+
+ cout << "Program completed" << endl;
+ return 0;
+}
+
+// $Log: test03.cpp,v $
+// Revision 1.5 2011/02/20 13:44:06 acg
+// Andy Goodrich: updates for IEEE 1666 2011.
+//
+// Revision 1.4 2011/02/14 17:00:00 acg
+// Andy Goodrich: updated copyright and added cvs logging information inline.
+//
+// Revision 1.3 2011/01/14 14:23:58 acg
+// Andy Goodrich: Fixes for 1666_2011
+//
+// Revision 1.2 2009/05/22 16:07:26 acg
+// Andy Goodrich: process control updates.
+//
+// Revision 1.1.1.1 2006/12/15 20:26:03 acg
+// systemc_tests-2.3
+//
+// Revision 1.1 2006/12/14 21:40:10 acg
+// Andy Goodrich: moving test to new directory.
+//
+// Revision 1.2 2006/04/20 19:43:31 acg
+// Andy Goodrich: moved CVS log to end of file so that __LINE__ does not
+// change when a checkin is done.
+//
+// Revision 1.1 2006/04/17 20:10:55 acg
+// Andy Goodrich: First inclusion of test for suspend and resume support.
+//
diff --git a/src/systemc/tests/systemc/kernel/process_control/test04/golden/test04.log b/src/systemc/tests/systemc/kernel/process_control/test04/golden/test04.log
new file mode 100644
index 000000000..e6b84c69a
--- /dev/null
+++ b/src/systemc/tests/systemc/kernel/process_control/test04/golden/test04.log
@@ -0,0 +1,20 @@
+SystemC Simulation
+0 s:slave - in reset
+1 ns:slave - self-suspend...
+3 ns:master - resuming slave
+3 ns:slave - ... resumed
+4 ns:slave - self-disable ...
+4 ns:slave - ... executing ...
+6 ns:master - enabling slave
+7 ns:slave - ... enabled
+7 ns:master - sync reset on slave
+8 ns:slave - in reset
+9 ns:slave - in reset
+10 ns:slave - in reset
+10 ns:master - sync reset off slave
+11 ns:slave - self-suspend...
+13 ns:master - async reset on slave
+13 ns:slave - in reset
+
+Info: /OSCI/SystemC: Simulation stopped by user.
+Program completed
diff --git a/src/systemc/tests/systemc/kernel/process_control/test04/test04.cpp b/src/systemc/tests/systemc/kernel/process_control/test04/test04.cpp
new file mode 100644
index 000000000..c8e744c2b
--- /dev/null
+++ b/src/systemc/tests/systemc/kernel/process_control/test04/test04.cpp
@@ -0,0 +1,137 @@
+/*****************************************************************************
+
+ Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
+ more contributor license agreements. See the NOTICE file distributed
+ with this work for additional information regarding copyright ownership.
+ Accellera licenses this file to you under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with the
+ License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied. See the License for the specific language governing
+ permissions and limitations under the License.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ test04.cpp -- Test of interaction of suspend-resume, disable-enable, and
+ resets on processes
+
+ Original Author: Andy Goodrich
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ MODIFICATION LOG - modifiers, enter your name, affiliation, date and
+ changes you are making here.
+
+ Name, Affiliation, Date:
+ Description of Modification:
+
+ Revision log at end of the file to let __LINE__ give the same results
+ after a check-in.
+ *****************************************************************************/
+// $Log: test04.cpp,v $
+// Revision 1.5 2011/04/02 00:08:29 acg
+// Andy Goodrich: turn off corner case error checking.
+//
+// Revision 1.4 2011/03/07 19:32:14 acg
+// Andy Goodrich: addition to set sc_core::sc_allow_process_control_corners
+// to true so that this test avoids corner case error messages.
+//
+// Revision 1.3 2011/02/14 17:00:00 acg
+// Andy Goodrich: updated copyright and added cvs logging information inline.
+//
+
+#include "systemc.h"
+
+SC_MODULE(DUT)
+{
+ SC_CTOR(DUT)
+ {
+ SC_CTHREAD(master,m_clk.pos());
+ SC_CTHREAD(slave,m_clk.pos());
+ }
+ void slave()
+ {
+ m_handle0 = sc_get_current_process_handle();
+ cout << sc_time_stamp() << ":slave - in reset" << endl;
+ for (;;)
+ {
+ wait();
+ cout << sc_time_stamp() << ":slave - self-suspend..." << endl;
+ m_handle0.suspend();
+ cout << sc_time_stamp() << ":slave - ... resumed" << endl;
+ wait();
+ cout << sc_time_stamp() << ":slave - self-disable ..." << endl;
+ m_handle0.disable();
+ cout << sc_time_stamp() << ":slave - ... executing ..." << endl;
+ wait();
+ cout << sc_time_stamp() << ":slave - ... enabled" << endl;
+ wait();
+ wait();
+ wait();
+ }
+ }
+ void master()
+ {
+ m_handle1 = sc_get_current_process_handle();
+ for (;;)
+ {
+ wait();
+ wait();
+ wait();
+ cout << sc_time_stamp()
+ << ":master - resuming slave" << endl;
+ m_handle0.resume();
+ wait();
+ wait();
+ wait();
+ cout << sc_time_stamp()
+ << ":master - enabling slave" << endl;
+ m_handle0.enable();
+ wait();
+ cout << sc_time_stamp()
+ << ":master - sync reset on slave" << endl;
+ m_handle0.sync_reset_on();
+ wait();
+ wait();
+ wait();
+ cout << sc_time_stamp()
+ << ":master - sync reset off slave" << endl;
+ m_handle0.sync_reset_off();
+ wait();
+ wait();
+ wait();
+ cout << sc_time_stamp()
+ << ":master - async reset on slave" << endl;
+ m_handle0.reset();
+ wait(20);
+ sc_stop();
+ }
+ }
+ sc_in<bool> m_clk;
+ sc_process_handle m_handle0;
+ sc_process_handle m_handle1;
+};
+
+int sc_main(int argc, char* argv[])
+{
+ sc_core::sc_allow_process_control_corners = true;
+ sc_clock clock;
+ DUT dut("dut");
+
+ dut.m_clk(clock);
+
+ sc_core::sc_allow_process_control_corners = true;
+ sc_start();
+
+ cout << "Program completed" << endl;
+ return 0;
+}
diff --git a/src/systemc/tests/systemc/kernel/process_control/test05/golden/test05.log b/src/systemc/tests/systemc/kernel/process_control/test05/golden/test05.log
new file mode 100644
index 000000000..dd5bbfcbb
--- /dev/null
+++ b/src/systemc/tests/systemc/kernel/process_control/test05/golden/test05.log
@@ -0,0 +1,10 @@
+SystemC Simulation
+3 ns throwing my exception
+3 ns caught my exception
+4 ns throwing my exception
+4 ns caught my exception
+4 ns throwing your exception
+4 ns caught your exception
+
+Info: /OSCI/SystemC: Simulation stopped by user.
+Program completed
diff --git a/src/systemc/tests/systemc/kernel/process_control/test05/test05.cpp b/src/systemc/tests/systemc/kernel/process_control/test05/test05.cpp
new file mode 100644
index 000000000..5fe76c345
--- /dev/null
+++ b/src/systemc/tests/systemc/kernel/process_control/test05/test05.cpp
@@ -0,0 +1,112 @@
+/*****************************************************************************
+
+ Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
+ more contributor license agreements. See the NOTICE file distributed
+ with this work for additional information regarding copyright ownership.
+ Accellera licenses this file to you under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with the
+ License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied. See the License for the specific language governing
+ permissions and limitations under the License.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ test05.cpp -- Test user exception throws.
+
+ Original Author: Andy Goodrich, Forte Design Systems, 15 December 2006
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ MODIFICATION LOG - modifiers, enter your name, affiliation, date and
+ changes you are making here.
+
+ Name, Affiliation, Date:
+ Description of Modification:
+
+ *****************************************************************************/
+
+// $Log: test05.cpp,v $
+// Revision 1.3 2011/02/14 17:00:00 acg
+// Andy Goodrich: updated copyright and added cvs logging information inline.
+//
+
+#include "systemc.h"
+
+class my_exception {};
+class your_exception {};
+
+SC_MODULE(DUT)
+{
+ SC_CTOR(DUT)
+ {
+ SC_CTHREAD(thread,m_clk.pos());
+ SC_THREAD(monitor);
+ }
+ void monitor()
+ {
+ m_monitor_handle = sc_get_current_process_handle();
+ for (;;)
+ {
+ try
+ {
+ wait(m_never_event);
+ }
+ catch (my_exception& except)
+ {
+ cout << sc_time_stamp() << " caught my exception " << endl;
+ }
+ catch (your_exception& except)
+ {
+ cout << sc_time_stamp() << " caught your exception " << endl;
+ }
+ }
+ }
+ void thread()
+ {
+ my_exception exception;
+ your_exception other_exception;
+ for (;;)
+ {
+ wait(3);
+ cout << sc_time_stamp() << " throwing my exception " << endl;
+ m_monitor_handle.throw_it(exception);
+ wait();
+
+ // test that both exceptions appear.
+
+ cout << sc_time_stamp() << " throwing my exception " << endl;
+ m_monitor_handle.throw_it(exception);
+ cout << sc_time_stamp() << " throwing your exception " << endl;
+ m_monitor_handle.throw_it(other_exception);
+ wait();
+ wait();
+ sc_stop();
+ }
+ }
+ sc_in<bool> m_clk;
+ sc_process_handle m_monitor_handle;
+ sc_event m_never_event;
+};
+
+int sc_main(int argc, char* argv[])
+{
+ sc_clock clock;
+ DUT dut("dut");
+
+ dut.m_clk(clock);
+
+ sc_start();
+
+ cout << "Program completed" << endl;
+ return 0;
+}
diff --git a/src/systemc/tests/systemc/kernel/process_control/test06/golden/test06.log b/src/systemc/tests/systemc/kernel/process_control/test06/golden/test06.log
new file mode 100644
index 000000000..01aaf232f
--- /dev/null
+++ b/src/systemc/tests/systemc/kernel/process_control/test06/golden/test06.log
@@ -0,0 +1,21 @@
+SystemC Simulation
+top.parent.method_0 triggered (0 s @ 1)
+top.parent.thread_0 triggered (0 s @ 1)
+top.parent.method_0.thread_0 triggered (0 s @ 1)
+top.parent.thread_0.method_0 triggered (0 s @ 1)
+top.parent.method_0.thread_0.method_0 triggered (0 s @ 1)
+top.parent.thread_0.method_0.thread_0 triggered (0 s @ 1)
+top.parent.method_0.thread_0.method_0 triggered (10 ns @ 4)
+top.parent.thread_0.method_0 triggered (10 ns @ 4)
+top.parent.method_0 triggered (10 ns @ 4)
+top.parent.thread_0.method_0.thread_0 triggered (10 ns @ 4)
+top.parent.method_0.thread_0 triggered (10 ns @ 4)
+top.parent.thread_0 triggered (10 ns @ 4)
+top.parent.thread_0 kill requested (sc_thread_process) (10 ns @ 4)
+top.parent.thread_0.method_0.thread_0 local deleted (10 ns @ 4)
+top.parent.thread_0 local deleted (10 ns @ 4)
+top.parent.method_0 kill requested (sc_method_process) (10 ns @ 4)
+top.parent.method_0.thread_0 local deleted (10 ns @ 4)
+top.parent ended (20 ns @ 7)
+
+Info: /OSCI/SystemC: Simulation stopped by user.
diff --git a/src/systemc/tests/systemc/kernel/process_control/test06/test06.cpp b/src/systemc/tests/systemc/kernel/process_control/test06/test06.cpp
new file mode 100644
index 000000000..616e3acf7
--- /dev/null
+++ b/src/systemc/tests/systemc/kernel/process_control/test06/test06.cpp
@@ -0,0 +1,130 @@
+//----------------------------------------------------------------------
+// Copyright 2009 Cadence Design Systems, Inc.
+// All Rights Reserved Worldwide
+// Copyright 2009 Forte Design Systems, Inc.
+// Copyright 2010 OFFIS Institute for Information technology
+//
+// test06: test hierarchical kills
+//----------------------------------------------------------------------
+
+#define SC_INCLUDE_DYNAMIC_PROCESSES
+#include <systemc.h>
+
+SC_MODULE(top) {
+public:
+ SC_CTOR(top) {
+ SC_THREAD(parent);
+ sensitive << clk.pos();
+ dont_initialize();
+ }
+
+ void proc_tree( unsigned depth, unsigned width, bool as_method, bool spawn_only )
+ {
+ unsigned w = width;
+ if (sc_time_stamp() == SC_ZERO_TIME || spawn_only )
+ while( depth && w --> 0 )
+ {
+ sc_spawn_options sp;
+ sp.set_sensitivity( &clk.pos() );
+
+ if(as_method) // we are spawned as method, spawn a thread
+ {
+ sc_spawn( sc_bind( &top::proc_tree, this, depth-1, width, !as_method, false )
+ , sc_gen_unique_name("thread"), &sp );
+ }
+ else // we are spawned as thread, spawn a method
+ {
+ sp.spawn_method();
+ sc_spawn( sc_bind( &top::proc_tree, this, depth-1, width, !as_method, false )
+ , sc_gen_unique_name("method"), &sp );
+ }
+ }
+
+ if(spawn_only) return;
+
+ std::cout << sc_get_current_process_handle().name()
+ << " triggered "
+ << "(" << sc_time_stamp() << " @ " << sc_delta_count() << ")"
+ << std::endl;
+
+ // start thread
+ if( !as_method ) thread_loop();
+ }
+
+ void thread_loop()
+ {
+ struct local_ {
+ ~local_(){
+ std::cout
+ << sc_get_current_process_handle().name()
+ << " local deleted "
+ << "(" << sc_time_stamp() << " @ " << sc_delta_count() << ")"
+ << std::endl;
+ }
+ } l; l=l;
+
+ unsigned rounds = 5;
+ while( rounds --> 0 )
+ {
+ wait();
+ std::cout << sc_get_current_process_handle().name()
+ << " triggered "
+ << "(" << sc_time_stamp() << " @ " << sc_delta_count() << ")"
+ << std::endl;
+ }
+ std::cout << sc_get_current_process_handle().name()
+ << " ended "
+ << "(" << sc_time_stamp() << " @ " << sc_delta_count() << ")"
+ << std::endl;
+ }
+
+ void parent()
+ {
+ proc_tree( 3, 1, true , true );
+ proc_tree( 3, 1, false, true );
+
+ wait();
+
+ // copy children (needed, since children may get reordered)
+ std::vector< sc_object* > children =
+ sc_get_current_process_handle().get_child_objects();
+
+ std::vector< sc_object* >::const_iterator it = children.begin();
+
+ while( it != children.end() )
+ {
+ sc_process_handle h( *it++ );
+ sc_assert( h.valid() );
+
+ std::cout << h.name() << " "
+ << "kill requested "
+ << "(" << h.get_process_object()->kind() << ") "
+ << "(" << sc_time_stamp() << " @ " << sc_delta_count() << ")"
+ << std::endl;
+
+ h.kill( SC_INCLUDE_DESCENDANTS );
+ }
+
+ wait();
+
+ std::cout << sc_get_current_process_handle().name()
+ << " ended "
+ << "(" << sc_time_stamp() << " @ " << sc_delta_count() << ")"
+ << std::endl;
+
+ wait();
+ sc_stop();
+ while(true) wait();
+ }
+
+ sc_in<bool> clk;
+};
+
+int sc_main (int argc, char *argv[])
+{
+ sc_clock clk("clk", 10, SC_NS, 0.5);
+ top t("top");
+ t.clk(clk);
+ sc_start();
+ return 0;
+}
diff --git a/src/systemc/tests/systemc/kernel/process_control/test07/golden/test07.log b/src/systemc/tests/systemc/kernel/process_control/test07/golden/test07.log
new file mode 100644
index 000000000..015022982
--- /dev/null
+++ b/src/systemc/tests/systemc/kernel/process_control/test07/golden/test07.log
@@ -0,0 +1,90 @@
+SystemC Simulation
+------ (50 ns) ------
+ dut (sc_module)
+ dut.parent (sc_thread_process) (running)
+----------------------
++++ dut.parent.child0 starting (50 ns)
++++ dut.parent.child1 starting (50 ns)
+------ (100 ns) ------
+ dut (sc_module)
+ dut.parent (sc_thread_process) (running)
+ dut.parent.child0 (sc_thread_process) (running)
+ dut.parent.child0.local (sc_object)
+ dut.parent.child1 (sc_thread_process) (running)
+ dut.parent.child1.local (sc_object)
+ dut.parent.child1.dyn_obj (sc_object)
+----------------------
++++ dut.parent.child1.grandchild starting (150 ns)
++++ dut.parent.child0.grandchild starting (150 ns)
+------ (200 ns) ------
+ dut (sc_module)
+ dut.parent (sc_thread_process) (running)
+ dut.parent.child0 (sc_thread_process) (running)
+ dut.parent.child0.local (sc_object)
+ dut.parent.child0.grandchild (sc_thread_process) (running)
+ dut.parent.child0.grandchild.local (sc_object)
+ dut.parent.child1 (sc_thread_process) (running)
+ dut.parent.child1.local (sc_object)
+ dut.parent.child1.dyn_obj (sc_object)
+ dut.parent.child1.grandchild (sc_thread_process) (running)
+ dut.parent.child1.grandchild.local (sc_object)
+----------------------
++++ dut.parent.child1 exiting (250 ns)
++++ dut.parent.child1.local deleted
++++ dut.parent.child0 exiting (250 ns)
++++ dut.parent.child0.local deleted
+------ (300 ns) ------
+ dut (sc_module)
+ dut.parent (sc_thread_process) (running)
+ dut.parent.child0 (sc_thread_process) (terminated)
+ dut.parent.child0.grandchild (sc_thread_process) (running)
+ dut.parent.child0.grandchild.local (sc_object)
+ dut.parent.child1 (sc_thread_process) (terminated)
+ dut.parent.child1.grandchild (sc_thread_process) (running)
+ dut.parent.child1.grandchild.local (sc_object)
+ dut.parent.child1.dyn_obj (sc_object)
+----------------------
++++ dut.parent.child1.grandchild exiting (350 ns)
++++ dut.parent.child1.grandchild.local deleted
++++ dut.parent.child0.grandchild exiting (350 ns)
++++ dut.parent.child0.grandchild.local deleted
+------ (400 ns) ------
+ dut (sc_module)
+ dut.parent (sc_thread_process) (running)
+ dut.parent.child1 (sc_thread_process) (terminated)
+ dut.parent.child1.dyn_obj (sc_object)
+----------------------
++++ dut.parent.child1.dyn_obj deleted
+------ (500 ns) ------
+ dut (sc_module)
+ dut.parent (sc_thread_process) (running)
+----------------------
++++ dut.parent.child0 starting (500 ns)
++++ dut.parent.child1 starting (500 ns)
+------ (600 ns) ------
+ dut (sc_module)
+ dut.parent (sc_thread_process) (running)
+ dut.parent.child0 (sc_thread_process) (running)
+ dut.parent.child0.local (sc_object)
+ dut.parent.child1 (sc_thread_process) (running)
+ dut.parent.child1.local (sc_object)
+----------------------
++++ dut.parent.child1.grandchild starting (600 ns)
++++ dut.parent.child0.grandchild starting (600 ns)
++++ dut.parent.child0.local deleted
++++ dut.parent.child1.grandchild.local deleted
++++ dut.parent.child1.local deleted
++++ kills sent ... (650 ns)
+------ (700 ns) ------
+ dut (sc_module)
+ dut.parent (sc_thread_process) (running)
+ dut.parent.child0 (sc_thread_process) (terminated)
+ dut.parent.child0.grandchild (sc_thread_process) (running)
+ dut.parent.child0.grandchild.local (sc_object)
+----------------------
++++ dut.parent exiting (700 ns)
++++ dut.parent.child0.grandchild exiting (800 ns)
++++ dut.parent.child0.grandchild.local deleted
+------ (900 ns) ------
+ dut (sc_module)
+----------------------
diff --git a/src/systemc/tests/systemc/kernel/process_control/test07/test07.cpp b/src/systemc/tests/systemc/kernel/process_control/test07/test07.cpp
new file mode 100644
index 000000000..5478d6d7d
--- /dev/null
+++ b/src/systemc/tests/systemc/kernel/process_control/test07/test07.cpp
@@ -0,0 +1,204 @@
+/*****************************************************************************
+
+ Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
+ more contributor license agreements. See the NOTICE file distributed
+ with this work for additional information regarding copyright ownership.
+ Accellera licenses this file to you under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with the
+ License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied. See the License for the specific language governing
+ permissions and limitations under the License.
+
+ *****************************************************************************/
+/*****************************************************************************
+
+ test07.cpp -- Test handling of process objects with living descendants
+
+ Original Author: Philipp A. Hartmann, OFFIS
+
+ *****************************************************************************/
+/*****************************************************************************
+ MODIFICATION LOG - modifiers, enter your name, affiliation, date and
+ changes you are making here.
+
+ Name, Affiliation, Date:
+ Description of Modification:
+
+ *****************************************************************************/
+// $Log: test07.cpp,v $
+// Revision 1.2 2011/02/14 17:00:00 acg
+// Andy Goodrich: updated copyright and added cvs logging information inline.
+//
+
+#define SC_INCLUDE_DYNAMIC_PROCESSES
+#include <systemc.h>
+
+void
+dump_hierarchy(
+ std::vector< sc_object* > const & objs = sc_get_top_level_objects()
+ , unsigned level = 0
+)
+{
+ if (!level)
+ std::cout << "------ " << "(" << sc_time_stamp() << ")" << " ------"
+ << std::endl;
+
+ std::vector<sc_object*>::const_iterator it = objs.begin();
+ for( ; it != objs.end(); it++ )
+ {
+ std::cout << std::string( level + 1, ' ' )
+ << (*it)->name() << " (" << (*it)->kind() << ")";
+
+ sc_process_handle h(*it);
+
+ std::cout << ( h.valid() // is it a process? -> print state
+ ? (! h.terminated() ? " (running)" : " (terminated)" )
+ : "" )
+ << std::endl;
+
+ dump_hierarchy( (*it)->get_child_objects(), level+1 );
+ }
+
+ if (!level)
+ std::cout << "---------------------- " << std::endl;
+}
+
+struct my_object : sc_object {
+ my_object( const char* name ) : sc_object( name ) {}
+ ~my_object()
+ {
+ std::cout << "+++ " << this->name() << " deleted" << std::endl;
+ }
+};
+
+SC_MODULE(DUT)
+{
+ SC_CTOR(DUT)
+ : leaf_(0)
+ {
+ SC_THREAD(parent);
+ }
+
+ enum start_options
+ {
+ no_children = 0,
+ start_child_proc = 1,
+ create_child_obj = 2,
+ both_children = 3
+ };
+
+ void child( start_options opt ){
+ start();
+
+ my_object local( "local" );
+
+ if( opt & create_child_obj )
+ leaf_=new my_object("dyn_obj");
+
+ wait( 100, SC_NS );
+
+ if( opt & start_child_proc )
+ sc_spawn( sc_bind( &DUT::child, this, no_children )
+ , "grandchild" );
+
+ wait( 100, SC_NS );
+ end();
+ }
+
+ void parent()
+ {
+ // only parent alive
+ wait( 50, SC_NS );
+ dump_hierarchy();
+
+ sc_spawn( sc_bind( &DUT::child, this, start_child_proc ), "child0" );
+ sc_spawn( sc_bind( &DUT::child, this, both_children ), "child1" );
+
+ // direct children up and running
+ wait( 50, SC_NS );
+ dump_hierarchy();
+
+ // grandchildren started, child object created
+ wait( 100, SC_NS );
+ dump_hierarchy();
+
+ // direct children ended (zombies kept)
+ wait( 100, SC_NS );
+ dump_hierarchy();
+
+ // grandhildren ended (zombie with child object kept)
+ wait( 100, SC_NS );
+ dump_hierarchy();
+
+ // child object removed, zombies deleted
+ delete leaf_; leaf_ = 0;
+ wait( 100, SC_NS );
+ dump_hierarchy();
+
+ {
+ // create another pair of children
+ sc_process_handle
+ h0 = sc_spawn( sc_bind( &DUT::child, this, start_child_proc ), "child0" ),
+ h1 = sc_spawn( sc_bind( &DUT::child, this, start_child_proc ), "child1" );
+
+ wait( 100, SC_NS );
+ dump_hierarchy();
+
+ // and kill them, after it has spawned its grandchild
+ wait( 50, SC_NS );
+ h0.kill();
+ h1.kill( SC_INCLUDE_DESCENDANTS );
+
+ std::cout << "+++ kills sent ... "
+ << "(" << sc_time_stamp() << ")"
+ << std::endl;
+
+ // needed to avoid segfault
+ //wait(SC_ZERO_TIME);
+
+ } // drop handles
+
+ wait( 50, SC_NS );
+ dump_hierarchy();
+
+ end();
+ }
+
+ void start()
+ {
+ std::cout
+ << "+++ "
+ << sc_get_current_process_handle().name()
+ << " starting "
+ << "(" << sc_time_stamp() << ")"
+ << std::endl;
+ }
+ void end()
+ {
+ std::cout
+ << "+++ "
+ << sc_get_current_process_handle().name()
+ << " exiting "
+ << "(" << sc_time_stamp() << ")"
+ << std::endl;
+ }
+
+ my_object* leaf_;
+};
+
+
+int sc_main( int, char*[] )
+{
+ DUT dut("dut");
+ sc_start(900, SC_NS );
+ // everything cleaned up (only module still alive)
+ dump_hierarchy();
+
+ return 0;
+}
diff --git a/src/systemc/tests/systemc/kernel/process_control/test08/golden/test08.log b/src/systemc/tests/systemc/kernel/process_control/test08/golden/test08.log
new file mode 100644
index 000000000..c08a26aec
--- /dev/null
+++ b/src/systemc/tests/systemc/kernel/process_control/test08/golden/test08.log
@@ -0,0 +1,16 @@
+SystemC Simulation
+0 s target: initializing
+10 ns tb: firing event
+10 ns target: awoke
+20 ns tb: suspending target
+30 ns tb: firing event while target suspended
+40 ns tb: resetting target
+40 ns target: initializing
+50 ns tb: resuming target
+60 ns tb: 10ns after resume
+70 ns tb: firing event again
+70 ns target: awoke
+80 ns tb: stopping
+
+Info: /OSCI/SystemC: Simulation stopped by user.
+Program completed
diff --git a/src/systemc/tests/systemc/kernel/process_control/test08/test08.cpp b/src/systemc/tests/systemc/kernel/process_control/test08/test08.cpp
new file mode 100644
index 000000000..8e5a91599
--- /dev/null
+++ b/src/systemc/tests/systemc/kernel/process_control/test08/test08.cpp
@@ -0,0 +1,127 @@
+/*****************************************************************************
+
+ Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
+ more contributor license agreements. See the NOTICE file distributed
+ with this work for additional information regarding copyright ownership.
+ Accellera licenses this file to you under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with the
+ License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied. See the License for the specific language governing
+ permissions and limitations under the License.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ test08.cpp -- Test of suspend and asynchronous reset interaction
+
+ Original Author: Andy Goodrich, 14 Februrary 2011
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ MODIFICATION LOG - modifiers, enter your name, affiliation, date and
+ changes you are making here.
+
+ Name, Affiliation, Date:
+ Description of Modification:
+
+ *****************************************************************************/
+// $Log: test08.cpp,v $
+// Revision 1.4 2011/04/02 00:08:36 acg
+// Andy Goodrich: turn off corner case error checking.
+//
+// Revision 1.3 2011/03/07 19:32:16 acg
+// Andy Goodrich: addition to set sc_core::sc_allow_process_control_corners
+// to true so that this test avoids corner case error messages.
+//
+// Revision 1.2 2011/02/20 13:44:06 acg
+// Andy Goodrich: updates for IEEE 1666 2011.
+//
+// Revision 1.1 2011/02/14 16:59:29 acg
+// Andy Goodrich: first check in.
+//
+
+#include "systemc.h"
+
+sc_event event1;
+sc_process_handle t;
+SC_MODULE(DUT)
+{
+ SC_CTOR(DUT)
+ {
+ SC_THREAD(thread);
+ t = sc_get_current_process_handle();
+ }
+ void thread()
+ {
+ cout << sc_time_stamp() << " target: initializing" << endl;
+ for (;;)
+ {
+ wait(event1);
+ cout << sc_time_stamp() << " target: awoke" << endl;
+ }
+ }
+};
+
+SC_MODULE(TB)
+{
+ SC_CTOR(TB)
+ {
+ SC_THREAD(tb_thread);
+ }
+ void tb_thread()
+ {
+ wait( 10, SC_NS );
+ cout << sc_time_stamp() << " tb: firing event " << endl;
+ event1.notify();
+ wait( 10, SC_NS );
+
+ cout << sc_time_stamp() << " tb: suspending target " << endl;
+ t.suspend();
+ wait( 10, SC_NS );
+
+ cout << sc_time_stamp() << " tb: firing event while target suspended"
+ << endl;
+ event1.notify();
+ wait( 10, SC_NS );
+
+ cout << sc_time_stamp() << " tb: resetting target " << endl;
+ t.reset();
+ wait( 10, SC_NS );
+
+ cout << sc_time_stamp() << " tb: resuming target" << endl;
+ t.resume();
+ wait( 10, SC_NS );
+
+ cout << sc_time_stamp() << " tb: 10ns after resume" << endl;
+ wait( 10, SC_NS );
+
+ cout << sc_time_stamp() << " tb: firing event again" << endl;
+ event1.notify();
+ wait( 10, SC_NS );
+
+ cout << sc_time_stamp() << " tb: stopping" << endl;
+ sc_stop();
+ }
+};
+
+int sc_main(int argc, char* argv[])
+{
+ sc_core::sc_allow_process_control_corners = true;
+ DUT dut("dut");
+ TB tb("tb");
+
+ sc_core::sc_allow_process_control_corners = true;
+ sc_start();
+
+ cout << "Program completed" << endl;
+ return 0;
+}
diff --git a/src/systemc/tests/systemc/kernel/process_control/throw_it/test1/golden/test1.log b/src/systemc/tests/systemc/kernel/process_control/throw_it/test1/golden/test1.log
new file mode 100644
index 000000000..18c914736
--- /dev/null
+++ b/src/systemc/tests/systemc/kernel/process_control/throw_it/test1/golden/test1.log
@@ -0,0 +1,5 @@
+SystemC Simulation
+0 s: starting victim thread
+10 ns: in perpetrator throwing exception in victim
+10 ns: in victim thread, caught exception from pepetrator, exiting
+10 ns: in perpetrator after throwing exception in victim
diff --git a/src/systemc/tests/systemc/kernel/process_control/throw_it/test1/test1.cpp b/src/systemc/tests/systemc/kernel/process_control/throw_it/test1/test1.cpp
new file mode 100644
index 000000000..1a3ceb192
--- /dev/null
+++ b/src/systemc/tests/systemc/kernel/process_control/throw_it/test1/test1.cpp
@@ -0,0 +1,57 @@
+//----------------------------------------------------------------------
+// Copyright 2009 Cadence Design Systems, Inc.
+// All Rights Reserved Worldwide
+//----------------------------------------------------------------------
+
+#include <systemc.h>
+
+class my_exception {
+public:
+ my_exception(const char* s) : s_(s) { }
+ const char* message() { return s_.c_str(); }
+protected:
+ std::string s_;
+};
+
+SC_MODULE(top) {
+public:
+ SC_CTOR(top) {
+ SC_THREAD(victim);
+ h = sc_get_current_process_handle();
+ SC_THREAD(perpetrator);
+ }
+
+ void victim() {
+ try {
+ cerr << sc_time_stamp() << ": starting victim thread" << endl;
+ ::sc_core::wait(100, SC_NS);
+ }
+ catch (my_exception& x) {
+ cerr << sc_time_stamp() << ": in victim thread, caught exception "
+ << x.message() << ", exiting" << endl;
+ return;
+ }
+ }
+
+ void perpetrator() {
+ wait(10, SC_NS);
+ cerr << sc_time_stamp()
+ << ": in perpetrator throwing exception in victim "
+ << endl;
+ h.throw_it(my_exception("from pepetrator"));
+ cerr << sc_time_stamp()
+ << ": in perpetrator after throwing exception in victim "
+ << endl;
+ }
+
+protected:
+ sc_process_handle h;
+};
+
+int sc_main (int argc, char *argv[])
+{
+ top t("top");
+ sc_start();
+ return 0;
+}
+