1#include "systemc.h"
2
3class Sig : public sc_prim_channel {
4  public:
5	virtual void before_end_of_elaboration()
6	{
7		 cout << "prim_channel: before end of elaboration" << endl;
8	}
9	virtual void end_of_simulation()
10	{
11		 cout << "prim_channel: end of simulation" << endl;
12	}
13	virtual void start_of_simulation()
14	{
15		 cout << "prim_channel: start of simulation" << endl;
16	}
17};
18
19SC_MODULE(X)
20{
21	SC_CTOR(X)
22	{
23		SC_CTHREAD(y, clk.pos());
24	}
25	void y()
26	{
27		wait();
28	}
29	sc_in_clk clk;
30};
31
32int sc_main(int argc, char* argv[])
33{
34	sc_clock clock;
35	Sig      signal;
36	X        x("x");
37
38	x.clk(clock);
39
40	if ( sc_start_of_simulation_invoked() )
41		 cout << __FILE__ << "(" << __LINE__ << "): bad start flag should be false" << endl;
42	if ( sc_end_of_simulation_invoked() )
43		 cout << __FILE__ << "(" << __LINE__ << "): bad end flag should be false" << endl;
44
45	sc_start(2, SC_NS);
46	if ( !sc_start_of_simulation_invoked() )
47		 cout << __FILE__ << "(" << __LINE__ << "): bad start flag should be true" << endl;
48
49	sc_stop();
50	if ( !sc_end_of_simulation_invoked() )
51		 cout << __FILE__ << "(" << __LINE__ << "): bad end flag should be true" << endl;
52
53	 cout << "Program completed" << endl;
54
55    return 0;
56}
57
58