I ran the below code with parameter value = 4, 8 and 16 , to know if there is a logic to determine how many times an item gets repeated in the distribution using the number of iterations and weight or is it always random.
Using value = 4, output : array = 1 3 3 0
*I was expecting item 0 to appear more times as its weight is more compared to item 3. Don’t know the reason why item 3 is distributed more.
Using value = 8, output : array = 1 3 3 0 0 2 3 0
Using value = 16, output : array = 1 3 3 0 0 2 3 0 0 2 1 2 3 3 1 3
From above outputs it seems like a random distribution. Let us say, I want item 0 to be distributed 10 times. Is there any mathematical formula or logic to get item 0 to be distributed 10 times ?
class mem_tx;
rand bit [1:0] burst;
constraint burst_dist_c {
burst dist {0:=10, 1:=3, 2:=5, 3:=8};
}
endclass
/////////////////
module top;
parameter value = 4;
mem_tx tx;
bit [1:0] arr [] = new[value];
initial begin
tx = new();
for(int i=0;i<value;i++) begin
assert(tx.randomize());
arr[i] = tx.burst;
end
$display("array = %0p", arr);
end
endmodule