首页 > 其他分享 >SystemVerilog -- 11.2 SystemVerilog Concurrent Assertions

SystemVerilog -- 11.2 SystemVerilog Concurrent Assertions

时间:2024-05-09 22:23:15浏览次数:20  
标签:failed clk -- PASS sv Concurrent testbench tb SystemVerilog

SystemVerilog Concurrent Assertions

Concurrent Assertions描述了跨越仿真时间的行为,并且仅在时钟边沿发生时进行评估。

SystemVerilog Concurrent Assertions语句可以在与其它语句同时运行的模块、接口或程序块中指定。以下是Concurrent Assertions的属性:

  • 根据采样变量中的值在时钟边沿评估测试表达式
  • 变量的采样是在预设区域完成的,表达式的评估是在仿真调度器的观察区域完成的
  • 它可以放置在过程、模块、接口或程序块中
  • 它可用于动态和形式验证技术

Example #1

两个信号ab在适中的正边沿声明和驱动,并具有一些随机值,以说明Concurrent Assertions的工作原理。Assertions由Immediate语句编写,该语句定义了时钟事件中信号之间的关系。assert property

在本例中,在整个仿真中,信号ab在时钟的正沿均应为高电平。对于发现ab为零的所有实例,Assertion预计会失败。

module tb;
  bit a, b;
  bit clk;

  always #10 clk = ~clk;

  initial begin
    for (int i = 0; i < 10; i++) begin
      @(posedge clk);
      a <= $ramdom;
      b <= $ramdom;
      $display ("[%0t] a=%0b b=%0b", $time, a, b);
    end
    #10 $finish;
  end

  // This assertion runs for entire duration of simulation
  // Ensure that both signals are high at posedge clk
  assert proerty (@(posedge clk) a & b);
endmodule

Assertion在clk的每个正边沿上执行,并使用预置区域中的变量值计算表达式,这是给定时钟边沿之前的增量周期。因此,如果时钟从0变为1的同一边沿上的a从0变为1,则用于Assertion的a的值将为零,因为它在时钟边沿之前为零。

可以看出,对于发现ab为零的所有情况,assertion都失败,因为语句中给出的表达式在整个模拟过程中都应为真。assert

Time (ns) a b Result
10 0 0 FAIL
30 0 1 FAIL
50 1 1 PASS
70 1 1 PASS
90 1 0 FAIL
110 1 1 PASS
130 0 1 FAIL
150 1 0 FAIL
170 1 0 FAIL
190 1 0 FAIL

模拟日志

Compiler version P-2019.06-1; Runtime version P-2019.06-1; Dec 11 15:26 2019
[10] a=0 b=0
"testbench.sv", 24; tb.unnamed$$_4: started at 10ns failed at 10ns
  Offending '(a & b)'
[30] a=0 b=1
"testbench.sv", 24; tb.unnamed$$_4: started at 30ns failed at 30ns
  Offending '(a & b)'
[50] a=1 b=1
[70] a=1 b=1
[90] a=1 b=0
"testbench.sv", 24; tb.unnamed$$_4: started at 90ns failed at 90ns
  Offending '(a & b)'
[110] a=1 b=1
[130] a=0 b=1
"testbench.sv", 24; tb.unnamed$$_4: started at 130ns failed at 130ns
  Offending '(a & b)'
[150] a=1 b=0
"testbench.sv", 24; tb.unnamed$$_4: started at 150ns failed at 150ns
  Offending '(a & b)'
[170] a=1 b=0
"testbench.sv", 24; tb.unnamed$$_4: started at 170ns failed at 170ns
  Offending '(a & b)'
[190] a=1 b=0
"testbench.sv", 24; tb.unnamed$$_4: started at 190ns failed at 190ns
  Offending '(a & b)'
$finish called from file "testbench.sv", line 14.
$finish at simulation time        200

Example #2

从上面的示例中,定义为语句属性的表达式被修改为 OR 条件。assert

module tb;
  bit a, b;
  bit clk;

  always #10 clk = ~clk;

  initial begin
    for (int i = 0; i < 10; i++) begin
      @(posedge clk);
      a <= $ramdom;
      b <= $ramdom;
      $display ("[%0t] a=%0b b=%0b", $time, a, b);
    end
    #10 $finish;
  end

  // This assertion runs for entire duration of simulation
  // Ensure that atleast 1 of the two signals is high on every clk
  assert proerty (@(posedge clk) a | b);
endmodule
Time (ns) a b Result
10 0 0 FAIL
30 0 1 PASS
50 1 1 PASS
70 1 1 PASS
90 1 0 PASS
110 1 1 PASS
130 0 1 PASS
150 1 0 PASS
170 1 0 PASS
190 1 0 PASS

模拟日志

Compiler version P-2019.06-1; Runtime version P-2019.06-1; Dec 11 15:26 2019
[10] a=0 b=0
"testbench.sv", 24; tb.unnamed$$_4: started at 10ns failed at 10ns
  Offending '(a | b)'
[30] a=0 b=1
[50] a=1 b=1
[70] a=1 b=1
[90] a=1 b=0
[110] a=1 b=1
[130] a=0 b=1
[150] a=1 b=0
[170] a=1 b=0
[190] a=1 b=0
$finish called from file "testbench.sv", line 14.

Example #3

定义为语句属性的表达式在否定“a”后从上例修改为XNOR条件。

