class disttest;// extends uvm_test;
rand bit [2:0] addr1;
task rcase();
randcase
6 : addr1 = 5 ;
4 : addr1 = 7 ;
endcase
endtask
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<20; ii++) begin
tc.randomize();
tc.rcase();
addr1q.push_back(tc.addr1);
end
res1 = addr1q.find(x) with (x>5);
res2 = addr1q.find(x) with (x<6);
$display("%p, %p",res1, res2);
end
endmodule
Results:
//10 iterations of for loop produced: '{7, 7, 7}, ‘{5, 5, 5, 5, 5, 5, 5}
//20 iterations of for loop produced:’{7, 7, 7, 7, 7, 7, 7, 7, 7}, '{5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5}
For 10 iterations: I expected 4 times the value 7 and 6 times the value 5
For 20 iterations: I expected 8 times value 7 and 12 times value 5.
Is the test expect incorrect?