bogus_reset.cpp revision 12855:588919e0e4aa
1// Bogus reset 2 3#include <systemc> 4 5using namespace sc_core; 6using std::cout; 7using std::endl; 8 9struct M5: sc_module 10{ 11 M5(sc_module_name _name) 12 { 13 SC_THREAD(ticker); 14 SC_THREAD(calling); 15 SC_METHOD(target); 16 sensitive << ev; 17 dont_initialize(); 18 t = sc_get_current_process_handle(); 19 } 20 21 sc_process_handle t; 22 sc_event ev; 23 24 void ticker() 25 { 26 for (;;) 27 { 28 wait(10, SC_NS); 29 ev.notify(); 30 } 31 } 32 33 void calling() 34 { 35 wait(15, SC_NS); 36 // target runs at 10 NS due to notification of ev 37 38 t.reset(); 39 // target runs at 15 NS due to reset. 40 41 sc_stop(); 42 } 43 44 void target() 45 { 46 cout << "Target called at " << sc_time_stamp() << endl; 47 } 48 49 SC_HAS_PROCESS(M5); 50}; 51 52int sc_main(int argc, char* argv[]) 53{ 54 M5 m("m"); 55 56 sc_start(); 57 58 cout << endl << "Success" << endl; 59 return 0; 60} 61 62