cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
sai_shashi
Explorer
Explorer
2,252 Views
Registered: ‎07-25-2016

Reading decimal values from SDK

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

0 Kudos
Reply
1 Reply
pvenugo
Moderator
Moderator
2,113 Views
Registered: ‎07-31-2012

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


-------------------------------------------------------------------------
Don’t forget to reply, kudo, and accept as solution.
-------------------------------------------------------------------------
0 Kudos
Reply