0

var_1从值 0 变为 1,然后从 1 变为 2,依此类推直到 15,但不是在连续的采样点上。我在每个时钟周期进行采样,但值可能会在一些任意clk周期后发生变化。我写的过渡覆盖不起作用。我们可以为这种情况编写转换覆盖吗?

bit [3:0] var_1;
    var1: coverpoint var_1  
    {
    bins var_1_trans_bin = (0=>1=>2=>3=>4=>5=>6=>7=>8=>9=>10=>11=>12=>13=>14=>15);
    bins var_1_bin[] = {[0:15]};
    }

我看到var_1_bin100% 被覆盖,但var_1_trans_bin.

这是整个代码:

module GRG_coverpoint;

  bit [3:0] var_1;
  bit Running;
  bit clk;

// Example showing bins and transitions
covergroup CG1 @(posedge clk);
  coverpoint var_1
  {
    bins var_1_trans_bin = (0=>1=>2=>3=>4=>5=>6=>7=>8=>9=>10=>11=>12=>13=>14=>15);
    bins var_1_bin[] = {[0:15]};
  }
endgroup

initial begin
  automatic CG1 cg1_inst = new;
  for (int j = 0; j < 16; j++)
  begin
    var_1 = j;
    #20;
  end
  $display ("CG1 Coverage = %.2f%%", cg1_inst.get_coverage());
  Running = 0;
end

initial begin
  clk = 0;
  Running = 1;
  while (Running) begin
    #5 clk = ~clk;
  end
  $display ("Finished!!");
end

endmodule
4

1 回答 1

0

正如您所意识到的,您不想在每个时钟周期对覆盖率进行采样。您只想在var_1更改值时对其进行采样。您可以声明covergroup没有可选的coverage_event(在您的情况下),然后在每次变量更改时在单独的程序块中@(posedge clk)调用该方法:sample

module GRG_coverpoint;

  bit [3:0] var_1;
  bit [3:0] var_2;
  bit Running;
  bit clk;

// Example showing bins and transitions
covergroup CG1;
  coverpoint var_1
  {
    bins var_1_trans_bin = (0=>1=>2=>3=>4=>5=>6=>7=>8=>9=>10=>11=>12=>13=>14=>15);
    bins var_1_bin[] = {[0:15]};
  }
endgroup

CG1 cg1_inst = new;

initial begin
    cg1_inst.sample(); // Sample the initial 0 value
    forever @(var_1) cg1_inst.sample();
end

initial begin
  for (int j = 0; j < 16; j++)
  begin
    var_1 = j;
    #20;
  end
  $display ("CG1 Coverage = %.2f%%", cg1_inst.get_coverage());
  Running = 0;
end

initial begin
  clk = 0;
  Running = 1;
  while (Running) begin
    #5 clk = ~clk;
  end
  $display ("Finished!!");
end

endmodule
于 2021-10-01T20:58:41.250 回答