Altera_Forum
Honored Contributor
12 years agoFloating point math
Hello,this would be my first real job with fpga, and because of that, i need some help.
Originally i was using STM32F4 to make single point DFT from 128 point array, but even at 250MHz it is too slow. C code looks like this (first creating coefficients in memory, so i can use very fast FMAC operation from memory) float sum_array(int* A) { int k = 0; float cos_fast[128]={0}; float sin_fast[128]={0}; while(k<128) { cos_fast[k]=cosf((6.28318531*k*6)/128); sin_fast[k] =sinf((6.28318531*k*6)/128); k++; } float real = 0; float imag = 0; for (k=0;k<128; k++) { real+=cos_fast[k]*A[k]; imag+=sin_fast[k]*A[k]; } return real,imag; } idea is to use like counter, but it couns by giving f32 number from memory or other place, than multiply that with 16b value from adc ( again, diferent types of data, should i just convert to number to f32 by adding zeros to sign and exponent, and use u16 bits to mantissa? ) After that i just sum each number to older number, and create output to my trusty STM32F4 with answer )