nsherwoo
Newbie level 2
Hey all,
Trying to get a random number between 0 and 15.
I'm trying to use Uniform and I'm getting this error:
"VHDL Unsupported Feature error at <location>: cannot synthesize non-constant real objects or values"
hitcheck: process(address, hit, hit_index)
variable tag_bits: std_logic_vector(5 downto 0);
variable seed1, seed2: positive:=42;
variable rand: real; <-----it's complaining about this variable.
variable int_rand: integer;
begin
UNIFORM(seed1, seed2, rand);
tag_bits := address(7 downto 2);
if tag_bits = tag_array(0) then
hit <= '1';
hit_index <= 0;
.....--lots of stuff
else
hit<= '0';
int_rand := INTEGER(TRUNC(rand*15.0));
hit_index <= int_rand;
end if;
end process;
Any help would be much appreciated.
I found a similar snippet of code here:
https://www.velocityreviews.com/forums/t22430-random-number-generator.html
(last reply is someone who like me is getting this error.
edit-
Sorry, I should mention I have these two lines much higher in my code.
use ieee.math_real.all; -- for UNIFORM, TRUNC
use ieee.numeric_std.all; -- for TO_UNSIGNED --Don't think I'm using this one.
Trying to get a random number between 0 and 15.
I'm trying to use Uniform and I'm getting this error:
"VHDL Unsupported Feature error at <location>: cannot synthesize non-constant real objects or values"
hitcheck: process(address, hit, hit_index)
variable tag_bits: std_logic_vector(5 downto 0);
variable seed1, seed2: positive:=42;
variable rand: real; <-----it's complaining about this variable.
variable int_rand: integer;
begin
UNIFORM(seed1, seed2, rand);
tag_bits := address(7 downto 2);
if tag_bits = tag_array(0) then
hit <= '1';
hit_index <= 0;
.....--lots of stuff
else
hit<= '0';
int_rand := INTEGER(TRUNC(rand*15.0));
hit_index <= int_rand;
end if;
end process;
Any help would be much appreciated.
I found a similar snippet of code here:
https://www.velocityreviews.com/forums/t22430-random-number-generator.html
(last reply is someone who like me is getting this error.
edit-
Sorry, I should mention I have these two lines much higher in my code.
use ieee.math_real.all; -- for UNIFORM, TRUNC
use ieee.numeric_std.all; -- for TO_UNSIGNED --Don't think I'm using this one.