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] 进行划分。
那么如何根据采样时间的变量值重用相同的覆盖点来生成动态范围呢?