Assertions: Page 1 of 2
Assertions: Page 1 of 2
Assertions: Page 1 of 2
Page 1 of 2
WHAT IS ASSERTION?
An Assertion in the context of a programming language is a statement that validates assumptions or checks conditions in a program. A piece of verification code to validate behaviour, coverage goals and
constraints of a design.
EXAMPLES:
Write will follow read after 6 clock cycles. FIFO must never overflow. Read and Write should not happen at same clock cycle. Checking Reset condition in SONET when data is valid. A signal must never become unknown.
Benefits of Assertions?
In traditional verification approach we will inject random stimulus into the DUT and checks result at output. For complex designs coverage and debugging is harder.
Assertions
comes
here
to
improve
the
verification process.
Increases bug detection possibility at RTL level. Reduces time to develop. Great help in debug for large nightmare design random tests. Open verification libraries Instantiate libraries in your design, connect the signals and verify your design.
in 2 clock cycles.
FRAME LDF CLK
SV Assertion
Verilog Assertion
Procedural : Dont have good control over time. Difficult to test for parallel events in the same time period. Verbose - If Assertions increases it becomes difficult to handle No Functional coverage - No built-in mechanism for coverage.
Declarative language - Gives excellent control over time. More built-in functions. Provides constructs to collect functional coverage.
LANGUAGE HIERARCHY
SEQUENCES (Sequence, and, or, intersect, throughout, within,cycle delay, repetition, ended, first_match)
PASS
ASSERTION Coverage
Types of Assertions
Two types of assertions defined in the SVA.
Immediate Assertions
Concurrent Assertions
Immediate Assertions:
These are event driven and procedural in nature Mainly used in simulation block Based on clock cycles Evaluated in Observed region
Immediate Assertions
An assertion is basically a statement that something must be true, similar to if statement. Expression is non temporal.
If an expression is not true and it does not have an associated else part,
When we set property and if we wont specify failure case of the property, then by default language dictates simulator should give
Concurrent Assertions
Immediate assertion describes a logic behaviour at an instant of time, where a concurrent assertion detects a behaviour over time to be specified. The variables used in a concurrent assertion are sampled in the Preponed region of a time slot and the assertions are evaluated during the Observe region. Both these regions occur immediately before a clock edge. Concurrent assertions are checked throughout simulation. They usually appear inside procedural block or with in a module.
In concurrent assertion there are three main components. Sequence Property Assert - property
positive edge of the clock. If the transition does not occur, the assertion will fail.
At clock cycle 2, the sampled value of data signal within the sequence is 1. A transition of value from 0 to 1 is a rising edge and hence, the sequence s2
Sequence Expressions
Define formal arguments in a sequence definition and re-use the same sequence for other signals in design that have similar behavior. For example,
between.
Consider the following example at pose edge of clock a should be high, after two clock cycles b should be high, after four clock cycles c should be high and
This operator specify that an expression will match the number of times
specified not necessarily on continuous clock cycles. Syntax: signal [->] The Boolean expression y has been true 4 times, but not necessarily on successive clocks x has been true 4, 5, 6 or 7 times, not necessarily on consecutive clocks The Boolean expression y has been true thrice, not necessarily on consecutive clocks, 1st occurrence of y happens after 3 clocks cycles of x. The last one occurs 6 clock cycles before z.
This is very similar to "go to" repetition except that it does not require that the
last match on the signal repetition happen in the clock cycle before the end the
entire sequence matching. Only expressions are allowed to repeat in "go to" and "nonconsecutive repetitions. Sequences are not allowed. Syntax: Signal [= n] The Boolean expression y has been true 4 times, but not necessarily on successive clocks and there may be additional clock cycles after the last true y before the sequence completes. x has been true 4,5,6 or 7 times, once again not necessarily on consecutive clocks, and with possible additional clocks after words when x is not true. y [=4]
x [=4:7]
The binary operator "and" can be used to combine two sequences logically. The final property succeeds when both the sequences succeed. The result of and operation is a match, if Both sequences must start at the same time. Sequences may end at different times. The end time of the match i.e. when the match is recognized is the end time of the longer sequence.
A B t1 t1 t5 t7
A,B Match at t7
CLK
D
C B A t1
t2 t7
t8
t1
t1
t5
t5
A,B Match at t5
CLK
B A CLK
t1
t1
t5
B A CLK
t1
t6
t1
t4
seq has formal arguments, say, a, b and c, the end of seq is denoted by
s1(a, b, c).ended.
Delays
Fixed time window ## n - n clock cycles delay n can be zero (no delay) Must be a positive integer a ## 1 b - This means b starts one clock after a ends. a ##2 b.ended - This means b completes 2 clock ticks after a completes Fixed Time interval ## [m : n] With in m to n clock cycles delay ## [1:3] With in 1 to 3 clock cycles delay n must be greater than m Indefinite timing window ## [1 : $] Between one clock cycle and end of the simulation This is called the "eventuality" operator.
Implication operators
Implication operators only used inside the property. Two types of operators Overlapping ( Non overlapping ( ) )
Overlapping If enable is high at posedge of clock write should be high at same positive edge of clock and read must be high 2 clock cycles later.
Level Sensitive
detected to be high, then two clock cycle later, signal "c" should be high. Sequence seqb
checks that, After 1 clock cycles from the current positive edge of the clock, signal "d should be low.
The final property checks that, if sequence seqa succeeds, then a check for sequence
seqb is performed.
Clock in Sequence
Clock in Property
Clock in Assert
Assertions - Variables
Variables can be used in sequences and properties. A common use for this occurs in pipelines: In this example, the variable v is assigned the value of DataIn unconditionally on each clock. Five clocks later, DataOut is expected to equal the assigned value. Each invocation of the property (here there is one invocation on every clock) has its own copy of v.
Coverage Statements
Cover property statements can be used to monitor sequences and other behavioral aspects of a design for functional coverage.
The simulator keeps a count of the number of times the property in the cover
property statement holds or fails. This can be used to determine whether or not certain aspects of the designs
The system functions $onehot and $onehot0 are used for checking one-hot encoded signals. $onehot(expr) returns true if exactly one bit of expr is high;
Sequence Coverage:
For each sequence count the number of times the sequences Attempted, matched, real match and not attempted.
Summary
Assertions are great way to verify complex designs . Assertions only can be used to completely authenticate a design as robust By creating testbench with functional coverage we can understand which all functionalities of the design are covered in test Creation of testbench with functional coverage requires detailed verification plan