Forum Discussion
Altera_Forum
Honored Contributor
16 years agoInstructions do not work with custom floatt
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!!!!1 Reply
- Altera_Forum
Honored Contributor
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).