112855Sgabeblack@google.com#include "systemc.h" 212855Sgabeblack@google.com 312855Sgabeblack@google.comclass Sig : public sc_prim_channel { 412855Sgabeblack@google.com public: 512855Sgabeblack@google.com virtual void before_end_of_elaboration() 612855Sgabeblack@google.com { 712855Sgabeblack@google.com cout << "prim_channel: before end of elaboration" << endl; 812855Sgabeblack@google.com } 912855Sgabeblack@google.com virtual void end_of_simulation() 1012855Sgabeblack@google.com { 1112855Sgabeblack@google.com cout << "prim_channel: end of simulation" << endl; 1212855Sgabeblack@google.com } 1312855Sgabeblack@google.com virtual void start_of_simulation() 1412855Sgabeblack@google.com { 1512855Sgabeblack@google.com cout << "prim_channel: start of simulation" << endl; 1612855Sgabeblack@google.com } 1712855Sgabeblack@google.com}; 1812855Sgabeblack@google.com 1912855Sgabeblack@google.comSC_MODULE(X) 2012855Sgabeblack@google.com{ 2112855Sgabeblack@google.com SC_CTOR(X) 2212855Sgabeblack@google.com { 2312855Sgabeblack@google.com SC_CTHREAD(y, clk.pos()); 2412855Sgabeblack@google.com } 2512855Sgabeblack@google.com void y() 2612855Sgabeblack@google.com { 2712855Sgabeblack@google.com wait(); 2812855Sgabeblack@google.com sc_stop(); 2912855Sgabeblack@google.com } 3012855Sgabeblack@google.com sc_in_clk clk; 3112855Sgabeblack@google.com}; 3212855Sgabeblack@google.com 3312855Sgabeblack@google.comint sc_main(int argc, char* argv[]) 3412855Sgabeblack@google.com{ 3512855Sgabeblack@google.com sc_clock clock; 3612855Sgabeblack@google.com Sig signal; 3712855Sgabeblack@google.com X x("x"); 3812855Sgabeblack@google.com 3912855Sgabeblack@google.com x.clk(clock); 4012855Sgabeblack@google.com 4112855Sgabeblack@google.com if ( sc_start_of_simulation_invoked() ) 4212855Sgabeblack@google.com cout << __FILE__ << "(" << __LINE__ << "): bad start flag should be false" << endl; 4312855Sgabeblack@google.com if ( sc_end_of_simulation_invoked() ) 4412855Sgabeblack@google.com cout << __FILE__ << "(" << __LINE__ << "): bad end flag should be false" << endl; 4512855Sgabeblack@google.com 4612855Sgabeblack@google.com sc_start(2, SC_NS); 4712855Sgabeblack@google.com if ( !sc_start_of_simulation_invoked() ) 4812855Sgabeblack@google.com cout << __FILE__ << "(" << __LINE__ << "): bad start flag should be true" << endl; 4912855Sgabeblack@google.com 5012855Sgabeblack@google.com if ( !sc_end_of_simulation_invoked() ) 5112855Sgabeblack@google.com cout << __FILE__ << "(" << __LINE__ << "): bad end flag should be true" << endl; 5212855Sgabeblack@google.com 5313158Sgabeblack@google.com cout << "Program completed" << endl; 5412855Sgabeblack@google.com 5512855Sgabeblack@google.com return 0; 5612855Sgabeblack@google.com} 5712855Sgabeblack@google.com 58