Error in float_generic_pkg.to_float(sfixed)

Description The function float_pkg.to_float(sfixed) does not convert the minimum value correctly. For example, the value -1.0 as a sfixed(0 downto -15) would be x"8000". This should convert to a 32-bit float as x"BF800000". The erroneous value returned is x"B7800000".

The following code demonstrates the issue.

library ieee; use ieee.fixed_pkg.all; use ieee.float_pkg.all;

entity to_float_error is

end entity to_float_error;

architecture tb of to_float_error is

constant minus_one : real := -1.0; signal my_sfixed : sfixed(0 downto -15); signal correct_real : real; signal correct_real_from_float : real; signal error_real_from_float : real; signal correct_float : float32; signal error_float : float32;

begin -- architecture tb

main : process is begin -- process main

  -- convert -1.0 of type real to sfixed and to float
  my_sfixed     <= to_sfixed(minus_one, 0, -15);  -- x"8000"
  correct_float <= to_float(minus_one);  -- x"BF800000"
  wait for 1 ns;
  -- convert the sfixed value to float
  error_float   <= to_float(my_sfixed);  -- should also be x"BF80000" but is 
  wait for 1 ns;
  -- go back to real
  correct_real  <= to_real(my_sfixed);
  correct_real_from_float <= to_real(correct_float);
  error_real_from_float   <= to_real(error_float);
  wait for 1 ns;
  wait;

end process main;

end architecture tb;

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information