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/kernel/phase_callbacks/test01 | |
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/kernel/phase_callbacks/test01')
-rw-r--r-- | src/systemc/tests/systemc/kernel/phase_callbacks/test01/golden/test01.log | 7 | ||||
-rw-r--r-- | src/systemc/tests/systemc/kernel/phase_callbacks/test01/test01.cpp | 57 |
2 files changed, 64 insertions, 0 deletions
diff --git a/src/systemc/tests/systemc/kernel/phase_callbacks/test01/golden/test01.log b/src/systemc/tests/systemc/kernel/phase_callbacks/test01/golden/test01.log new file mode 100644 index 000000000..9e42301d0 --- /dev/null +++ b/src/systemc/tests/systemc/kernel/phase_callbacks/test01/golden/test01.log @@ -0,0 +1,7 @@ +SystemC Simulation +prim_channel: before end of elaboration +prim_channel: start of simulation + +Info: /OSCI/SystemC: Simulation stopped by user. +prim_channel: end of simulation +Program completed diff --git a/src/systemc/tests/systemc/kernel/phase_callbacks/test01/test01.cpp b/src/systemc/tests/systemc/kernel/phase_callbacks/test01/test01.cpp new file mode 100644 index 000000000..c4095aae3 --- /dev/null +++ b/src/systemc/tests/systemc/kernel/phase_callbacks/test01/test01.cpp @@ -0,0 +1,57 @@ +#include "systemc.h" + +class Sig : public sc_prim_channel { + public: + virtual void before_end_of_elaboration() + { + cout << "prim_channel: before end of elaboration" << endl; + } + virtual void end_of_simulation() + { + cout << "prim_channel: end of simulation" << endl; + } + virtual void start_of_simulation() + { + cout << "prim_channel: start of simulation" << endl; + } +}; + +SC_MODULE(X) +{ + SC_CTOR(X) + { + SC_CTHREAD(y, clk.pos()); + } + void y() + { + wait(); + sc_stop(); + } + sc_in_clk clk; +}; + +int sc_main(int argc, char* argv[]) +{ + sc_clock clock; + Sig signal; + X x("x"); + + x.clk(clock); + + if ( sc_start_of_simulation_invoked() ) + cout << __FILE__ << "(" << __LINE__ << "): bad start flag should be false" << endl; + if ( sc_end_of_simulation_invoked() ) + cout << __FILE__ << "(" << __LINE__ << "): bad end flag should be false" << endl; + + sc_start(2, SC_NS); + if ( !sc_start_of_simulation_invoked() ) + cout << __FILE__ << "(" << __LINE__ << "): bad start flag should be true" << endl; + + if ( !sc_end_of_simulation_invoked() ) + cout << __FILE__ << "(" << __LINE__ << "): bad end flag should be true" << endl; + + cerr << "Program completed" << endl; + + return 0; +} + |