15 SVAssertionsLecture1
15 SVAssertionsLecture1
15 SVAssertionsLecture1
System-Level Modeling and Verification for Communications System Verilog Assertions Lecture 1 Prof. Xiaofang Zhou ASIC & Systems, Dept. of Microeletronics FUDAN University Shanghai, CHINA
Outline
Templates
function template class template
Homeworks
2
What's Assertion
Assertion is a description of a property of the design. During simulation, the assertion fails if:
the expected property does not happen some forbidden property happened
Prepone (sample) ...... Active (design) ...... Observed (assertions) Reactive (testbench)
To next time slot
Observed
Property expressions are evaluated.
Reactive
Pass/fail code are scheduled.
Immediate assertions
Placed in procedural blocks Used only with dynamic simulation
always_comb begin a_ab : assert ( a || b ); end
endmodule
7
Concurrent assertions
Beased on clock cycles Test expression is evaluated at clock edges Placed in procedural block, a module, an
interface or a program definition. Use with static (formal) and dynamic verification tools
P_a_or_b_is_high: assert property (@(posedge clk) (a || b));
8
0 100 200 300 400 500 600 700 800 900 1000
Fail Fail Fail Fail Fail Fail Ok!! Ok!! Ok!! Fail Ok!!
xx xx xx 00 00 01 10 11 00 01 10
P_a_or_b_is_high: assert property (@(posedge clk) (a || b)) $display($time,"\tOk!!\t", a, b); else $display($time,"\tFail\t", a, b);
always @(posedge clk or posedge rst) if (rst == 1'b1) {a, b} <= 2'b0; else {a, b} <= #20 {a, b} + 2'b01; initial begin clk = 1'b1; rst = 1'b0; # 220 rst = 1'b1; # 200 rst = 1'b0; end endmodule
200
400
600
800
1000
0 100 200 300 400 500 600 700 800 900 1000
Fail Fail Fail Fail Fail Fail Ok!! Ok!! Ok!! Fail Ok!!
xx xx xx 00 00 00 01 10 11 00 01
10
Steps of SVA
sequence: combination of several events, either on the same clock edge or over a period of time
sequence name_of_sequence; test_expression; endsequence
11
edge expressions
Monitor the transition of signal value from one clock cycle to the next True if LSB of signal/expr changed to 1 $rose(bool_expr or signal) True if LSB of signal/expr changed to 0 $fall(bool_expr or signal) True if value of signal/expr did not change $stable(bool_expr or signal)
sequence s_stb; @(posedge clk) $rose(STB_I); endsequence
12
Formal arguments
Arguments allowed in sequence definition
13
14
Implication operator
@(posedge clk) STB ##2 ACK;
Pass when STB is 1 and ##2 ACK is 1 Fail when STB is 0 (Wrong starting point)
@(posedge clk) STB |-> ##2 ACK;
ant |-> ##delay con |-> |=> can only be used at property level.
18
Nested implication
Several conditions leads to a final
consequence a_ISR: asset property @(posedge clk) S_INTERRUPT |-> ##1 S_WRITE |-> ##1 S_READ;
20
a_SAFE_WB: asset property @(posedge clk) S_NEW_STB |-> ##[1:100] ACK_I ##1 !ACK_I
indow w d e erlapp v a f te r 1 o r d o d n f n a ] u , 0 o h 10 es hig oes low pper b o u [0: g o I n _ ACK le, it g means c ] y c $ : k 1 [ cloc
21
module xyz(..); parameter delay = 2; property p_delay; @(posedge clk) x |=> ##delay y; endproperty aa: assert property(p_delay); endmodule module zzz(..); Gen_chk #(.delay(1)) i1(..); Gen_chk i2(..);
22
true, $past()
`true is a placeholder and always success
sequence s @(posedge clk) a ##2 b ##3 `true; // seq s is prolonged endsequence
Consecutive repetition
Match continuously for a number of clocks
STB ##1 STB ##1 STB STB [*3]
Repeat sequences
(x ##2 y) ##1 (x ##2 y) ##1 (x ##2 y) (x ##2 y)[*3]
Non-consecutive repetition
similar to goto repetition Last match needn't to be the end of entire sequence matching. [=n] @(posedge clk) x |-> ##1 (y[->3]) ##1 z @(posedge clk) x |-> ##1 (y[=3]) ##1 z
25
"and" construct
sequence sx; @(posedge clk) x##[1:2] y; endsequence sequence sy; @(posedge clk) s || a; endsequence property p; @(posedge clk) sx and sy; endproperty a: assert property(p);
26
"intersect" construct
Combine two sequences by "intersect"
Both sequences have the same starting point They also must have the same end point i.e. two sequences with the same length
To control the length of a sequence sequence ss; a ##[1:$] b ##[2:$] c; endsequence; property pp; @(posedge clk) 1[*10:20] intersect ss; endproperty; a_pp: assert property(pp);
27
there may exists more than one matches. "first_match" tells SV to discard other matches when first sequence match if found.
28
"throughout" construct
Implication|-> |=>checks for precondition once. "throughout" checks the condition holds true during the evaluation of entire sequence (condition_expr) throughout (sequence)
a_SAFE_WB: asset property @(posedge clk) S_NEW_STB |-> (STB_I) throughout (##[1:100] ACK_I ##1 !ACK_I)
29
"within" construct seq1 within seq2 seq1 happens within the start and completion of seq2
start matching point of seq2 must happen before that of seq1 Ending matching point of seq1 must happen before that of seq2
31
@(posedge CLK) disable iff (RST_N == 1'b0) $..... endproperty a_blah: assert property(blah);
In the above sample, the checker will issue vacuous successes when RST_N is low.
32
Arguments in property
Formal arguments
property blah(a, b); @(posedge clk) a |-> b; endproperty; aa : assert property(blah(stb, cs));
33
Multiple clocking
SVA allows a seq. or prop. to have multiple clock definitions for sampling individual signals or subseq.
property bar; @(posedge CLK1) WRITE ##1 @(posedge CLK2) READ eneproperty
only ##1 or |=> allowed between multiple clocks. Using ##0, ##2, |-> are illegal.
34
"matched" construct
@(posedge clk_b) (seq_a).matched |=> seq_b sequence s_a; @posedge clka) $rose(req); endsequence;
sequence s_b; @posedge clkb) $rose(ack); endsequence; property p_match; @(posedge clk2) s_a.matched |=> s_b; eneproperty
35
"expect" construct
"expect" wait for a property initial begin #1000 ; expect (@(posedge clk) ##[1:100] STB_I == 1'b1) $display($time, "STB asserted\n"); else begin $display($time, "no STB\n"); $finish(); end end
36
property foo; int addr; @(posedge CLK) (WB_WRITE, addr = ADR_I) |-> ##[1:$] (WB_READ and (addr == ADR_I), $display("bla bla bla"); ) endproperty
37
References
S. Vijayaraghavan, M. Ramanathan, A Practical Guide for SystemVerilog Assertions, Springer Science+Business Media, Inc 2005 (, SystemVerilog Assertions 2006) SystemVerilog 3.1a Language Referece Manual, Accellera Organization, Inc, 2004 S. Sutherland, S. Davidmann, P. Flake, SystemVerilog for Design, 2nd ed, Springer 2006
39
Thank You
40