If I use a blocking expression in the covergroup, do I need a sample directive from the previous code?

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

If I use a blocking expression in the covergroup, do I need a sample directive from the previous code?

问题

一个覆盖组(covergroup)可以从过程代码中的样本指令(如.sample())以及覆盖组内的阻塞表达式(例如@(clk)@(signal))触发。

如果在覆盖组中实现了一个阻塞表达式,是否需要一个样本指令.sample()

class func_cov extends uvm_subscriber #(seq_item);
  covergroup cg @(posedge clk);
    option.per_instance = 1; // 每个实例的覆盖
    option.auto_bin_max = 256; // 设置最大的 bin 数
    option.type_option = UVM_UNSIGNED; // 将覆盖类型设置为无符号
    option.weight = 1; // 设置覆盖权重
    // 向覆盖组添加覆盖点
    coverpoint req.addr {
      bins range[] = {0, 255, 512, 1023};
    }
    coverpoint req.data {
      bins data_range[] = {[0:255], [256:511], [512:767], [768:1023]};
    }
  endgroup

  function new(string name = "func_cov", uvm_component parent = null);
    super.new(name, parent);
  endfunction

  function void build_phase(uvm_phase phase);
    super.build_phase(phase);
    cg = new("cg", this);
  endfunction

  function void write(seq_item req);
    // 收集覆盖数据
    cg.sample();
  endfunction
endclass
英文:

A covergroup is triggered from a sample directive from procedural code such as .sample() and from a blocking expression within a covergroup such as @(clk) or @(signal).

If I implement a blocking expression in the covergroup, do I need a sample directive .sample()?

class func_cov extends uvm_subscriber #(seq_item);
  covergroup cg @(posedge clk);
    option.per_instance = 1; // Per instance coverage
    option.auto_bin_max = 256; // Set maximum number of bins
    option.type_option = UVM_UNSIGNED; // Set coverage type to unsigned
    option.weight = 1; // Set coverage weight
    // Add coverage points to the covergroup
    coverpoint req.addr {
      bins range[] = {0, 255, 512, 1023};
    }
    coverpoint req.data {
      bins data_range[] = {[0:255], [256:511], [512:767], [768:1023]};
    }
  endgroup

  function new(string name = "func_cov", uvm_component parent = null);
    super.new(name, parent);
  endfunction

  function void build_phase(uvm_phase phase);
    super.build_phase(phase);
    cg = new("cg", this);
  endfunction

  function void write(seq_item req);
    // Collect coverage data
    cg.sample();
  endfunction
endclass

答案1

得分: 1

不需要调用sample方法。在您的代码中,覆盖率在coverage_event上进行采样,即@(posedge clk)

请参考IEEE Std 1800-2017,第19.3节"定义覆盖模型:covergroup"。

英文:

> If I implement a blocking expression in the covergroup, do I need a
> sample directive .sample()?

No, you do not need to call the sample method. In your code, coverage is sampled at the coverage_event, which is @(posedge clk)

Refer to IEEE Std 1800-2017, section 19.3 Defining the coverage model: covergroup.

huangapple
  • 本文由 发表于 2023年3月7日 20:49:51
  • 转载请务必保留本文链接:https://go.coder-hub.com/75662192.html
匿名

发表评论

匿名网友

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

确定