Achieving Dynamic delays in SVA using subroutine

In reply to MICRO_91:

In reply to ben@SystemVerilog.us:
Thanks Ben for the detailed explanation .
So b is evaluated ONLY once at T:5 i.e same time as consequent is evaluated .It isn’t evaluated again after task completes

[Ben] Correct. The way I see it, The subroutines (i.e., tasks) are scheduled in the Reactive region, like an action block. There is no blocking to the sequence within the assertion.
If you have a function that return a value, e.g., (seq, v=f(v)), the f(v) is considered
an expression and is evaluated in the Observed Region. If the function is void,
e.g., (seq, f_void(v) then f_void is executed in the Reactive Region. The task or void function
once started can complete after the assertion that called is done.
Am verifying this statement with a colleague

A few questions regarding :
I was referring section 16.11 of the LRM which says :

All subroutine calls attached to a sequence are executed at every end point of the sequence. For each end point, the attached calls are executed in the order they appear in the list. Assertion evaluation does not wait on or receive data back from any attached subroutine. The subroutines are scheduled in the Reactive region,like an action block.

This means that although property expression ( variables ‘a’, ‘b’ ) is evaluated in observed region the task dynamic_delay2 gets executed in Reactive region ?
So ‘b’ would be evaluated in Observed region at T:5 before $display within the task which executes in Reactive region at T:5 .

[Ben] Youre referring to this code:

..@( posedge clk )  a  |->  ( 1, dynamic_delay2( val ) ) ##0 b ;
task dynamic_delay2( int cnt );  
    $display("Task called at T:%0t with i/p arg == %0d",$time,cnt);
...

Yes. Also, b may have schaged value if it was updated in the NBA region.
You should use $sampled(cnt) instead of cnt.

(1) As both $display in PASS/FAIL action block as well as $display in task dynamic_delay2 execute in Reactive region , is there a pre-defined order of execution b/w the 2 $displays?

Its probably a tool thing, but my guess is that there is queue

(2) Also what does the following mean : “All subroutine calls attached to a sequence are executed at every end point of the sequence.” ?

That is true. for example: sequence s; a ##1 b; endsequence
…(a ##1 b, v=1) // v==1 after a ##1 bl the end point o that sequence
…(s, v=1) // v==1 at the end point of s
Ben Cohen
Ben@systemverilog.us
Link to the list of papers and books that I wrote, many are now donated.

or Cohen_Links_to_papers_books - Google Docs

Getting started with verification with SystemVerilog