Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
12747 Discussions

Instructions do not work with custom floatt

Altera_Forum
Honored Contributor II
1,323 Views

Hi Everybody!!! 

 

I created a custom instruction and it is not working for floating point. It worked only with integer value. I've used the macro that was defined in the Altera Manual: 

 

# define ALT_CI_TESTE_INST_N 0x00000000  

# define ALT_CI_TESTE_INST (A) __builtin_custom_fnf(ALT_CI_TESTE_INST_N, (A)) 

 

By the manual should be working. 

 

Excerpt from my test code 

 

# include <stdio.h> 

# include "system.HA" 

int main () 

float x = ALT_CI_TESTE_INST (0.0); 

printf ( "Value:% f", x); 

 

return 0; 

 

 

The following appears on the console: 

----------------- 

Value:  

----------------- 

 

 

If anyone can help me, please respond. I am Brazilian and I do not know English very well, then no doubt, explain again.  

 

Thank you!!!!
0 Kudos
1 Reply
Altera_Forum
Honored Contributor II
484 Views

Try this instead: 

 

float x = ALT_CI_TESTE_INST(0.0f); 

 

The 'f' tells the compiler to use a single precision value instead of double precision (default). There is also a flag you can pass to the compiler to tell it to treat all floating point constants as type 'float' instead of 'double' but I forget what to use (I don't recommend it either since you might accidentally break some code that needed to use double precision constants).
0 Kudos
Reply