summaryrefslogtreecommitdiff
path: root/src/systemc/tests/systemc/kernel/phase_callbacks/test02/test02.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/systemc/tests/systemc/kernel/phase_callbacks/test02/test02.cpp')
-rw-r--r--src/systemc/tests/systemc/kernel/phase_callbacks/test02/test02.cpp57
1 files changed, 57 insertions, 0 deletions
diff --git a/src/systemc/tests/systemc/kernel/phase_callbacks/test02/test02.cpp b/src/systemc/tests/systemc/kernel/phase_callbacks/test02/test02.cpp
new file mode 100644
index 000000000..2f4f3c285
--- /dev/null
+++ b/src/systemc/tests/systemc/kernel/phase_callbacks/test02/test02.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_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;
+
+ sc_stop();
+ if ( !sc_end_of_simulation_invoked() )
+ cout << __FILE__ << "(" << __LINE__ << "): bad end flag should be true" << endl;
+
+ cerr << "Program completed" << endl;
+
+ return 0;
+}
+