Reply To: Patch: Support for random integer_vector

Why OSVVM™? Forums OSVVM Patch: Support for random integer_vector Reply To: Patch: Support for random integer_vector

#730
Jim Lewis
Member

Edit note:  12/31  Revised RandIntV unique parameter to be type natural rather than boolean.

I am looking at getting these into the 2013.12 or 2014.01 release.  @Trond, I cannot access your google code repository.  I have written my own versions.  What has me perplexed is how to handle generating a vector vs. a unique vector result.

My current RandIntV is:

```    impure function RandIntV (Min, Max : integer ; Unique : natural ; Size : natural) return integer_vector is
variable result : integer_vector(1 to Size) ;
begin
-- if Unique = 0, it is more efficient to call RandIntV(Min, Max, Size)
for i in result'range loop
result(i) := RandInt(Min, Max, result(maximum(1, 1 + i - Unique) to Size)) ;
end loop ;
return result ;
end function RandIntV ; ```

What bothers me is should it be one function with a parameter (perhaps optional) or should it be two separate functions, like RandIntV and RandIntVU (for unique).  Not really liking either one.
The problem as I see is that we need these for (min,max), (min,max,exclude), (vector) and (vector, exclude):

```    impure function RandIntV (Min, Max : integer; Size : natural) return integer_vector ;
impure function RandIntV (Min, Max : integer; Unique : natural; Size : natural) return integer_vector ;
impure function RandRealV (Min, Max : real; Size : natural) return real_vector ;

impure function RandIntV (Min, Max : integer; Exclude : integer_vector ; Size : natural) return integer_vector ;
impure function RandIntV (Min, Max : integer; Exclude : integer_vector ; Unique : natural; Size : natural) return integer_vector ;
-- no excludes for real vectors

impure function RandIntV (A : integer_vector ; Size : natural) return integer_vector ;
impure function RandIntV (A : integer_vector ; Unique : natural; Size : natural) return integer_vector ;
impure function RandRealV (A : real_vector ;   Size : natural) return real_vector ;

impure function RandIntV (A : integer_vector ; Exclude: integer_vector ; Size : natural) return integer_vector ;
impure function RandIntV (A : integer_vector ; Exclude: integer_vector ; Unique : natural; Size : natural) return integer_vector ;
-- no excludes for real vectors

```

Any input appreciated.

Jim