112855Sgabeblack@google.com#include <systemc> 212855Sgabeblack@google.com#include <cstring> 312855Sgabeblack@google.comusing namespace sc_core; 412855Sgabeblack@google.comusing namespace sc_dt; 512855Sgabeblack@google.comusing std::cout; 612855Sgabeblack@google.comusing std::endl; 712855Sgabeblack@google.com 812855Sgabeblack@google.com// 33) Process macros in (before_)end_of_elaboration 912855Sgabeblack@google.com 1012855Sgabeblack@google.comSC_MODULE(M) 1112855Sgabeblack@google.com{ 1212855Sgabeblack@google.com SC_CTOR(M) 1312855Sgabeblack@google.com { 1412855Sgabeblack@google.com SC_THREAD(T); 1512855Sgabeblack@google.com } 1612855Sgabeblack@google.com void T() 1712855Sgabeblack@google.com { 1812855Sgabeblack@google.com } 1912855Sgabeblack@google.com void before_end_of_elaboration() 2012855Sgabeblack@google.com { 2112855Sgabeblack@google.com SC_THREAD(T1); 2212855Sgabeblack@google.com sc_process_handle h = sc_get_current_process_handle(); 2312855Sgabeblack@google.com sc_assert(h.valid() == true); 2412855Sgabeblack@google.com sc_assert(strcmp(h.name(), "top.m.T1") == 0); 2512855Sgabeblack@google.com sc_assert(h.proc_kind() == SC_THREAD_PROC_); 2612855Sgabeblack@google.com sc_assert(h.get_process_object() != 0); 2712855Sgabeblack@google.com std::vector<sc_object*> children = h.get_child_objects(); 2812855Sgabeblack@google.com sc_assert(children.size() == 0); 2912855Sgabeblack@google.com sc_assert(h.get_parent_object() == this); 3012855Sgabeblack@google.com sc_assert(h.terminated() == false); 3112855Sgabeblack@google.com sc_assert(h.dynamic() == false); 3212855Sgabeblack@google.com 3312855Sgabeblack@google.com SC_METHOD(M1); 3412855Sgabeblack@google.com h = sc_get_current_process_handle(); 3512855Sgabeblack@google.com sc_assert(h.valid() == true); 3612855Sgabeblack@google.com sc_assert(strcmp(h.name(), "top.m.M1") == 0); 3712855Sgabeblack@google.com sc_assert(h.proc_kind() == SC_METHOD_PROC_); 3812855Sgabeblack@google.com sc_assert(h.get_process_object() != 0); 3912855Sgabeblack@google.com children = h.get_child_objects(); 4012855Sgabeblack@google.com sc_assert(children.size() == 0); 4112855Sgabeblack@google.com sc_assert(h.get_parent_object() == this); 4212855Sgabeblack@google.com sc_assert(h.terminated() == false); 4312855Sgabeblack@google.com sc_assert(h.dynamic() == false); 4412855Sgabeblack@google.com } 4512855Sgabeblack@google.com 4612855Sgabeblack@google.com void end_of_elaboration() 4712855Sgabeblack@google.com { 4812855Sgabeblack@google.com SC_THREAD(T2); 4912855Sgabeblack@google.com sc_process_handle h = sc_get_current_process_handle(); 5012855Sgabeblack@google.com sc_assert(h.valid() == true); 5112855Sgabeblack@google.com sc_assert(strcmp(h.name(), "top.m.T2") == 0); 5212855Sgabeblack@google.com sc_assert(h.proc_kind() == SC_THREAD_PROC_); 5312855Sgabeblack@google.com sc_assert(h.get_process_object() != 0); 5412855Sgabeblack@google.com std::vector<sc_object*> children = h.get_child_objects(); 5512855Sgabeblack@google.com sc_assert(children.size() == 0); 5612855Sgabeblack@google.com sc_assert(h.get_parent_object() == this); 5712855Sgabeblack@google.com sc_assert(h.terminated() == false); 5812855Sgabeblack@google.com sc_assert(h.dynamic() == true); 5912855Sgabeblack@google.com 6012855Sgabeblack@google.com SC_METHOD(M2); 6112855Sgabeblack@google.com h = sc_get_current_process_handle(); 6212855Sgabeblack@google.com sc_assert(h.valid() == true); 6312855Sgabeblack@google.com sc_assert(strcmp(h.name(), "top.m.M2") == 0); 6412855Sgabeblack@google.com sc_assert(h.proc_kind() == SC_METHOD_PROC_); 6512855Sgabeblack@google.com sc_assert(h.get_process_object() != 0); 6612855Sgabeblack@google.com children = h.get_child_objects(); 6712855Sgabeblack@google.com sc_assert(children.size() == 0); 6812855Sgabeblack@google.com sc_assert(h.get_parent_object() == this); 6912855Sgabeblack@google.com sc_assert(h.terminated() == false); 7012855Sgabeblack@google.com sc_assert(h.dynamic() == true); 7112855Sgabeblack@google.com } 7212855Sgabeblack@google.com 7312855Sgabeblack@google.com void T1 () 7412855Sgabeblack@google.com { 7512855Sgabeblack@google.com sc_process_handle h = sc_get_current_process_handle(); 7612855Sgabeblack@google.com sc_assert(h.valid() == true); 7712855Sgabeblack@google.com sc_assert(strcmp(h.name(), "top.m.T1") == 0); 7812855Sgabeblack@google.com sc_assert(h.proc_kind() == SC_THREAD_PROC_); 7912855Sgabeblack@google.com sc_assert(h.get_process_object() != 0); 8012855Sgabeblack@google.com std::vector<sc_object*> children = h.get_child_objects(); 8112855Sgabeblack@google.com sc_assert(children.size() == 0); 8212855Sgabeblack@google.com sc_assert(h.get_parent_object() == this); 8312855Sgabeblack@google.com sc_assert(h.terminated() == false); 8412855Sgabeblack@google.com sc_assert(h.dynamic() == false); 8512855Sgabeblack@google.com } 8612855Sgabeblack@google.com void M1 () 8712855Sgabeblack@google.com { 8812855Sgabeblack@google.com sc_process_handle h = sc_get_current_process_handle(); 8912855Sgabeblack@google.com sc_assert(h.valid() == true); 9012855Sgabeblack@google.com sc_assert(strcmp(h.name(), "top.m.M1") == 0); 9112855Sgabeblack@google.com sc_assert(h.proc_kind() == SC_METHOD_PROC_); 9212855Sgabeblack@google.com sc_assert(h.get_process_object() != 0); 9312855Sgabeblack@google.com std::vector<sc_object*> children = h.get_child_objects(); 9412855Sgabeblack@google.com sc_assert(children.size() == 0); 9512855Sgabeblack@google.com sc_assert(h.get_parent_object() == this); 9612855Sgabeblack@google.com sc_assert(h.terminated() == false); 9712855Sgabeblack@google.com sc_assert(h.dynamic() == false); 9812855Sgabeblack@google.com } 9912855Sgabeblack@google.com void T2 () 10012855Sgabeblack@google.com { 10112855Sgabeblack@google.com sc_process_handle h = sc_get_current_process_handle(); 10212855Sgabeblack@google.com sc_assert(h.valid() == true); 10312855Sgabeblack@google.com sc_assert(strcmp(h.name(), "top.m.T2") == 0); 10412855Sgabeblack@google.com sc_assert(h.proc_kind() == SC_THREAD_PROC_); 10512855Sgabeblack@google.com sc_assert(h.get_process_object() != 0); 10612855Sgabeblack@google.com std::vector<sc_object*> children = h.get_child_objects(); 10712855Sgabeblack@google.com sc_assert(children.size() == 0); 10812855Sgabeblack@google.com sc_assert(h.get_parent_object() == this); 10912855Sgabeblack@google.com sc_assert(h.terminated() == false); 11012855Sgabeblack@google.com sc_assert(h.dynamic() == true); 11112855Sgabeblack@google.com } 11212855Sgabeblack@google.com void M2 () 11312855Sgabeblack@google.com { 11412855Sgabeblack@google.com sc_process_handle h = sc_get_current_process_handle(); 11512855Sgabeblack@google.com sc_assert(h.valid() == true); 11612855Sgabeblack@google.com sc_assert(strcmp(h.name(), "top.m.M2") == 0); 11712855Sgabeblack@google.com sc_assert(h.proc_kind() == SC_METHOD_PROC_); 11812855Sgabeblack@google.com sc_assert(h.get_process_object() != 0); 11912855Sgabeblack@google.com std::vector<sc_object*> children = h.get_child_objects(); 12012855Sgabeblack@google.com sc_assert(children.size() == 0); 12112855Sgabeblack@google.com sc_assert(h.get_parent_object() == this); 12212855Sgabeblack@google.com sc_assert(h.terminated() == false); 12312855Sgabeblack@google.com sc_assert(h.dynamic() == true); 12412855Sgabeblack@google.com } 12512855Sgabeblack@google.com}; 12612855Sgabeblack@google.com 12712855Sgabeblack@google.comstruct Top: sc_module 12812855Sgabeblack@google.com{ 12912855Sgabeblack@google.com M *m; 13012855Sgabeblack@google.com Top(sc_module_name) 13112855Sgabeblack@google.com { 13212855Sgabeblack@google.com m = new M("m"); 13312855Sgabeblack@google.com } 13412855Sgabeblack@google.com}; 13512855Sgabeblack@google.com 13612855Sgabeblack@google.comint sc_main(int argc, char* argv[]) 13712855Sgabeblack@google.com{ 13812855Sgabeblack@google.com cout << "Should be silent..." << endl; 13912855Sgabeblack@google.com Top top("top"); 14012855Sgabeblack@google.com sc_start(); 14112855Sgabeblack@google.com 14212855Sgabeblack@google.com cout << endl << "Success" << endl; 14312855Sgabeblack@google.com return 0; 14412855Sgabeblack@google.com} 145