SlideShare a Scribd company logo
SV ASSERTIONS
Introduction
There are two significant pieces of technology that are used by almost all verification
engineers.
1. A constrained random test bench
2. Code coverage tool.
The test benches normally perform 3 different
tasks 1. Stimulus generation.
2. Self-checking mechanisms.
3. Functional coverage measurement.
Self-checking processes usually targets two
specific areas 1. Protocol checking.
2. Data checking.
Functional coverage provides a measure of verification completeness. and it gives
1. Protocol coverage. 2. Test plan coverage.
Fig: constrained random test bench without assertions.
What is an Assertion?
An assertion is a statement that a certain property must be true.
Assertions are used to,
- Document the functionality of the design
- Check that the intent of the design is met over simulation time
- Determine if verification tested the design (coverage)
Assertions can be specified,
- By the design engineer as part of the model
- By the verification engineer as part of the test program
Verilog does not provide an assertion construct.
-Verification checks must be coded with programming
statements.
Fig: DUT with Assertions
Why using sv assertions important?
 It’s a verification technique i.e. embedded in the language
Gives “white box” visibility into the design
 Enables specifying design requirement with assertions
can specify design requirements using an executable language
 Enables easier detecting of design problems
In simulation, design errors can be automatically detected
Error reports show when error occurred with insight as to why
Formal analysis tools can prove that the mode functionality does or does
not match the assertion.
Can generate “counter-examples”(test cases) for assertion failures
 Enables constrained random verification with coverage.
 Assertion written in Verilog and SVA
 VERILOG
always @(posedge a)
begin
repeat (1) @(posedge clk);
fork: a_to_b
begin
@posedge (b)
$display("SUCCESS: b arrived in timen", $time);
disable a_to_b;
end
begin
repeat (3) @(posedge clk);
$display("ERROR:b did not arrive in timen", $time);
disable a_to_b;
end
join
end
 SV ASSERTION
a_to_b_chk:assert property@(posedge elk) $rose(a) |-> ##[1:3] $ r o s e (b) );
Fig. Waveform for sample assertion
System Verilog Scheduling
Preponed - Values are sampled for the
assertion variables in this region. In this region,
a net or variable cannot change its state. This
allows the sampling of the most stable value at
the beginning of the timeslot.
Observed - All the property expressions are
evaluated in this region.
Reactive - The pass/fail code from the
evaluation of the properties are
scheduled in this region.
Fig. Simplified SV event schedule flow chart
Building blocks of SVA
sequence name_of_sequence;
< t e s t e x p r e s s i o n >;
endsequence
property name_of_property;
< test expression >; or
< complex sequence expressions >;
endproperty
a s s e r t i o n _ n a m e : a s s e r t property( p r o p e r t y _ n a m e );
Types of assertions
Concurrent assertions
Based on clock cycles.
Used with both static&dynamic verification
tools
Placed in procedural block,module,an
interface or program definition
Evalution at clock edges
 Ex:
a_cc: assert property(@(posedge
clk)not (a && b));
Immediate assertions
Based on simulation event semantics.
Used with dynamic verification tools
Placed in procedural block definition
evaluated just like any other Verilog
expression within a procedural block.
 Ex: always_comb
b e g in
a _ i a : a s s e r t (a && b ) ;
end
Fig: Waveform for a sample concurrent assertion
Fig: Waveform for a sample immediate assertion
A simple action block
It can be used for controlling the simulation environment and gathering functional
coverage data.
user can also print a custom error or success message using the "action block" in the assert
statement
property pr;
@(posedge clk) a ##2 b;
endproperty
ass : assert property(pr)
$display("Property pr succeededn");
else
$ d i s p l a y (" P r o p e r t y pr f a i l e d  n " );
The checker ass shown above uses simple display statements in the action block to
print successes and failures.
Assertion Severity Levels
• The assertion failure behavior can be specified
$fatal: Implicit $finish call.
$error: A run-time error severity; software continues execution.
$warning: A run-time warning; software continues execution.
$info: No severity, just print the message.
• Severity level is included in assertion failure message.
• Severity can optionally include further message
information using $display syntax
always@(posedge clk)
ack_chk:assert!(acka&&ackb)
else
$error(“%m failure”);
always@(posedge enable)
Assert !(valid)
Else
Begin
$warning;
$display(“invalid enable”);
err_count++;
end
Sequence with edge definitions
 $rose:
sequence s2;
@(posedge clk) $rose(a);
endsequence
Fig: Waveform for $rose
Sequence with edge definitions
$fell: $fell( Boolean expression or signal name) returns true if the least significant bit of
the expression changed to 0. Otherwise, it returns false.
sequence seq_fell;
@(posedge clk) $fell(a);
endsequence
Sequence seq_fell checks that the signal "a" transitions to a value of 0 on every positive edge
of the clock. If the transition does not occur, the assertion will fail.
$stable: $stable(Boolean expression or signal name) returns true if the value of the
expression did not change. Otherwise, it returns false.
sequence seq_stable;
@(posedge clk) $stable(a);
endsequence
Sequence seq_stable checks that the signal "a" is stable on every positive edge of the clock. If
the there is any transition occur, the assertion will fail.
Sequence with edge definitions
$past: $past(signal_name, number of clock cycles) provides the value of the signal from the
previous clock cycle.
-Below Property checks that, in the given positive clock edge, if the “b” is high, then 2 cycles before that, a was
high.
property p;
@(posedge clk) b |-> ( $past(a,2) == 1);
endproperty
a: assert property(p);
$past construct with gating signal:
The $past construct can be used with a gating signal. on a given clock edge, the gating signal has to be true
even before checking for the consequent condition.
$past (signal_name, number of clock cycles, gating signal)
Below Property checks that, in the given positive clock edge, if the “b” is high, then 2 cycles before
that, a was high only if the gating signal "c' is valid on any given positive edge of the clock.
Property p;
@(posedge clk) b |-> ($past(a,2,c) == 1);
endproperty
a: assert property(p);
Sequence with logical relationship
 Sequence h, checks that on every positive edge of the clock, either signal