module tb;
  bit a, b;
  bit clk;

  always #10 clk = ~clk;

  initial begin
    for (int i = 0; i < 10; i++) begin
      @(posedge clk);
      a <= $ramdom;
      b <= $ramdom;
      $display ("[%0t] a=%0b b=%0b", $time, a, b);
    end
    #10 $finish;
  end
endmodule
Time (ns) a b Expression !(a^b) Result
10 0 0 0 FAIL
30 0 1 1 PASS
50 1 1 0 FAIL
70 1 1 0 FAIL
90 1 0 1 PASS
110 1 1 0 FAIL
130 0 1 1 PASS
150 1 0 1 PASS
170 1 0 1 PASS
190 1 0 1 PASS

模拟日志

Compiler version P-2019.06-1; Runtime version P-2019.06-1; Dec 11 15:26 2019
[10] a=0 b=0
"testbench.sv", 24; tb.unnamed$$_4: started at 10ns failed at 10ns
  Offending '(!((!a)^b))'
[30] a=0 b=1
[50] a=1 b=1
"testbench.sv", 24; tb.unnamed$$_4: started at 50ns failed at 50ns
  Offending '(!((!a)^b))'
[70] a=1 b=1
"testbench.sv", 24; tb.unnamed$$_4: started at 70ns failed at 70ns
  Offending '(!((!a)^b))'
[90] a=1 b=0
[110] a=1 b=1
"testbench.sv", 24; tb.unnamed$$_4: started at 110ns failed at 110ns
  Offending '(!((!a)^b))'
[130] a=0 b=1
[150] a=1 b=0
[170] a=1 b=0
[190] a=1 b=0
$finish called from file "testbench.sv", line 14.
$finish at simulation time        200

标签:failed,clk,--,PASS,sv,Concurrent,testbench,tb,SystemVerilog
From: https://www.cnblogs.com/sys-123456/p/18181028

相关文章

  • 基于harris角点和RANSAC算法的图像拼接matlab仿真
    1.算法运行效果图预览   2.算法运行软件版本MATLAB2022a 3.算法理论概述      Harris角点检测是一种局部特征检测方法,它寻找图像中具有显著局部曲率变化的位置,即边缘转折点或角点。主要通过计算图像窗口内的自相关矩阵M,并对其特征值进行评估。Harris响应函......
  • 关于vue2自己得到的陈果(不懂的知识点)
    ref引用相关的知识点:ref='ruleRef'this.$refs.ruleRef.resetFields()        只针对表单的重置this,$refs.ruleRef.validate(valid=>{    这里validate是进行一次检验,参数是一个回调函数,valid是一个布尔值,表示表单的检验是否通过if(!valid)......
  • XML Schema(XSD)详解:定义 XML 文档结构合法性的完整指南
    XMLSchema描述了XML文档的结构。XMLSchema语言也称为XMLSchemaDefinition(XSD)。 <?xmlversion="1.0"?> <xs:schemaxmlns:xs="http://www.w3.org/2001/XMLSchema">   <xs:elementname="note"> <xs:compl......
  • Your Post Title Here
    VSCode实时预览还需要执行Markdown:OpenPreviewtotheSide命令来实现。在命令窗口输入Markdown:OpenPreviewtotheSide命令---#一级标题##二级标题###三级标题####四级标题#####五级标题######六级标题====创建脚注格式类似这样[^RUNOOB]。......
  • 图论-割点与割边
    这是摘自算法书上的一篇Tarjan求割点算法dfn[i]代表时间戳数组back[i]代表该点不依靠祖先节点能回到的最远的祖先节点采用链式前向星建图,结果存储在iscut[]数组中点击查看代码inthead[N],cnt=0;structEdge{intfrom,to,nxt;}e[N<<1];voidadd(......
  • 鸿蒙HarmonyOS实战-ArkUI事件(单一手势)
    ......
  • 2024.5 做题记录
    2023.5做题记录[Violet]天使玩偶显然发现我们需要在时间轴上进行cdq分治,然后统计答案。问题在于这个绝对值不好维护,需要进行转化。如果我们钦定这个点最近的点在它的左下方,那么绝对值就可以化为\(dis(A,B)=(A_x-B_x)+(A_y-B_y)=(A_x+A_y)-(B_x+B_y)\)。显然前面的括号是定......
  • m基于遗传优化的LDPC码NMS译码算法最优归一化参数计算和误码率matlab仿真
    1.算法仿真效果matlab2022a仿真结果如下: 遗传优化迭代过程:   误码率对比:     2.算法涉及理论知识概要       低密度奇偶校验码(Low-DensityParity-CheckCode,LDPC码)因其优越的纠错性能和近似香农极限的潜力,在现代通信系统中扮演着重要角色。......
  • TestMarkdown
    VSCode实时预览还需要执行Markdown:OpenPreviewtotheSide命令来实现。在命令窗口输入Markdown:OpenPreviewtotheSide命令---#一级标题##二级标题###三级标题####四级标题#####五级标题######六级标题====创建脚注格式类似这样[^RUNOOB]。......
  • .NET有哪些好用的定时任务调度框架
    .NET有哪些好用的定时任务调度框架前言定时任务调度的相关业务在日常工作开发中是一个十分常见的需求,经常有小伙伴们在技术群提问:有什么好用的定时任务调度框架推荐的?今天大姚给大家分享5个.NET开源、简单、易用、免费的任务调度框架,帮助大家在做定时任务调度框架技术选型的时候......