Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
15 years ago

floating point CI

Hello there,

i´ve included the "floating point ci" in the Design, and tried to use it in the software.

Current Code :


volatile float f, f1, f2, f3;
      
f1 = 1.9f;
f2 = 0.5f;
      
f = f1 * f2;
f = f1 + f2;
f = f1 - f2;
f = f1 / f2;
      
f3 = f;
Assembly code for f = f1 + f2:


0x00000290 <main+144>: ldw    r2,276(sp)
0x00000294 <main+148>: ldw    r3,280(sp)
0x00000298 <main+152>: custom 253,r2,r2,r3
0x0000029c <main+156>: stw    r2,272(sp)
Problem :

the result in f or f3 is always the same and wrong.

When i debug the assembly code then i see that the custom code is used but i can´t unterstand what´s wrong.

I hope somebody can help me.

Thanks

Tobias

Informations :

Service Pack Installed: 3

Help Version: Quartus II Help Version 7.2

1 Reply

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    I have the same problem here - consistant and WRONG values from each of the basic FP operations ONLY when the custom instruction is used. The results (as expected) are correct when the FP library is called instead. I followed the "Using NIOS II F-P Custom Instructions" Tutorial to update the SOPC and then applied the " -mcustom-fpu-cfg=60-2" flag for all of my compilation.

    Sure would like to see what is wrong here; must be a common issue, eh?

    Thanks all!