Jump to content

sc_signal event


rahuljn

Recommended Posts

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;
}
 

Link to post
Share on other sites

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

Link to post
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...