Altera_Forum
Honored Contributor
15 years agoHow to write floating-point value to custom logic???
Hi all,
I worte a component which is using altfp_sqrt of megafunction, then I checked the simulation with avalon interface signal, it's match the timing and need 17 cycles. All configurations are set in sopc. BUT in nios, when I wrote the floating-point data using IOWR, the sqrt component did not compute. My code is under below # include <stdio.h># include <float.h># include <unistd.h># include "system.h" int main() { float data_in = 2.0; float ans; IOWR(SQRT_BASE, 0, data_in); //regnum = 0 is data_in usleep(1);//because 17 cycle delay ans = IORD(SQRT_BASE, 1); //regnum = 1 is calculate result printf("%f\n", ans); return 0; } The value will show 0.000000 If I change the data format such like this: unsigned in data_in = 0x40000000; //IEEE-754 format, equivalence 2.0 unsigned int ans; So, I can get the correct value, but the data type is NOT floating-point If I want to use custom logic to calculate floating-point in NIOS, how to solve this problem??? thanks all