Professional Documents
Culture Documents
The Fast Fourier Transform: (And DCT Too )
The Fast Fourier Transform: (And DCT Too )
Nimrod Peleg
Oct. 2002
1
Outline
• Introduce Fourier series and transforms
• Introduce Discrete Time Fourier Transforms,
(DTFT)
• Introduce Discrete Fourier Transforms (DFT)
• Consider operational complexity of DFT
• Deduce a radix-2 FFT algorithm
• Consider some implementation issues of FFTs
with DSPs
• Introduce the sliding FFT (SFFT) algorithm
2
The Frequency Domain
• The frequency domain does not carry any
information that is not in the time domain.
• The power in the frequency domain is that it is simply
another way of looking at signal information.
• Any operation or inspection done in one domain is
equally applicable to the other domain, except that
usually one domain makes a particular operation or
inspection much easier than in the other domain.
• frequency domain information is extremely important
and useful in signal processing.
3
3 Basic Representations for FT
• 1. An Exponential Form
4
The Fourier Series: Exponential Form
Im(Ck )
k tan 1
Re(Ck )
Again: Ck are Complex Numbers ! 7
The Trigonometric Form
Reminder:
xp (t )=A0 + AkCos(k 0t )+BkSin(k 0t )
e j e-j
k =1
A0
1
T p Tp
xp (t )dt = DC = Average value of xp (t ) Cos =
2
Ak = xp (t )Cos (k 0t )dt
e j -e-j
Sin =
Tp
Bk = xp (t )Sin(k 0t )dt
Tp
2j
All three forms are identical and are related using Euler’s identity:
e j Cos jSin
Thus, the coefficients of the different forms are related by:
2Ck Ak jBk ; C 0 = A0
Bk Im(Ck )
k tan 1 tan 1
Ak Re(Ck ) 8
The Fourier Transform 1/3
C ( )
d
2
z
x ( t ) e jt dt
1 d
Increase TP = Period Increases : No Repetition:
Tp 2 2
Discrete frequency variable becomes continuous: k 0
C ( )
2 x ( t )e dt
j t
d 10
The Fourier Transform 3/3
C ( )
We define: 2 X ( ) F{ x(t )
d
z z
1
X ( ) x ( t ) e jt dt x (t ) x ( ) e jt d
2
11
Signal Representation by Delta Function
Instead of a continuous signal we have a “collection of samples”:
13
Discrete Time Fourier Transform 2/3
Inverse
Inverse
1 1 Discrete
t
j( n )
Fourier x( t ) d x(n) d
j
x ( )e x ( )e
2 2 Time Fourier
Transform
Transform
e j 2 n cos(2 n) j sin(2 n) 1
16
1 result: Nyquist Sampling Rate
st
2/2
Ts
HTs
Ts BUT : Ts
H s
2
s =2 H
Ts 17
Practical DTFT
Take only N time domain samples
N 1
x () x ( n )e
n
j n
x ( ) x ( n )e
n0
j n
2k N 1
j 2 kn / N
x( ) x ( n) e k 0,1,2,..., N 1
N n0
18
The DFT
Since the only variable in 2k / N is k , the DTFT is written:
N 1
j 2 kn / N
x ( k ) x ( n) e k 0,1,2,..., N 1
n0
j 2 / N
Using the shorthand notation: WN e (Twiddle Factor)
19
Usage of DFT
• The DFT pair allows us to move between
the time and frequency domains while using
the DSP.
• The time domain sequence x[n] is discrete
and has spacing Ts, while the frequency
domain sequence X[k] is discrete and has
spacing 1/NT [Hz].
20
DFT Relationships
Time Domain Frequency Domain
X(n) |x(k)|
N Samples
N Samples
21
Practical Considerations
N 1
Standard DFT: X N (k ) xn (k )WNkn 0 k N 1
n 0
2 2
j( 2) j( )
Manipulating the twiddle factor W e
2
N
N
e N/ 2
WN / 2
N N
1 1
2 2
Xn (k ) x(2r )W Nrk 2 W Nk x( 2r 1)W Nrk 2
r 0 r 0
23
FFT complexity
N 1 N 1
2 2
xN (k ) x
r 0
( 2 r )W rk
N /2 W k
N x
r 0
( 2 r 1)W rk
N /2
For 1000 point FFT, 5002 + 5002 + 500 = 50,500 multiplications, saving
1,000,000 - 50,500 = 945,000 multiplications
24
Time Decimation
Splitting the original series into two is called decimation in time
Let us take a short series where N = 8
2 2
j k j 2k
W2k e 2 e 4 W22 k
Now our FFT becomes:
A ‘flow-diagram’ of it:
x(0)
+ +
W4 0
x(2) W 40
0
0
x(2) 2 X4(1)
1 2
j 4
W44 e 4 1 W40
x(1) 2 X4(2) 2
0 j 6
W46 e 4 1 W42
x(3) 2 3 X4(3)
28
The Butterfly
Twiddle Conversions
A Typical Butterfly
W40 = 1
x1 X1 X1 = x1 + WNk x2
W41 = -j
W42 = -1
x2 WNk X2 X2 = x1 – WNk x2
W43 = j
30
Bit-Reversal
• If we look at the inputs to the butterfly FFT, we can see
that the inputs are not in the same order as the output.
• To perform an FFT quickly, we need a method of
shuffling these input data addresses around to the
correct order.
• This can be done either by reversing the order of the
bits that make up the address of the data, or by pointer
manipulation (bit reversed addition).
• Many DSPs have special addressing modes that allow
them to automatically shuffle the data in the
background.
31
Bit-Reversal example
x(0) X4(0)
0
0
• To obtain the output
x(2) 2 X4(1) in ascending order
1
the input values must
2
x(1)
0
X4(2)
be loaded in the
x(3) 2 3 X4(3)
order: {0,2,1,3}
• for 512 or 1024 it is
much more
complicated...
32
8-point Bit-Reversal
• Consider a 3-bit address (8 possible locations).
• After starting at zero, we add half of the FFT
length at each address access with carrying from
left to right (!)
36