for suspend/resume
#include "systemc.h" class test : public sc_module { public : sc_process_handle t ; SC_HAS_PROCESS(test); test(sc_module_name){ SC_THREAD(run); t = sc_get_current_process_handle(); SC_THREAD(run2); } void run(){ wait(10,SC_NS); cout<<"T :run1 "<<sc_time_stamp().value()<<endl; wait(5,SC_NS); cout<<"T :run2 "<<sc_time_stamp().value()<<endl; } void run2(){ wait(10,SC_NS); cout<<"T :run3 "<<sc_time_stamp().value()<<endl; t.suspend(); //t.disable(); cout<<"T :run4 "<<sc_time_stamp().value()<<endl; wait(20,SC_NS); cout<<"T :run5 "<<sc_time_stamp().value()<<endl; t.resume(); //t.enable(); cout<<"T :run6 "<<sc_time_stamp().value()<<endl; //t.reset(); } }; int sc_main(int, char**){ test t("test"); sc_start(); return 0; }
mic-24@localhost tmp]$ ./run.x SystemC 2.3.1-Accellera --- May 1 2014 15:38:34 Copyright (c) 1996-2014 by all Contributors, ALL RIGHTS RESERVED T :run1 10000 T :run3 10000 T :run4 10000 T :run5 30000 T :run6 30000 T :run2 30000
here i dont understand why final value is 30000 not 35000 and what happenened to this "wait(5,SC_NS);"
now in disable/resume
#include "systemc.h" class test : public sc_module { public : sc_process_handle t ; SC_HAS_PROCESS(test); test(sc_module_name){ SC_THREAD(run); t = sc_get_current_process_handle(); SC_THREAD(run2); } void run(){ wait(10,SC_NS); cout<<"T :run1 "<<sc_time_stamp().value()<<endl; wait(5,SC_NS); cout<<"T :run2 "<<sc_time_stamp().value()<<endl; } void run2(){ wait(10,SC_NS); cout<<"T :run3 "<<sc_time_stamp().value()<<endl; //t.suspend(); t.disable(); cout<<"T :run4 "<<sc_time_stamp().value()<<endl; wait(20,SC_NS); cout<<"T :run5 "<<sc_time_stamp().value()<<endl; //t.resume(); t.enable(); cout<<"T :run6 "<<sc_time_stamp().value()<<endl; //t.reset(); } }; int sc_main(int, char**){ test t("test"); sc_start(); return 0; }
[mic-24@localhost tmp]$ ./run.x SystemC 2.3.1-Accellera --- May 1 2014 15:38:34 Copyright (c) 1996-2014 by all Contributors, ALL RIGHTS RESERVED T :run1 10000 T :run3 10000 Error: (E559) Undefined process control interaction: attempt to disable a thread with timeout wait: test.run In file: ../../../../src/sysc/kernel/sc_process.cpp:345 In process: test.run2 @ 10 ns [mic-24@localhost tmp]$
what is the problem here ???