112855Sgabeblack@google.com#include <systemc> 212855Sgabeblack@google.comusing namespace sc_core; 312855Sgabeblack@google.comusing namespace sc_dt; 412855Sgabeblack@google.comusing std::cout; 512855Sgabeblack@google.comusing std::endl; 612855Sgabeblack@google.com 712855Sgabeblack@google.com// 11) sc_is_running() 812855Sgabeblack@google.com 912855Sgabeblack@google.comstruct my_port: sc_port<sc_signal_in_if<int> > 1012855Sgabeblack@google.com{ 1112855Sgabeblack@google.com my_port() 1212855Sgabeblack@google.com { 1312855Sgabeblack@google.com sc_assert(sc_is_running() == false); 1412855Sgabeblack@google.com } 1512855Sgabeblack@google.com ~my_port() 1612855Sgabeblack@google.com { 1712855Sgabeblack@google.com sc_assert(sc_is_running() == false); 1812855Sgabeblack@google.com } 1912855Sgabeblack@google.com void before_end_of_elaboration() 2012855Sgabeblack@google.com { 2112855Sgabeblack@google.com sc_assert(sc_is_running() == false); 2212855Sgabeblack@google.com } 2312855Sgabeblack@google.com void end_of_elaboration() 2412855Sgabeblack@google.com { 2512855Sgabeblack@google.com sc_assert(sc_is_running() == false); 2612855Sgabeblack@google.com } 2712855Sgabeblack@google.com void start_of_simulation() 2812855Sgabeblack@google.com { 2912855Sgabeblack@google.com sc_assert(sc_is_running() == false); 3012855Sgabeblack@google.com } 3112855Sgabeblack@google.com void end_of_simulation() 3212855Sgabeblack@google.com { 3312855Sgabeblack@google.com sc_assert(sc_is_running() == false); 3412855Sgabeblack@google.com } 3512855Sgabeblack@google.com int read() 3612855Sgabeblack@google.com { 3712855Sgabeblack@google.com sc_assert(sc_is_running() == true); 3812855Sgabeblack@google.com return (*this)->read(); 3912855Sgabeblack@google.com } 4012855Sgabeblack@google.com}; 4112855Sgabeblack@google.com 4212855Sgabeblack@google.comSC_MODULE(M) 4312855Sgabeblack@google.com{ 4412855Sgabeblack@google.com my_port p; 4512855Sgabeblack@google.com SC_CTOR(M) 4612855Sgabeblack@google.com { 4712855Sgabeblack@google.com sc_assert(sc_is_running() == false); 4812855Sgabeblack@google.com SC_THREAD(T); 4912855Sgabeblack@google.com SC_METHOD(ME); 5012855Sgabeblack@google.com } 5112855Sgabeblack@google.com ~M() 5212855Sgabeblack@google.com { 5312855Sgabeblack@google.com sc_assert(sc_is_running() == false); 5412855Sgabeblack@google.com } 5512855Sgabeblack@google.com void T() 5612855Sgabeblack@google.com { 5712855Sgabeblack@google.com int i = p.read(); 5812855Sgabeblack@google.com sc_assert(sc_is_running() == true); 5912855Sgabeblack@google.com wait (1, SC_NS); 6012855Sgabeblack@google.com sc_assert(sc_is_running() == true); 6112855Sgabeblack@google.com wait (1, SC_NS); 6212855Sgabeblack@google.com sc_assert(sc_is_running() == true); 6312855Sgabeblack@google.com wait (1, SC_NS); 6412855Sgabeblack@google.com } 6512855Sgabeblack@google.com void ME() 6612855Sgabeblack@google.com { 6712855Sgabeblack@google.com sc_assert(sc_is_running() == true); 6812855Sgabeblack@google.com } 6912855Sgabeblack@google.com void before_end_of_elaboration() 7012855Sgabeblack@google.com { 7112855Sgabeblack@google.com sc_assert(sc_is_running() == false); 7212855Sgabeblack@google.com } 7312855Sgabeblack@google.com void end_of_elaboration() 7412855Sgabeblack@google.com { 7512855Sgabeblack@google.com sc_assert(sc_is_running() == false); 7612855Sgabeblack@google.com } 7712855Sgabeblack@google.com void start_of_simulation() 7812855Sgabeblack@google.com { 7912855Sgabeblack@google.com sc_assert(sc_is_running() == false); 8012855Sgabeblack@google.com } 8112855Sgabeblack@google.com void end_of_simulation() 8212855Sgabeblack@google.com { 8312855Sgabeblack@google.com sc_assert(sc_is_running() == false); 8412855Sgabeblack@google.com } 8512855Sgabeblack@google.com}; 8612855Sgabeblack@google.com 8712855Sgabeblack@google.comstruct Top: sc_module 8812855Sgabeblack@google.com{ 8912855Sgabeblack@google.com M *m; 9012855Sgabeblack@google.com sc_signal<int> sig; 9112855Sgabeblack@google.com Top(sc_module_name) 9212855Sgabeblack@google.com { 9312855Sgabeblack@google.com sc_assert(sc_is_running() == false); 9412855Sgabeblack@google.com m = new M("m"); 9512855Sgabeblack@google.com m->p.bind(sig); 9612855Sgabeblack@google.com } 9712855Sgabeblack@google.com}; 9812855Sgabeblack@google.com 9912855Sgabeblack@google.comint sc_main(int argc, char* argv[]) 10012855Sgabeblack@google.com{ 10112855Sgabeblack@google.com cout << "Should be silent..." << endl; 10212855Sgabeblack@google.com 10312855Sgabeblack@google.com sc_assert(sc_is_running() == false); 10412855Sgabeblack@google.com Top top("top"); 10512855Sgabeblack@google.com sc_assert(sc_is_running() == false); 10612855Sgabeblack@google.com sc_start(); 10712855Sgabeblack@google.com 10812855Sgabeblack@google.com cout << endl << "Success" << endl; 10912855Sgabeblack@google.com return 0; 11012855Sgabeblack@google.com} 111