Jump to content

any restrictions on expression in wait(expression)?


mastrick

Recommended Posts

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)?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

  • 8 years later...

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