mastrick Posted September 26, 2012 Report Share Posted September 26, 2012 The LRM says that an "event control expression" can include a non-virtual function as long as it has a singular return value. Do those restrictions apply to the expression within wait()? If any function is allowed within wait, should I expect that the wait will unblock within the same time that the function return value changes (to whatever would make the expression true)? Quote Link to comment Share on other sites More sharing options...
dave_59 Posted September 26, 2012 Report Share Posted September 26, 2012 The issue with functions in wait expressions or event controls is that the LRM only defines a few conditions when the expression must be evaluated to see if the result has changed. And that is when any operand in the expression changes. That includes arguments to any function calls as well as any objects referenced directly in the expression. An object is considered changed when any of it members has changed. The problem is that a class member can be a reference to another child class object, but when the child object changes, the reference in the parent object does not. It is the same problem as shallow copy versus deep copy, except here it is shallow events versus deep events. If you have a parent-child hierarchy of class objects and you are waiting on a method that looks into the value of child object, it won't unblock until something in the parent changes, or some other operand in the expression changes and causes the whole expression to be re-evaluated. For example class A; bit B1; endclass class B; A a = new; bit B2; function bit getB1; return a.B1; endfunction function bit getB2; return B2; endfunction endclass task run; wait(getB2()); // evaluated when B2 changes wait(getB1()); // evaluated when B2 changes not when a.B1 changes endtask Quote Link to comment Share on other sites More sharing options...
mastrick Posted September 26, 2012 Author Report Share Posted September 26, 2012 Thanks for the detailed response, Dave. Can you clarify one point? Your example shows that wait(getB2()) is evaluated when B2 changes, but your text says "when any operand in the expression changes. That includes arguments to any function calls as well as any objects referenced directly in the expression". B2 is not an argument to the function nor referenced directly in the expression. Is there another category of operands that covers B2? Quote Link to comment Share on other sites More sharing options...
dave_59 Posted September 26, 2012 Report Share Posted September 26, 2012 getB2() is implicitly this.getB2(). Since B2 is a member of 'this', a change event to B2 is also change event to 'this'. So wait(this.getB2()) will call getB2 for evaluation whenever there is a change event on 'this' (as well as calling getB2() upon first executing the wait statement) Quote Link to comment Share on other sites More sharing options...
mastrick Posted September 26, 2012 Author Report Share Posted September 26, 2012 Thanks again, Dave. That makes perfect sense to me. Perhaps we could get some of your text in the next update to the LRM? Quote Link to comment Share on other sites More sharing options...
salmantanvir Posted June 2, 2021 Report Share Posted June 2, 2021 Hi, Could someone clarify if there is a performance impact when using a function in an event control expression instead of a signal? Br, Salman Quote Link to comment Share on other sites More sharing options...
dave_59 Posted June 7, 2021 Report Share Posted June 7, 2021 Of course @(func(signal)) is going to cost more in performance than just plain @(signal). 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.