System Verilog Assertions 231230 094337
System Verilog Assertions 231230 094337
ASSERTIONS
HANUMANTHA RAO G
CONTENTS
● INTRODUCTION TO SVA
● BUILDING BLOCKS
● SVA TERMINOLOGY
● IMPLICATION OPERATORS
● REPETITION OPERATORS
● BUILT IN FUNCTIONS
● CONSTRUCTS
● ASSERTION DIRECTIVES
● NESTED IMPLICATIONS
● FORMAL ARGUMENTS
INTRODUCTION TO SVA
● Verification :: Main objective of verification is to verify the design under test (DUT) thoroughly and
make sure there are no functional bugs.
● There are 2 parts we consider to verify the design
● Code coverage make sure all the lines of the design executed at least once.
● Because of huge complexity of the designs, we need to make sure good quality of test bench which
can be randomize.
● These test bench should have self checking mechanisms , because it is difficult to check the each
simulation behaviour and it may prone to human error.
● These checking process are two types.
sequenc e name_of_sequence ;
endsequence
sequence s1;
@{posedge clk) a || b;
endsequence
CONT…
● PROPERTY :: No of sequences can be combined logically or sequentially to create more complex
sequences. This is called Property.
● We need to provide the clock inside sequence or property.
● Basic syntax for property is ::
property name_of_property;
endproperty
● Property is the one which will be verified during simulation. It has to be asserted to take effect in
simulation.
● SVA provides a keyword assert to check the property.
● Syntax ::
a) Test expression is evaluated just like any other Verilog expression within a procedural block.
Ex ::
assert($fifo_empty);
end
CONT…
2. CONCURRENT ASSERTIONS ::
sequence seq;
endsequence
● In the above sequence, 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.
1. OVERLAPPED ::
If there is a match on the antecedent, then the consequent expression is evaluated in the same clock
cycle. Overlapped implication is denoted by the symbol |->.
The implication construct can be used only with property definitions. It cannot be used in sequences.
CONT…
● OVERLAPPED WITH DELAY :: We can you the delays(no of clock cycles) after which property should
valid.
CONT…
● IMPLICATION WITH SEQUENCE ::
CONT…
● IMPLICATION WITH TIMING WINDOW :: we can use timing window, if behaviour was expected within
some clocks
CONT..
● INFINITE TIMING WINDOW :: we can use infinite timing window, if there is no time bound for the
response.
CONT…
2. NON-OVERLAPPED ::
● If there is a match on the antecedent, then the consequent expression is evaluated in the next clock
cycle. Non-overlapped implication is denoted by the symbol |=>.
REPETETION OPERATORS
● If signal "start" is high on a given positive edge of the clock, then, starting from the next clock cycle,
signal "a" stays high for 3 continuous clock cycles; one clock cycle after that, signal "stop" is high
● Suppose same sequence, when signal “a” has to be high for many cycles it will be difficult to right the
assertion. In those cases we can write these repetition operators.
If we want to check that a signal or a sequence will match continuously for the number of clocks
specified, we use this repetition operator.
On a sequence ::
CONT …
● Sequence with delay window ::
CONT…
● It is also possible to provide a window for the number of repetitions.
● After start signal asserted, waits for 2 cycles, then “a” should be high, “a” can be high for 1 to infinite clock
cycles.but after “a” is low, Then after 1 cycle stop will be high.
CONT…
● Go to repetition operator [->] ::
● if there is a vahd start signal on any given positive edge of the clock, 2 clock cycles later, signal "a" will
repeat three times continuously or intermittently before there is a valid stop signal
CONT…
● Non-consecutive repetition operator [=] ::
Property p26 ;
Endproperty
● After valid start, 2 cycles after “a” will be high for 3 clocks continuously or intermittently before valid
stop. Here a could be low any no of cycles before valid stop.
CONT…
BUILT-IN FUNCTIONS
● $onehot(expression) :: checks for only one bit of expression is high at a time. Returns value 1 if only 1 bit is
high.
● $onehot0(expression) :: checks for 1 bit or none of the bits are high.Returns value 1 if only 1 bit or 0 bit is
high.
● $isunknown(expression) :: checks if any bit of expression is X or Z.
CONT…
● $rose(expression) :: monitors the rising edge of the expression. If expression is multiple bit size, LSB bit
will be considered.
● $fell(expression) :: monitors the failing edge of the expression. If expression is multiple bit size, LSB bit
will be considered.
● $countones(expression) :: count no of bits high in the expression. X and Z values are not counted as 1’s.
property system_prop;
@ (posedge clk) ($rose(req) && $past( ! req,1)) |=> ($rose(gnt) && $past( ! gnt,1));
endproperty
CONT…
● $stable(expression) :: checks the expression was stable or not compared from current evaluation time to
previous evaluation time. Returns 1 if it was stable.
CONT…
● $changed(expression) :: returns 1 if the expression value changed from previous evaluation time time to
current evaluation time.
●
CONSTRUCTS
● AND :: The binary operator "and" can be used to combine two sequences logically. The final property
succeeds when both the sequences succeed. Both sequences must have the same starting point but
they can have different ending points. The starting point of the check is when the first sequence
succeeds and the end point is when the other sequence succeeds
●
CONT…
● INTERSECT :: The "intersect" operator is very similar to the "and" operator with one additional requirement.
Both the sequences need to start at the same time and complete at the same time. In other words, the length of
both sequences should be the same.
● sequence s1;
endsequence
sequence s2;
endsequence
property intersect_prop;
Endproperty
sequence seq;
Endsequence
Property P1;
property within_prop;
31 endpropert
\\\
CONT…
● Disable iff :: Sometimes if we dont want to proceed the check if some condition is true.
● In that case SVA has a construct called disable iff, it acts like a asynchronous reset to the checker.
#100;
End
property prop;
endproperty
initial begin
#100;
end
CONT…
● Matched :: Whenever a sequence is defined with multiple clocks, the construct "matched" is used to detect
the endpoint of the first sequence.
●
CONT…
● If-else ::
NESTED IMPLICATION
● SVA allows having nested implication.
● These are useful when we multiple gating conditions.
USING FORMAL ARGUMENTS
● If we want to repeat some of the properties, that can be defined with formal arguments.
● Property is bound to a specific clock.