【问题标题】:Dynamic Coverpoints in Coverage Systemverilog覆盖系统verilog中的动态覆盖点
【发布时间】:2015-06-04 18:54:42
【问题描述】:
class conf;
  typedef struct packed
  {
    int ns_size;
    int limit;
  } ns;

  int num_ns_supported;
  ns num_ns[];

  function new(input int s=5);     
    num_ns_supported = s;
    num_ns = new[s];
    foreach(num_ns[i])
    begin
      num_ns[i].ns_size = (1000 * (i+1));         
    end
  endfunction
endclass

class pac;
  int nsid=1;
  int slba;
endclass

class c;
  pac p;
  conf cfg;

  covergroup x;
    option.per_instance = 1;
    a : coverpoint p.slba
    {
      bins range[3] = {[32'h0000_0000 : cfg.num_ns[p.nsid-1].ns_size]};
    }
  endgroup

  function new(input conf ca);     
    p = new();
    cfg = ca;
    x = new();
  endfunction

  function void sample(input pac p1);
    p = p1;
    x.sample();
  endfunction
endclass

program p1;
  conf cfg = new(6);
  pac p = new();
  c co = new(cfg);

  initial
  begin
    p.nsid = 1;
    p.slba = 550;
    co.sample(p);
    p.nsid = 2;
    co.sample(p);
  end  
endprogram

在这段代码中,我需要使用与受尊重的 num_ns 结构相关联的范围来覆盖 slba。

但在这段代码中,范围将仅根据 num_ns[0] 进行划分。

那么如何根据采样时间的变量值重复使用相同的覆盖点来生成动态范围?

【问题讨论】:

    标签: system-verilog function-coverage questasim


    【解决方案1】:

    您所要求的无法完成,也没有任何意义。见https://verificationacademy.com/forums/coverage/how-get-values-different-bins-coverpoint

    【讨论】:

    • 好的,如果动态覆盖点是不可能的,那么有没有其他方法可以通过正常/固定覆盖点解决问题,因为我的覆盖范围中有这种情况?
    • 您将不得不解释您期望如何计算覆盖率,即如果您更改每个样本的 bin 结构,您希望如何实现 100% 的覆盖率?覆盖率应该起作用的方式是在模拟开始时设置一组箱,每个样本都命中一个箱。如果在模拟结束时所有 bin 都已命中,则您将获得该覆盖点的 100% 覆盖。试着用一个更小的例子解释你想做什么,显示每个样本会命中哪些 bin,并显示足够的样本来解释如何获得 100% 的覆盖率。
    • 这里我将尝试向您解释要求。 (1) 我想覆盖所有 num_ns 结构的 ns_size 字段的 3 个范围。 (2) 现在在这种情况下,num_ns 结构的数量是动态的,并作为新方法中的参数传递。所以我不能将不同的coverpoints用于相同的目的,因为我不知道需要多少个coverpoints......既然systemverilog中没有动态coverpoints,那么为了这个目的,我怎么能符合要求吗?
    • 现在对于覆盖点的采样,这里有几个例子。 (1) p.nsid = 1 和 p.slba = 550,那么与 num_ns[0] 结构相关的覆盖点的 range[2] 应该被命中,因为 num_ns[0].ns_size = 1000,所以 550 将在 range[ 2](中等范围)。 (2) p.nsid = 2 和 p.slba = 550,那么与 num_ns[1] 结构相关的覆盖点的 range[1] 应该被命中,因为 num_ns[1].ns_size = 2000。所以 550 将在 range[ 1](低范围)。 (3) 类似地,对于任何 p.slba,适当的 num_ns[p.nsid - 1].ns_size 范围应该会被命中。 ......
    • 好的,我想你需要做的是创建一个covergroup实例数组,每个num_ns元素一个。然后选择covergroup 元素以使用p.nsid 作为索引进行采样。关键是一旦你的类被构建并且 num_ns 的大小被定义,你就可以为你的覆盖组构建所有的 bin。构造一个covergroups数组有点困难,因为您必须在类之外声明covergroup并将您的coverpoint值作为示例参数传递。
    【解决方案2】:

    @dave_59 给出了这个问题的答案。但我只会用他的逻辑发布更新的代码。

    动态覆盖点是不可能的。所以这是另一个具有相同目的的解决方案,具有固定的覆盖点。

    class conf;
      typedef struct packed
      {
        int ns_size;
        int limit;
      } ns;
    
      int num_ns_supported;
      ns num_ns[];
    
      function new(input int s=5);     
        num_ns_supported = s;
        num_ns = new[s];
        foreach(num_ns[i])
        begin
          num_ns[i].ns_size = (1000 * (i+1));         
        end
      endfunction
    endclass
    
    class pac;
      int nsid=1;
      int slba;
    endclass
    
    covergroup x (int nsid, input conf cfg) with function sample(int slba);
    option.per_instance = 1;
      a : coverpoint slba
      {
        bins range[3] = {[32'h0000_0000 : cfg.num_ns[nsid].ns_size]};
      }
    endgroup
    
    class c;
      pac p;
      conf cfg;
      x cg[];
    
      function new(input conf ca);     
        p = new();
        cfg = ca;
        cg = new[cfg.num_ns_supported];
        foreach(cfg.num_ns[i])
          cg[i] = new(i, cfg);
      endfunction
    
      function void sample(input pac p1);
        p = p1;
        cg[p.nsid-1].sample(p.slba);
      endfunction
    endclass
    
    program p1;
      conf cfg = new(6);
      pac p = new();
      c co = new(cfg);
    
      initial
      begin
        p.nsid = 1;
        p.slba = 550;
        co.sample(p);
        p.nsid = 2;
        co.sample(p);
      end  
    endprogram
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-04-30
      • 2021-05-08
      • 2012-12-07
      • 2013-01-19
      • 1970-01-01
      • 2012-03-16
      • 2015-12-15
      相关资源
      最近更新 更多