> procedure rand_time(

> variable seed1, seed2 : inout positive;

> min, max : in integer;

> result : out time

> ) is

> variable rand : real;

> begin

> uniform(seed1, seed2, rand);

> result := (integer(real(min) + (rand * (real(max)-real(min)) ) ))* 1

> ps;

> end procedure;
Another point: this function doesnt have the correct probability for

min and max occuring.

If n is the probability for any value occuring, the values of Min and

Max themselves have a probability of n/2. This is because the integer

conversion function rounds to nearest rather than truncate which means

min and max only have a 0-0.5 range each, rather than 0-1.0.

eg:

Min = 0, Max = 3.

result Actual output

before rounding

0.0-0.5 0

0.5-1.5 1

1.5-2.5 2

2.5-3.0 3

Therefore 1 and 2 are each twice as likely to occur than 0 and 3.

I have a very similar procedure for integers, and found the solution

to the problem thus (thanks to who posted the random testing package

the other week

):

procedure rand_int( variable seed1, seed2 : inout positive; min, max :

in integer; result : out integer) is

variable rand : real;

variable val_range : real;

begin

assert (max >= min) report "Rand_int: Range Error" severity Failure;

uniform(seed1, seed2, rand);

val_range := real(Max - Min + 1);

result := integer( trunc(rand * val_range )) + min;

end procedure;

This increases the