Cheatsheets - AMIQ Consulting
Cheatsheets - AMIQ Consulting
Cheatsheets - AMIQ Consulting
SystemVerilog Assertions
SVA Syntax
Property
Sequences
Variables
System functions
SystemVerilog Assertions
Type Description
Immediate Syntax:
assertions
else
//fail block
Concurrent Are SVA directives used to verify that a property holds. Syntax:
assertions
property my_property;
endproperty
Cover Is a SVA directive used to verify that a property occurs during simulation. Syntax:
property my_property;
endproperty
SVA Syntax
Property
Declaration:
// property_statement
endproperty
Operator Description
Overlapping Syntax:
sequence
implication
operator |-> sequence1 |-> sequence2
sequence2 will start in the same clock cycle in which sequence1 will end
Example:
//Antecedent //Consequent
Operator Description
Non-overlapping Syntax:
sequence
implication
operator |=> sequence1 |=> sequence2
sequence2 will start one clock cycle after sequence1 has ended
Example:
Observation!
not Syntax:
not my_property;
Example:
property my_propery;
@(posedge clk)
signal1 |-> signal2;
endproperty
and Syntax:
property my_property;
endproperty
Both properties should start at the same evaluation time and may end at different
cycles. The assertion will pass only if both properties hold.
or Syntax:
property my_property;
property1 or property2;
endproperty
Both properties should start at the same evaluation time and may end at different
cycles. The assertion will pass only if at least one property holds.
until Syntax:
property my_property;
endproperty
my_property evaluates to true if property1 evaluates to true for every clock cycle
beginning with the starting point, and finishing one clock cycle before property2
starts to evaluate to true.
Example:
property my_property;
endproperty
Operator Description
until_with Syntax:
property my_property;
endproperty
my_property evaluates to true if property1 evaluates to true for every clock cycle
beginning with the starting point, and finishing the same cycle when property2
starts to evaluate to true.
Example:
property my_property;
endproperty
property my_property;
disable iff(boolean_condition)
//property_statement
endproperty
Example:
@(posedge clk)
disable iff(rst_n == 0)
endproperty
Sequences
Declaration:
sequence my_sequence [(port0, port1, ...)]
//sequence expressions
endsequence
Operator Description
Temporal delay
signal1 ##1 signal2
## with integer
Temporal delay
signal1 ##[0:2] signal2
## with range
Delay = 0
Delay = 1
Delay = 2
Operator Description
Consecutive Where n,m are natural numbers, m>n>=1. The $ sign can be used to represent
repetition [*m] or infinity.
[+] Example:
Abbreviations:
Non-consecutive Example 1:
repetition [=n],
[=n:m]
signal1[=2]
Example 2:
The difference between the two non-consecutive repetition is that the pattern
matching is finished after the last active pulse.
Example 2:
and Syntax:
Example:
The evaluation starts at the same clock time (if each sequence has it’s own clock,
then the AND starts at the first clocking event of each sequence), but it is not
necessary to finish at the same time. The and sequence fails to match when any of
the sequences fail to match.
Operator Description
or Syntax:
seq1 or seq2
Example:
The result of OR-ing two sequence is a match when at least one of the two
sequences is a match.
intersect It is similar to the and operator, except that the the two sequences must end at the
same time.
Syntax:
Example:
within Syntax:
Example:
The starting point of seq1 must be after or at the same time as the starting
point of seq2.
The ending point of seq1 must be before or at the same time as the ending
point of seq2.
throughout The throughout operator specifies that a signal must hold throughout a sequence.
Syntax:
Example:
Method Description
first_match Used to specify that only the first sequence match is considered from a range of
possible matches, the rest being discarded. Syntax:
first_match(seq);
Example:
Method Description
sequence my_seq
endsequence
property
@(posedge clk)
first_match(my_seq) |=> signal3
endproperty
Implicit first_match:
Possible match1
Possible match2
assertion.
Example:
Option1:
Option2:
Method Description
triggered Used to test if the end point of a sequence was reached. An end point is a boolean
expression that represents the evaluation of a thread at its last clock cycle. Syntax:
My_seq.triggered
Example:
sequence my_seq;
endsequence
sequence my_new_seq;
endsequence
Variables
Declaration of a sequence:
endsequence
Types Description
sequence
event
Types Description
Initialization Rules:
Example:
);
// Assertion Variables Declaration
endsequence
Fa_signal will be initialized first with the preponed value of signal1, then avd_signal
will be initialized.
Assignments Local variables can be assigned within the sequence matched item list, each
variable being separated from each other by using comma in the parentheses.
Example:
);
// Assertion Variables Declaration
endsequence
flag <= 1;
endfunction
User-defined Local variables cannot be used in temporal ranges, but they can be used as
repetitions counters for user-defined repetitions or delays.
endsequence
sequence my_seq
local logic s;
endsequence
endsequence
sequence my_seq
local logic s;
endsequence
endsequence
sequence my_seq
local logic s;
endsequence
In this case the end point of binded_seq(s) must occur 1 clock cycle after signal2
was asserted. The starting point of binded_seq(s) is before signal2 is asserted.
intersect with The or operand generates two concurrent threads, each thread having separate
local variables copies of the local variables. If a local variable is set on one thread, the other
thread wouldn’t be able to access it.
Types Description
Example:
//illegal sequence
sequence my_sequence;
int signal_cp;
endsequence
// legal sequence
sequence my_sequence;
int signal_cp1;
int signal_cp2;
endsequence
Types Description
System functions
Function Description
$rose(signal) Returns true if the signal has changed value to 1 in the current evaluation cycle
$fell(signal) Returns true if the signal has changed value to 0 in the current evaluation cycle
$stable(signal) Returns true if the signal has the same value as it had in the previous evaluation
cycle
$past(signal, Returns the value of the signal at a previous evaluation cycle specified through
number_of_cc) the number_of_cc argument