I am trying to understand event generation in systemc. I found that it depends on the order of thread registration in constructor.
#include <systemc.h>
SC_MODULE(EventTest){
sc_event ev1;
void p1(){
ev1.notify();
ev1.notify(0, SC_NS);
}
void p2(){
wait(ev1);
cout<<"ev1 is activated at "<<sc_time_stamp()<<endl;
wait(ev1);
cout<<"ev1-2 is activated at "<<sc_time_stamp()<<endl;
}
SC_CTOR(EventTest){
SC_THREAD(p1);
SC_THREAD(p2);
}
};
int sc_main(int argc, char *argv[]){
EventTest d("d");
sc_start();
return 1;
}
output : ev1 is activated at 0 s
if i change the in SC_CTOR
to >
SC_THREAD(p2);
SC_THREAD(p1);
then output is >
ev1 is activated at 0 s
ev1-2 is activated at 0 s
Please someone tell how does the order of registration affect event generation?