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/compliance_1666/test203b | |
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/compliance_1666/test203b')
-rw-r--r-- | src/systemc/tests/systemc/compliance_1666/test203b/golden/test203b.log | 4 | ||||
-rw-r--r-- | src/systemc/tests/systemc/compliance_1666/test203b/test203b.cpp | 68 |
2 files changed, 72 insertions, 0 deletions
diff --git a/src/systemc/tests/systemc/compliance_1666/test203b/golden/test203b.log b/src/systemc/tests/systemc/compliance_1666/test203b/golden/test203b.log new file mode 100644 index 000000000..d1a84db9a --- /dev/null +++ b/src/systemc/tests/systemc/compliance_1666/test203b/golden/test203b.log @@ -0,0 +1,4 @@ +SystemC Simulation +Should be silent... + +Success diff --git a/src/systemc/tests/systemc/compliance_1666/test203b/test203b.cpp b/src/systemc/tests/systemc/compliance_1666/test203b/test203b.cpp new file mode 100644 index 000000000..07f4cb506 --- /dev/null +++ b/src/systemc/tests/systemc/compliance_1666/test203b/test203b.cpp @@ -0,0 +1,68 @@ +#define SC_INCLUDE_DYNAMIC_PROCESSES + +#include <systemc> +using namespace sc_core; +using namespace sc_dt; +using std::cout; +using std::endl; + +// 3) terminated_event() + +SC_MODULE(M) +{ + SC_CTOR(M) + { + SC_THREAD(T); + } + + void T() + { + sc_process_handle h1 = sc_spawn(sc_bind(&M::proc, this, 2)); + sc_process_handle h2 = sc_spawn(sc_bind(&M::proc, this, 3)); + sc_process_handle h3 = sc_spawn(sc_bind(&M::proc, this, 1)); + sc_assert(sc_time_stamp() == sc_time(0, SC_NS)); + wait(h1.terminated_event() & h2.terminated_event() & h3.terminated_event()); + sc_assert(sc_time_stamp() == sc_time(3, SC_NS)); + if (h1.valid()) sc_assert (h1.terminated()); + if (h2.valid()) sc_assert (h2.terminated()); + if (h3.valid()) sc_assert (h3.terminated()); + + h1 = sc_spawn(sc_bind(&M::proc, this, 10)); + h2 = sc_spawn(sc_bind(&M::proc, this, 30)); + h3 = sc_spawn(sc_bind(&M::proc, this, 20)); + sc_assert(sc_time_stamp() == sc_time(3, SC_NS)); + wait(h1.terminated_event() | h2.terminated_event() | h3.terminated_event()); + sc_assert(sc_time_stamp() == sc_time(13, SC_NS)); + sc_assert(h2.valid()); + sc_assert( !h2.terminated() ); + sc_assert(h3.valid()); + sc_assert( !h3.terminated() ); + + wait(h2.terminated_event() & h3.terminated_event()); + sc_assert(sc_time_stamp() == sc_time(33, SC_NS)); + } + void proc(int delay) + { + wait(delay * sc_time(1, SC_NS)); + } +}; + +SC_MODULE(Top) +{ + M *m; + SC_CTOR(Top) + { + m = new M("m"); + } +}; + +int sc_main(int argc, char* argv[]) +{ + cout << "Should be silent..." << endl; + + Top top("top"); + sc_start(); + + cout << endl << "Success" << endl; + return 0; +} |