Forum Discussion

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

floating point in quartus and nios

i wanted to add floating point in my sopc desgin.so I selected floating point hw in sopc builder.After compiling i wrote a code for floating point in nios ide.my code shown below.

# include <stdio.h># include <system.h># include <math.h># include "altera_avalon_timer_regs.h"# include "sys/alt_timestamp.h"# include "floating_point.h"# include <float.h>

int main()

{

float A = 32.223;

float B = 23.333;

float C_MUL1=0;

alt_u32 num_ticks = 0;

alt_u32 time1,time2;

if (alt_timestamp_start() < 0)

{

printf("Timer init failed \n");

}

else

{

printf("Floating point checking!\n\n");

time1 = alt_timestamp();

C_MUL1 = A*B;

time2 = alt_timestamp();

printf("C_MUL1= %f\n",C_MUL1);

printf("time1 is %u\n",time1);

printf("time2 is %u\n",time2);

}

return 0;

}

My qstion is whether my code is correct or not?Whether i needed to use custum instruction for accessing floating point?

regards,

Nasik
No RepliesBe the first to reply