使用”with”而不是”iff”导致的功能覆盖问题

huangapple go评论65阅读模式
英文:

Functional coverage problem using with instead of iff

问题

覆盖率在使用 with 时不显示,但当我使用 iff 替代 with 时,它正常工作。 我做错了什么?

英文:
module tb;
  logic [1:0] a,b;
  logic sel;
  
  covergroup c;
    option.per_instance = 1;
    coverpoint a{
      wildcard bins a_={2'b??} with (sel);
    }
    coverpoint b{
      wildcard bins b_={2'b??} iff (!sel);
    }
  endgroup
    
    c ci;
    
    initial begin
      ci=new();
      repeat(10) begin
        a=$random;
        b=$random;
        sel=$random;
        $display("%d %d %d",a,b,sel);
        ci.sample();
        #1;
      end
    end
    
endmodule

Coverage is not showing when I am using with, but when I use iff in place of with, it's working. What I am doing wrong?

答案1

得分: 1

在VCS上运行您的代码时,我得到了一个有用的编译错误:

错误-[FCIWCS] 无效的'with'子句规范
tb.sv,第8行
tb,"a_cp"
在coverpoint bin上指定的'with'子句没有任何影响,是无效的;它应该至少包含一个'item'关键字的出现。
请移除或更正该子句并进行编译。

sel替换为item可以解决问题:

coverpoint a{
wildcard bins a_={2'b??} with (item);
}

然而,在Cadence的模拟器上运行代码仍会产生编译错误:

不支持通配符 bin 的'with'表达式。

使用iff更具可移植性。

英文:

When I run your code on VCS, I get a helpful compile error:

Error-[FCIWCS] Invalid 'with' clause specification
tb.sv, 8
tb, "a_cp"
  The 'with' clause specified on the coverpoint bin does not have any impact 
  and is invalid; it should contain at least one occurence of the 'item' 
  keyword.
  Please remove or correct the clause and compile

Replacing sel with item works:

coverpoint a{
  wildcard bins a_={2'b??} with (item);
}

However, running the code on Cadence's simulator still produces a compile error:

> with expression is not supported for wildcard bin.

Using iff is more portable.

答案2

得分: 1

在一个 bin 表达式中,with 子句在 covergroup 构建时被评估一次,确定了作为 coverpoint 一部分创建的 bin 值集合。由于在此时 sel 未初始化,因此不会为 coverpoint a 创建任何 bin。

在一个 bin 表达式中,iff 子句每次对 covergroup 进行采样时都会被评估,实际上它是一个样本使能表达式。它对创建的 bin 值的选择没有影响。

很可能使用 iff 会符合您的预期行为。

英文:

The with clause in a bin expression gets evaluated once at the point when the covergroup gets constructed and determines the set of which bin values that get created as part of a coverpoint. Since sel is uninitialized at that point, there are no bins created for coverpoint a.

The iff clause in a bin expression gets evaluated each time the covergroup gets sampled and is effectively a sample enable expression. It has no effect on the selection of bin values created.

Most likely using iff matches your intended behavior.

huangapple
  • 本文由 发表于 2023年4月7日 01:40:23
  • 转载请务必保留本文链接:https://go.coder-hub.com/75952333.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定