test02.cpp revision 13158:886ca37b7665
114299Sbbruce@ucdavis.edu#include "systemc.h" 214299Sbbruce@ucdavis.edu 314299Sbbruce@ucdavis.educlass Sig : public sc_prim_channel { 414299Sbbruce@ucdavis.edu public: 514299Sbbruce@ucdavis.edu virtual void before_end_of_elaboration() 614299Sbbruce@ucdavis.edu { 714299Sbbruce@ucdavis.edu cout << "prim_channel: before end of elaboration" << endl; 814299Sbbruce@ucdavis.edu } 914299Sbbruce@ucdavis.edu virtual void end_of_simulation() 1014299Sbbruce@ucdavis.edu { 1114299Sbbruce@ucdavis.edu cout << "prim_channel: end of simulation" << endl; 1214299Sbbruce@ucdavis.edu } 1314299Sbbruce@ucdavis.edu virtual void start_of_simulation() 1414299Sbbruce@ucdavis.edu { 1514299Sbbruce@ucdavis.edu cout << "prim_channel: start of simulation" << endl; 1614299Sbbruce@ucdavis.edu } 1714299Sbbruce@ucdavis.edu}; 1814299Sbbruce@ucdavis.edu 1914299Sbbruce@ucdavis.eduSC_MODULE(X) 2014299Sbbruce@ucdavis.edu{ 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