summaryrefslogtreecommitdiff
path: root/src/systemc/tests/systemc/kernel/phase_callbacks/test01/test01.cpp
blob: c4095aae37131993708ac8a3afbf11686cb8c049 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
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;
}