Forum Discussion
Altera_Forum
Honored Contributor
19 years agohelp about fft code.
:) when i do fft project whose code is download from altera.com, there is piece of code like following. i can not understand why there is " >> PRESCALE ", can you explain it to me TempReal...
Altera_Forum
Honored Contributor
19 years agoI'm not familiar with this specific piece of code, but it looks like a common technique for fixed-point arithmetic.
Rather than using floating point, which is very expensive in gate count, values between zero and one (like the sine and cosine) are expressed as fractions. For convenience, all fractions have powers of two in the denominator. Also, since the denominator is the same for all fractions, adding and subtracting can just ignore it and use only the numerator. In floating point, that code would be: tmp = cos * data + sinreal * data; Using fractions instead of floating point: tmp = (cosNumer/denom) * data + (sinnumer/denom) * data; or tmp = (cosNumer * data + sinnumer * data ) / denom; Since denom is a power of two of the form (1 << SCALE), tmp = (cosNumer * data + sinnumer * data ) >> SCALE;