Altera_Forum
Honored Contributor
11 years agoto_float() "right bound of range must be a constant" error
I'm using Quartus 7.2. When trying to compile this piece of code:
variable denum : integer;
variable num : integer;
variable dividend : float (4 downto -27);
...
begin
...
dividend := to_float(num) / to_float(denum);
...
end process;
I keep getting this error: "Error (10454): VHDL syntax error at float_pkg_c.vhdl(3840): right bound of range must be a constant" The line in question in float_pkg_c.vhdl is:
for I in fract'high downto maximum (fract'high - shift + 1, 0) loop
The variable fract is calculated based on the parameter fraction_width, which is 27 in my case, therefore a constant. However, the shift variable is calculated based on the arg parameter (basically, a log2 of the absolute value of arg), which is the num variable in my case, therefore not a constant. I tried several modifications to my code (e.g. initializing the num and denum variables) and the float_pkg_c.vhdl file itself (e.g. explicit casting to integer) to no avail. The only way I found to pass that line is to remove the shift variable from the loop, as this is practically of no interest because the obvious impact on functionality, it can serve as a starting point for solving the problem, I suppose. How can I cast a integer variable to float? I find it hard to believe that there is no way given that a package exists. Thanks in advance