diff options
author | Gabe Black <gabeblack@google.com> | 2018-05-24 01:37:55 -0700 |
---|---|---|
committer | Gabe Black <gabeblack@google.com> | 2018-08-08 10:09:54 +0000 |
commit | 16fa8d7cc8c92f5ab879e4cf9c6c0bbb3567860f (patch) | |
tree | 7b6faaacb4574a555e561534aa4a8508c0624c32 /src/systemc/tests/systemc/tmp | |
parent | 7235d3b5211d0ba8f528d930a4c1e7ad62eec51a (diff) | |
download | gem5-16fa8d7cc8c92f5ab879e4cf9c6c0bbb3567860f.tar.xz |
systemc: Import tests from the Accellera systemc distribution.
Change-Id: Iad76b398949a55d768a34d027a2d8e3739953da6
Reviewed-on: https://gem5-review.googlesource.com/10845
Reviewed-by: Giacomo Travaglini <giacomo.travaglini@arm.com>
Maintainer: Gabe Black <gabeblack@google.com>
Diffstat (limited to 'src/systemc/tests/systemc/tmp')
32 files changed, 1601 insertions, 0 deletions
diff --git a/src/systemc/tests/systemc/tmp/compliance_1666_2011/section_5.3.4.2/test01/golden/test01.log b/src/systemc/tests/systemc/tmp/compliance_1666_2011/section_5.3.4.2/test01/golden/test01.log new file mode 100644 index 000000000..0724df224 --- /dev/null +++ b/src/systemc/tests/systemc/tmp/compliance_1666_2011/section_5.3.4.2/test01/golden/test01.log @@ -0,0 +1,9 @@ +SystemC Simulation + +Warning: (W571) no activity or clock movement for sc_start() invocation +In file: <removed by verify.pl> + +Warning: (W571) no activity or clock movement for sc_start() invocation +In file: <removed by verify.pl> + +Success diff --git a/src/systemc/tests/systemc/tmp/compliance_1666_2011/section_5.3.4.2/test01/test01.cpp b/src/systemc/tests/systemc/tmp/compliance_1666_2011/section_5.3.4.2/test01/test01.cpp new file mode 100644 index 000000000..169311fca --- /dev/null +++ b/src/systemc/tests/systemc/tmp/compliance_1666_2011/section_5.3.4.2/test01/test01.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. + + *****************************************************************************/ + +// test01.cpp -- sc_start With Event Starvation Policy +// +// Original Author: John Aynsley, Doulos +// +// MODIFICATION LOG - modifiers, enter your name, affiliation, date and +// +// $Log: test01.cpp,v $ +// Revision 1.1 2011/02/05 21:14:24 acg +// Andy Goodrich: moving tests John Aynsley will replace. +// +// Revision 1.2 2011/01/25 20:54:03 acg +// Andy Goodrich: regolden for new delta counter rules. +// +// Revision 1.1 2011/01/24 12:06:06 acg +// Andy Goodrich: changes for IEEE 1666 2011 +// + +#include <systemc> +using namespace sc_core; +using std::cout; +using std::endl; + +SC_MODULE(Top) +{ + SC_CTOR(Top) + { + SC_THREAD(T); + } + + sc_event ev; + + void T() + { + ev.notify(150, SC_NS); + } +}; + +int sc_main(int argc, char* argv[]) +{ + Top top("top"); + + sc_assert( sc_get_status() == SC_ELABORATION ); + sc_assert( sc_time_stamp() == SC_ZERO_TIME ); + sc_start(100, SC_NS); + sc_assert( sc_time_stamp() == sc_time(100, SC_NS) ); + + sc_start(10, SC_NS, SC_RUN_TO_TIME); + sc_assert( sc_time_stamp() == sc_time(110, SC_NS) ); + + sc_start(10, SC_NS, SC_EXIT_ON_STARVATION); + // sc_assert( sc_time_stamp() == sc_time(120, SC_NS) ); + sc_assert( sc_time_stamp() == sc_time(110, SC_NS) ); + + sc_start(80, SC_NS, SC_EXIT_ON_STARVATION); + sc_assert( sc_time_stamp() == sc_time(150, SC_NS) ); + + sc_start(); + sc_assert( sc_time_stamp() == sc_time(150, SC_NS) ); + sc_assert( sc_get_status() == SC_PAUSED ); + + cout << endl << "Success" << endl; + return 0; +} diff --git a/src/systemc/tests/systemc/tmp/compliance_1666_2011/section_6.6/test01/golden/test01.log b/src/systemc/tests/systemc/tmp/compliance_1666_2011/section_6.6/test01/golden/test01.log new file mode 100644 index 000000000..2a87849ba --- /dev/null +++ b/src/systemc/tests/systemc/tmp/compliance_1666_2011/section_6.6/test01/golden/test01.log @@ -0,0 +1,16 @@ +SystemC Simulation +T2: time = 10 ns +T2: time = 20 ns +suspend: time = 25 ns +resume: time = 45 ns +T2: time = 45 ns +T2: time = 50 ns +T2: time = 60 ns +disable: time = 65 ns +enable: time = 85 ns +T2: time = 90 ns +T2: time = 100 ns + +Info: /OSCI/SystemC: Simulation stopped by user. + +End Of Test diff --git a/src/systemc/tests/systemc/tmp/compliance_1666_2011/section_6.6/test01/test01.cpp b/src/systemc/tests/systemc/tmp/compliance_1666_2011/section_6.6/test01/test01.cpp new file mode 100644 index 000000000..ee8d29416 --- /dev/null +++ b/src/systemc/tests/systemc/tmp/compliance_1666_2011/section_6.6/test01/test01.cpp @@ -0,0 +1,106 @@ +/***************************************************************************** + + 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 -- Quick Test Of Process Control On Threads For IEEE 1666-2011 +// +// Original Author: John Aynsley, Doulos +// +// MODIFICATION LOG - modifiers, enter your name, affiliation, date and +// +// $Log: test01.cpp,v $ +// Revision 1.2 2011/03/07 19:32:18 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.1 2011/02/05 21:13:19 acg +// Andy Goodrich: move of tests John Aynsley will replace. +// +// Revision 1.1 2011/01/14 14:23:16 acg +// Andy Goodrich: new test. +// + +#define SC_INCLUDE_DYNAMIC_PROCESSES +#include <systemc> + +using namespace sc_core; +using std::cout; +using std::endl; + +SC_MODULE(Top) +{ + SC_CTOR(Top) + { + SC_THREAD(gen); + SC_THREAD(T1); + h1 = sc_get_current_process_handle(); + SC_THREAD(T2); + h2 = sc_get_current_process_handle(); + } + + sc_event ev; + + sc_process_handle h1, h2; + + void gen() + { + for (;;) + { + wait(10, SC_NS); + ev.notify(); + } + } + + void T1() + { + wait(25, SC_NS); + cout << "suspend: time = " << sc_time_stamp() << endl; + h2.suspend(); + wait(20, SC_NS); + cout << "resume: time = " << sc_time_stamp() << endl; + h2.resume(); + wait(20, SC_NS); + + cout << "disable: time = " << sc_time_stamp() << endl; + h2.disable(); + wait(20, SC_NS); + cout << "enable: time = " << sc_time_stamp() << endl; + h2.enable(); + wait(20, SC_NS); + sc_stop(); + } + + void T2() + { + for (;;) + { + wait(ev); + cout << "T2: time = " << sc_time_stamp() << endl; + } + } +}; + +int sc_main(int argc, char* argv[]) +{ + Top top("top"); + sc_core::sc_allow_process_control_corners = true; + sc_start(); + + cout << endl << "End Of Test" << endl; + return 0; +} diff --git a/src/systemc/tests/systemc/tmp/compliance_1666_2011/section_6.6/test02/golden/test02.log b/src/systemc/tests/systemc/tmp/compliance_1666_2011/section_6.6/test02/golden/test02.log new file mode 100644 index 000000000..973018653 --- /dev/null +++ b/src/systemc/tests/systemc/tmp/compliance_1666_2011/section_6.6/test02/golden/test02.log @@ -0,0 +1,8 @@ +SystemC Simulation +Target called at 10 ns +Target called at 20 ns +Target called at 35 ns +Target called at 40 ns +Target called at 50 ns + +Info: /OSCI/SystemC: Simulation stopped by user. diff --git a/src/systemc/tests/systemc/tmp/compliance_1666_2011/section_6.6/test02/test02.cpp b/src/systemc/tests/systemc/tmp/compliance_1666_2011/section_6.6/test02/test02.cpp new file mode 100644 index 000000000..ca18bdeb8 --- /dev/null +++ b/src/systemc/tests/systemc/tmp/compliance_1666_2011/section_6.6/test02/test02.cpp @@ -0,0 +1,128 @@ +/***************************************************************************** + + 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 Method Suspending Itself +// +// Original Author: John Aynsley, Doulos +// +// MODIFICATION LOG - modifiers, enter your name, affiliation, date and +// +// $Log: test02.cpp,v $ +// Revision 1.3 2011/03/07 19:32:19 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/05 21:13:26 acg +// Andy Goodrich: move of tests John Aynsley will replace. +// +// Revision 1.1 2011/01/20 16:54:54 acg +// Andy Goodrich: changes for IEEE 1666 2011. +// + +#define SC_INCLUDE_DYNAMIC_PROCESSES + +#include <systemc> + +using namespace sc_core; +using std::cout; +using std::endl; + +struct M5: sc_module +{ + M5(sc_module_name _name) + { + SC_THREAD(ticker); + SC_THREAD(calling); + SC_METHOD(target); + sensitive << ev; + dont_initialize(); + t = sc_get_current_process_handle(); + suspend_target = false; + resume_target = false; + } + + sc_process_handle t; + sc_event ev; + bool suspend_target; + bool resume_target; + + void ticker() + { + for (;;) + { + wait(10, SC_NS); + ev.notify(); + } + } + + void calling() + { + wait(15, SC_NS); + // Target runs at 10 NS + + suspend_target = true; + wait(10, SC_NS); + // Target runs at 20 NS and suspends itself + + wait(10, SC_NS); + // Target does not run at 30 NS + + suspend_target = false; + t.resume(); + // Target runs at 35 NS + + wait(10, SC_NS); + // Target runs at 40 NS + + suspend_target = true; + resume_target = true; + wait(10, SC_NS); + // Target runs at 50 NS + + sc_stop(); + } + + void target() + { + cout << "Target called at " << sc_time_stamp() << endl; + if (suspend_target) + t.suspend(); + if (resume_target) + { + t.resume(); + suspend_target = false; + } + } + + SC_HAS_PROCESS(M5); +}; + +int sc_main(int argc, char* argv[]) +{ + M5 m("m"); + + sc_core::sc_allow_process_control_corners = true; + sc_start(); + + return 0; +} + diff --git a/src/systemc/tests/systemc/tmp/compliance_1666_2011/section_6.6/test03/golden/test03.log b/src/systemc/tests/systemc/tmp/compliance_1666_2011/section_6.6/test03/golden/test03.log new file mode 100644 index 000000000..5cc0f85cb --- /dev/null +++ b/src/systemc/tests/systemc/tmp/compliance_1666_2011/section_6.6/test03/golden/test03.log @@ -0,0 +1,8 @@ +SystemC Simulation +Target called/reset at 0 s +Target awoke at 10 ns +Target awoke at 20 ns +Target called/reset at 25 ns +Target awoke at 30 ns + +Info: /OSCI/SystemC: Simulation stopped by user. diff --git a/src/systemc/tests/systemc/tmp/compliance_1666_2011/section_6.6/test03/test03.cpp b/src/systemc/tests/systemc/tmp/compliance_1666_2011/section_6.6/test03/test03.cpp new file mode 100644 index 000000000..61e4e948c --- /dev/null +++ b/src/systemc/tests/systemc/tmp/compliance_1666_2011/section_6.6/test03/test03.cpp @@ -0,0 +1,113 @@ +/***************************************************************************** + + 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 -- Quick Test Of kill() And reset() sc_process_handle Methods. +// +// Original Author: John Aynsley, Doulos +// +// MODIFICATION LOG - modifiers, enter your name, affiliation, date and +// +// $Log: test03.cpp,v $ +// Revision 1.1 2011/02/05 21:13:26 acg +// Andy Goodrich: move of tests John Aynsley will replace. +// +// Revision 1.1 2011/01/20 16:55:01 acg +// Andy Goodrich: changes for IEEE 1666 2011. +// + +#define SC_INCLUDE_DYNAMIC_PROCESSES + +#include <systemc> + +using namespace sc_core; +using std::cout; +using std::endl; + +struct M3: sc_module +{ + M3(sc_module_name _name) + { + SC_THREAD(ticker); + SC_THREAD(calling); + SC_THREAD(target); + t = sc_get_current_process_handle(); + } + + sc_process_handle t; + sc_event ev; + int count; + + void ticker() + { + for (;;) + { + wait(10, SC_NS); + ev.notify(); + } + } + + void calling() + { + wait(15, SC_NS); + // Target runs at time 10 NS due to notification + sc_assert( count == 1 ); + + wait(10, SC_NS); + // Target runs again at time 20 NS due to notification + sc_assert( count == 2 ); + + t.reset(); + // Target reset immediately at time 25 NS + sc_assert( count == 0 ); + + wait(10, SC_NS); + // Target runs again at time 30 NS due to notification + sc_assert( count == 1 ); + + t.kill(); + // Target killed immediately at time 35 NS + sc_assert( t.terminated() ); + + sc_stop(); + } + + void target() + { + cout << "Target called/reset at " << sc_time_stamp() << endl; + count = 0; + for (;;) + { + wait(ev); + cout << "Target awoke at " << sc_time_stamp() << endl; + ++count; + } + } + + SC_HAS_PROCESS(M3); +}; + +int sc_main(int argc, char* argv[]) +{ + M3 m("m"); + + sc_start(); + + return 0; +} + diff --git a/src/systemc/tests/systemc/tmp/compliance_1666_2011/section_6.6/test04/golden/test04.log b/src/systemc/tests/systemc/tmp/compliance_1666_2011/section_6.6/test04/golden/test04.log new file mode 100644 index 000000000..cfeb74f2d --- /dev/null +++ b/src/systemc/tests/systemc/tmp/compliance_1666_2011/section_6.6/test04/golden/test04.log @@ -0,0 +1,8 @@ +SystemC Simulation +Target called/reset at 0 s +Target awoke at 10 ns +Target called/reset at 20 ns +Target called/reset at 30 ns +Target awoke at 40 ns + +Info: /OSCI/SystemC: Simulation stopped by user. diff --git a/src/systemc/tests/systemc/tmp/compliance_1666_2011/section_6.6/test04/test04.cpp b/src/systemc/tests/systemc/tmp/compliance_1666_2011/section_6.6/test04/test04.cpp new file mode 100644 index 000000000..d172bcfeb --- /dev/null +++ b/src/systemc/tests/systemc/tmp/compliance_1666_2011/section_6.6/test04/test04.cpp @@ -0,0 +1,108 @@ +/***************************************************************************** + + 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 -- Quick Test Of Synchronous Reset sc_process_handle Support +// +// Original Author: John Aynsley, Doulos +// +// MODIFICATION LOG - modifiers, enter your name, affiliation, date and +// +// $Log: test04.cpp,v $ +// Revision 1.1 2011/02/05 21:13:26 acg +// Andy Goodrich: move of tests John Aynsley will replace. +// +// Revision 1.1 2011/01/20 16:55:07 acg +// Andy Goodrich: changes for IEEE 1666 2011. +// + +#define SC_INCLUDE_DYNAMIC_PROCESSES + +#include <systemc> + +using namespace sc_core; +using std::cout; +using std::endl; + +struct M: sc_module +{ + M(sc_module_name _name) + { + SC_THREAD(ticker); + SC_THREAD(calling); + SC_THREAD(target); + t = sc_get_current_process_handle(); + } + + sc_process_handle t; + sc_event ev; + + void ticker() + { + for (;;) + { + wait(10, SC_NS); + ev.notify(); + } + } + + void calling() + { + wait(15, SC_NS); + // Target runs at time 10 NS due to notification + + t.sync_reset_on(); + // Target does not run at time 15 NS + + wait(10, SC_NS); + // Target is reset at time 20 NS due to notification + + wait(10, SC_NS); + // Target is reset again at time 30 NS due to notification + + t.sync_reset_off(); + // Target does not run at time 35 NS + + wait(10, SC_NS); + // Target runs at time 40 NS due to notification + + sc_stop(); + } + + void target() + { + cout << "Target called/reset at " << sc_time_stamp() << endl; + for (;;) + { + wait(ev); + cout << "Target awoke at " << sc_time_stamp() << endl; + } + } + + SC_HAS_PROCESS(M); +}; + +int sc_main(int argc, char* argv[]) +{ + M m("m"); + + sc_start(); + + return 0; +} + diff --git a/src/systemc/tests/systemc/tmp/compliance_1666_2011/section_6.6/test05/golden/test05.log b/src/systemc/tests/systemc/tmp/compliance_1666_2011/section_6.6/test05/golden/test05.log new file mode 100644 index 000000000..81a9fd590 --- /dev/null +++ b/src/systemc/tests/systemc/tmp/compliance_1666_2011/section_6.6/test05/golden/test05.log @@ -0,0 +1,11 @@ +SystemC Simulation +Target called/reset at 0 s +Target awoke at 10 ns +Target awoke at 20 ns +sc_unwind_exception caught by target +Target called/reset at 25 ns +Target awoke at 30 ns +sc_unwind_exception caught by target +sc_unwind_exception caught by ticker + +Info: /OSCI/SystemC: Simulation stopped by user. diff --git a/src/systemc/tests/systemc/tmp/compliance_1666_2011/section_6.6/test05/test05.cpp b/src/systemc/tests/systemc/tmp/compliance_1666_2011/section_6.6/test05/test05.cpp new file mode 100644 index 000000000..31cc771b4 --- /dev/null +++ b/src/systemc/tests/systemc/tmp/compliance_1666_2011/section_6.6/test05/test05.cpp @@ -0,0 +1,152 @@ +/***************************************************************************** + + 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 -- Reset and kill a thread process, including nested kills +// +// Original Author: John Aynsley, Doulos +// +// MODIFICATION LOG - modifiers, enter your name, affiliation, date and +// +// $Log: test05.cpp,v $ +// Revision 1.1 2011/02/05 21:13:26 acg +// Andy Goodrich: move of tests John Aynsley will replace. +// +// Revision 1.2 2011/01/25 20:54:03 acg +// Andy Goodrich: regolden for new delta counter rules. +// +// Revision 1.1 2011/01/24 12:06:10 acg +// Andy Goodrich: changes for IEEE 1666 2011 +// + + +#include <systemc> + +using namespace sc_core; +using std::cout; +using std::endl; + +struct M3: sc_module +{ + M3(sc_module_name _name) + { + SC_THREAD(ticker); + k = sc_get_current_process_handle(); + + SC_THREAD(calling); + + SC_THREAD(target); + t = sc_get_current_process_handle(); + + killing_over = false; + } + + sc_process_handle t, k; + sc_event ev; + int count; + bool killing_over; + + void ticker() + { + for (;;) + { + try { + wait(10, SC_NS); + ev.notify(); + } + catch (const sc_unwind_exception& ex) { + // ticker process killed by target + cout << "sc_unwind_exception caught by ticker" << endl; + sc_assert( sc_is_unwinding() ); + sc_assert( !ex.is_reset() ); + sc_assert( count == 1 ); + sc_assert( !killing_over ); + throw ex; + } + } + } + + void calling() + { + wait(15, SC_NS); + // Target runs at time 10 NS due to notification + sc_assert( count == 1 ); + + wait(10, SC_NS); + // Target runs again at time 20 NS due to notification + sc_assert( count == 2 ); + + t.reset(); + // Target reset immediately at time 25 NS + sc_assert( count == 0 ); + + wait(10, SC_NS); + // Target runs again at time 30 NS due to notification + sc_assert( count == 1 ); + + t.kill(); + sc_assert( !killing_over ); + killing_over = true; + + // Target killed immediately at time 35 NS + sc_assert( t.terminated() ); + sc_assert( k.terminated() ); + + sc_stop(); + } + + void target() + { + cout << "Target called/reset at " << sc_time_stamp() << endl; + count = 0; + for (;;) + { + try { + wait(ev); + cout << "Target awoke at " << sc_time_stamp() << endl; + ++count; + } + catch (const sc_unwind_exception& ex) { + cout << "sc_unwind_exception caught by target" << endl; + if (count == 2) + sc_assert( ex.is_reset() ); + else if (count == 1) + { + sc_assert( !ex.is_reset() ); + sc_assert( !killing_over ); + k.kill(); + } + else + sc_assert( false ); + throw ex; + } + } + } + + SC_HAS_PROCESS(M3); +}; + +int sc_main(int argc, char* argv[]) +{ + M3 m("m"); + + sc_start(); + + return 0; +} + diff --git a/src/systemc/tests/systemc/tmp/others/OLD_kill_reset/OLD_kill_reset.cpp b/src/systemc/tests/systemc/tmp/others/OLD_kill_reset/OLD_kill_reset.cpp new file mode 100644 index 000000000..c35c11b9e --- /dev/null +++ b/src/systemc/tests/systemc/tmp/others/OLD_kill_reset/OLD_kill_reset.cpp @@ -0,0 +1,80 @@ +#define SC_INCLUDE_DYNAMIC_PROCESSES + +#include <systemc> + +using namespace sc_core; +using std::cout; +using std::endl; + +struct M3: sc_module +{ + M3(sc_module_name _name) + { + SC_THREAD(ticker); + SC_THREAD(calling); + SC_THREAD(target); + t = sc_get_current_process_handle(); + } + + sc_process_handle t; + sc_event ev; + int count; + + void ticker() + { + for (;;) + { + wait(10, SC_NS); + ev.notify(); + } + } + + void calling() + { + wait(15, SC_NS); + // Target runs at time 10 NS due to notification + sc_assert( count == 1 ); + + wait(10, SC_NS); + // Target runs again at time 20 NS due to notification + sc_assert( count == 2 ); + + t.reset(); + // Target reset immediately at time 25 NS + sc_assert( count == 0 ); + + wait(10, SC_NS); + // Target runs again at time 30 NS due to notification + sc_assert( count == 1 ); + + t.kill(); + // Target killed immediately at time 35 NS + sc_assert( t.terminated() ); + + sc_stop(); + } + + void target() + { + cout << "Target called/reset at " << sc_time_stamp() << endl; + count = 0; + for (;;) + { + wait(ev); + cout << "Target awoke at " << sc_time_stamp() << endl; + ++count; + } + } + + SC_HAS_PROCESS(M3); +}; + +int sc_main(int argc, char* argv[]) +{ + M3 m("m"); + + sc_start(); + + return 0; +} + diff --git a/src/systemc/tests/systemc/tmp/others/OLD_kill_reset/golden/OLD_kill_reset.log b/src/systemc/tests/systemc/tmp/others/OLD_kill_reset/golden/OLD_kill_reset.log new file mode 100644 index 000000000..5cc0f85cb --- /dev/null +++ b/src/systemc/tests/systemc/tmp/others/OLD_kill_reset/golden/OLD_kill_reset.log @@ -0,0 +1,8 @@ +SystemC Simulation +Target called/reset at 0 s +Target awoke at 10 ns +Target awoke at 20 ns +Target called/reset at 25 ns +Target awoke at 30 ns + +Info: /OSCI/SystemC: Simulation stopped by user. diff --git a/src/systemc/tests/systemc/tmp/others/OLD_sc_start_starvation/OLD_sc_start_starvation.cpp b/src/systemc/tests/systemc/tmp/others/OLD_sc_start_starvation/OLD_sc_start_starvation.cpp new file mode 100644 index 000000000..76fb5d09b --- /dev/null +++ b/src/systemc/tests/systemc/tmp/others/OLD_sc_start_starvation/OLD_sc_start_starvation.cpp @@ -0,0 +1,48 @@ +
+// sc_start with event starvation policy
+
+#include <systemc>
+using namespace sc_core;
+using std::cout;
+using std::endl;
+
+SC_MODULE(Top)
+{
+ SC_CTOR(Top)
+ {
+ SC_THREAD(T);
+ }
+
+ sc_event ev;
+
+ void T()
+ {
+ ev.notify(150, SC_NS);
+ }
+};
+
+int sc_main(int argc, char* argv[])
+{
+ Top top("top");
+
+ sc_assert( sc_get_status() == SC_ELABORATION );
+ sc_assert( sc_time_stamp() == SC_ZERO_TIME );
+ sc_start(100, SC_NS);
+ sc_assert( sc_time_stamp() == sc_time(100, SC_NS) );
+
+ sc_start(10, SC_NS, SC_RUN_TO_TIME);
+ sc_assert( sc_time_stamp() == sc_time(110, SC_NS) );
+
+ sc_start(10, SC_NS, SC_EXIT_ON_STARVATION);
+ sc_assert( sc_time_stamp() == sc_time(110, SC_NS) );
+
+ sc_start(80, SC_NS, SC_EXIT_ON_STARVATION);
+ sc_assert( sc_time_stamp() == sc_time(150, SC_NS) ); // FAILS - time = 200 NS
+
+ sc_start();
+ sc_assert( sc_time_stamp() == sc_time(150, SC_NS) );
+ sc_assert( sc_get_status() == SC_PAUSED );
+
+ cout << endl << "Success" << endl;
+ return 0;
+}
diff --git a/src/systemc/tests/systemc/tmp/others/OLD_sc_start_starvation/golden/OLD_sc_start_starvation.log b/src/systemc/tests/systemc/tmp/others/OLD_sc_start_starvation/golden/OLD_sc_start_starvation.log new file mode 100644 index 000000000..0724df224 --- /dev/null +++ b/src/systemc/tests/systemc/tmp/others/OLD_sc_start_starvation/golden/OLD_sc_start_starvation.log @@ -0,0 +1,9 @@ +SystemC Simulation + +Warning: (W571) no activity or clock movement for sc_start() invocation +In file: <removed by verify.pl> + +Warning: (W571) no activity or clock movement for sc_start() invocation +In file: <removed by verify.pl> + +Success diff --git a/src/systemc/tests/systemc/tmp/others/bogus_reset/bogus_reset.cpp b/src/systemc/tests/systemc/tmp/others/bogus_reset/bogus_reset.cpp new file mode 100644 index 000000000..d816456cd --- /dev/null +++ b/src/systemc/tests/systemc/tmp/others/bogus_reset/bogus_reset.cpp @@ -0,0 +1,61 @@ +// Bogus reset
+
+#include <systemc>
+
+using namespace sc_core;
+using std::cout;
+using std::endl;
+
+struct M5: sc_module
+{
+ M5(sc_module_name _name)
+ {
+ SC_THREAD(ticker);
+ SC_THREAD(calling);
+ SC_METHOD(target);
+ sensitive << ev;
+ dont_initialize();
+ t = sc_get_current_process_handle();
+ }
+
+ sc_process_handle t;
+ sc_event ev;
+
+ void ticker()
+ {
+ for (;;)
+ {
+ wait(10, SC_NS);
+ ev.notify();
+ }
+ }
+
+ void calling()
+ {
+ wait(15, SC_NS);
+ // target runs at 10 NS due to notification of ev
+
+ t.reset();
+ // target runs at 15 NS due to reset.
+
+ sc_stop();
+ }
+
+ void target()
+ {
+ cout << "Target called at " << sc_time_stamp() << endl;
+ }
+
+ SC_HAS_PROCESS(M5);
+};
+
+int sc_main(int argc, char* argv[])
+{
+ M5 m("m");
+
+ sc_start();
+
+ cout << endl << "Success" << endl;
+ return 0;
+}
+
diff --git a/src/systemc/tests/systemc/tmp/others/bogus_reset/golden/bogus_reset.log b/src/systemc/tests/systemc/tmp/others/bogus_reset/golden/bogus_reset.log new file mode 100644 index 000000000..d270e77be --- /dev/null +++ b/src/systemc/tests/systemc/tmp/others/bogus_reset/golden/bogus_reset.log @@ -0,0 +1,7 @@ +SystemC Simulation +Target called at 10 ns +Target called at 15 ns + +Info: /OSCI/SystemC: Simulation stopped by user. + +Success diff --git a/src/systemc/tests/systemc/tmp/others/is_unwinding_bug/golden/is_unwinding_bug.log b/src/systemc/tests/systemc/tmp/others/is_unwinding_bug/golden/is_unwinding_bug.log new file mode 100644 index 000000000..e7d0691d0 --- /dev/null +++ b/src/systemc/tests/systemc/tmp/others/is_unwinding_bug/golden/is_unwinding_bug.log @@ -0,0 +1,12 @@ +SystemC Simulation +Target called/reset at 0 s +Target awoke at 10 ns +Unwinding at 20 ns +Target called/reset at 20 ns +Target awoke at 30 ns +Unwinding at 35 ns +Target called/reset at 35 ns + +Info: /OSCI/SystemC: Simulation stopped by user. + +Success diff --git a/src/systemc/tests/systemc/tmp/others/is_unwinding_bug/is_unwinding_bug.cpp b/src/systemc/tests/systemc/tmp/others/is_unwinding_bug/is_unwinding_bug.cpp new file mode 100644 index 000000000..0dc33a59f --- /dev/null +++ b/src/systemc/tests/systemc/tmp/others/is_unwinding_bug/is_unwinding_bug.cpp @@ -0,0 +1,80 @@ +// sync_reset_on/off + +#define SC_INCLUDE_DYNAMIC_PROCESSES + +#include <systemc> + +using namespace sc_core; +using std::cout; +using std::endl; + +struct M2: sc_module +{ + M2(sc_module_name _name) + { + SC_THREAD(ticker); + SC_THREAD(calling); + SC_THREAD(target); + t = sc_get_current_process_handle(); + } + + sc_process_handle t; + sc_event ev; + + void ticker() + { + for (;;) + { + wait(10, SC_NS); + ev.notify(); + } + } + + void calling() + { + wait(15, SC_NS); + + t.sync_reset_on(); + wait(10, SC_NS); + + t.sync_reset_off(); + wait(10, SC_NS); + + t.reset(); + wait(SC_ZERO_TIME); + + sc_stop(); + } + + void target() + { + cout << "Target called/reset at " << sc_time_stamp() << endl; + + for (;;) + { + try { + wait(ev); + cout << "Target awoke at " << sc_time_stamp() << endl; + } + catch (const sc_unwind_exception& ex) { + cout << "Unwinding at " << sc_time_stamp() << endl; + sc_assert( t.is_unwinding() ); + sc_assert( sc_is_unwinding() ); + throw ex; + } + } + } + + SC_HAS_PROCESS(M2); +}; + +int sc_main(int argc, char* argv[]) +{ + M2 m("m"); + + sc_start(); + + cout << endl << "Success" << endl; + return 0; +} + diff --git a/src/systemc/tests/systemc/tmp/others/kill_reset/golden/kill_reset.log b/src/systemc/tests/systemc/tmp/others/kill_reset/golden/kill_reset.log new file mode 100644 index 000000000..81a9fd590 --- /dev/null +++ b/src/systemc/tests/systemc/tmp/others/kill_reset/golden/kill_reset.log @@ -0,0 +1,11 @@ +SystemC Simulation +Target called/reset at 0 s +Target awoke at 10 ns +Target awoke at 20 ns +sc_unwind_exception caught by target +Target called/reset at 25 ns +Target awoke at 30 ns +sc_unwind_exception caught by target +sc_unwind_exception caught by ticker + +Info: /OSCI/SystemC: Simulation stopped by user. diff --git a/src/systemc/tests/systemc/tmp/others/kill_reset/kill_reset.cpp b/src/systemc/tests/systemc/tmp/others/kill_reset/kill_reset.cpp new file mode 100644 index 000000000..65d140fc7 --- /dev/null +++ b/src/systemc/tests/systemc/tmp/others/kill_reset/kill_reset.cpp @@ -0,0 +1,116 @@ +// Reset and kill a thread process, including nested kills
+
+#include <systemc>
+
+using namespace sc_core;
+using std::cout;
+using std::endl;
+
+struct M3: sc_module
+{
+ M3(sc_module_name _name)
+ {
+ SC_THREAD(ticker);
+ k = sc_get_current_process_handle();
+
+ SC_THREAD(calling);
+
+ SC_THREAD(target);
+ t = sc_get_current_process_handle();
+
+ killing_over = false;
+ }
+
+ sc_process_handle t, k;
+ sc_event ev;
+ int count;
+ bool killing_over;
+
+ void ticker()
+ {
+ for (;;)
+ {
+ try {
+ wait(10, SC_NS);
+ ev.notify();
+ }
+ catch (const sc_unwind_exception& ex) {
+ // ticker process killed by target
+ cout << "sc_unwind_exception caught by ticker" << endl;
+ sc_assert( !ex.is_reset() );
+ sc_assert( count == 1 );
+ sc_assert( !killing_over );
+ throw ex;
+ }
+ }
+ }
+
+ void calling()
+ {
+ wait(15, SC_NS);
+ // Target runs at time 10 NS due to notification
+ sc_assert( count == 1 );
+
+ wait(10, SC_NS);
+ // Target runs again at time 20 NS due to notification
+ sc_assert( count == 2 );
+
+ t.reset();
+ // Target reset immediately at time 25 NS
+ sc_assert( count == 0 );
+
+ wait(10, SC_NS);
+ // Target runs again at time 30 NS due to notification
+ sc_assert( count == 1 );
+
+ t.kill();
+ sc_assert( !killing_over );
+ killing_over = true;
+
+ // Target killed immediately at time 35 NS
+ sc_assert( t.terminated() ); // FAILS IN PRESENCE OF k.kill(); on line 96
+ sc_assert( k.terminated() );
+
+ sc_stop();
+ }
+
+ void target()
+ {
+ cout << "Target called/reset at " << sc_time_stamp() << endl;
+ count = 0;
+ for (;;)
+ {
+ try {
+ wait(ev);
+ cout << "Target awoke at " << sc_time_stamp() << endl;
+ ++count;
+ }
+ catch (const sc_unwind_exception& ex) {
+ cout << "sc_unwind_exception caught by target" << endl;
+ if (count == 2)
+ sc_assert( ex.is_reset() );
+ else if (count == 1)
+ {
+ sc_assert( !ex.is_reset() );
+ sc_assert( !killing_over );
+ k.kill();
+ }
+ else
+ sc_assert( false );
+ throw ex;
+ }
+ }
+ }
+
+ SC_HAS_PROCESS(M3);
+};
+
+int sc_main(int argc, char* argv[])
+{
+ M3 m("m");
+
+ sc_start();
+
+ return 0;
+}
+
diff --git a/src/systemc/tests/systemc/tmp/others/method_suspends_itself/golden/method_suspends_itself.log b/src/systemc/tests/systemc/tmp/others/method_suspends_itself/golden/method_suspends_itself.log new file mode 100644 index 000000000..973018653 --- /dev/null +++ b/src/systemc/tests/systemc/tmp/others/method_suspends_itself/golden/method_suspends_itself.log @@ -0,0 +1,8 @@ +SystemC Simulation +Target called at 10 ns +Target called at 20 ns +Target called at 35 ns +Target called at 40 ns +Target called at 50 ns + +Info: /OSCI/SystemC: Simulation stopped by user. diff --git a/src/systemc/tests/systemc/tmp/others/method_suspends_itself/method_suspends_itself.cpp b/src/systemc/tests/systemc/tmp/others/method_suspends_itself/method_suspends_itself.cpp new file mode 100644 index 000000000..aea645c45 --- /dev/null +++ b/src/systemc/tests/systemc/tmp/others/method_suspends_itself/method_suspends_itself.cpp @@ -0,0 +1,88 @@ +#define SC_INCLUDE_DYNAMIC_PROCESSES + +#include <systemc> + +using namespace sc_core; +using std::cout; +using std::endl; + +struct M5: sc_module +{ + M5(sc_module_name _name) + { + SC_THREAD(ticker); + SC_THREAD(calling); + SC_METHOD(target); + sensitive << ev; + dont_initialize(); + t = sc_get_current_process_handle(); + suspend_target = false; + resume_target = false; + } + + sc_process_handle t; + sc_event ev; + bool suspend_target; + bool resume_target; + + void ticker() + { + for (;;) + { + wait(10, SC_NS); + ev.notify(); + } + } + + void calling() + { + wait(15, SC_NS); + // Target runs at 10 NS + + suspend_target = true; + wait(10, SC_NS); + // Target runs at 20 NS and suspends itself + + wait(10, SC_NS); + // Target does not run at 30 NS + + suspend_target = false; + t.resume(); + // Target runs at 35 NS + + wait(10, SC_NS); + // Target runs at 40 NS + + suspend_target = true; + resume_target = true; + wait(10, SC_NS); + // Target runs at 50 NS + + sc_stop(); + } + + void target() + { + cout << "Target called at " << sc_time_stamp() << endl; + if (suspend_target) + t.suspend(); + if (resume_target) + { + t.resume(); + suspend_target = false; + } + } + + SC_HAS_PROCESS(M5); +}; + +int sc_main(int argc, char* argv[]) +{ + M5 m("m"); + + sc_core::sc_allow_process_control_corners = true; + sc_start(); + + return 0; +} + diff --git a/src/systemc/tests/systemc/tmp/others/priority_bug/golden/priority_bug.log b/src/systemc/tests/systemc/tmp/others/priority_bug/golden/priority_bug.log new file mode 100644 index 000000000..9eee67f21 --- /dev/null +++ b/src/systemc/tests/systemc/tmp/others/priority_bug/golden/priority_bug.log @@ -0,0 +1,4 @@ +SystemC Simulation +Target called/reset at 0 s + +Info: /OSCI/SystemC: Simulation stopped by user. diff --git a/src/systemc/tests/systemc/tmp/others/priority_bug/priority_bug.cpp b/src/systemc/tests/systemc/tmp/others/priority_bug/priority_bug.cpp new file mode 100644 index 000000000..a5dd2e664 --- /dev/null +++ b/src/systemc/tests/systemc/tmp/others/priority_bug/priority_bug.cpp @@ -0,0 +1,63 @@ +#include <systemc> + +using namespace sc_core; +using std::cout; +using std::endl; + +struct M4: sc_module +{ + M4(sc_module_name _name) + { + SC_THREAD(calling); + SC_THREAD(target); + t = sc_get_current_process_handle(); + } + + sc_process_handle t; + sc_event ev; + int count; + + void calling() + { + + t.sync_reset_on(); + wait(10, SC_NS); + + t.suspend(); + wait(10, SC_NS); + + t.disable(); + wait(10, SC_NS); + + t.enable(); + ev.notify(); + wait(10, SC_NS); // !!!!!! target is RESET WHILE STILL SUSPENDED !!!!!! + + sc_stop(); + } + + void target() + { + cout << "Target called/reset at " << sc_time_stamp() << endl; + count = 0; + for (;;) + { + wait(ev); + cout << "Target awoke at " << sc_time_stamp() << " count = " << count << endl; + ++count; + } + } + + SC_HAS_PROCESS(M4); +}; + +int sc_main(int argc, char* argv[]) +{ + M4 m("m"); + + sc_core::sc_allow_process_control_corners = true; + sc_start(); + + return 0; +} + diff --git a/src/systemc/tests/systemc/tmp/others/sc_start_starvation/golden/sc_start_starvation.log b/src/systemc/tests/systemc/tmp/others/sc_start_starvation/golden/sc_start_starvation.log new file mode 100644 index 000000000..510e7e741 --- /dev/null +++ b/src/systemc/tests/systemc/tmp/others/sc_start_starvation/golden/sc_start_starvation.log @@ -0,0 +1,15 @@ +SystemC Simulation + +Warning: (W571) no activity or clock movement for sc_start() invocation +In file: <removed by verify.pl> +sc_time_stamp() = 150 ns +sc_pending_activity_at_future_time() = 1 +sc_time_to_pending_activity() = 100 ns + +Warning: (W571) no activity or clock movement for sc_start() invocation +In file: <removed by verify.pl> + +Warning: (W571) no activity or clock movement for sc_start() invocation +In file: <removed by verify.pl> + +Success diff --git a/src/systemc/tests/systemc/tmp/others/sc_start_starvation/sc_start_starvation.cpp b/src/systemc/tests/systemc/tmp/others/sc_start_starvation/sc_start_starvation.cpp new file mode 100644 index 000000000..bcc743c43 --- /dev/null +++ b/src/systemc/tests/systemc/tmp/others/sc_start_starvation/sc_start_starvation.cpp @@ -0,0 +1,85 @@ +
+// sc_start with event starvation policy
+
+#define SC_INCLUDE_DYNAMIC_PROCESSES
+
+#include <systemc>
+using namespace sc_core;
+using std::cout;
+using std::endl;
+
+SC_MODULE(Top)
+{
+ SC_CTOR(Top)
+ {
+ SC_THREAD(T);
+ }
+
+ sc_event ev2;
+
+ void T()
+ {
+ sc_assert( sc_get_status() == SC_RUNNING );
+ ev2.notify(150, SC_NS);
+
+ //wait(ev2); // Inserting this line makes the test pass
+ }
+};
+
+int sc_main(int argc, char* argv[])
+{
+ Top top("top");
+
+ sc_event ev;
+ ev.notify(250, SC_NS);
+
+ sc_assert( sc_get_status() == SC_ELABORATION );
+ sc_assert( sc_time_stamp() == SC_ZERO_TIME );
+ sc_start(100, SC_NS);
+ sc_assert( sc_get_status() == SC_PAUSED );
+ sc_assert( sc_time_stamp() == sc_time(100, SC_NS) );
+
+ sc_start(10, SC_NS, SC_RUN_TO_TIME);
+ sc_assert( sc_time_stamp() == sc_time(110, SC_NS) );
+
+ sc_start(10, SC_NS, SC_EXIT_ON_STARVATION);
+ sc_assert( sc_time_stamp() == sc_time(110, SC_NS) );
+
+ sc_start(80, SC_NS, SC_EXIT_ON_STARVATION);
+
+ cout << "sc_time_stamp() = " << sc_time_stamp() << endl;
+ cout << "sc_pending_activity_at_future_time() = " << sc_pending_activity_at_future_time() << endl;
+ cout << "sc_time_to_pending_activity() = " << sc_time_to_pending_activity() << endl;
+
+ sc_assert( sc_time_stamp() == sc_time(150, SC_NS) ); // FAILS. Does not see ev2
+
+ sc_start(50, SC_NS, SC_EXIT_ON_STARVATION);
+ sc_assert( sc_time_stamp() == sc_time(150, SC_NS) );
+
+ sc_start(50, SC_NS, SC_RUN_TO_TIME);
+ sc_assert( sc_time_stamp() == sc_time(200, SC_NS) );
+
+ sc_start();
+ sc_assert( sc_get_status() == SC_PAUSED );
+ sc_assert( sc_time_stamp() == sc_time(250, SC_NS) );
+
+ ev.notify(SC_ZERO_TIME);
+ sc_start();
+ sc_assert( sc_time_stamp() == sc_time(250, SC_NS) );
+
+ ev.notify(10, SC_NS);
+ sc_start();
+ sc_assert( sc_time_stamp() == sc_time(260, SC_NS) );
+
+ ev.notify(10, SC_NS);
+ sc_start(sc_time(100, SC_NS), SC_EXIT_ON_STARVATION);
+ sc_assert( sc_time_stamp() == sc_time(270, SC_NS) );
+
+ ev.notify(10, SC_NS);
+ sc_start(sc_time(100, SC_NS)); // SC_RUN_TO_TIME
+ sc_assert( sc_time_stamp() == sc_time(370, SC_NS) );
+ sc_assert( sc_get_status() == SC_PAUSED );
+
+ cout << endl << "Success" << endl;
+ return 0;
+}
diff --git a/src/systemc/tests/systemc/tmp/others/sc_writer_bug/golden/sc_writer_bug.log b/src/systemc/tests/systemc/tmp/others/sc_writer_bug/golden/sc_writer_bug.log new file mode 100644 index 000000000..40bfc2caa --- /dev/null +++ b/src/systemc/tests/systemc/tmp/others/sc_writer_bug/golden/sc_writer_bug.log @@ -0,0 +1,5 @@ +SystemC Simulation +port written in top.m1 at 1 ps +port written in top.m2 at 2 ps + +Success diff --git a/src/systemc/tests/systemc/tmp/others/sc_writer_bug/sc_writer_bug.cpp b/src/systemc/tests/systemc/tmp/others/sc_writer_bug/sc_writer_bug.cpp new file mode 100644 index 000000000..a54ceddf5 --- /dev/null +++ b/src/systemc/tests/systemc/tmp/others/sc_writer_bug/sc_writer_bug.cpp @@ -0,0 +1,69 @@ +// sc_writer_policy template argument of class sc_signal
+
+#define SC_INCLUDE_DYNAMIC_PROCESSES
+#include <systemc>
+
+using namespace sc_core;
+using namespace sc_dt;
+using std::cout;
+using std::endl;
+using std::string;
+
+
+struct M: sc_module
+{
+ sc_inout<bool> port;
+
+ sc_time delay;
+
+ M(sc_module_name _name, sc_time _delay)
+ : port("port")
+ , delay(_delay)
+ {
+ SC_THREAD(T);
+ }
+
+ void T()
+ {
+ wait(delay);
+ port.write(true);
+ cout << "port written in " << name() << " at " << sc_time_stamp()
+ << endl;
+ wait(sc_time(1, SC_NS));
+ }
+
+ SC_HAS_PROCESS(M);
+};
+
+struct Top: sc_module
+{
+ M *m1;
+ M *m2;
+
+ sc_signal<bool,SC_MANY_WRITERS> multi_sig_1;
+
+ Top(sc_module_name _name)
+ : multi_sig_1("multi_sig_1")
+ {
+ m1 = new M("m1", sc_time(1, SC_PS));
+ m2 = new M("m2", sc_time(2, SC_PS));
+
+ m1->port.bind(multi_sig_1);
+ m2->port.bind(multi_sig_1);
+
+ multi_sig_1.write(true);
+ }
+
+ SC_HAS_PROCESS(Top);
+};
+
+
+int sc_main(int argc, char* argv[])
+{
+ Top top("top");
+ sc_start(5,SC_PS);
+
+ cout << endl << "Success" << endl;
+ return 0;
+}
+
diff --git a/src/systemc/tests/systemc/tmp/others/sync_reset/golden/sync_reset.log b/src/systemc/tests/systemc/tmp/others/sync_reset/golden/sync_reset.log new file mode 100644 index 000000000..cfeb74f2d --- /dev/null +++ b/src/systemc/tests/systemc/tmp/others/sync_reset/golden/sync_reset.log @@ -0,0 +1,8 @@ +SystemC Simulation +Target called/reset at 0 s +Target awoke at 10 ns +Target called/reset at 20 ns +Target called/reset at 30 ns +Target awoke at 40 ns + +Info: /OSCI/SystemC: Simulation stopped by user. diff --git a/src/systemc/tests/systemc/tmp/others/sync_reset/sync_reset.cpp b/src/systemc/tests/systemc/tmp/others/sync_reset/sync_reset.cpp new file mode 100644 index 000000000..dfe7fbc54 --- /dev/null +++ b/src/systemc/tests/systemc/tmp/others/sync_reset/sync_reset.cpp @@ -0,0 +1,75 @@ +#define SC_INCLUDE_DYNAMIC_PROCESSES + +#include <systemc> + +using namespace sc_core; +using std::cout; +using std::endl; + +struct M: sc_module +{ + M(sc_module_name _name) + { + SC_THREAD(ticker); + SC_THREAD(calling); + SC_THREAD(target); + t = sc_get_current_process_handle(); + } + + sc_process_handle t; + sc_event ev; + + void ticker() + { + for (;;) + { + wait(10, SC_NS); + ev.notify(); + } + } + + void calling() + { + wait(15, SC_NS); + // Target runs at time 10 NS due to notification + + t.sync_reset_on(); + // Target does not run at time 15 NS + + wait(10, SC_NS); + // Target is reset at time 20 NS due to notification + + wait(10, SC_NS); + // Target is reset again at time 30 NS due to notification + + t.sync_reset_off(); + // Target does not run at time 35 NS + + wait(10, SC_NS); + // Target runs at time 40 NS due to notification + + sc_stop(); + } + + void target() + { + cout << "Target called/reset at " << sc_time_stamp() << endl; + for (;;) + { + wait(ev); + cout << "Target awoke at " << sc_time_stamp() << endl; + } + } + + SC_HAS_PROCESS(M); +}; + +int sc_main(int argc, char* argv[]) +{ + M m("m"); + + sc_start(); + + return 0; +} + |