6-2
6-2
Lecture Overview
Introduction to In this lecture, you will. . .
SystemVerilog
Learn the structure of the SVA language
Assertions (SVA)
Learn how to construct sequence
Harry D. Foster
Learn how to construct properties
Chief Scientist Verification
IC Verification Solutions Division Apply SVA on real examples
2 H Foster, EE 382M, Verification of Digital Systems, Spring 2018 © Mentor Graphics Corporation
2 HF, UT Austin, Feb 2020
SystemVerilog Assertions
© Mentor Graphics Corporation 4 H Foster, EE 382M, Verification of Digital Systems, Spring 2018 © Mentor Graphics Corporation
4 HF, UT Austin, Feb 2020
“Process 2 is in the critical section” “eventually process 2 will enter the critical section”
Fp p
X p – p holds in the next state.
“Process 2 will be in the critical section in the next state” • G p – always (i.e., globally) p holds.
“process 1 and 2 are always mutually exclusive”
Xp p
Gp p p p p p p
5 H Foster, EE 382M, Verification of Digital Systems, Spring 2018 © Mentor Graphics Corporation 6 H Foster, EE 382M, Verification of Digital Systems, Spring 2018 © Mentor Graphics Corporation
5 HF, UT Austin, Feb 2020 6 HF, UT Austin, Feb 2020
Strong operators – F, U
[p W q] – “p holds from now until q holds” (weak) Used to express liveness properties,
i.e. “something good eventually happens”
pWq p p p p p p
7 H Foster, EE 382M, Verification of Digital Systems, Spring 2018 © Mentor Graphics Corporation 8 H Foster, EE 382M, Verification of Digital Systems, Spring 2018 © Mentor Graphics Corporation
7 HF, UT Austin, Feb 2020 8 HF, UT Austin, Feb 2020
p p p
9 H Foster, EE 382M, Verification of Digital Systems, Spring 2018 © Mentor Graphics Corporation 10 H Foster, EE 382M, Verification of Digital Systems, Spring 2018 © Mentor Graphics Corporation
9 HF, UT Austin, Feb 2020 10 HF, UT Austin, Feb 2020
11 H Foster, EE 382M, Verification of Digital Systems, Spring 2018 © Mentor Graphics Corporation 12 H Foster, EE 382M, Verification of Digital Systems, Spring 2018 © Mentor Graphics Corporation
11 HF, UT Austin, Feb 2020 12 HF, UT Austin, Feb 2020
13 H Foster, EE 382M, Verification of Digital Systems, Spring 2018 © Mentor Graphics Corporation 14 H Foster, EE 382M, Verification of Digital Systems, Spring 2018 © Mentor Graphics Corporation
13 HF, UT Austin, Feb 2020 14 HF, UT Austin, Feb 2020
Linear Formalisms
15 H Foster, EE 382M, Verification of Digital Systems, Spring 2018 © Mentor Graphics Corporation © Mentor Graphics Corporation
15 HF, UT Austin, Feb 2020
• Checker packaging
assert property (@(posedge clk) disable iff (~rst_n)
Assertion
Units !(grant0 & grant1));
Directives
(assert, cover) • assert, assume, cover
Directives
Sequences (assert, cover) rst_n
(Sequential Expressions) • How Boolean events
are related over time Properties
nexttime p p
Note: s_eventually is a strong version of this operator in SVA.
21 H Foster, EE 382M, Verification of Digital Systems, Spring 2018 © Mentor Graphics Corporation 22 H Foster, EE 382M, Verification of Digital Systems, Spring 2018 © Mentor Graphics Corporation
21 HF, UT Austin, Feb 2020 22 HF, UT Austin, Feb 2020
SVA: p until q
Note: there is an implicit always when asserting a property: p until q p p p p p p
assert property(p);
23 H Foster, EE 382M, Verification of Digital Systems, Spring 2018 © Mentor Graphics Corporation 24 H Foster, EE 382M, Verification of Digital Systems, Spring 2018 © Mentor Graphics Corporation
23 HF, UT Austin, Feb 2020 24 HF, UT Austin, Feb 2020
25 H Foster, EE 382M, Verification of Digital Systems, Spring 2018 © Mentor Graphics Corporation © Mentor Graphics Corporation
25 HF, UT Austin, Feb 2020
Sequences Sequence
— Temporal delay ##n with an integer n.
So far we have examined LTL-based assertions
We now we introduce SVA sequences
— Multiple Boolean expressions are evaluated start ##1 transfer
in a linear order of increasing time
Assertion
Units clk
Directives
(assert, cover)
start
Properties
Sequences transfer
(Sequential Expressions)
Boolean Expressions
27 H Foster, EE 382M, Verification of Digital Systems, Spring 2018 © Mentor Graphics Corporation 28 H Foster, EE 382M, Verification of Digital Systems, Spring 2018 © Mentor Graphics Corporation
27 HF, UT Austin, Feb 2020 28 HF, UT Austin, Feb 2020
clk clk
start start
transfer transfer
29 H Foster, EE 382M, Verification of Digital Systems, Spring 2018 © Mentor Graphics Corporation 30 H Foster, EE 382M, Verification of Digital Systems, Spring 2018 © Mentor Graphics Corporation
29 HF, UT Austin, Feb 2020 30 HF, UT Austin, Feb 2020
• Sequence • Sequence
• Consecutive repetition [*m] or range [*m:n] • Consecutive repetition [*m] or range [*m:n]
- Use $ to represent infinity - Use $ to represent infinity
clk clk
start start
transfer transfer
31 H Foster, EE 382M, Verification of Digital Systems, Spring 2018 © Mentor Graphics Corporation 32 H Foster, EE 382M, Verification of Digital Systems, Spring 2018 © Mentor Graphics Corporation
31 HF, UT Austin, Feb 2020 32 HF, UT Austin, Feb 2020
• Sequence • Sequence
• Consecutive repetition [*m] or range [*m:n] • Consecutive repetition [*m] or range [*m:n]
- Use $ to represent infinity - Use $ to represent infinity
clk clk
start start
transfer transfer
clk clk
start start
[*] represents [*] represents
zero to infinity zero to infinity
transfer transfer
start[=2] !start[*] ##1 start ##1 !start[*] ##1 start ##1 !start[*] start[->2] !start[*] ##1 start ##1 !start[*] ##1 start
35 H Foster, EE 382M, Verification of Digital Systems, Spring 2018 © Mentor Graphics Corporation 36 H Foster, EE 382M, Verification of Digital Systems, Spring 2018 © Mentor Graphics Corporation
35 HF, UT Austin, Feb 2020 36 HF, UT Austin, Feb 2020
Assertion
Units
ready ##1 start |-> go ##1 done
Directives
(assert, cover) clk
Properties ready
Sequences
start
(Sequential Expressions) go
assertion property ( @(posedge clk) ready ##1 start |-> go ##1 done );
37 H Foster, EE 382M, Verification of Digital Systems, Spring 2018 © Mentor Graphics Corporation 38 H Foster, EE 382M, Verification of Digital Systems, Spring 2018 © Mentor Graphics Corporation
37 HF, UT Austin, Feb 2020 38 HF, UT Austin, Feb 2020
39 H Foster, EE 382M, Verification of Digital Systems, Spring 2018 © Mentor Graphics Corporation 40 H Foster, EE 382M, Verification of Digital Systems, Spring 2018 © Mentor Graphics Corporation
39 HF, UT Austin, Feb 2020 40 HF, UT Austin, Feb 2020
a_0_fair: a_0_fair:
assert property (@(posedge clk) disable iff (reset) assert property (@(posedge clk) disable iff (reset)
$rose(req[0]) |-> not (!gnt[0] throughout (gnt[1])[->2])); req[0] |-> not (!gnt[0] throughout (gnt[1])[->2]));
clk clk
req[0] req[0]
req[0] gnt[0] req[0] gnt[0]
req[1]
Arbiter gnt[1]
gnt[0]
req[1]
Arbiter gnt[1]
gnt[0]
gnt[1] gnt[1]
41 H Foster, EE 382M, Verification of Digital Systems, Spring 2018 © Mentor Graphics Corporation 42 H Foster, EE 382M, Verification of Digital Systems, Spring 2018 © Mentor Graphics Corporation
41 HF, UT Austin, Feb 2020 42 HF, UT Austin, Feb 2020
a_0_fair: a_1_fair:
assert property (@(posedge clk) disable iff (reset) assert property (@(posedge clk) disable iff (reset)
$rose(req[0]) |-> not (!gnt[0] throughout (gnt[1])[->2])); $rose(req[1] |-> not (!gnt[1] throughout (gnt[0])[->2]));
clk clk
req[0] req[1]
req[0] gnt[0] req[0] gnt[0]
req[1]
Arbiter gnt[1]
gnt[0]
req[1]
Arbiter gnt[1]
gnt[0]
gnt[1] gnt[1]
43 H Foster, EE 382M, Verification of Digital Systems, Spring 2018 © Mentor Graphics Corporation 44 H Foster, EE 382M, Verification of Digital Systems, Spring 2018 © Mentor Graphics Corporation
43 HF, UT Austin, Feb 2020 44 HF, UT Austin, Feb 2020
45 H Foster, EE 382M, Verification of Digital Systems, Spring 2018 © Mentor Graphics Corporation 46 H Foster, EE 382M, Verification of Digital Systems, Spring 2018 © Mentor Graphics Corporation
45 HF, UT Austin, Feb 2020 46 HF, UT Austin, Feb 2020
47 H Foster, EE 382M, Verification of Digital Systems, Spring 2018 © Mentor Graphics Corporation 48 H Foster, EE 382M, Verification of Digital Systems, Spring 2018 © Mentor Graphics Corporation
47 HF, UT Austin, Feb 2020 48 HF, UT Austin, Feb 2020
• $rose( expression )
• $fell( expression )
clk
• $stable( expression )
start
• $past( expression [, number_of_ticks] )
transfer
49 H Foster, EE 382M, Verification of Digital Systems, Spring 2018 © Mentor Graphics Corporation 50 H Foster, EE 382M, Verification of Digital Systems, Spring 2018 © Mentor Graphics Corporation
49 HF, UT Austin, Feb 2020 50 HF, UT Austin, Feb 2020
• $onehot0 (<expression>)
clk
- Returns true if at most one bit of the expression is high
start
• $isunknown (<expression>)
transfer - Returns true if any bit of the expression is X or Z
- This is equivalent to ^<expression> === ’bx
$rose(start) is a short cut for the sequence !start ##1 start
51 H Foster, EE 382M, Verification of Digital Systems, Spring 2018 © Mentor Graphics Corporation 52 H Foster, EE 382M, Verification of Digital Systems, Spring 2018 © Mentor Graphics Corporation
51 HF, UT Austin, Feb 2020 52 HF, UT Austin, Feb 2020
Some assertions require additional modeling code // assertion modeling code – not part of the design
— In addition to the assertion constructs `ifdef ASSERT_ON
int cnt = 0;
LIFO always @(posedge clk)
clk
if (!rst_n)
clk
rst_n rst_n
cnt <= 0;
A
else
Controller data_in data_out
put full cnt <= cnt + put – get;
get // assert no LIFO overflow
A empty
assert property (@posedge clk disable iff (~rst_n)
!((cnt + put – get) > `DEPTH));
// assert no LIFO underflow
assert property (@posedge clk disable iff (!rst_n) !((cnt + put) < get));
`endif
// Assert that the LIFO controller cannot overflow nor underflow
55 H Foster, EE 382M, Verification of Digital Systems, Spring 2018 © Mentor Graphics Corporation © Mentor Graphics Corporation
55 HF, UT Austin, Feb 2020
clk
rst_n
sel[0]
en
Control
Bridge
CPU 1 CPU 2 Datapath UART
I/F addr
I/F
LIFO
write
Bus A Bus B
Arbiter I/F I/F
rdata
Datapath
Memory Graphics wdata
Controller Controller LIFO Timer Master Slave 0
0 1 2 3 4 0 1 2 3 4
write write
sel[0] sel[0]
en en
BUS STATE INACTIVE START ACTIVE INACTIVE BUS STATE INACTIVE START ACTIVE INACTIVE
59 H Foster, EE 382M, Verification of Digital Systems, Spring 2018 © Mentor Graphics Corporation 60 H Foster, EE 382M, Verification of Digital Systems, Spring 2018 © Mentor Graphics Corporation
59 HF, UT Austin, Feb 2020 60 HF, UT Austin, Feb 2020
setup
p_valid_start_transition START is followed by ACTIVE no transfer START
sel[0] == 1
en == 0
no transfer START p_no_error_state Bus state must be valid: !(se==0 & en==1) ACTIVE
sel[0] == 1
en == 1
61 H Foster, EE 382M, Verification of Digital Systems, Spring 2018 © Mentor Graphics Corporation 62 H Foster, EE 382M, Verification of Digital Systems, Spring 2018 © Mentor Graphics Corporation
61 HF, UT Austin, Feb 2020 62 HF, UT Austin, Feb 2020
`ifdef ASSERTION_ON
//Map bus control values to conceptual states property p_valid_inactive_transition;
if (~rst_n) begin @(posedge clk) disable iff (bus_reset)
bus_reset = 1; ( bus_inactive) |=>
bus_inactive = 1; ((bus_inactive) || (bus_start));
bus_start = 0; endproperty
bus_active = 0; INACTIVE a_valid_inactive_transition: INACTIVE
sel[0] == 0 sel[0] == 0
bus_error = 0; en == 0
assert property (p_valid_inactive_transition); en == 0
else begin
property p_valid_start_transition;
bus_reset = 0; no transfer
START
sel[0] == 1
no transfer
START
sel[0] == 1
@(posedge clk) disable iff (bus_reset)
bus_inactive = ~sel & ~en; en == 0 en == 0
63 H Foster, EE 382M, Verification of Digital Systems, Spring 2018 © Mentor Graphics Corporation 64 H Foster, EE 382M, Verification of Digital Systems, Spring 2018 © Mentor Graphics Corporation
63 HF, UT Austin, Feb 2020 64 HF, UT Austin, Feb 2020
65 H Foster, EE 382M, Verification of Digital Systems, Spring 2018 © Mentor Graphics Corporation © Mentor Graphics Corporation
65 HF, UT Austin, Feb 2020
Directives
(assert, cover) • assert, assume, cover
Binding Checkers
EXERCISES
Ex.1: Simple Shift Buffer Example Ex.1: Signal is Valid After Reset
After reset, the input d_in should never be unknown. After reset, the input d_in should never be unknown.
After reset, state[7:0] must have only a single bit low. After reset, state[7:0] must have only a single bit low.
state: 11101111, 1011111, 0111111, 11111110, … state: 11101111, 1011111, 0111111, 11111110, …
Whenever start is high, then start must be low in the next Whenever start is high, then start must be low in the next
cycle and remain low until after the next strictly subsequent cycle and remain low until after the next strictly subsequent
cycle in which complete is high. cycle in which complete is high.
complete may not be high unless start was high in a complete may not be high unless start was high in a
preceding cycle and complete was not high in any of the preceding cycle and complete was not high in any of the
intervening cycles. intervening cycles.
A LIFO contains the following controls: A LIFO contains the following controls:
— put : add data to LIFO — put : add data to LIFO
— get : remove data from LIFO — get : remove data from LIFO
— cnt counter that points to the next available 7
— cnt counter that points to the next available 7
location in the LIFO (4’b1000 represents full) location in the LIFO (4’b1000 represents full)
cnt 6 cnt 6
5 5
It is not possible to overflow the LIFO a_no_overflow: assert property
4 4
(@(posedge clk) disable iff (reset)
3 3
2 !(cnt == 4’b1000 & put & !get) 2
It is not possible to underflow the LIFO
1 ); 1
0 0
81 H Foster, EE 382M, Verification of Digital Systems, Spring 2018 © Mentor Graphics Corporation © Mentor Graphics Corporation
81 HF, UT Austin, Feb 2020 82 HF, UT Austin, Feb 2020
www.mentor.com
© Mentor Graphics Corporation