"a" or signal "b" is high. If both the signals are low, the assertion will fail.
 Ex:sequence h;
@(posedge clk) a||b;
endsequence
Clk
a
b
h
Fig: Waveform for sequence h
Clock definitions in SVA
In general, the clocks in property definitions and keep the sequences
independent of the clocks.
 This will help increase the re-use of the basic sequence definitions.
Ex: sequence ha;
a ##2 b;
endsequence
property p;
@(posedge clk) ha;
endproperty
ast : assert property(p);
Forbidding a property
sometimes we expect the property to be false always. If the property is
true, the assertion fails.
Ex: sequence ha;
@(posedge clk) a ##2 b;
endsequenee
property v;
not ha;
endproperty
vh : assert property(v);
Clk
a
b
vh
Fig: Waveform of SVA checker forbidding a property
Implication operator
Implication is equivalent to an if-then structure.
The left hand side of the implication is called the "antecedent" and the right hand side is
called the "consequent."
The antecedent is the gating condition. If the antecedent succeeds, then the consequent is
evaluated.
The implication construct can be used only with property definitions. It cannot be used in
sequences.
There are 2 types of implication:1.Overlapped implication(|->) 2.Non-overlapped
implication(|=>)
Overlapped implication
If there is a match on the antecedent, then the consequent expression is evaluated in
the same clock cycle.
 Ex: property pr;
@(posedge elk) A |-> B;
end property
ass : assert property(pr);
Clk
A
B
ass
 A vacuous success is one where signal "a" was not high and the assertion succeeded by
default.
 A failure is one where a valid high on signal "a" was detected and at the same
clock edge a valid high on signal "b" was not detected high.
Fig: Waveform for property pr
Non-overlapped implication(|=>)
If there is a match on the antecedent, then the consequent expression is evaluated in the
next clock cycle.
Ex: property hr;
@(posedge clk) A|=>B;
endproperty
ass : assert property(hr);
Clk
A
B
ass
Fig:Waveform for property ass
 In above property checks that, if signal "a" is high on a given positive clock edge, then
