test01.cpp revision 12855
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 sc_stop(); 29 } 30 sc_in_clk clk; 31}; 32 33int sc_main(int argc, char* argv[]) 34{ 35 sc_clock clock; 36 Sig signal; 37 X x("x"); 38 39 x.clk(clock); 40 41 if ( sc_start_of_simulation_invoked() ) 42 cout << __FILE__ << "(" << __LINE__ << "): bad start flag should be false" << endl; 43 if ( sc_end_of_simulation_invoked() ) 44 cout << __FILE__ << "(" << __LINE__ << "): bad end flag should be false" << endl; 45 46 sc_start(2, SC_NS); 47 if ( !sc_start_of_simulation_invoked() ) 48 cout << __FILE__ << "(" << __LINE__ << "): bad start flag should be true" << endl; 49 50 if ( !sc_end_of_simulation_invoked() ) 51 cout << __FILE__ << "(" << __LINE__ << "): bad end flag should be true" << endl; 52 53 cerr << "Program completed" << endl; 54 55 return 0; 56} 57 58