112855Sgabeblack@google.com#define SC_INCLUDE_DYNAMIC_PROCESSES 212855Sgabeblack@google.com 312855Sgabeblack@google.com#include <systemc> 412855Sgabeblack@google.comusing namespace sc_core; 512855Sgabeblack@google.comusing namespace sc_dt; 612855Sgabeblack@google.comusing std::cout; 712855Sgabeblack@google.comusing std::endl; 812855Sgabeblack@google.com 912855Sgabeblack@google.com// 3) terminated_event() 1012855Sgabeblack@google.com 1112855Sgabeblack@google.comSC_MODULE(M) 1212855Sgabeblack@google.com{ 1312855Sgabeblack@google.com SC_CTOR(M) 1412855Sgabeblack@google.com { 1512855Sgabeblack@google.com SC_THREAD(T); 1612855Sgabeblack@google.com } 1712855Sgabeblack@google.com 1812855Sgabeblack@google.com void T() 1912855Sgabeblack@google.com { 2012855Sgabeblack@google.com sc_process_handle h1 = sc_spawn(sc_bind(&M::proc, this, 2)); 2112855Sgabeblack@google.com sc_process_handle h2 = sc_spawn(sc_bind(&M::proc, this, 3)); 2212855Sgabeblack@google.com sc_process_handle h3 = sc_spawn(sc_bind(&M::proc, this, 1)); 2312855Sgabeblack@google.com sc_assert(sc_time_stamp() == sc_time(0, SC_NS)); 2412855Sgabeblack@google.com wait(h1.terminated_event() & h2.terminated_event() & h3.terminated_event()); 2512855Sgabeblack@google.com sc_assert(sc_time_stamp() == sc_time(3, SC_NS)); 2612855Sgabeblack@google.com if (h1.valid()) sc_assert (h1.terminated()); 2712855Sgabeblack@google.com if (h2.valid()) sc_assert (h2.terminated()); 2812855Sgabeblack@google.com if (h3.valid()) sc_assert (h3.terminated()); 2912855Sgabeblack@google.com 3012855Sgabeblack@google.com h1 = sc_spawn(sc_bind(&M::proc, this, 10)); 3112855Sgabeblack@google.com h2 = sc_spawn(sc_bind(&M::proc, this, 30)); 3212855Sgabeblack@google.com h3 = sc_spawn(sc_bind(&M::proc, this, 20)); 3312855Sgabeblack@google.com sc_assert(sc_time_stamp() == sc_time(3, SC_NS)); 3412855Sgabeblack@google.com wait(h1.terminated_event() | h2.terminated_event() | h3.terminated_event()); 3512855Sgabeblack@google.com sc_assert(sc_time_stamp() == sc_time(13, SC_NS)); 3612855Sgabeblack@google.com sc_assert(h2.valid()); 3712855Sgabeblack@google.com sc_assert( !h2.terminated() ); 3812855Sgabeblack@google.com sc_assert(h3.valid()); 3912855Sgabeblack@google.com sc_assert( !h3.terminated() ); 4012855Sgabeblack@google.com 4112855Sgabeblack@google.com wait(h2.terminated_event() & h3.terminated_event()); 4212855Sgabeblack@google.com sc_assert(sc_time_stamp() == sc_time(33, SC_NS)); 4312855Sgabeblack@google.com } 4412855Sgabeblack@google.com void proc(int delay) 4512855Sgabeblack@google.com { 4612855Sgabeblack@google.com wait(delay * sc_time(1, SC_NS)); 4712855Sgabeblack@google.com } 4812855Sgabeblack@google.com}; 4912855Sgabeblack@google.com 5012855Sgabeblack@google.comSC_MODULE(Top) 5112855Sgabeblack@google.com{ 5212855Sgabeblack@google.com M *m; 5312855Sgabeblack@google.com SC_CTOR(Top) 5412855Sgabeblack@google.com { 5512855Sgabeblack@google.com m = new M("m"); 5612855Sgabeblack@google.com } 5712855Sgabeblack@google.com}; 5812855Sgabeblack@google.com 5912855Sgabeblack@google.comint sc_main(int argc, char* argv[]) 6012855Sgabeblack@google.com{ 6112855Sgabeblack@google.com cout << "Should be silent..." << endl; 6212855Sgabeblack@google.com 6312855Sgabeblack@google.com Top top("top"); 6412855Sgabeblack@google.com sc_start(); 6512855Sgabeblack@google.com 6612855Sgabeblack@google.com cout << endl << "Success" << endl; 6712855Sgabeblack@google.com return 0; 6812855Sgabeblack@google.com} 69