Jump to content

Static Sensitivity to "AND" of two events


ArjunMadhudi

Recommended Posts

I want my method/thread to be triggered only when both clk goes high and reset goes high. (i.e Func2 is triggered when sensitive to [clk.pos() and reset]). I tried doing below but received an error target.h:44:33: error: no match for 'operator&' in '((target*)this)->target::clk.sc_core::sc_in<bool>::pos() & ((target*)this)->target::nreset'
code:

        SC_METHOD(func2);
        sensitive<<(nreset&clk.pos());
        dont_initialize();

 

Link to comment
Share on other sites

You would want to use an sc_event_and_list. See IEEE1666 section 5.8. As its intended use is with next_trigger() and wait() you would need to move the sensitivity into your method. So the constructor part becomes

 SC_METHOD(func2);

and func2 should something like (snippet of your module):

sc_core::sc_event_and_list ev_list;

void end_of_elaboration(){
	ev_list |= clk.posedge_event();
	ev_list |= nreset;
}

void func2(){
	next_trigger(ev_list);
	// your code here
	...
}

 

Link to comment
Share on other sites

Please be aware, that an sc_and_event_list does not imply that the events in the list are triggered at the same time. I would suggest to keep the only the clock sensitivity and act on the triggers in the body of the method instead:
 

SC_METHOD(func2);
  sensitive << clk.pos();
  dont_initialize();

// ...

void func2() {
  if( nreset.posedge() ) { // nreset went high in this clock cycle
    // ... 
  }
}

Alternatively, you can be sensitive to nreset.pos()  and check for clk.posedge() (as a consistency check), if you don't have anything else to do in the body of the method.  With this approach, you might be able to avoid unnecessary triggers of the method.

Side note to Eyck: There's a small typo in the example above, which should should use "&=" to append to an sc_event_and_list.

ev_list &= nreset;

 

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...