基于参数的covergroup的多个实例

问题描述 投票:0回答:1

我想根据参数创建封面组的多个实例(最好使用不同的名称,以便相应地对每个实例进行采样)。然后我想使用 Sample() 函数对这些封面组进行采样。是否可以使用 for 循环创建它们?我尝试使用生成循环,但出现错误,因为覆盖收集器是基于类的覆盖而不是模块。

我想要的伪代码:

covergroup cg_unit(int i);
  coverpoint(signal[i])
  { bins xyz={1'b1}; }
endgroup

function new();
  for(int i=0;i<PARAM;i++)
  begin
    cg_unit[i] = new(i);      //It shouldn't necessarily be an array, but I want different names for each instance
  end
endfunction

...

task write();
   for(int i=0;i<PARAM;i++)
  begin
    cg_unit[i].sample();
  end
endtask
code-coverage system-verilog
1个回答
0
投票

每个 covergroup 都有一个

option.name
,您可以访问它,但我不建议编写它,因为每个组已经被唯一命名。您所要求的听起来像以下之一,但如果您已经为每个实例都有一个单独的覆盖收集器,那么问题就已经解决了。

// Declare covergroup inside class

class fcov_c #(parameter NUM);
  covergroup cg(string _comment);
    option.comment = _comment;
    // ...
  endgroup

  function new();
    cg = new($sformatf("MY COMMENT NUM: %0d", NUM));
  endfunction

endclass

class other_class_c;
  fcov_c#(1) cov1;
  fcov_c#(2) cov2;
  fcov_c#(4) cov4;

  function new();
    cov1 = new();
    cov2 = new();
    cov4 = new();
  endfunction
endclass

// Define covergroup outside class (but still in package)

covergroup cg(string _comment);
  option.comment = _comment;
  // ...
endgroup

class fcov_c #(parameter NUM);

  cg my_cg[NUM];

  function new();
    for (int idx=0; idx<NUM; idx++) begin
      my_cg[idx] = new($sformatf("MY COMMENT NUM: %0d", idx));
    end
  endfunction

endclass

仅供参考,这些示例都不需要从参数派生“_comment”

© www.soinside.com 2019 - 2024. All rights reserved.