class disttest;
rand bit [2:0] addr;
constraint c1 { addr dist {[0:5] := 6, [6:7] := 4}; }
covergroup cg (); //@(posedge clk);
coverpoint addr;
endgroup
endclass
module top();
bit clk;
int addrq[$], addr1q[$], res1[$], res2[$];
always #10 clk = ~clk;
initial begin
disttest tc;
tc = new();
for(int ii=0; ii<10; ii++) begin
tc.randomize();
addrq.push_back(tc.addr);
end
res1 = addrq.find(x) with (x>5);
res2 = addrq.find(x) with (x<6);
$display("%p, %p",res1, res2);
end
endmodule
Results:
//20 iterations of for loop produced: '{6, 7, 6, 6, 6}, '{4, 1, 2, 5, 2, 1, 0, 2, 3, 2, 3, 4, 0, 2, 5}
//10 iterations produced: '{6, 7, 6, 6, 6}, '{4, 1, 2, 5, 2}
I expected it to generate 6,7 values - 4 times and any value between 0-5 - 6 times.
Is the test expect wrong?