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++
12603 Discussions

floating point in quartus and nios

Altera_Forum
Honored Contributor II
1,094 Views

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
0 Kudos
0 Replies
Reply