02-15-2017 09:46 PM
HI there,
I have a design in System generator which outputs decimal values less than zero.
I have exported it as an IP core and i need to read those values from the memory using SDK.
when i read those values from memory they are only zeros.
Can someone help me to read those decimal values.? How can i do that?
Thanks in advance
shashi
02-26-2017 09:12 AM
Hi,
I have a reference C application.
This function convert IEE754 32-bit floating point format into decimal, for 64-bit just change some constants
function float2dec(fpin: std_logic_vector(31 downto 0)) return real is
constant xdiv: real := 2.0**23;
variable exp,mant: integer;
variable multexp,mantdec: real;
variable res: real;
begin
exp := conv_integer(fpin(30 downto 23)) - 127;
multexp := 2.0**exp;
mant := conv_integer('1' & fpin(22 downto 0));
mantdec := real(mant)/xdiv;
res := mantdec*multexp;
--check sign
if(fpin(31)='1')then
res := -res;
end if;
return(res);
end float2dec;
Regards
Praveen