system verilog assertion

assertion 作用

(1) 检测一个条件有没有发生;(2)检测一系列动作有没有发生。可以直接介入硬件内部信号,bind到硬件。

1. 当拍assert,“ |-> ”。

上升沿
always @(posedge clock) 
a_example1: assert(A && !B);
或者
property example1;
    @(posedge clock) A |-> !B;
endproperty
a_example1: assert property(example1);
或者
a_example1: assert property(@(posedge clock) A |-> !B);


下降沿
always @(negedge clock) 
a_example2: assert(A && !B);
或者
property example2;
    @(negedge clock) A |-> !B;
endproperty
a_example2: assert property(example2);
或者
a_example2: assert property(@(negedge clock) A |-> !B);

变化沿
a_example2: assert property(@(A or B)  C || D);

2. 下一拍assert,“ |=> ”。

always @(posedge clock)
a_example1: assert(A |=> B);
或者
property example1;
    @(posedge clock) A |=> B;
endproperty
assert property(example1);
或者
a_example1: assert property(@(posedge clock) A |=> !B);

3. 推后几拍,##clcyes。

a_example1: assert property(@(posedge clock) A ##1 B ##2 C);//this will check the condition every cycle, the expression must be true every cycle.

a_example2: assert property(@(posedge clock) A |-> B ##2 C);//this will check the condition every cycle, the expression must be true only when A is true at posedge clock.

a_example3: assert property(@(posedge clock) A |=> ##[1:3] !B);//this will check the condition every cycle, the expression must be true only when A is true at posedge clock.

4. 连续重复次数,BOOL[*serval],[*min:max],min可以为0,max可以为无限大。

property EXAMPLE1
    @(posedge clock) A[*5] |=> A;
endproperty
a_example1: assert property(EXAMPLE1);

property EXAMPLE2
    @(posedge clock) A ##1 !A |-> !A[*2:5] ##1 A;
endproperty
a_example2: assert property(EXAMPLE2);

5. 不连续重复次数,BOOL[->serval];[->min:max],min可以为0,max可以为无限大。BOOL表达式在第serval次为TRUE,且在下一个sequence判断时,也是TRUE。

property EXAMPLE1
    @(posedge clock) A |=> B[->2] ##1 C;
endproperty
a_example1: assert property(EXAMPLE1);

property EXAMPLE2
    @(posedge clock) A |-> B[->2:5] ##1 C[->1:3];
endproperty
a_example2: assert property(EXAMPLE2);

6. 不连续重复次数,BOOL[=serval];[->min:max],min可以为0,max可以为无限大。BOOL表达式在第serval次为TRUE,且在下一个sequence判断时,可以不是TRUE。

property EXAMPLE1
    @(posedge clock) A |=> B[=2] ##1 C;
endproperty
a_example1: assert property(EXAMPLE1);

property EXAMPLE2
    @(posedge clock) A |-> B[=2:5] ##1 C[->1:3];
endproperty
a_example2: assert property(EXAMPLE2);

7. or

a_example1: assert(@(posedge clock) A |-> B or C);//hwen A is true, either of B or C is true, the result is true

8. not

sequence BC;
    B ##1 C;
endsequence;
property EXAMPLE1;
(posedge clock) A |-> not(BC);
endproperty
a_example1: assert property(EXAMPLE1);

 

9. $rose(BOOL),在当前的clock上升沿之前,判断是否检测到BOOL的上升沿,如果有,接着判断B。

property EXAMPLE1;
@(posedge clock) $rose(A) |-> B;
endproperty
a_example1: assert property(EXAMPLE1);

10. $fell(BOOL),在当前的clock上升沿之前,判断是否检测到BOOL的下降沿,如果有,接着判断B。

property EXAMPLE1;
@(posedge clock) $fell(A) |=> !B;
endproperty
a_example1: assert property(EXAMPLE1);

11. $stable(BOOL),BOOL与上一clcok的值比较,判断是否保持原值。

property EXAMPLE1;
@(posedge clock) !A |=> $stable(B);
endproperty
a_example1: assert property(EXAMPLE1);

12. $past(BOOL,serval),与BOOL的前serval clock的值比较,判断是否一致。

property EXAMPLE1;
@(posedge clock) !A |=> (B == $past(C,2));
endproperty
a_example1: assert property(EXAMPLE1);

13. $disable,disable iff(!A)是使能条件,第一条件是clock上升沿,第二条件是iff(!A),这个语句才有效,即如果A为0,才接着判断后面的sequence。

property EXAMPLE1;
@(posedge clock) disable iff(!A) B |=> C ##1 D ##2 E;
endproperty
a_example1: assert property(EXAMPLE1);

14. $onehot(BOOL),判断BOOL中的1的个数,非0时,assert成功。

property EXAMPLE1;
@(posedge clock) $onehot(A);
endproperty
a_example1: assert property(EXAMPLE1);

15. $onehot0,判断BOOL中的1的个数,不多于1个时,assert成功。

property EXAMPLE1;
@(posedge clock) $onehot(A);
endproperty
a_example1: assert property(EXAMPLE1);

16. countones,判断BOOL中的1的个数,等于相应的值时,assert成功。

property EXAMPLE1;
@(posedge clock) $countones(A)==2;
endproperty
a_example1: assert property(EXAMPLE1);

17. isunknown,判断是否有Z 、X态。

property EXAMPLE1;
@(posedge clock) $isunknown(A);
endproperty
a_example1: assert property(EXAMPLE1);

18. and,如下,B和C必须在同一时间为TRUE,不必同一时间为FALSE。

 
property EXAMPLE1;
(posedge clock) A |-> B and C;
endproperty
a_example1: assert property(EXAMPLE1);

19. intersect,如下,B和C必须在同一时间为TRUE,同一时间为FALSE。

 
property EXAMPLE1;
(posedge clock) A |-> B intersect C;
endproperty
a_example1: assert property(EXAMPLE1);

20. first_match()

property EXAMPLE1;
(posedge clock) first_match(A ##[1:2] |-> B intersect C);
endproperty
a_example1: assert property(EXAMPLE1);

21. within

sequence C;
   C ##1 !C;
endsequence
property EXAMPLE1;
(posedge clock) $rose(A) |=> C[*5] within !A[->1];
endproperty
a_example1: assert property(EXAMPLE1);

22. throughout

sequence C;
   C ##1 !C;
endsequence
property EXAMPLE1;
(posedge clock) $rose(A) |=> (B throughout C[*5]) ##1 !A;
endproperty
a_example1: assert property(EXAMPLE1);

23. if else

property EXAMPLE1;
(posedge clock) A ##1 (B || C)[->1] |-> 
if(B)
    (##1 D)
else 
    (##1 E);
endproperty
a_example1: assert property(EXAMPLE1);

24. .ended()

sequence ab;
    @(posedge clock) $fell(a) ##1 $rose(b);
endsequence
property EXAMPLE1;
(posedge clock) $rose(C) |-> AB(A,B).ended();
endproperty
a_example1: assert property(EXAMPLE1);

25. .matched()

sequence ab;
    @(posedge clock) $fell(a) ##1 $rose(b);
endsequence
property EXAMPLE1;
(posedge clock) $rose(C) |-> AB(A,B) |=> ((posedge clock1) AB(A,B).matched())[->1];
endproperty
a_example1: assert property(EXAMPLE1);

26. expect

sequence ABC1;
    A ##2 B ##2 C;
endsequence
property ABC2;
    @(posedge clock) A |=> ABC1;
endproperty

expect(@(posedge clock) (ABC1)); // PASS
expect(ABC2);                 ; // PASS
@(posedge clock) expect(ABC1)  ; // FAIL

 

 

 

 

  • 0
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值