test233.cpp revision 12855:588919e0e4aa
1#include <systemc> 2#include <cstring> 3using namespace sc_core; 4using namespace sc_dt; 5using std::cout; 6using std::endl; 7 8// 33) Process macros in (before_)end_of_elaboration 9 10SC_MODULE(M) 11{ 12 SC_CTOR(M) 13 { 14 SC_THREAD(T); 15 } 16 void T() 17 { 18 } 19 void before_end_of_elaboration() 20 { 21 SC_THREAD(T1); 22 sc_process_handle h = sc_get_current_process_handle(); 23 sc_assert(h.valid() == true); 24 sc_assert(strcmp(h.name(), "top.m.T1") == 0); 25 sc_assert(h.proc_kind() == SC_THREAD_PROC_); 26 sc_assert(h.get_process_object() != 0); 27 std::vector<sc_object*> children = h.get_child_objects(); 28 sc_assert(children.size() == 0); 29 sc_assert(h.get_parent_object() == this); 30 sc_assert(h.terminated() == false); 31 sc_assert(h.dynamic() == false); 32 33 SC_METHOD(M1); 34 h = sc_get_current_process_handle(); 35 sc_assert(h.valid() == true); 36 sc_assert(strcmp(h.name(), "top.m.M1") == 0); 37 sc_assert(h.proc_kind() == SC_METHOD_PROC_); 38 sc_assert(h.get_process_object() != 0); 39 children = h.get_child_objects(); 40 sc_assert(children.size() == 0); 41 sc_assert(h.get_parent_object() == this); 42 sc_assert(h.terminated() == false); 43 sc_assert(h.dynamic() == false); 44 } 45 46 void end_of_elaboration() 47 { 48 SC_THREAD(T2); 49 sc_process_handle h = sc_get_current_process_handle(); 50 sc_assert(h.valid() == true); 51 sc_assert(strcmp(h.name(), "top.m.T2") == 0); 52 sc_assert(h.proc_kind() == SC_THREAD_PROC_); 53 sc_assert(h.get_process_object() != 0); 54 std::vector<sc_object*> children = h.get_child_objects(); 55 sc_assert(children.size() == 0); 56 sc_assert(h.get_parent_object() == this); 57 sc_assert(h.terminated() == false); 58 sc_assert(h.dynamic() == true); 59 60 SC_METHOD(M2); 61 h = sc_get_current_process_handle(); 62 sc_assert(h.valid() == true); 63 sc_assert(strcmp(h.name(), "top.m.M2") == 0); 64 sc_assert(h.proc_kind() == SC_METHOD_PROC_); 65 sc_assert(h.get_process_object() != 0); 66 children = h.get_child_objects(); 67 sc_assert(children.size() == 0); 68 sc_assert(h.get_parent_object() == this); 69 sc_assert(h.terminated() == false); 70 sc_assert(h.dynamic() == true); 71 } 72 73 void T1 () 74 { 75 sc_process_handle h = sc_get_current_process_handle(); 76 sc_assert(h.valid() == true); 77 sc_assert(strcmp(h.name(), "top.m.T1") == 0); 78 sc_assert(h.proc_kind() == SC_THREAD_PROC_); 79 sc_assert(h.get_process_object() != 0); 80 std::vector<sc_object*> children = h.get_child_objects(); 81 sc_assert(children.size() == 0); 82 sc_assert(h.get_parent_object() == this); 83 sc_assert(h.terminated() == false); 84 sc_assert(h.dynamic() == false); 85 } 86 void M1 () 87 { 88 sc_process_handle h = sc_get_current_process_handle(); 89 sc_assert(h.valid() == true); 90 sc_assert(strcmp(h.name(), "top.m.M1") == 0); 91 sc_assert(h.proc_kind() == SC_METHOD_PROC_); 92 sc_assert(h.get_process_object() != 0); 93 std::vector<sc_object*> children = h.get_child_objects(); 94 sc_assert(children.size() == 0); 95 sc_assert(h.get_parent_object() == this); 96 sc_assert(h.terminated() == false); 97 sc_assert(h.dynamic() == false); 98 } 99 void T2 () 100 { 101 sc_process_handle h = sc_get_current_process_handle(); 102 sc_assert(h.valid() == true); 103 sc_assert(strcmp(h.name(), "top.m.T2") == 0); 104 sc_assert(h.proc_kind() == SC_THREAD_PROC_); 105 sc_assert(h.get_process_object() != 0); 106 std::vector<sc_object*> children = h.get_child_objects(); 107 sc_assert(children.size() == 0); 108 sc_assert(h.get_parent_object() == this); 109 sc_assert(h.terminated() == false); 110 sc_assert(h.dynamic() == true); 111 } 112 void M2 () 113 { 114 sc_process_handle h = sc_get_current_process_handle(); 115 sc_assert(h.valid() == true); 116 sc_assert(strcmp(h.name(), "top.m.M2") == 0); 117 sc_assert(h.proc_kind() == SC_METHOD_PROC_); 118 sc_assert(h.get_process_object() != 0); 119 std::vector<sc_object*> children = h.get_child_objects(); 120 sc_assert(children.size() == 0); 121 sc_assert(h.get_parent_object() == this); 122 sc_assert(h.terminated() == false); 123 sc_assert(h.dynamic() == true); 124 } 125}; 126 127struct Top: sc_module 128{ 129 M *m; 130 Top(sc_module_name) 131 { 132 m = new M("m"); 133 } 134}; 135 136int sc_main(int argc, char* argv[]) 137{ 138 cout << "Should be silent..." << endl; 139 Top top("top"); 140 sc_start(); 141 142 cout << endl << "Success" << endl; 143 return 0; 144} 145