signal "b" should be high on the next clock edge.
Timing windows in SVA Checkers
property vs;
@(posedge clk) (a && b) |-> ##[1:3] c;
endproperty
is : assert property(vs);
Follows like below
(a && b) |-> ##[1] c or
(a && b) |-> ##[2] c or
(a && b) |->##[3] c
Fig: Waveform for property “is”
Overlapping window gives `0’ instead of 1 from above example(##[0:3]). So The value of signal "c" is detected
high in the same clock edge as the valid match on the antecedent.
• Indefinite window gives $ instead of 3 from above example(##[1:$]). "$" sign which implies that there is no
upper bound for timing.
clk
a
b
c
is
Repetition operators
SVA language provides three different types of repetition operators.
1.Consecutive repetition: This allows the user to specify that a signal or a sequence will match
continuously for the number of clocks specified. The simple syntax shown below.
signal or sequence [*n];
"n" is the number of times the expression should match repeatedly.
2.go to repetition: This allows the user to specify that an expression will match the number
of times specified not necessarily on continuous clock cycles.
The main requirement of "go to "repeat is that the last match on the expression
checked for repetition should happen in the clock cycle before the end of the entire sequence
matching. The simple syntax shown below.
Signal [->n]
3.non-consecutive repetition: 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. The simple syntax shown as Signal [=n]
Consecutive repetition operator [*]
Property sr;
@(posedge clk) $rose(start) |->##2 (a[*3]) ##2 stop ##1 !stop;
endproperty
is: assert property(sr);
clk
start
a
stop
is
Fig: Waveform for SVA checker using consecutive repeat
 Property sr checks that two clock cycles after a valid start, signal "a"stays high for 3
continuous clock cycles and two clock cycles after that, signal "stop" is high. One clock
cycle later signal "stop" is low.
Go to repetition operator [->]
property hr;
@(posedge clk) $rose(start) |->##2 (a[->3]) ##1 stop;
endproperty clk
ass: assert property(hr); start
a
stop
Fig: Waveform for SVA checker using go to repetition operator
Property hr checks that, 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.
ass
Non-consecutive repetition operator [=]
Property pr;
@(posedge clk) $rose(start)|->##2 (a[=3]) ##1 stop ##1 !stop;
endproperty clk
ass: assert property(pr);
start
a
stop
ass
 Property pr checks that if there is a valid 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. One clock cycle later, the signal "stop" should be
detected low.
 Here there is no expectation that there is a valid match on signal "a“ in the previous cycle
of a valid match on "stop" signal.
Fig: Waveform for SVA checker using non-consecutive repetition operator
The “and" ,“or" constructs
The binary operators "and“, “or" can be used to combine two sequences logically.
Both sequences must have the same starting point but they can have different ending points.
sequence s1;
@(posedge clk) a##[l:2] b;
endsequence
sequence s2 ;
@(posedge clk) c##[2:3] d;
endsequence
property And;
@(posedge clk) s1 and s2;
endproperty
and: assert property(And);
property Or;
@(posedge clk) s1 or s2;
endproperty Fig: Waveform for SVA checker using "and“ , ”or” constructs
or: assert property(Or);
Sequence s1 and s2 are two independent sequences. The property pr combines them with an and
operator. The property succeeds when both the sequences succeed.
clk
a
b
c
d
and
or
The "intersect" construct
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.
sequence s1;
@(posedge clk) a##[l:2] b;
endsequence
sequence s2 ;
@(posedge clk) c##[2:3] d;
endsequence
property And;
@(posedge clk) s1 and s2;
endproperty
and: assert property(And);
property Int; Fig: Waveform for SVA checker for intersect constructs
@(posedge clk) s1 intersect s2;
• endproperty
int: assert property(Int);
clk
a
b
c
d
and
int
The "firstmatch" construct
It is sometimes convenient to discard all sequence matches but the first one.
The construct "first_match" ensures that only the first sequence match is used and the
others are discarded.
sequence s1;
@(posedge clk) a ##[1:3] b;
endsequence
sequence s2;
@(posedge clk) c ##[2:3] d;
endsequence
property pr;
@(posedge clk) first_match(s1 or s2);
endproperty
ass: assert property(pr) ;
When the property pr gets evaluated, the first one to match will be kept and every other match will
be discarded.
clk
a
b
c
d
ass
Fig: Waveform for SVA checker using "first_match" construct
The "throughout" construct
 Implication checks for precondition once on the clock edge and then starts evaluating the consequent part. Hence, it
does not care if the antecedent remains true or not.
 To make sure that certain condition holds true during the evaluation of the entire sequence, "throughout" operator
should be used
property pr;
@(posedge clk) $fell(start) |->
(!start) throughout
(##1 (!a&&!b) ##1 (c[->3]) ##1 (a&&b));
endproperty
ass: assert property(pr);
 a. The check starts when signal "start" has a falling edge.
 b. Test the expression ((!a&&!b) ##1 (c[->3]) ##1 (a&&b)).
 c. The sequence checks that between the falling edge of signals "a"and "b," and the rising edge of signals "a" and
"b," signal "c"should repeat itself 3 times continuously or intermittently,
d. During the entire test expression, signal "start" should always below.
clk
start
b
c
a
ass
Fig: Waveform for SVA checker using "hroughout" construct
The "within" construct
The containment of a sequence within another sequence can be expressed using within
operator.
 syntax is given as seq1 within seq2.
This means that seq1 happens within the start and completion of seq2.
My_seq1 start with “rdy” and end with “done”, the design must have 8 “read”s.
sequence my_seq1;
read[=8] within (rdy ##[9:15] done);
endsequence: my_seq1
The "disable iff " construct
In certain design conditions, we don't want to proceed with the check if some condition is
true. Like an asynchronous reset for the checker so SVA providing “disable iff”.
property pr;
@(posedge clk)
disable iff (reset)
$rose(start) |=> a[=2] ##1 b[=2] ##1 !start
endproperty
a34: assert property(pr);
Fig: Waveform for SVA checker using "disable iff construct
Built-in system functions
$onehot(expression) - checks that only one bit of the expression can be high on any given
clock edge.
$onehot0(expression) - checks only one bit of the expression can be high or none of the bits
can be high on any given clock edge.
$isunknown(expresslon) - checks if any bit of the expression is X or Z.
$countones(expression)- counts the number of bits that are high in a vector.
 a33a: assert property( @(posedge clk) $onehot(state) );
 a33b: assert property( @(posedge clk) $onehot0(state) );
 a33c: assert property( @(posedge clk) $isunknown(bus) ) ;
 a33d: assert property( @(posedge clk) $countones(bus)> 1 );
Connecting SVA to the design
The bind directive can be specified in any of the following:
• A module
• An interface
• A compilation-unit scope
SVA checkers can be connected to the design by two different methods.
1. Embed or in-line the checkers in the module definition.
2. Bind the checkers to a module, an instance of a module or multiple instances of a
module.
The syntax for binding is as follows.
• bind <module_name or instance name> <checker name> <checker instance name>
<design signals>;
SVA for functional coverage
SVA provides a keyword "cover" to specify protocol coverage.
The basic syntax of a cover statement is as follows.
• <cover_name> : cover property(property_name)
The results of the cover statement will provide the following information:
• 1. Number of times the property was attempted.
• 2. Number of times the property succeeded.
• 3. Number of times the property failed.
• 4. Number of times the property succeeded vacuously.
A sample coverage log from a simulation for the checker "mutexchk" is shown
below.
• c_mutex, 12 attempts, 12 match, 0 vacuous match

More Related Content

PPTX
Introduction to System verilog
Pushpa Yakkala
 
ODP
axi protocol
Azad Mishra
 
PPTX
Ch 6 randomization
Team-VLSI-ITMU
 
PDF
UVM TUTORIAL;
Azad Mishra
 
PDF
UVM Methodology Tutorial
Arrow Devices
 
PDF
Challenges in Using UVM at SoC Level
DVClub
 
PPTX
System verilog control flow
Pushpa Yakkala
 
PDF
UVM REF GUIDE (1).pdf
sauryakumar3
 
Introduction to System verilog
Pushpa Yakkala
 
axi protocol
Azad Mishra
 
Ch 6 randomization
Team-VLSI-ITMU
 
UVM TUTORIAL;
Azad Mishra
 
UVM Methodology Tutorial
Arrow Devices
 
Challenges in Using UVM at SoC Level
DVClub
 
System verilog control flow
Pushpa Yakkala
 
UVM REF GUIDE (1).pdf
sauryakumar3
 

What's hot (20)

PPTX
System verilog coverage
Pushpa Yakkala
 
PPT
system verilog
Vinchipsytm Vlsitraining
 
PPTX
SystemVerilog Assertion.pptx
Nothing!
 
PPTX
SOC Verification using SystemVerilog
Ramdas Mozhikunnath
 
PDF
Uvm presentation dac2011_final
sean chen
 
PPTX
Axi protocol
Rohit Kumar Pathak
 
PDF
Session 7 code_functional_coverage
Nirav Desai
 
PDF
Session 8 assertion_based_verification_and_interfaces
Nirav Desai
 
PDF
Session 6 sv_randomization
Nirav Desai
 
PPT
SystemVerilog Assertions verification with SVAUnit - DVCon US 2016 Tutorial
Amiq Consulting
 
PDF
System verilog important
elumalai7
 
PDF
Ral by pushpa
Pushpa Yakkala
 
PDF
How to create SystemVerilog verification environment?
Sameh El-Ashry
 
PDF
CPU Verification
Ramdas Mozhikunnath
 
PPTX
ASIC design verification
Gireesh Kallihal
 
PPTX
Amba presentation2
Rashi Aggarwal
 
PDF
Coverage and Introduction to UVM
Dr. Shivananda Koteshwar
 
PPTX
AXI Protocol.pptx
Yazan Yousef
 
PDF
System verilog verification building blocks
Nirav Desai
 
PPTX
SystemVerilog based OVM and UVM Verification Methodologies
Ramdas Mozhikunnath
 
System verilog coverage
Pushpa Yakkala
 
system verilog
Vinchipsytm Vlsitraining
 
SystemVerilog Assertion.pptx
Nothing!
 
SOC Verification using SystemVerilog
Ramdas Mozhikunnath
 
Uvm presentation dac2011_final
sean chen
 
Axi protocol
Rohit Kumar Pathak
 
Session 7 code_functional_coverage
Nirav Desai
 
Session 8 assertion_based_verification_and_interfaces
Nirav Desai
 
Session 6 sv_randomization
Nirav Desai
 
SystemVerilog Assertions verification with SVAUnit - DVCon US 2016 Tutorial
Amiq Consulting
 
System verilog important
elumalai7
 
Ral by pushpa
Pushpa Yakkala
 
How to create SystemVerilog verification environment?
Sameh El-Ashry
 
CPU Verification
Ramdas Mozhikunnath
 
ASIC design verification
Gireesh Kallihal
 
Amba presentation2
Rashi Aggarwal
 
Coverage and Introduction to UVM
Dr. Shivananda Koteshwar
 
AXI Protocol.pptx
Yazan Yousef
 
System verilog verification building blocks
Nirav Desai
 
SystemVerilog based OVM and UVM Verification Methodologies
Ramdas Mozhikunnath
 
Ad

Similar to System verilog assertions (20)

PPTX
assertion.pptx
VarunP31
 
PPT
Digital System Design-Switchlevel and Behavioural Modeling
Indira Priyadarshini
 
PPTX
Lecture-5 Behavioral timing controls.pptx
Deepika rani sona
 
PPTX
Control Structures in C
sana shaikh
 
PPTX
PTC(procedure timing control) in verilog hdl language.pptx
mayankasare
 
PDF
Interactive Transmission System Computation Unit
mayankraj0805
 
PPSX
White Box testing by Pankaj Thakur, NITTTR Chandigarh
Pankaj Thakur
 
PPT
Unit 4 - Features of Verilog HDL (1).ppt
partheepan118
 
PPT
Lecture05 abap on line
Milind Patil
 
PDF
人力
emasaka
 
PDF
Lecture07(DHDNBK)-Behavior-Modelling.pdf
thanhfacebook123dn
 
PPTX
CONTROL FLOW in C.pptx
SmitaAparadh
 
PPTX
Scalar expressions and control structures in perl
sana mateen
 
PDF
verilog modelling and types of modellings
ReguMohanraj
 
PPT
ComputerLangugesProgramingCSECourseCh05-part2.ppt
ReemAlwani1
 
PDF
C Operators and Control Structures.pdf
MaryJacob24
 
PDF
[C++][a] tutorial 2
yasir_cesc
 
PDF
INTERVIEW QUESTIONS_Verilog_PART-2.pdf
DrViswanathKalannaga1
 
PDF
Verilog Tasks & Functions
anand hd
 
assertion.pptx
VarunP31
 
Digital System Design-Switchlevel and Behavioural Modeling
Indira Priyadarshini
 
Lecture-5 Behavioral timing controls.pptx
Deepika rani sona
 
Control Structures in C
sana shaikh
 
PTC(procedure timing control) in verilog hdl language.pptx
mayankasare
 
Interactive Transmission System Computation Unit
mayankraj0805
 
White Box testing by Pankaj Thakur, NITTTR Chandigarh
Pankaj Thakur
 
Unit 4 - Features of Verilog HDL (1).ppt
partheepan118
 
Lecture05 abap on line
Milind Patil
 
人力
emasaka
 
Lecture07(DHDNBK)-Behavior-Modelling.pdf
thanhfacebook123dn
 
CONTROL FLOW in C.pptx
SmitaAparadh
 
Scalar expressions and control structures in perl
sana mateen
 
verilog modelling and types of modellings
ReguMohanraj
 
ComputerLangugesProgramingCSECourseCh05-part2.ppt
ReemAlwani1
 
C Operators and Control Structures.pdf
MaryJacob24
 
[C++][a] tutorial 2
yasir_cesc
 
INTERVIEW QUESTIONS_Verilog_PART-2.pdf
DrViswanathKalannaga1
 
Verilog Tasks & Functions
anand hd
 
Ad

More from HARINATH REDDY (7)

PPTX
Ambha axi
HARINATH REDDY
 
PDF
Sv data types and sv interface usage in uvm
HARINATH REDDY
 
PPTX
High Bandwidth Memory(HBM)
HARINATH REDDY
 
PPTX
UVM Driver sequencer handshaking
HARINATH REDDY
 
PPTX
Flow measurement
HARINATH REDDY
 
PPTX
DIGITAL DESIGN
HARINATH REDDY
 
PPTX
GFSK DEMODULATOR
HARINATH REDDY
 
Ambha axi
HARINATH REDDY
 
Sv data types and sv interface usage in uvm
HARINATH REDDY
 
High Bandwidth Memory(HBM)
HARINATH REDDY
 
UVM Driver sequencer handshaking
HARINATH REDDY
 
Flow measurement
HARINATH REDDY
 
DIGITAL DESIGN
HARINATH REDDY
 
GFSK DEMODULATOR
HARINATH REDDY
 

Recently uploaded (20)

PPTX
Chapter_Seven_Construction_Reliability_Elective_III_Msc CM
SubashKumarBhattarai
 
PPTX
MT Chapter 1.pptx- Magnetic particle testing
ABCAnyBodyCanRelax
 
PDF
67243-Cooling and Heating & Calculation.pdf
DHAKA POLYTECHNIC
 
PDF
The Effect of Artifact Removal from EEG Signals on the Detection of Epileptic...
Partho Prosad
 
PPT
1. SYSTEMS, ROLES, AND DEVELOPMENT METHODOLOGIES.ppt
zilow058
 
PDF
2025 Laurence Sigler - Advancing Decision Support. Content Management Ecommer...
Francisco Javier Mora Serrano
 
PPTX
Tunnel Ventilation System in Kanpur Metro
220105053
 
PPTX
Inventory management chapter in automation and robotics.
atisht0104
 
PDF
FLEX-LNG-Company-Presentation-Nov-2017.pdf
jbloggzs
 
PPTX
database slide on modern techniques for optimizing database queries.pptx
aky52024
 
PDF
Packaging Tips for Stainless Steel Tubes and Pipes
heavymetalsandtubes
 
PDF
Natural_Language_processing_Unit_I_notes.pdf
sanguleumeshit
 
PDF
Zero carbon Building Design Guidelines V4
BassemOsman1
 
PDF
Cryptography and Information :Security Fundamentals
Dr. Madhuri Jawale
 
PDF
LEAP-1B presedntation xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
hatem173148
 
DOCX
SAR - EEEfdfdsdasdsdasdasdasdasdasdasdasda.docx
Kanimozhi676285
 
PPT
Understanding the Key Components and Parts of a Drone System.ppt
Siva Reddy
 
PPTX
Victory Precisions_Supplier Profile.pptx
victoryprecisions199
 
PDF
AI-Driven IoT-Enabled UAV Inspection Framework for Predictive Maintenance and...
ijcncjournal019
 
PPTX
Information Retrieval and Extraction - Module 7
premSankar19
 
Chapter_Seven_Construction_Reliability_Elective_III_Msc CM
SubashKumarBhattarai
 
MT Chapter 1.pptx- Magnetic particle testing
ABCAnyBodyCanRelax
 
67243-Cooling and Heating & Calculation.pdf
DHAKA POLYTECHNIC
 
The Effect of Artifact Removal from EEG Signals on the Detection of Epileptic...
Partho Prosad
 
1. SYSTEMS, ROLES, AND DEVELOPMENT METHODOLOGIES.ppt
zilow058
 
2025 Laurence Sigler - Advancing Decision Support. Content Management Ecommer...
Francisco Javier Mora Serrano
 
Tunnel Ventilation System in Kanpur Metro
220105053
 
Inventory management chapter in automation and robotics.
atisht0104
 
FLEX-LNG-Company-Presentation-Nov-2017.pdf
jbloggzs
 
database slide on modern techniques for optimizing database queries.pptx
aky52024
 
Packaging Tips for Stainless Steel Tubes and Pipes
heavymetalsandtubes
 
Natural_Language_processing_Unit_I_notes.pdf
sanguleumeshit
 
Zero carbon Building Design Guidelines V4
BassemOsman1
 
Cryptography and Information :Security Fundamentals
Dr. Madhuri Jawale
 
LEAP-1B presedntation xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
hatem173148
 
SAR - EEEfdfdsdasdsdasdasdasdasdasdasdasda.docx
Kanimozhi676285
 
Understanding the Key Components and Parts of a Drone System.ppt
Siva Reddy
 
Victory Precisions_Supplier Profile.pptx
victoryprecisions199
 
AI-Driven IoT-Enabled UAV Inspection Framework for Predictive Maintenance and...
ijcncjournal019
 
Information Retrieval and Extraction - Module 7
premSankar19
 

System verilog assertions

  • 2. Introduction There are two significant pieces of technology that are used by almost all verification engineers. 1. A constrained random test bench 2. Code coverage tool. The test benches normally perform 3 different tasks 1. Stimulus generation. 2. Self-checking mechanisms. 3. Functional coverage measurement. Self-checking processes usually targets two specific areas 1. Protocol checking. 2. Data checking. Functional coverage provides a measure of verification completeness. and it gives 1. Protocol coverage. 2. Test plan coverage. Fig: constrained random test bench without assertions.
  • 3. What is an Assertion? An assertion is a statement that a certain property must be true. Assertions are used to, - Document the functionality of the design - Check that the intent of the design is met over simulation time - Determine if verification tested the design (coverage) Assertions can be specified, - By the design engineer as part of the model - By the verification engineer as part of the test program Verilog does not provide an assertion construct. -Verification checks must be coded with programming statements. Fig: DUT with Assertions
  • 4. Why using sv assertions important?  It’s a verification technique i.e. embedded in the language Gives “white box” visibility into the design  Enables specifying design requirement with assertions can specify design requirements using an executable language  Enables easier detecting of design problems In simulation, design errors can be automatically detected Error reports show when error occurred with insight as to why Formal analysis tools can prove that the mode functionality does or does not match the assertion. Can generate “counter-examples”(test cases) for assertion failures  Enables constrained random verification with coverage.
  • 5.  Assertion written in Verilog and SVA  VERILOG always @(posedge a) begin repeat (1) @(posedge clk); fork: a_to_b begin @posedge (b) $display("SUCCESS: b arrived in timen", $time); disable a_to_b; end begin repeat (3) @(posedge clk); $display("ERROR:b did not arrive in timen", $time); disable a_to_b; end join end  SV ASSERTION a_to_b_chk:assert property@(posedge elk) $rose(a) |-> ##[1:3] $ r o s e (b) ); Fig. Waveform for sample assertion
  • 6. System Verilog Scheduling Preponed - Values are sampled for the assertion variables in this region. In this region, a net or variable cannot change its state. This allows the sampling of the most stable value at the beginning of the timeslot. Observed - All the property expressions are evaluated in this region. Reactive - The pass/fail code from the evaluation of the properties are scheduled in this region. Fig. Simplified SV event schedule flow chart
  • 7. Building blocks of SVA sequence name_of_sequence; < t e s t e x p r e s s i o n >; endsequence property name_of_property; < test expression >; or < complex sequence expressions >; endproperty a s s e r t i o n _ n a m e : a s s e r t property( p r o p e r t y _ n a m e );
  • 8. Types of assertions Concurrent assertions Based on clock cycles. Used with both static&dynamic verification tools Placed in procedural block,module,an interface or program definition Evalution at clock edges  Ex: a_cc: assert property(@(posedge clk)not (a && b)); Immediate assertions Based on simulation event semantics. Used with dynamic verification tools Placed in procedural block definition evaluated just like any other Verilog expression within a procedural block.  Ex: always_comb b e g in a _ i a : a s s e r t (a && b ) ; end
  • 9. Fig: Waveform for a sample concurrent assertion Fig: Waveform for a sample immediate assertion
  • 10. A simple action block It can be used for controlling the simulation environment and gathering functional coverage data. user can also print a custom error or success message using the "action block" in the assert statement property pr; @(posedge clk) a ##2 b; endproperty ass : assert property(pr) $display("Property pr succeededn"); else $ d i s p l a y (" P r o p e r t y pr f a i l e d n " ); The checker ass shown above uses simple display statements in the action block to print successes and failures.
  • 11. Assertion Severity Levels • The assertion failure behavior can be specified $fatal: Implicit $finish call. $error: A run-time error severity; software continues execution. $warning: A run-time warning; software continues execution. $info: No severity, just print the message. • Severity level is included in assertion failure message. • Severity can optionally include further message information using $display syntax always@(posedge clk) ack_chk:assert!(acka&&ackb) else $error(“%m failure”); always@(posedge enable) Assert !(valid) Else Begin $warning; $display(“invalid enable”); err_count++; end
  • 12. Sequence with edge definitions  $rose: sequence s2; @(posedge clk) $rose(a); endsequence Fig: Waveform for $rose
  • 13. Sequence with edge definitions $fell: $fell( Boolean expression or signal name) returns true if the least significant bit of the expression changed to 0. Otherwise, it returns false. sequence seq_fell; @(posedge clk) $fell(a); endsequence Sequence seq_fell checks that the signal "a" transitions to a value of 0 on every positive edge of the clock. If the transition does not occur, the assertion will fail. $stable: $stable(Boolean expression or signal name) returns true if the value of the expression did not change. Otherwise, it returns false. sequence seq_stable; @(posedge clk) $stable(a); endsequence Sequence seq_stable checks that the signal "a" is stable on every positive edge of the clock. If the there is any transition occur, the assertion will fail.
  • 14. Sequence with edge definitions $past: $past(signal_name, number of clock cycles) provides the value of the signal from the previous clock cycle. -Below Property checks that, in the given positive clock edge, if the “b” is high, then 2 cycles before that, a was high. property p; @(posedge clk) b |-> ( $past(a,2) == 1); endproperty a: assert property(p); $past construct with gating signal: The $past construct can be used with a gating signal. on a given clock edge, the gating signal has to be true even before checking for the consequent condition. $past (signal_name, number of clock cycles, gating signal) Below Property checks that, in the given positive clock edge, if the “b” is high, then 2 cycles before that, a was high only if the gating signal "c' is valid on any given positive edge of the clock. Property p; @(posedge clk) b |-> ($past(a,2,c) == 1); endproperty a: assert property(p);
  • 15. Sequence with logical relationship  Sequence h, checks that on every positive edge of the clock, either signal "a" or signal "b" is high. If both the signals are low, the assertion will fail.  Ex:sequence h; @(posedge clk) a||b; endsequence Clk a b h Fig: Waveform for sequence h
  • 16. Clock definitions in SVA In general, the clocks in property definitions and keep the sequences independent of the clocks.  This will help increase the re-use of the basic sequence definitions. Ex: sequence ha; a ##2 b; endsequence property p; @(posedge clk) ha; endproperty ast : assert property(p);
  • 17. Forbidding a property sometimes we expect the property to be false always. If the property is true, the assertion fails. Ex: sequence ha; @(posedge clk) a ##2 b; endsequenee property v; not ha; endproperty vh : assert property(v); Clk a b vh Fig: Waveform of SVA checker forbidding a property
  • 18. Implication operator Implication is equivalent to an if-then structure. The left hand side of the implication is called the "antecedent" and the right hand side is called the "consequent." The antecedent is the gating condition. If the antecedent succeeds, then the consequent is evaluated. The implication construct can be used only with property definitions. It cannot be used in sequences. There are 2 types of implication:1.Overlapped implication(|->) 2.Non-overlapped implication(|=>)
  • 19. Overlapped implication If there is a match on the antecedent, then the consequent expression is evaluated in the same clock cycle.  Ex: property pr; @(posedge elk) A |-> B; end property ass : assert property(pr); Clk A B ass  A vacuous success is one where signal "a" was not high and the assertion succeeded by default.  A failure is one where a valid high on signal "a" was detected and at the same clock edge a valid high on signal "b" was not detected high. Fig: Waveform for property pr
  • 20. Non-overlapped implication(|=>) If there is a match on the antecedent, then the consequent expression is evaluated in the next clock cycle. Ex: property hr; @(posedge clk) A|=>B; endproperty ass : assert property(hr); Clk A B ass Fig:Waveform for property ass  In above property checks that, if signal "a" is high on a given positive clock edge, then signal "b" should be high on the next clock edge.
  • 21. Timing windows in SVA Checkers property vs; @(posedge clk) (a && b) |-> ##[1:3] c; endproperty is : assert property(vs); Follows like below (a && b) |-> ##[1] c or (a && b) |-> ##[2] c or (a && b) |->##[3] c Fig: Waveform for property “is” Overlapping window gives `0’ instead of 1 from above example(##[0:3]). So The value of signal "c" is detected high in the same clock edge as the valid match on the antecedent. • Indefinite window gives $ instead of 3 from above example(##[1:$]). "$" sign which implies that there is no upper bound for timing. clk a b c is
  • 22. Repetition operators SVA language provides three different types of repetition operators. 1.Consecutive repetition: This allows the user to specify that a signal or a sequence will match continuously for the number of clocks specified. The simple syntax shown below. signal or sequence [*n]; "n" is the number of times the expression should match repeatedly. 2.go to repetition: This allows the user to specify that an expression will match the number of times specified not necessarily on continuous clock cycles. The main requirement of "go to "repeat is that the last match on the expression checked for repetition should happen in the clock cycle before the end of the entire sequence matching. The simple syntax shown below. Signal [->n] 3.non-consecutive repetition: 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. The simple syntax shown as Signal [=n]
  • 23. Consecutive repetition operator [*] Property sr; @(posedge clk) $rose(start) |->##2 (a[*3]) ##2 stop ##1 !stop; endproperty is: assert property(sr); clk start a stop is Fig: Waveform for SVA checker using consecutive repeat  Property sr checks that two clock cycles after a valid start, signal "a"stays high for 3 continuous clock cycles and two clock cycles after that, signal "stop" is high. One clock cycle later signal "stop" is low.
  • 24. Go to repetition operator [->] property hr; @(posedge clk) $rose(start) |->##2 (a[->3]) ##1 stop; endproperty clk ass: assert property(hr); start a stop Fig: Waveform for SVA checker using go to repetition operator Property hr checks that, 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. ass
  • 25. Non-consecutive repetition operator [=] Property pr; @(posedge clk) $rose(start)|->##2 (a[=3]) ##1 stop ##1 !stop; endproperty clk ass: assert property(pr); start a stop ass  Property pr checks that if there is a valid 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. One clock cycle later, the signal "stop" should be detected low.  Here there is no expectation that there is a valid match on signal "a“ in the previous cycle of a valid match on "stop" signal. Fig: Waveform for SVA checker using non-consecutive repetition operator
  • 26. The “and" ,“or" constructs The binary operators "and“, “or" can be used to combine two sequences logically. Both sequences must have the same starting point but they can have different ending points. sequence s1; @(posedge clk) a##[l:2] b; endsequence sequence s2 ; @(posedge clk) c##[2:3] d; endsequence property And; @(posedge clk) s1 and s2; endproperty and: assert property(And); property Or; @(posedge clk) s1 or s2; endproperty Fig: Waveform for SVA checker using "and“ , ”or” constructs or: assert property(Or); Sequence s1 and s2 are two independent sequences. The property pr combines them with an and operator. The property succeeds when both the sequences succeed. clk a b c d and or
  • 27. The "intersect" construct 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. sequence s1; @(posedge clk) a##[l:2] b; endsequence sequence s2 ; @(posedge clk) c##[2:3] d; endsequence property And; @(posedge clk) s1 and s2; endproperty and: assert property(And); property Int; Fig: Waveform for SVA checker for intersect constructs @(posedge clk) s1 intersect s2; • endproperty int: assert property(Int); clk a b c d and int
  • 28. The "firstmatch" construct It is sometimes convenient to discard all sequence matches but the first one. The construct "first_match" ensures that only the first sequence match is used and the others are discarded. sequence s1; @(posedge clk) a ##[1:3] b; endsequence sequence s2; @(posedge clk) c ##[2:3] d; endsequence property pr; @(posedge clk) first_match(s1 or s2); endproperty ass: assert property(pr) ; When the property pr gets evaluated, the first one to match will be kept and every other match will be discarded. clk a b c d ass Fig: Waveform for SVA checker using "first_match" construct
  • 29. The "throughout" construct  Implication checks for precondition once on the clock edge and then starts evaluating the consequent part. Hence, it does not care if the antecedent remains true or not.  To make sure that certain condition holds true during the evaluation of the entire sequence, "throughout" operator should be used property pr; @(posedge clk) $fell(start) |-> (!start) throughout (##1 (!a&&!b) ##1 (c[->3]) ##1 (a&&b)); endproperty ass: assert property(pr);  a. The check starts when signal "start" has a falling edge.  b. Test the expression ((!a&&!b) ##1 (c[->3]) ##1 (a&&b)).  c. The sequence checks that between the falling edge of signals "a"and "b," and the rising edge of signals "a" and "b," signal "c"should repeat itself 3 times continuously or intermittently, d. During the entire test expression, signal "start" should always below. clk start b c a ass Fig: Waveform for SVA checker using "hroughout" construct
  • 30. The "within" construct The containment of a sequence within another sequence can be expressed using within operator.  syntax is given as seq1 within seq2. This means that seq1 happens within the start and completion of seq2. My_seq1 start with “rdy” and end with “done”, the design must have 8 “read”s. sequence my_seq1; read[=8] within (rdy ##[9:15] done); endsequence: my_seq1
  • 31. The "disable iff " construct In certain design conditions, we don't want to proceed with the check if some condition is true. Like an asynchronous reset for the checker so SVA providing “disable iff”. property pr; @(posedge clk) disable iff (reset) $rose(start) |=> a[=2] ##1 b[=2] ##1 !start endproperty a34: assert property(pr); Fig: Waveform for SVA checker using "disable iff construct
  • 32. Built-in system functions $onehot(expression) - checks that only one bit of the expression can be high on any given clock edge. $onehot0(expression) - checks only one bit of the expression can be high or none of the bits can be high on any given clock edge. $isunknown(expresslon) - checks if any bit of the expression is X or Z. $countones(expression)- counts the number of bits that are high in a vector.  a33a: assert property( @(posedge clk) $onehot(state) );  a33b: assert property( @(posedge clk) $onehot0(state) );  a33c: assert property( @(posedge clk) $isunknown(bus) ) ;  a33d: assert property( @(posedge clk) $countones(bus)> 1 );
  • 33. Connecting SVA to the design The bind directive can be specified in any of the following: • A module • An interface • A compilation-unit scope SVA checkers can be connected to the design by two different methods. 1. Embed or in-line the checkers in the module definition. 2. Bind the checkers to a module, an instance of a module or multiple instances of a module. The syntax for binding is as follows. • bind <module_name or instance name> <checker name> <checker instance name> <design signals>;
  • 34. SVA for functional coverage SVA provides a keyword "cover" to specify protocol coverage. The basic syntax of a cover statement is as follows. • <cover_name> : cover property(property_name) The results of the cover statement will provide the following information: • 1. Number of times the property was attempted. • 2. Number of times the property succeeded. • 3. Number of times the property failed. • 4. Number of times the property succeeded vacuously. A sample coverage log from a simulation for the checker "mutexchk" is shown below. • c_mutex, 12 attempts, 12 match, 0 vacuous match