ASSERTIONS
ASSERTIONS
IN
SYSTEM VERILOG
SUBSCRIBE TO “VLSI TO YOU”
Assertions
▪ System Verilog merges benefits from different assertion languages into one,
thus giving the best from all languages.
▪ Due to native support of assertions in SV, assertions can be added to the
design and testbench directly without needing to add special interface.
▪ SVA is easy to learn and implement.
▪ Same assertions can be re-used in both functional and formal assertions.
▪ System Verilog supports two types of assertions: immediate
assertions and concurrent assertions.
IMMEDIATE ASSERTIONS
An assertion that checks a condition at the current simulation time is called
immediate assertions.
CONCURRENT ASSERTIONS.
An assertion that checks the sequence of events spread over multiple clock
cycles is called a concurrent assertion
Immediate Assertions
An assertion that checks a condition at the current simulation time is called
immediate assertions. They are executed like procedural statements like the if-
else statements.
Since the assertion is a statement that something must be true, the failure of an
assertion shall have a severity associated with it. By default, the severity of an
assertion failure is an error.
Assertion severity levels
#15 b=0;
#20 a=1;
#10; $finish;
end
//Immediate assertion
endmodule
Concurrent Assertion
An assertion that checks the sequence of events spread over multiple
clock cycles is called a concurrent assertion. They execute in parallel with
other always blocks concurrently, hence it is known as a concurrent
assertion.
1. Unlike immediate assertion, the concurrent assertion is evaluated only at
clock tick. Thus, it is a clock-based evaluation model and an expression
used in the concurrent assertion is always tied to a clock definition.
2. The variables used in the assertions are sampled in the preponed region of
the simulation time slot but it is evaluated at the observe region and
execute pass/fail statements in the reactive region.
3. A concurrent assertion can be declared in an always or initial block and
that can be placed in an interface, program, or module block.
4. An assert keyword is used to check the property.
5. The Keyword differentiates the immediate assertion from the concurrent
assertion is “property.”
The property is the one that is verified during a simulation. It has to be asserted
to take effect during a simulation. SVA provides a keyword called “assert” to
check the property.
4. ## [min:max] represents a range of clock cycles. Where min and max must
be 0 or greater than 0.
##0 -> means that there should be no delay and expression on LHS and RHS
should hold true at same time.
##1 -> means that the expression present on RHS should be true after one
clock cycle of LHS.
##[2:4] valid -> assert statement will fail if valid is not set to 1 within 2 to 4
clock cycles after input_data becomes 1.
Repetition operators
sequence seq;
@(posedge clk) req1 ##1 req2[*2:4]; In this example, if req1 is true then after 1 clock cycle,
endsequence req2 must be true for a minimum of 2 and a maximum
of 4 consecutive clock cycles.
sequence seq; In this example, once req1 holds true after one clock
@(posedge clk) req1 ##1 req2[=4]; cycle req2 must be true for 4 clock cycles but it is not
endsequence mandatory to be consecutive clock cycles.
sequence seq;
@(posedge clk) req1 ##1 req2[=2:4];
endsequence
once req1 holds true after one clock cycle, req2 must
be true for a minimum of 2 and a maximum of 4 clock
cycles but it is not mandatory to be consecutive
clock cycles.
Clock defined in the sequence definition
sequence seq;
a ##2 b;
endsequence
sequence seq;
property p; @(posedge clk) a ##2 b;
@(posedge clk) seq; endsequence
endproperty
a_1 : assert property(p);
Non-overlapped implication
sequence seq_1;
(a && b) ##1 c;
endsequence
sequence seq_2;
##2 !d;
endsequence
property p;
@(posedge clk) seq_1 |-> seq_2;
endproperty
a: assert property(p);
Timing windows in SVA Checkers
property p;
@(posedge clk) a |-> ##[1:4] b;
endproperty if signal “a” is high on a given positive clock edge, then within
a: assert property(p); 1 to 4 clock cycles, the signal “b” should be high.
property p;
Overlapping timing window @(posedge clk) a |-> ##[0:4] b;
if signal “a” is high on a given positive clock edge, then endproperty
signal “b” should be high in the same clock cycle or a: assert property(p);
within 4 clock cycles.
sequence seq;
@(posedge clk) a ##2 b;
endsequence The sequence checks that if signal “a” is high on a
given positive edge of the clock, then after 2 clock
property p; cycles, signal “b” shall not be high. The keyword “not” is
not seq; used to specify that the property should never be true.
endproperty
a_1: assert property(p);