In reply to mhild7:
You can create queue of values that can be used as your bins if you use the right expression
module test();
parameter WIDTH = 8;
bit [WIDTH-1:0] sig;
typedef bit [WIDTH-1:0] bins_queue_t[$];
covergroup cg(ref bit [WIDTH-1:0] x, int maxVal, int minVal, int bin_cnt);
cp: coverpoint x {
bins custom_bins[] = bins_queue_compute(maxVal, minVal, bin_cnt);
}
endgroup
function automatic bins_queue_t bins_queue_compute (int maxVal, int minVal, int bin_cnt);
bins_queue_t bins_q;
int stepping;
stepping = (maxVal - minVal)/bin_cnt;
for(int i = minVal; i < maxVal; i+=stepping) begin
bins_q.push_back(i);
end
$display("bins_q = %p", bins_q);
return bins_q;
endfunction
initial begin
cg m_cg;
int upper;
int lower;
int num;
upper = 20;
lower = 5;
num = 5;
m_cg = new(sig, upper, lower, num);
repeat(10) begin
if(!std::randomize(sig) with {sig inside {[lower:upper]};}) $fatal(1, "Randomize Failed");
$display("sig = %p", sig);
m_cg.sample();
$display("m_cg coverage = %0g", m_cg.get_inst_coverage());
end
end
endmodule
HTH,
-R