Using sequence as event contol

In reply to ben@SystemVerilog.us:

The way I think it works is that functions called in a sequence_matchedItem
are scheduled in the Observed region. If the function returns a value, it is executed immediately. Thus,
function bit f(bit i) return !i; endfunction
property p;
bit x;
(a, x=f(c)) ## d==x …; // x is updated in the Observed region
// Otherwise you could not complete the sequence

I agree. The same is confirmed in LRM.


LRM 16.10  Local variables :
Initialization assignments shall be performed in the Observed region in the order that they appear in the sequence or property declaration.

The sequence or property shall assign a value to the local variable prior to the point at which the reference is made.

As ‘x’ will be assigned in observed region, function ‘f’ executes in Observed region as well.
( Hence I believe functions with return type (i.e non-void functions) called as part of sequence_match_item execute in Observed region )

  1. Regarding the order of execution between the assignment within the subroutine and execution of action block,

(a) LRM 16.11 Calling subroutines on match of a sequence :

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.

Hence can I state the following ?

Since both void function/task as well as action blocks execute in Reactive region, there is no pre-defined order of execution between the two

In the code, assignment to ‘length’ within void function ‘Length’ as well as $display within action block execute in Reactive region.
As a result there is no pre-defined order of execution between the function ‘Length’ and action block.