Dear All,
Currently I'm learning the coverage. It's very powerful methods for verification I think.
But I'v got a problem that I'm trying to get a non-duplicated randomized value .
Here is the code.
class packet;
rand bit[4:0] img_index;
rand bit[31:0] crop_seed;
constraint const_img_index
{
(img_index >= 0 && img_index <= 4);javascript:void(0)
img_index dist {[0:4] :/ 1};
}
constraint const_crop_seed
{
crop_seed dist {[0:4] :/ 1};
}
covergroup img_src;
img_idx : coverpoint img_index {
bins b_0 = {32'h0};
bins b_1 = {32'h1};
bins b_2 = {32'h2};
bins b_3 = {32'h3};
}
crop_seed : coverpoint crop_seed {
bins b_0 = {32'h0};
bins b_1 = {32'h1};
bins b_2 = {32'h2};
bins b_3 = {32'h3};
}
CROSS: cross img_idx, crop_seed;
endgroup
endclass
module constr_dist;
initial begin
packet pkt;
pkt = new();
$display("------------------------------------");
foreach(pkt.img_index[i]) begin
pkt.randomize();
$display("\const_img_index = %0d",pkt.img_index);
end
$display("------------------------------------");
$display("------------------------------------");
end
endmodule
I got the duplicated randomized value from the codes the below.
------------------------------------
const_img_index = 1
const_img_index = 1
const_img_index = 0
const_img_index = 0
const_img_index = 0
------------------------------------
------------------------------------
1. How to get non-duplicate randomized values? I expected that
const_img_index has 5 values from 0 to 4. but the same value come out.
2. If all bins don't hit, I want to keep running randomize until all bins hits. Is there any possible way to get this method?
SIM: https://www.edaplayground.com/x/fc4N