ArjunMadhudi Posted July 30, 2019 Report Share Posted July 30, 2019 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(); Quote Link to comment Share on other sites More sharing options...
Eyck Posted July 30, 2019 Report Share Posted July 30, 2019 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 ... } ArjunMadhudi 1 Quote Link to comment Share on other sites More sharing options...
Philipp A Hartmann Posted July 30, 2019 Report Share Posted July 30, 2019 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; David Black and ArjunMadhudi 1 1 Quote Link to comment Share on other sites More sharing options...
Eyck Posted August 1, 2019 Report Share Posted August 1, 2019 @Philipp A Hartmann you are right, '|=' would imply and or list. 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.