赞
踩
前言:在数字电路验证中,常常需要对某一组信号之间的关系做检查,此时就要用到SystemVerilog Assertion。用过能掌握SVA的一些语法,将大大减小了check的代码量。针对信号持续重复的情况,SVA提供了三种重复操作符:Consecutive repetition(持续性重复),go to repetition(跟随重复操作)和non-consecutive repetition(非连续重复操作)。本文将分别介绍这三种操作符的含义及使用方法。
(a##1b)[*3]; //等价于 a##1b##1a##1b##1a##1b
- property p21;
- @(posedge clk);
- $rose(start)|->##2 (a[*3]) ##2 stop ##1 !stop;
- endproperty
-
- a21: assert property(p21) else $error();
- property p23;
- @(posedge clk)
- $rose |-> ##2 ((a##[1:4]b)[*3]) ##2 stop;
- endproperty
-
- a23: assert property(p23) else $error();
- //(a##[1:4]b)[*3]等价于:
- //((a##1b) or (a##2 b) or (a##3 b) or (a##4b))##1
- //((a##1b) or (a##2 b) or (a##3 b) or (a##4b))##1
- //((a##1b) or (a##2 b) or (a##3 b) or (a##4b))
- property p24;
- @(posedge clk)
- $rose(start) |-> ##2 (a[*1:$]) ##1 stop;
- endproperty
-
- a24: assert property(p24) else $error();
- property p25;
- @(posedge clk)
- $rose(start) |->##2 (a[->3]) ##1 stop;
- endproperty
-
- a25:assert property(p25) else $error();
- property p26;
- @(posedge clk)
- $rose(start) |->##2 (a[=3]) ##1 stop ##1 !stop;
- endproperty
-
- a26:assert property(p26) else $error();
- property b_posedge();
- @(posedge clk_ck) disable iff(~rst_n)
- $rose(a) |-> ($rose(b)[1]) ##1 $fell(a);
- endproperty
- sequence s28a;
- @(posedge clk) a##[1:2] b;
- endsequence
-
- sequence s28b;
- @(posedge clk) c##[2:3] d;
- endsequence
-
- property p28;
- @(posedge clk) s28a intersect s28b;
- endproperty
-
- a28:assert property(p28) else $error();
- property p35;
- @(posedge clk) 1[*3:5] intersect(a##[1:$] b ##[1:$] c));
- endproperty
-
- a35:assert property(p35) else $error();
- sequence s30a;
- @(posedge clk) a##[1:3] b;
- endsequence
-
- sequence s30b;
- @(posedge clk) c##[2:3]d;
- endsequence
-
- property p30;
- @(posedge clk) first_match(s30a or s30b);
- endporperty
-
- a32:assert property(p30) else $error();
- property p31;
- @(posedge clk)
- $fell(start) |-> (!start) throughout (##1 (!a&&!b) ##1 (c[->3]) ##1 (a&&b));
- endproperty
-
- a31:assert property(p31) else $error();
- sequence s32a;
- @(posedge clk)
- ((!a&&!b) ##1 (c[->3]) ##1 (a##b));
- endsequence
-
- sequence s32b;
- @(posedge clk)
- $fell(start) ##[5:10] $rose(start);
- endsequence
-
- sequence s32;
- @(posedge clk) s32a within s32b;
- endsequence
-
- property p32;
- @(posedge clk) $fell(start)|->s32;
- endproperty
-
- a32:assert property(p32) else $error();
- sequence s_a;
- @(posedge clk1) $rose(a);
- endsequence
-
- sequence s_b;
- @(posedge clk2) $rose(b);
- endsequence
-
- property p_match;
- @(posedge clk2) s_a.matched |=> s_b;
- endproperty
-
- a_match: assert property(p_match);
- property p_if_else;
- @(posedge clk) ($fell(start) ##1 (a||b)) |->
- if(a)
- (c[->2] ##1 e);
- else
- (d[->2] ##1 f);
- endproperty
-
- a_if_else:assert: property(p_if_else) else $error();
- initial begin
- @(posedge clk);
- #2ns cpu_ready=1'b1;
- expect(@(posedge clk) ##[1:16] memory_ready =='b1)
- $dispaly("Hand shake successful\n");
- else begin
- $display("Hand shake failed:exiting");
- $finish();
- end
- for(i=0;i<64;i++) begin
- ...
- end
- end
- property p_local_var1;
- int lvar1;
- @(posedge clk)
- ($rose(enable1),lvar1=a) |-> ##4 (aa==(lvar1*lvar1*lvar1));
- endproperty
-
- a_local_var1: assert property(p_local_var1) else $error();
- sequence s27a;
- a##[1:2] b;
- endsequece
-
- sequence s27b;
- c##[2:3] d;
- endsequence
-
- property p27;
- @(posedge clk) s27a and s27b;
- endproperty
-
- a27:assert property(p27) else $error();
- sequence s29a;
- @(posedge clk) a##[1:2] b;
- endsequence
-
- sequence s29b;
- @(posedge clk)c##[2:3]d;
- endsequence
-
- property p29;
- @(posedge clk) s29a or s29b;
- endproperty
-
- a29: assert property(p29) else $error();
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。