Contact
Back to Home

Can you detail the process of setting up an SVA in System Verilog to ensure a signal's rise from 0 to 1 before another's descent from 1 to 0?

Featured Answer

Question Analysis

The question is about setting up a SystemVerilog Assertion (SVA) to monitor the behavior of two signals. Specifically, it asks you to ensure that one signal, which we will call A, transitions from 0 to 1 before another signal, B, transitions from 1 to 0. This is a common requirement in digital design verification where the relative timing of signal transitions must be verified to be in expected order. It involves understanding of the SystemVerilog Assertion syntax and temporal expressions to capture the desired behavior.

Answer

To set up an SVA to ensure that a signal A rises from 0 to 1 before another signal B descends from 1 to 0, you can use temporal operators provided by SystemVerilog. Here's how you can define such an assertion:

property signal_order_check;
  @(posedge clk) // Trigger on the rising edge of the clock
    (A == 0 && B == 1) |=> // Precondition: A is 0 and B is 1
    (##1 A == 1) ##[0:$] (B == 0); // A must rise before B falls
endproperty

assert property (signal_order_check)
  else $error("Signal A did not rise before signal B fell.");

Explanation:

  • Property Definition: We define a property called signal_order_check.
  • Clocking Event: @(posedge clk) specifies that this property is evaluated on the rising edge of a clock signal clk.
  • Precondition: (A == 0 && B == 1) specifies the initial condition where A should be 0 and B should be 1.
  • Implication Operator (|=>): This operator is used to indicate that whenever the precondition is satisfied, the sequence on the right must eventually occur.
  • Sequence:
    • ##1 A == 1: This indicates that A should transition to 1 one clock cycle after the precondition is observed.
    • ##[0:$] (B == 0): This specifies that B should transition to 0 at some point after A becomes 1. The [0:$] operator allows any number of cycles (including 0) to pass before B transitions to 0.
  • Assertion: The assert statement checks the property signal_order_check. If the assertion fails (i.e., if A does not rise before B falls), it triggers an error message.

By using this property, you can effectively monitor and ensure the required timing relationship between the signals A and B in your design.