Until now in previous articles, simple boolean expressions were checked on every clock edge. But sequential checks take several clock cycles to complete and the time delay is specified by ## sign.

## Operator

If a is not high on any given clock cycle, the sequence starts and fails on the same cycle. However, if a is high on any clock, the assertion starts and succeeds if b is high 2 clocks later. It fails if b is low 2 clocks later.

module tb;
  bit a, b;
  bit clk;
  // This is a sequence that says 'b' should be high 2 clocks after
  // 'a' is found high. The sequence is checked on every positive
  // edge of the clock which ultimately ends up having multiple 
  // assertions running in parallel since they all span for more
  // than a single clock cycle.
  sequence s_ab;
    @(posedge clk) a ##2 b;
  // Print a display statement if the assertion passed
  assert property(s_ab) 
  	$display ("[%0t] Assertion passed !", $time);
  always #10 clk = ~clk;
  initial begin
    for (int i = 0; i < 10; i++) begin
      @(posedge clk);
      a <= $random;
      b <= $random;                    
      $display("[%0t] a=%b b=%b", $time, a, b);
    #20 $finish;

Time (ns) a b Sequence Start Result
10 0 0 No FAIL ([email protected], [email protected])
30 0 1 No FAIL ([email protected], [email protected])
50 1 1 Yes
70 1 1 Yes
90 1 0 Yes FAIL ([email protected], [email protected])
110 1 1 Yes PASS ([email protected], [email protected])
130 0 1 No PASS ([email protected], [email protected])
150 1 0 Yes FAIL ([email protected], [email protected])
170 1 0 Yes
190 1 0 Yes FAIL ([email protected], [email protected])
Simulation Log
Compiler version P-2019.06-1; Runtime version P-2019.06-1;  Jan 16 06:49 2020
[10] a=0 b=0
"testbench.sv", 14: tb.unnamed$$_0: started at 10ns failed at 10ns
	Offending 'a'
[30] a=0 b=1
"testbench.sv", 14: tb.unnamed$$_0: started at 30ns failed at 30ns
	Offending 'a'
[50] a=1 b=1
[70] a=1 b=1
[90] a=1 b=0
"testbench.sv", 14: tb.unnamed$$_0: started at 50ns failed at 90ns
	Offending 'b'
[110] a=1 b=1
[110] Assertion passed !
[130] a=0 b=1
"testbench.sv", 14: tb.unnamed$$_0: started at 130ns failed at 130ns
	Offending 'a'
[130] Assertion passed !
[150] a=1 b=0
"testbench.sv", 14: tb.unnamed$$_0: started at 110ns failed at 150ns
	Offending 'b'
[170] a=1 b=0
[190] a=1 b=0
"testbench.sv", 14: tb.unnamed$$_0: started at 150ns failed at 190ns
	Offending 'b'
$finish called from file "testbench.sv", line 27.
$finish at simulation time                  210
           V C S   S i m u l a t i o n   R e p o r t 
Time: 210 ns