SystemVerilog Implication operator

Implication Operator

sequence seq;
  @(posedge clk) a ##2 b;
endsequence

In the above sequence, we can observe that sequence starts on every positive edge of the clock and it looks for โ€œaโ€ to be high on every positive clock edge. If the signal โ€œaโ€ is not high on any given positive clock edge, an error is issued by the checker.

If we want the sequence to be checked only after โ€œaโ€ is high, this can be achieved by using the implication operator.

The implication is equivalent to an if-then structure. The left-hand side of the implication is called the โ€œantecedentโ€ and the right-hand side is called the โ€œconsequent.โ€ The antecedent is the gating condition. If the antecedent succeeds, then the consequent is evaluated.

The implication construct can be used only with property definitions. It cannot be used in sequences.

There are 2 types of implication:

  • Overlapped implication
  • Non-overlapped implication

Overlapped implication

The overlapped implication is denoted by the symbol |->.

If there is a match on the antecedent, then the consequent expression is evaluated in the same clock cycle.

Below property checks that, if signal โ€œaโ€ is high on a given positive clock edge, then signal โ€œbโ€ should also be high on the same clock edge.

property p;
  @(posedge clk) a |-> b;
endproperty
a: assert property(p);

Click to execute onย ย ย 

Non-overlapped implication

The non-overlapped implication is denoted by the symbol |=>.

If there is a match on the antecedent, then the consequent expression is evaluated in the next clock cycle.

Below property checks that, if signal โ€œaโ€ is high on a given positive clock edge, then signal โ€œbโ€ should be high on the next clock edge.

property p;
  @(posedge clk) a |=> b;
endproperty
a: assert property(p);

Click to execute onย ย ย 

The implication with a fixed delay on the consequent

Below property checks that, if signal โ€œaโ€ is high on a given positive clock edge, then signal โ€œbโ€ should be high after 2 clock cycles.

property p;
  @(posedge clk) a |-> ##2 b;
endproperty
a: assert property(p);

Click to execute onย ย ย 

The implication with a sequence as an antecedent

Below property checks that, if the sequence seq_1 is true on a given positive edge of the clock, then start checking the seq_2 (โ€œdโ€ should be low, 2 clock cycles after seq_1 is true).

sequence seq_1;
 (a && b) ##1 c;
endsequence

sequence seq_2;
  ##2 !d;
endsequence

property p;
  @(posedge clk) seq_1 |-> seq_2;
endpeoperty
a: assert property(p);

Click to execute onย ย ย 

Timing windows in SVA Checkers

Below property checks that, if signal โ€œaโ€ is high on a given positive clock edge, then within 1 to 4 clock cycles, the signal โ€œbโ€ should be high.

property p;
  @(posedge clk) a |-> ##[1:4] b;
endproperty
a: assert property(p);

Click to execute onย ย ย 

Overlapping timing window

Below property checks that, if signal โ€œaโ€ is high on a given positive clock edge, then signal โ€œbโ€ should be high in the same clock cycle or within 4 clock cycles.

property p;
  @(posedge clk) a |-> ##[0:4] b;
endproperty
a: assert property(p);

Click to execute onย ย ย 

Indefinite timing window

The upper limit of the timing window specified in the right-hand side can be defined with a โ€œ$โ€ sign which implies that there is no upper bound for timing. This is called the โ€œeventualityโ€ operator. The checker will keep checking for a match until the end of the simulation.

Below property checks that, if signal โ€œaโ€ is high on a given positive clock edge, then signal โ€œbโ€ will be high eventually starting from the next clock cycle.

property p;
  @(posedge clk) a |-> ##[1:$] b;
endproperty
a: assert property(p);

Click to execute onย ย ย 

โฎ Previous Next โฏ