0
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] 进行划分。

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

4

2 回答 2

2

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

于 2015-06-04T21:07:13.320 回答
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
于 2015-06-06T09:47:53.720 回答