Switch the C source to fixed point
In VHDL, all signals should be in integer. So let's modify the C source to switch all variables from floating to fixed point.

(1) Type of integer in VC++
Type Bits Range
char 8 -128 to 128
short 16

-32,768 to 32,767

long 32

-2,147,483,648
to 2,147,483,647

int 32

-2,147,483,648
to 2,147,483,647

long long 64

-9,223,372,036
,854,775,808 to 9,223,372,036
,854,775,807

Note: this manner fits only in VC++.


(2) Why the range of input is only 32 ??

In 1024-point FFT, the result(spectrum) can be 1024 times bigger than the input. So that, if you want to have the output in [-32768, +32768), the input should be limited in [-32, +32).
(1) Change variables to integer
  • All variables are defined as "int" or "long long". (see CoffeeBreak 1)
  • Execute right-shift after multiplication.
(2) Execute fixed point FFT
  • FFT shows 6kHz in the spectrum.
  • The spectrum stays in the same shape after switching to fixed point.
(3) Inspect fixed point FFT
  • Magnitude of spectrum is 1,500.
  • Note the result becomes much bigger. (see CoffeeBreak 2)

Back


Top Page