SystemVerilog Assertion
Part 3: Sequence Match Operators
Prev: Sequence Match operators 
Next: More Sequence Match Operators
The FIRST_MATCH operator
As we saw earlier in
the case of an or operator, the result of a match
operation can be multiple matches (as s1 or s2
matched at times t3 and t2). Multiple matches may also result when
one or more of the operands contain a range delay (such as,
(s1 ##[1:5] s2) and s3)).
However, it is often desirable just to find the first of these
matches and ignore the rest. The unary sequence operator
first_match does just that.
In our earlier example of the
or operator, s1 or s2 produces matches at time t3
and t2. However, first_match(s1 or s2) produces a match
at time t3 only. No further match is detected later at time t2.
The THROUGHOUT operator
Sometimes it is useful to find a match during an interval such that
a sequence matches and a given expression is also true during that
interval. The throughout operator achieves this.
The general usage model of the throughout operator is
expr throughout sequence. Another equivalent way of expressing
the same thing is (expr) [*0:$] intersect sequence.
The following is an example of the throughout operator
(Figure 5). Here the signal sig1 goes low for the duration
of the sequence s1. So, (~sig1) throughout s1 is a
match is this case. However, the signal sig2 is high only after
the sequence s1 starts. So, there is no match for the
sequence sig2 throughout s1.
 Figure 5: 'throughout' operation
The WITHIN operator
The binary sequence containment operator within checks if
a sequence matches for consecutive clock ticks and another sequence
matches a subset of those consecutive clock ticks. If the sequences
s1 matches between time t1 and t2 and the sequence s2
matches between t3 and t4, the sequence s1 within s2 matches
if
 t1 is no earlier than t3, and
 t4 is no later than t2.
In Figure 5, s2 within s1 is a match during the time when
s2 is a match, but s1 within s2 is never a match.
The .ended method
The ended is a method (as opposed to operators that we are
discussing so far) on a sequence that returns a true value, if the
sequence ends on that clock tick, or false, if the sequence still
matches. If s1 is a sequence, s1.ended denotes the
end of the sequence s1. If s1 has formal arguments,
say, a, and c, the end of s1 is denoted by
s1(a, b, c).ended.
Prev: Sequence Match Operators 
Next: More Sequence Match Operators
