wtr
Full Member level 5
Hello all,
See the following
The random number generator can do one random number, however when called again later in the sequence it does not generate a different number.
Is this because my seed is re-initialised each time?
If I externally change the seed in, then I can manipulate it accordingly. Is there a way I can somehow link the seed to the run time?
Regards,
Wes
See the following
Code VHDL - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 function get_slv_no (W : integer) return std_logic_vector is variable seed1 : positive ; variable seed2 : positive ; variable re1 : integer; variable re2 : real ; -- variable num : std_logic_vector (15 downto 0) ; variable num_t : std_logic_vector (W-1 downto 0) ; begin for I in 1 to W/16 loop uniform (seed1,seed2,re2); re1 := integer (re2 * real(2**16 -1)); num_t(16*I-1 downto 16*(I-1)) := std_logic_vector ( to_unsigned (re1,16)); end loop; return num_t; end function;
Code VHDL - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 test : process is begin wait for 10 ns; num32 <= get_slv_no(num32'length); wait for 10 ns; num64 <= get_slv_no(num64'length); wait for 10 ns; num512 <= get_slv_no(num512'length); wait for 10 ns; num512 <= get_slv_no(num512'length); wait for 10 ns; num512 <= get_slv_no(num512'length); wait for 10 ns; num32 <= (others => '0'); wait for 10 ns; num32 <= get_slv_no(num32'length); wait for 10 ns; num32 <= get_slv_no(num32'length); wait for 10 ns; report "" severity failure; end process;
The random number generator can do one random number, however when called again later in the sequence it does not generate a different number.
Is this because my seed is re-initialised each time?
If I externally change the seed in, then I can manipulate it accordingly. Is there a way I can somehow link the seed to the run time?
Regards,
Wes