rahuljn Posted November 4, 2014 Report Share Posted November 4, 2014 Hi Guys, Is there a way to cancel the event which results when we write on a signal. In the following code every time when I am writing on a signal, I also cancel the event on the next line but still process2 is activated. Thanks Rahuljn #include "systemc.h" SC_MODULE(event_trial){ public: sc_signal<bool> sig; SC_CTOR(event_trial) { SC_THREAD(process1); SC_THREAD(process2); } void process1(){ for(int i=0;i<3;i++){ wait(5, SC_NS); sig.write(!sig.read()); cout<<"writing on signal at "<<sc_time_stamp().value()<<"("<<sc_delta_count()<<")\n"; const_cast<sc_event*>(&(sig.default_event()))->cancel(); } } void process2(){ for(;{ wait(sig.default_event()); cout<<"\tevent arrived "<<sc_time_stamp().value()<<"("<<sc_delta_count()<<")\n"; } } }; int sc_main(int , char**){ event_trial et("et"); sc_start(); return 0;} Quote Link to comment Share on other sites More sharing options...
Philipp A Hartmann Posted November 4, 2014 Report Share Posted November 4, 2014 The events of an sc_signal are triggered during the update phase of the simulation. Therefore, you can't cancel the event from a SystemC process. What are you trying to achieve? Why are you sensitive to an sc_signal event, if you don't want to be triggered? Quote Link to comment Share on other sites More sharing options...
rahuljn Posted November 5, 2014 Author Report Share Posted November 5, 2014 Hi Plilipp Actually I want in some cases I do not want it to be triggered so I need to cancel the cprresponding event such cases. As per the standard, there is a cancel() function with the sc_event class and it is possible to cancel the event notification (except the immediate one). Now when we write on a signal, it also trigger an event which is notified in next delta cycle so it should be possible to cancel the event. This is exactly what I am trying to do with const_cast<sc_event*>(&(sig.default_event()))->cancel(); Thanks Rahuljn Quote Link to comment Share on other sites More sharing options...
rahuljn Posted November 5, 2014 Author Report Share Posted November 5, 2014 Hi Philipp Yes, it is clear now. If the notification occurs during update phase then we can not cancel this like what I did. Thanks for your help. Thanks RahulJn Quote Link to comment Share on other sites More sharing options...
David Black Posted November 9, 2014 Report Share Posted November 9, 2014 I think Philipp's two questions still stand: What are you trying to achieve? Why are you sensitive to an sc_signal event, if you don't want to be triggered? You will get a better response if you can answer these. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.