From 16fa8d7cc8c92f5ab879e4cf9c6c0bbb3567860f Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Thu, 24 May 2018 01:37:55 -0700 Subject: systemc: Import tests from the Accellera systemc distribution. Change-Id: Iad76b398949a55d768a34d027a2d8e3739953da6 Reviewed-on: https://gem5-review.googlesource.com/10845 Reviewed-by: Giacomo Travaglini Maintainer: Gabe Black --- .../compliance_1666/test203b/golden/test203b.log | 4 ++ .../systemc/compliance_1666/test203b/test203b.cpp | 68 ++++++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 src/systemc/tests/systemc/compliance_1666/test203b/golden/test203b.log create mode 100644 src/systemc/tests/systemc/compliance_1666/test203b/test203b.cpp (limited to 'src/systemc/tests/systemc/compliance_1666/test203b') 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 +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; +} -- cgit v1.2.3