Forum Discussion
3 Replies
- Altera_Forum
Honored Contributor
For simulation or on hardware?
- Altera_Forum
Honored Contributor
for simulation
- Altera_Forum
Honored Contributor
if 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:
Remember, this code cannot be synthesised into an FPGA.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) );