Probabilistic function in Verilog

Dear Dave,

I was trying to run the below code:

#########################################
module test;

integer y, i;

initial
begin
repeat(20)
begin
#10;
y = $dist_uniform($random,1,10);
end
end

endmodule
#################################

But my observation was the values generated were not uniform as per the definition.

Could you please explain the behavior of this function?

In reply to sush:

Above code will generate random value between 1 to 10 for each repeat count.
Can you explain more in detail.
Like what is your behavior and what you are looking for ?

Thanks,
Harsh

In reply to sush:

Hi Sush. You need to use a statistical test like Kolmogorov-Smirnov or Chi-squared to determine if a sample of numbers is consistent / inconsistent with a particular distribution. In addition, for the above code the sample size (20) is way too small to determine anything about the underlying distribution.

In reply to sush:

See Why dist constraint doesnt produce exact solution? | Verification Academy

Also, use $urandom and $urandom_range instead of $random and $dist_uniform. They have much better distributions.

In reply to dave_59:

Hi,

I got the output as mentioned below:

        8

6

8

1

3

8

6

1

1

3

2

5

3

5

9

9

9

5

8

6

I was expecting that the output to be like each random value will be generated for an equal no of times.