Basic Assertions

Aug. 11, 2024 || Item:5.3.Basic Assertions

1. Timing delay

##<delay>: specifies a fixed number of clock cycles or time units to wait before evaluating the next condition or event.

##[min:max]: specifies a range of clock cycles or time units to wait before evaluating the next condition or event. The delay is variable within the specified range.

##[min:$]: same as above, but no upper limitation. 

Example

Output

2. Implication

Until now, assertions have always been checked. In some cases, we only want to check an assertion when certain conditions are met; this is when implication is used.

<antecedent> |-> <consequent>: overlapping implication. If the antecedent sequence is true, then the consequent sequence must start at the same time as the antecedent and must hold true. If antecedent sequence is false, the assertion will be skipped.

<antecedent> |=> <consequent>: non-overlapping implication. If the antecedent sequence is true, then the consequent sequence must start immediately after the antecedent finishes.

 3. Repetition

Repetition is a way to specify that a sequence of events must occur a certain number of times in a row.

@(posedge clk) tb_b |-> ##1 check_c_seq ##1 check_c_seq

same as

@(posedge clk) tb_b |-> ##1 check_c_seq[*2]

Example 1 (overlap)

Output 



5ns:   tb_b=0 => skip (PASS)

15ns: tb_b=0 => skip (PASS)

25ns: tb_b=1 => 1st check: tb_c must be true in next 2 cycles (35ns, 45ns).

35ns: tb_b=1 => 2nd check: tb_c must be true in next 2 cycles (45ns, 55ns).

          tb_c=1 => continue the 1st check. 

45ns: tb_b=0 => skip (PASS)

          tb_c=1 => 1st check is PASS

          tb_c=1 => continue the 2nd check.

55ns: tb_b=0 => skip (PASS)

          tb_c=0 => 2nd check is FAIL.

Example 2 (non-overlap)

Output 



5ns:   tb_b=0 => skip (PASS)

15ns: tb_b=0 => skip (PASS)

25ns: tb_b=1 => 1st check: start at next cycle (35ns) and tb_c must be true in next 2 cycles (45ns, 55ns).

35ns: tb_b=1 => 2nd check: start at next cycle (45ns) and tb_c must be true in next 2 cycles (55ns, 65ns).

45ns: tb_b=0 => skip (PASS)

          tb_c=1 => continue the 1st check.

55ns: tb_b=0 => skip (PASS)

          tb_c=0 => 1st check is FAIL.

          tb_c=0 => 1st check is FAIL.



Comments:

Leave a comment: