Forum Discussion
Altera_Forum
Honored Contributor
11 years agoif it is only for simulation, then you can use the uniform procedure from the math_real package. It generates random values in the range 0 - 1 that can then be used to scale other number. For example:
use ieee.math_real.all;
variable seed1, seed2 : positive;
variable rand : real;
variable rand_int : integer;
...
uniform(seed1, seed2, rand);
rand_int := integer( trunc(256 * rand) );
Remember, this code cannot be synthesised into an FPGA.