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 comment
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 comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...