112855Sgabeblack@google.com#include <systemc> 212855Sgabeblack@google.comusing namespace sc_core; 312855Sgabeblack@google.comusing namespace sc_dt; 412855Sgabeblack@google.comusing sc_core::wait; 512855Sgabeblack@google.comusing std::cout; 612855Sgabeblack@google.comusing std::endl; 712855Sgabeblack@google.com 812855Sgabeblack@google.com// 5) wait( int ) for SC_THREAD, primitives and global 912855Sgabeblack@google.com 1012855Sgabeblack@google.comvoid global() 1112855Sgabeblack@google.com{ 1212855Sgabeblack@google.com wait(); 1312855Sgabeblack@google.com sc_assert(sc_time_stamp() == sc_time(0, SC_NS)); 1412855Sgabeblack@google.com wait(3); 1512855Sgabeblack@google.com sc_assert(sc_time_stamp() == sc_time(3, SC_NS)); 1612855Sgabeblack@google.com} 1712855Sgabeblack@google.com 1812855Sgabeblack@google.comstruct Prim: sc_prim_channel 1912855Sgabeblack@google.com{ 2012855Sgabeblack@google.com void method() 2112855Sgabeblack@google.com { 2212855Sgabeblack@google.com wait(); 2312855Sgabeblack@google.com sc_assert(sc_time_stamp() == sc_time(4, SC_NS)); 2412855Sgabeblack@google.com wait(3); 2512855Sgabeblack@google.com sc_assert(sc_time_stamp() == sc_time(7, SC_NS)); 2612855Sgabeblack@google.com } 2712855Sgabeblack@google.com}; 2812855Sgabeblack@google.com 2912855Sgabeblack@google.comSC_MODULE(M) 3012855Sgabeblack@google.com{ 3112855Sgabeblack@google.com sc_in_clk clk; 3212855Sgabeblack@google.com Prim prim; 3312855Sgabeblack@google.com SC_CTOR(M) 3412855Sgabeblack@google.com { 3512855Sgabeblack@google.com SC_THREAD(T); 3612855Sgabeblack@google.com sensitive << clk.pos(); 3712855Sgabeblack@google.com } 3812855Sgabeblack@google.com void T() 3912855Sgabeblack@google.com { 4012855Sgabeblack@google.com global(); 4112855Sgabeblack@google.com prim.method(); 4212855Sgabeblack@google.com wait(); 4312855Sgabeblack@google.com sc_assert(sc_time_stamp() == sc_time(8, SC_NS)); 4412855Sgabeblack@google.com wait(3); 4512855Sgabeblack@google.com sc_assert(sc_time_stamp() == sc_time(11, SC_NS)); 4612855Sgabeblack@google.com sc_stop(); 4712855Sgabeblack@google.com } 4812855Sgabeblack@google.com}; 4912855Sgabeblack@google.com 5012855Sgabeblack@google.comstruct Top: sc_module 5112855Sgabeblack@google.com{ 5212855Sgabeblack@google.com M *m; 5312855Sgabeblack@google.com sc_clock clk; 5412855Sgabeblack@google.com Top(sc_module_name) 5512855Sgabeblack@google.com { 5612855Sgabeblack@google.com m = new M("m"); 5712855Sgabeblack@google.com m->clk.bind(clk); 5812855Sgabeblack@google.com } 5912855Sgabeblack@google.com}; 6012855Sgabeblack@google.com 6112855Sgabeblack@google.comint sc_main(int argc, char* argv[]) 6212855Sgabeblack@google.com{ 6312855Sgabeblack@google.com cout << "Should be silent..." << endl; 6412855Sgabeblack@google.com Top top("top"); 6512855Sgabeblack@google.com sc_start(); 6612855Sgabeblack@google.com 6712855Sgabeblack@google.com cout << endl << "Success" << endl; 6812855Sgabeblack@google.com return 0; 6912855Sgabeblack@google.com} 70