UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Visitor gwendal.hays
Visitor
583 Views
Registered: ‎11-17-2017

Microblaze FPU conversion u32 to float error

Hi everyone,

 

I'm working with a Kintex7 evaluation board, in which a Microblaze is implemented.

 

After having trouble with conversion from u32 to float, I wrote a simple code that explains my problem :

 

u32 test0=2159;
float test1=(float)test0;
float test2=test0*1.0f;

Let's say my data is 2159 (u32 : 0x0000086F), but I want to things like sines and cosines, for which I want to work with floats.

I am supposed to have for test1 and test2 0x4506F000, which is the hex representation of 2159.0f.

 

When I run this code in debug, I get 3.025E-42, which is 0x0000086F read as a float. 

 

The strangest thing is that when I set the compiler to use -O1 optimization, the error doesn't exist anymore, and the values are correct for this code, but later in the program it comes back.

 

There are some of my microblaze's settings :

 

Capture.PNG

Capture.PNG

I had to change manually these settings in the compiler : (same for linker)

 

Capture.PNG

 

Ask for more informations if needed !

 

Thank you very much :)

0 Kudos
1 Reply
Visitor gwendal.hays
Visitor
520 Views
Registered: ‎11-17-2017

Re: Microblaze FPU conversion u32 to float error

After looking at the disassembly, it looks like the instruction "flt" (used for conversion form int to float by the FPU) does nothing.

 

Here is the disassembly : 

Capture.PNG

I can see that the value of the r6 register does not change when the flt instruction is run ...

 

Maybe it can help ?

0 Kudos