chapter 19 fast fourier transform (fft) (theory …galia.fc.uaslp.mx/~rmariela/rtdsp/fft.pdflearning...
TRANSCRIPT
Chapter 19Chapter 19Fast Fourier Transform (FFT)Fast Fourier Transform (FFT)
(Theory and Implementation)(Theory and Implementation)
Learning ObjectivesLearning Objectives
�� DFT algorithm.DFT algorithm.�� Conversion of DFT to FFT algorithm.Conversion of DFT to FFT algorithm.
�� Implementation of the FFT algorithm.Implementation of the FFT algorithm.
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004Chapter 19, Slide 2
DFT AlgorithmDFT Algorithm
�� The Fourier transform of an analogue The Fourier transform of an analogue signal x(t) is given by:signal x(t) is given by:
( ) ( )∫+∞
∞−
−= dtetxX tjωω
�� The Discrete Fourier Transform (DFT) of The Discrete Fourier Transform (DFT) of
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004Chapter 19, Slide 3
�� The Discrete Fourier Transform (DFT) of The Discrete Fourier Transform (DFT) of a discretea discrete--time signal x(nT) is given by:time signal x(nT) is given by:
�� Where:Where:
( ) [ ]∑−
=
−=
1
0
2N
n
nkN
jenxkX
π
( ) [ ]nxnTx
Nk
=−= 1,1,0 K
-1
0
1
2Sampled signal
Am
plitu
de
DFT AlgorithmDFT Algorithm
�� If we let:If we let:N
Nj
We =− π2
then:then: ( ) [ ]∑−
=
=1
0
N
n
nkNWnxkX
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004Chapter 19, Slide 4
0 20 40 60 80 100 120-2
-1
Sample
0 0.1 0.2 0.3 0.4 0.50
0.2
0.4
0.6
0.8
1Frequency Domain
Normalised Frequency
Mag
nitu
de
DFT AlgorithmDFT Algorithm
( ) [ ]∑−
=
=1
0
N
n
nkNWnxkX
X(0) X(0) = x[0]W= x[0]WNN00 + x[1]W+ x[1]WNN
0*10*1 +…+ x[N+…+ x[N--1]W1]WNN0*(N0*(N--1)1)
X(1) X(1) = x[0]W= x[0]WNN00 + x[1]W+ x[1]WNN
1*11*1 +…+ x[N+…+ x[N--1]W1]WNN1*(N1*(N--1)1)
::
x[n] x[n] = input= input
X[k] X[k] = frequency bins= frequency bins
WW = twiddle factors= twiddle factors
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004Chapter 19, Slide 5
::
X(k) X(k) = x[0]W= x[0]WNN00 + x[1]W+ x[1]WNN
k*1k*1 +…+ x[N+…+ x[N--1]W1]WNNk*(Nk*(N--1)1)
::
X(NX(N--1)1) = x[0]W= x[0]WNN00 + x[1]W+ x[1]WNN
(N(N--1)*11)*1 +…+ x[N+…+ x[N--1]W1]WNN(N(N--1)(N1)(N--1)1)
Note: For N samples of x we have N frequencies Note: For N samples of x we have N frequencies representing the signal.representing the signal.
Performance of the DFT AlgorithmPerformance of the DFT Algorithm
�� The DFT requires NThe DFT requires N2 2 (NxN) complex (NxN) complex multiplications: multiplications: �� Each X(k) requires N complex Each X(k) requires N complex
multiplications.multiplications.�� Therefore to evaluate all the values of the Therefore to evaluate all the values of the
DFT ( X(0) to X(NDFT ( X(0) to X(N--1) ) N1) ) N22 multiplications are multiplications are
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004Chapter 19, Slide 6
DFT ( X(0) to X(NDFT ( X(0) to X(N--1) ) N1) ) N22 multiplications are multiplications are required.required.
�� The DFT also requires (NThe DFT also requires (N--1)*N complex 1)*N complex additions:additions:�� Each X(k) requires NEach X(k) requires N--1 additions.1 additions.�� Therefore to evaluate all the values of the Therefore to evaluate all the values of the
DFT (NDFT (N--1)*N additions are required.1)*N additions are required.
Performance of the DFT AlgorithmPerformance of the DFT Algorithm
20
40
60
80
100
120
Num
ber
of M
ultip
licat
ions
20
40
60
80
100
120
Num
ber
of A
dditi
ons
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004Chapter 19, Slide 7
00 1 2 3 4 5 6 7 8 9 10
Number of Samples
Num
ber
of M
ultip
licat
ions
00 1 2 3 4 5 6 7 8 9 10
Number of Samples
�� Can the number of computations required Can the number of computations required be reduced?be reduced?
DFT DFT →→→→→→→→ FFTFFT
�� A large amount of work has been devoted A large amount of work has been devoted to reducing the computation time of a to reducing the computation time of a DFT.DFT.
�� This has led to efficient algorithms which This has led to efficient algorithms which are known as the Fast Fourier Transform are known as the Fast Fourier Transform (FFT) algorithms.(FFT) algorithms.
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004Chapter 19, Slide 8
(FFT) algorithms.(FFT) algorithms.
DFT DFT →→→→→→→→ FFTFFT
x[n] = x[0], x[1], …, x[Nx[n] = x[0], x[1], …, x[N--1]1]
( ) [ ] 10 ;1
0
−≤≤=∑−
=
NkWnxkXN
n
nkN [1][1]
�� Lets divide the sequence x[n] into even Lets divide the sequence x[n] into even and odd sequences:and odd sequences:
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004Chapter 19, Slide 9
and odd sequences:and odd sequences:�� x[2n] x[2n] = x[0], x[2], …, x[N= x[0], x[2], …, x[N--2]2]�� x[2n+1] x[2n+1] = x[1], x[3], …, x[N= x[1], x[3], …, x[N--1]1]
22 − ππ
( ) [ ] [ ] ( )∑∑−
=
+
−
=
++=1
2
0
12
12
0
2 122
N
n
knN
N
n
nkN WnxWnxkX
DFT DFT →→→→→→→→ FFTFFT
[2][2]
�� Equation 1 can be rewritten as:Equation 1 can be rewritten as:
�� Since:Since:
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004Chapter 19, Slide 10
nkN
nkN
jnkN
jnk
N
W
eeW
2
2
22
22
=
==−−
ππ
( ) nkN
kN
knN WWW
2
12 ⋅=+
( ) [ ] [ ]
( ) ( )kZWkY
WnxWWnxkX
kN
N
n
nkN
kN
N
n
nkN
+=
++= ∑∑−
=
−
=
12
0 2
12
0 2
122
�� Then:Then:
DFT DFT →→→→→→→→ FFTFFT
�� The result is that an NThe result is that an N--point DFT can be point DFT can be divided into two N/2 point DFT’s:divided into two N/2 point DFT’s:
( ) [ ] 10 ;1
0
−≤≤=∑−
=
NkWnxkXN
n
nkN NN--point DFTpoint DFT
Where Y(k) and Z(k) are the two N/2 Where Y(k) and Z(k) are the two N/2
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004Chapter 19, Slide 11
( ) [ ] [ ]
( ) ( )kZWkY
WnxWWnxkX
kN
N
n
nkN
kN
N
n
nkN
+=
+= ∑∑−
=
−
=
12
0 2
2
12
0 2
1
�� Where Y(k) and Z(k) are the two N/2 Where Y(k) and Z(k) are the two N/2 point DFTs operating on even and odd point DFTs operating on even and odd samples respectively:samples respectively:
Two N/2Two N/2--point DFTspoint DFTs
( ) [ ] [ ]∑∑−
=
−
=
+=1
2
0 2
2
12
0 2
1
N
n
nkN
kN
N
n
nkN WnxWWnxkX
M
DFT DFT →→→→→→→→ FFTFFT
�� PeriodicityPeriodicity and and symmetrysymmetry of W can be of W can be exploited to simplify the DFT further:exploited to simplify the DFT further:
[3][3]
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004Chapter 19, Slide 12
[ ] [ ]∑∑−
=
++
−
=
++=
+1
2
0
2
2
22
12
0
2
2
12
N
n
Nkn
N
Nk
N
N
n
Nkn
N WnxWWnxN
kX
Or:Or:
And:And:
kN
kN
jj
kN
jN
Njk
Nj
Nk
N WeeeeeW −=−===−−−−−+ π
ππππ 22
2
22
2
kN
kN
jN
Njk
NjN
k
N WeeeW2
2
2
22
2
2
2
2
2
===−−−+
πππ
: Symmetry: Symmetry
: Periodicity: Periodicity
DFT DFT →→→→→→→→ FFTFFT
�� Symmetry and periodicity:Symmetry and periodicity:
WW 0 0 ==WW 88WW 44
WW8866
WW8877WW88
55
WWNNk+N/2 k+N/2 == --WWNN
kk
WWN/2N/2k+N/2 k+N/2 ==WWN/2N/2
kk
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004Chapter 19, Slide 13
WW880 0 ==WW88
88
WW881 1 = W= W88
99
WW8822
WW8844
WW8833
WWN/2N/2 ==WWN/2N/2
WW88k+4 k+4 == --WW88
kk
WW88k+8 k+8 == WW88
kk
[ ] [ ]
( ) ( )kZWkY
WnxWWnxN
kX
k
N
n
nkN
kN
N
n
nkN
−=
−=
+ ∑∑−
=
−
=
12
0 2
2
12
0 2
12
DFT DFT →→→→→→→→ FFTFFT
�� Finally by exploiting the symmetry and Finally by exploiting the symmetry and periodicity, Equation 3 can be written as:periodicity, Equation 3 can be written as:
[4][4]
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004Chapter 19, Slide 14
( ) ( )kZWkY kN−=
( ) ( ) ( )
( ) ( )
−=−=
+
−=+=
12
,0 ;2
12
,0 ;
NkkZWkY
NkX
NkkZWkYkX
kN
kN
K
K
DFT DFT →→→→→→→→ FFTFFT
�� Y(k) and WY(k) and WNNk k Z(k) only need to be Z(k) only need to be
calculated once and used for both calculated once and used for both equations.equations.
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004Chapter 19, Slide 15
calculated once and used for both calculated once and used for both equations.equations.
�� Note: the calculation is reduced from 0 to Note: the calculation is reduced from 0 to NN--1 to 0 to (N/2 1 to 0 to (N/2 -- 1).1).
DFT DFT →→→→→→→→ FFTFFT
�� Y(k) and Z(k) can also be divided into N/4 Y(k) and Z(k) can also be divided into N/4 point DFTs using the same process shown point DFTs using the same process shown above:above:
( ) ( ) ( )
( ) ( )
−=−=
+
−=+=
12
,0 ;2
12
,0 ;
NkkZWkY
NkX
NkkZWkYkX
kN
kN
K
K
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004Chapter 19, Slide 16
point DFTs using the same process shown point DFTs using the same process shown above:above:
( ) ( ) ( )
( ) ( )kVWkUN
kY
kVWkUkY
kN
kN
2
2
4−=
+
+= ( ) ( ) ( )
( ) ( )kQWkPN
kZ
kQWkPkZ
kN
kN
2
2
4−=
+
+=
�� The process continues until we reach 2 The process continues until we reach 2 point DFTs.point DFTs.
DFT DFT →→→→→→→→ FFTFFT
y[0]y[0]y[1]y[1]y[2]y[2]
y[Ny[N--2]2]
N/2 point N/2 point DFTDFT
x[0]x[0]x[2]x[2]x[4]x[4]
x[Nx[N--2]2]
x[1]x[1]x[3]x[3]
z[0]z[0]z[1]z[1]
X[N/2] = y[0]X[N/2] = y[0]--WW00z[0]z[0]--11
X[0] = y[0]+WX[0] = y[0]+W 00z[0]z[0]
WW00 X[N/2+1] = y[1]X[N/2+1] = y[1]--WW11z[1]z[1]
X[1] = y[1]+WX[1] = y[1]+W 11z[1]z[1]
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004Chapter 19, Slide 17
�� Illustration of the first decimation in time Illustration of the first decimation in time FFT.FFT.
N/2 point N/2 point DFTDFT
x[3]x[3]x[5]x[5]
x[Nx[N--1]1]
z[1]z[1]z[2]z[2]
z[N/2z[N/2--1]1]
--11WW00 X[N/2+1] = y[1]X[N/2+1] = y[1]--WW11z[1]z[1]--11WW11
FFT ImplementationFFT Implementation
�� Calculation of the output of a ‘butterfly’:Calculation of the output of a ‘butterfly’:U’=UU’=U rr ’+jU’+jU ii ’ = X(k)’ = X(k)
L’=LL’=L rr ’+jL’+jL ii ’ = X(k+N/2)’ = X(k+N/2)
Y(k) = UY(k) = Urr +jU+jU ii
WWNNkkZ(k) =Z(k) = (L(L rr +jL+jL ii)(W)(Wrr +jW+jW ii))
--11
Key:Key: U = UpperU = Upper r = realr = real
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004Chapter 19, Slide 18
�� Different methods are available for Different methods are available for calculating the outputs U’ and L’.calculating the outputs U’ and L’.
�� The best method is the one with the least The best method is the one with the least number of multiplications and additions.number of multiplications and additions.
Key:Key: U = UpperU = Upper r = realr = real
L = LowerL = Lower i = imaginaryi = imaginary
FFT ImplementationFFT Implementation
�� Calculation of the output of a ‘butterfly’:Calculation of the output of a ‘butterfly’:U’=UU’=U rr ’+jU’+jU ii ’’
L’=LL’=L rr ’+jL’+jL ii ’’
UUrr +jU+jU ii
(L(L rr +jL+jL ii)(W)(Wrr +jW+jW ii))--11
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004Chapter 19, Slide 19
( )( ) iiriirrririr WLWjLWjLWLjWWjLL −++=++
( ) ( )[ ] [ ]( ) ( )iriirriirr
irriiriirr
UWLWLjUWLWL
jUUWLWLjWLWLU
++++−=++++−=′
( ) ( ) ( )[ ]( ) ( )riiriiirrr
riiriirrir
WLWLUjWLWLU
WLWLjWLWLjUUL
−−++−=++−−+=′
FFT ImplementationFFT Implementation
�� Calculation of the output of a ‘butterfly’:Calculation of the output of a ‘butterfly’:
�� To further minimise the number of To further minimise the number of operations (* and +), the following are operations (* and +), the following are
U’=UU’=U rr ’+jU’+jU ii ’ = (L’ = (L r r WWr r -- LL i i WWi i + U+ Urr )+j(L)+j(L r r WWi i + L+ L i i WWr r + U+ Uii))
L’=LL’=L rr ’+jL’+jL ii ’ = (U’ = (Ur r -- LL r r WWr r + L+ L i i WWii)+j(U)+j(U i i -- LL r r WWi i -- LL i i WWrr ))
UUrr +jU+jU ii
(L(L rr +jL+jL ii)(W)(Wrr +jW+jW ii))--11
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004Chapter 19, Slide 20
operations (* and +), the following are operations (* and +), the following are calculated only once:calculated only once:temp1 = Ltemp1 = Lrr WWrr temp2 = Ltemp2 = LiiWWii temp3 = Ltemp3 = Lrr WWii temp4 = Ltemp4 = LiiWWrr
temp1_2 = temp1 temp1_2 = temp1 -- temp2temp2 temp3_4 = temp3 + temp4temp3_4 = temp3 + temp4
UUrr ’ ’ = temp1 = temp1 -- temp2 + Utemp2 + Urr = temp1_2 + U= temp1_2 + Urr
UUii ’ ’ = temp3 + temp4 + U= temp3 + temp4 + Uii = temp3_4 + U= temp3_4 + Uii
LL rr ’ ’ = U= U rr -- temp1 + temp2 temp1 + temp2 = U= Urr -- temp1_2temp1_2
LL ii ’ ’ = U= U ii -- temp3 temp3 -- temp4 temp4 = U= Uii -- temp3_4temp3_4
FFT Implementation (Butterfly Calculation)FFT Implementation (Butterfly Calculation)
�� Converting the butterfly calculation into Converting the butterfly calculation into ‘C’ code:‘C’ code:
temp1 = (y[lower].real * WR);temp1 = (y[lower].real * WR);
temp2 = (y[lower].imag * WI);temp2 = (y[lower].imag * WI);
temp3 = (y[lower].real * WI);temp3 = (y[lower].real * WI);
temp4 = (y[lower].imag * WR);temp4 = (y[lower].imag * WR);
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004Chapter 19, Slide 21
temp1_2 = temp1 temp1_2 = temp1 -- temp2;temp2;
temp3_4 = temp 3 + temp4;temp3_4 = temp 3 + temp4;
y[upper].real = temp1_2 + y[upper].real;y[upper].real = temp1_2 + y[upper].real;
y[upper].imag = temp3_4 + y[upper].imag;y[upper].imag = temp3_4 + y[upper].imag;
y[lower].imag = y[upper].imag y[lower].imag = y[upper].imag -- temp3_4;temp3_4;
y[lower].real = y[upper].real y[lower].real = y[upper].real -- temp1_2;temp1_2;
FFT ImplementationFFT Implementation
�� To efficiently implement the FFT To efficiently implement the FFT algorithm a few observations are made:algorithm a few observations are made:�� Each stage has the same number of Each stage has the same number of
butterflies (number of butterflies = N/2, N is butterflies (number of butterflies = N/2, N is number of points).number of points).
�� The number of DFT groups per stage is equal The number of DFT groups per stage is equal
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004Chapter 19, Slide 22
�� The number of DFT groups per stage is equal The number of DFT groups per stage is equal to (N/2to (N/2stagestage).).
�� The difference between the upper and lower The difference between the upper and lower leg is equal to 2leg is equal to 2stagestage--11..
�� The number of butterflies in the group is The number of butterflies in the group is equal to 2equal to 2stagestage--11..
FFT ImplementationFFT Implementation
WW00 --11
WW00 --11
WW --11
WW22 --11
--11WW00
WW00 --11
Example: 8 point FFTExample: 8 point FFT
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004Chapter 19, Slide 23
WW00 --11
WW00 --11
WW00
WW22 --11
--11WW00
WW11 --11
WW33 --11
--11WW22
�� Decimation in time FFT:Decimation in time FFT:�� Number of stages = logNumber of stages = log22NN�� Number of blocks/stage = N/2Number of blocks/stage = N/2stagestage
�� Number of butterflies/block = 2Number of butterflies/block = 2stagestage--11
FFT ImplementationFFT Implementation
WW00 --11
WW00 --11
WW --11
WW22 --11
--11WW00
WW00 --11
Example: 8 point FFTExample: 8 point FFT(1)(1) Number of stages:Number of stages:
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004Chapter 19, Slide 24
WW00 --11
WW00 --11
WW00
WW22 --11
--11WW00
WW11 --11
WW33 --11
--11WW22
�� Decimation in time FFT:Decimation in time FFT:�� Number of stages = logNumber of stages = log22NN�� Number of blocks/stage = N/2Number of blocks/stage = N/2stagestage
�� Number of butterflies/block = 2Number of butterflies/block = 2stagestage--11
FFT ImplementationFFT Implementation
WW00 --11
WW00 --11
WW --11
WW22 --11
--11WW00
WW00 --11
Example: 8 point FFTExample: 8 point FFT(1)(1) Number of stages:Number of stages:
�� NNstagesstages= 1= 1
Stage 1Stage 1
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004Chapter 19, Slide 25
WW00 --11
WW00 --11
WW00
WW22 --11
--11WW00
WW11 --11
WW33 --11
--11WW22
�� Decimation in time FFT:Decimation in time FFT:�� Number of stages = logNumber of stages = log22NN�� Number of blocks/stage = N/2Number of blocks/stage = N/2stagestage
�� Number of butterflies/block = 2Number of butterflies/block = 2stagestage--11
Example: 8 point FFTExample: 8 point FFT(1)(1) Number of stages:Number of stages:
�� NNstagesstages= 2= 2
FFT ImplementationFFT Implementation
WW00 --11
WW00 --11
WW --11
WW22 --11
--11WW00
WW00 --11
Stage 2Stage 2Stage 1Stage 1
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004Chapter 19, Slide 26
WW00 --11
WW00 --11
WW00
WW22 --11
--11WW00
WW11 --11
WW33 --11
--11WW22
�� Decimation in time FFT:Decimation in time FFT:�� Number of stages = logNumber of stages = log22NN�� Number of blocks/stage = N/2Number of blocks/stage = N/2stagestage
�� Number of butterflies/block = 2Number of butterflies/block = 2stagestage--11
Example: 8 point FFTExample: 8 point FFT(1)(1) Number of stages:Number of stages:
�� NNstagesstages= 3= 3
FFT ImplementationFFT Implementation
WW00 --11
WW00 --11
WW --11
WW22 --11
--11WW00
WW00 --11
Stage 2Stage 2 Stage 3Stage 3Stage 1Stage 1
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004Chapter 19, Slide 27
WW00 --11
WW00 --11
WW00
WW22 --11
--11WW00
WW11 --11
WW33 --11
--11WW22
�� Decimation in time FFT:Decimation in time FFT:�� Number of stages = logNumber of stages = log22NN�� Number of blocks/stage = N/2Number of blocks/stage = N/2stagestage
�� Number of butterflies/block = 2Number of butterflies/block = 2stagestage--11
Example: 8 point FFTExample: 8 point FFT(1)(1) Number of stages:Number of stages:
�� NNstagesstages= 3= 3(2)(2) Blocks/stage:Blocks/stage:
�� Stage 1:Stage 1:
FFT ImplementationFFT Implementation
WW00 --11
WW00 --11
WW --11
WW22 --11
--11WW00
WW00 --11
Stage 2Stage 2 Stage 3Stage 3Stage 1Stage 1
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004Chapter 19, Slide 28
WW00 --11
WW00 --11
WW00
WW22 --11
--11WW00
WW11 --11
WW33 --11
--11WW22
�� Decimation in time FFT:Decimation in time FFT:�� Number of stages = logNumber of stages = log22NN�� Number of blocks/stage = N/2Number of blocks/stage = N/2stagestage
�� Number of butterflies/block = 2Number of butterflies/block = 2stagestage--11
Example: 8 point FFTExample: 8 point FFT(1)(1) Number of stages:Number of stages:
�� NNstagesstages= 3= 3(2)(2) Blocks/stage:Blocks/stage:
�� Stage 1: NStage 1: Nblocksblocks = 1= 1
FFT ImplementationFFT Implementation
WW00 --11
WW00 --11
WW --11
WW22 --11
--11WW00
WW00 --11
Stage 2Stage 2 Stage 3Stage 3Stage 1Stage 1
Block 1Block 1
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004Chapter 19, Slide 29
WW00 --11
WW00 --11
WW00
WW22 --11
--11WW00
WW11 --11
WW33 --11
--11WW22
�� Decimation in time FFT:Decimation in time FFT:�� Number of stages = logNumber of stages = log22NN�� Number of blocks/stage = N/2Number of blocks/stage = N/2stagestage
�� Number of butterflies/block = 2Number of butterflies/block = 2stagestage--11
Example: 8 point FFTExample: 8 point FFT(1)(1) Number of stages:Number of stages:
�� NNstagesstages= 3= 3(2)(2) Blocks/stage:Blocks/stage:
�� Stage 1: NStage 1: Nblocksblocks = 2= 2
FFT ImplementationFFT Implementation
WW00 --11
WW00 --11
WW --11
WW22 --11
--11WW00
WW00 --11
Stage 2Stage 2 Stage 3Stage 3Stage 1Stage 1
Block 1Block 1
Block 2Block 2
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004Chapter 19, Slide 30
WW00 --11
WW00 --11
WW00
WW22 --11
--11WW00
WW11 --11
WW33 --11
--11WW22
�� Decimation in time FFT:Decimation in time FFT:�� Number of stages = logNumber of stages = log22NN�� Number of blocks/stage = N/2Number of blocks/stage = N/2stagestage
�� Number of butterflies/block = 2Number of butterflies/block = 2stagestage--11
Example: 8 point FFTExample: 8 point FFT(1)(1) Number of stages:Number of stages:
�� NNstagesstages= 3= 3(2)(2) Blocks/stage:Blocks/stage:
�� Stage 1: NStage 1: Nblocksblocks = 3= 3
FFT ImplementationFFT Implementation
WW00 --11
WW00 --11
WW --11
WW22 --11
--11WW00
WW00 --11
Stage 2Stage 2 Stage 3Stage 3Stage 1Stage 1
Block 1Block 1
Block 2Block 2
Block 3Block 3
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004Chapter 19, Slide 31
WW00 --11
WW00 --11
WW00
WW22 --11
--11WW00
WW11 --11
WW33 --11
--11WW22
�� Decimation in time FFT:Decimation in time FFT:�� Number of stages = logNumber of stages = log22NN�� Number of blocks/stage = N/2Number of blocks/stage = N/2stagestage
�� Number of butterflies/block = 2Number of butterflies/block = 2stagestage--11
Example: 8 point FFTExample: 8 point FFT(1)(1) Number of stages:Number of stages:
�� NNstagesstages= 3= 3(2)(2) Blocks/stage:Blocks/stage:
�� Stage 1: NStage 1: Nblocksblocks = 4= 4
FFT ImplementationFFT Implementation
WW00 --11
WW00 --11
WW --11
WW22 --11
--11WW00
WW00 --11
Stage 2Stage 2 Stage 3Stage 3Stage 1Stage 1
Block 1Block 1
Block 2Block 2
Block 3Block 3
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004Chapter 19, Slide 32
WW00 --11
WW00 --11
WW00
WW22 --11
--11WW00
WW11 --11
WW33 --11
--11WW22
�� Decimation in time FFT:Decimation in time FFT:�� Number of stages = logNumber of stages = log22NN�� Number of blocks/stage = N/2Number of blocks/stage = N/2stagestage
�� Number of butterflies/block = 2Number of butterflies/block = 2stagestage--11
Block 4Block 4
Example: 8 point FFTExample: 8 point FFT(1)(1) Number of stages:Number of stages:
�� NNstagesstages= 3= 3(2)(2) Blocks/stage:Blocks/stage:
�� Stage 1: NStage 1: Nblocksblocks = 4= 4�� Stage 2: NStage 2: Nblocksblocks = 1= 1
FFT ImplementationFFT Implementation
WW00 --11
WW00 --11
WW --11
WW22 --11
--11WW00
WW00 --11
Stage 2Stage 2 Stage 3Stage 3Stage 1Stage 1
Block 1Block 1
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004Chapter 19, Slide 33
WW00 --11
WW00 --11
WW00
WW22 --11
--11WW00
WW11 --11
WW33 --11
--11WW22
�� Decimation in time FFT:Decimation in time FFT:�� Number of stages = logNumber of stages = log22NN�� Number of blocks/stage = N/2Number of blocks/stage = N/2stagestage
�� Number of butterflies/block = 2Number of butterflies/block = 2stagestage--11
Example: 8 point FFTExample: 8 point FFT(1)(1) Number of stages:Number of stages:
�� NNstagesstages= 3= 3(2)(2) Blocks/stage:Blocks/stage:
�� Stage 1: NStage 1: Nblocksblocks = 4= 4�� Stage 2: NStage 2: Nblocksblocks = 2= 2
FFT ImplementationFFT Implementation
WW00 --11
WW00 --11
WW --11
WW22 --11
--11WW00
WW00 --11
Stage 2Stage 2 Stage 3Stage 3Stage 1Stage 1
Block 1Block 1
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004Chapter 19, Slide 34
WW00 --11
WW00 --11
WW00
WW22 --11
--11WW00
WW11 --11
WW33 --11
--11WW22
�� Decimation in time FFT:Decimation in time FFT:�� Number of stages = logNumber of stages = log22NN�� Number of blocks/stage = N/2Number of blocks/stage = N/2stagestage
�� Number of butterflies/block = 2Number of butterflies/block = 2stagestage--11
Block 2Block 2
Example: 8 point FFTExample: 8 point FFT(1)(1) Number of stages:Number of stages:
�� NNstagesstages= 3= 3(2)(2) Blocks/stage:Blocks/stage:
�� Stage 1: NStage 1: Nblocksblocks = 4= 4�� Stage 2: NStage 2: Nblocksblocks = 2= 2
FFT ImplementationFFT Implementation
WW00 --11
WW00 --11
WW --11
WW22 --11
--11WW00
WW00 --11
Stage 2Stage 2 Stage 3Stage 3Stage 1Stage 1
Block 1Block 1
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004Chapter 19, Slide 35
�� Stage 3: NStage 3: Nblocksblocks = 1= 1WW00 --11
WW00 --11
WW00
WW22 --11
--11WW00
WW11 --11
WW33 --11
--11WW22
�� Decimation in time FFT:Decimation in time FFT:�� Number of stages = logNumber of stages = log22NN�� Number of blocks/stage = N/2Number of blocks/stage = N/2stagestage
�� Number of butterflies/block = 2Number of butterflies/block = 2stagestage--11
Example: 8 point FFTExample: 8 point FFT(1)(1) Number of stages:Number of stages:
�� NNstagesstages= 3= 3(2)(2) Blocks/stage:Blocks/stage:
�� Stage 1: NStage 1: Nblocksblocks = 4= 4�� Stage 2: NStage 2: Nblocksblocks = 2= 2
FFT ImplementationFFT Implementation
WW00 --11
WW00 --11
WW --11
WW22 --11
--11WW00
WW00 --11
Stage 2Stage 2 Stage 3Stage 3Stage 1Stage 1
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004Chapter 19, Slide 36
�� Stage 3: NStage 3: Nblocksblocks = 1= 1(3)(3) B’flies/block:B’flies/block:
�� Stage 1:Stage 1:
WW00 --11
WW00 --11
WW00
WW22 --11
--11WW00
WW11 --11
WW33 --11
--11WW22
�� Decimation in time FFT:Decimation in time FFT:�� Number of stages = logNumber of stages = log22NN�� Number of blocks/stage = N/2Number of blocks/stage = N/2stagestage
�� Number of butterflies/block = 2Number of butterflies/block = 2stagestage--11
Example: 8 point FFTExample: 8 point FFT(1)(1) Number of stages:Number of stages:
�� NNstagesstages= 3= 3(2)(2) Blocks/stage:Blocks/stage:
�� Stage 1: NStage 1: Nblocksblocks = 4= 4�� Stage 2: NStage 2: Nblocksblocks = 2= 2
FFT ImplementationFFT Implementation
WW00 --11
WW00 --11
WW --11
WW22 --11
--11WW00
WW00 --11
Stage 2Stage 2 Stage 3Stage 3Stage 1Stage 1
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004Chapter 19, Slide 37
�� Stage 3: NStage 3: Nblocksblocks = 1= 1(3)(3) B’flies/block:B’flies/block:
�� Stage 1: NStage 1: Nbtfbtf = 1= 1
WW00 --11
WW00 --11
WW00
WW22 --11
--11WW00
WW11 --11
WW33 --11
--11WW22
�� Decimation in time FFT:Decimation in time FFT:�� Number of stages = logNumber of stages = log22NN�� Number of blocks/stage = N/2Number of blocks/stage = N/2stagestage
�� Number of butterflies/block = 2Number of butterflies/block = 2stagestage--11
Example: 8 point FFTExample: 8 point FFT(1)(1) Number of stages:Number of stages:
�� NNstagesstages= 3= 3(2)(2) Blocks/stage:Blocks/stage:
�� Stage 1: NStage 1: Nblocksblocks = 4= 4�� Stage 2: NStage 2: Nblocksblocks = 2= 2
FFT ImplementationFFT Implementation
WW00 --11
WW00 --11
WW --11
WW22 --11
--11WW00
WW00 --11
Stage 2Stage 2 Stage 3Stage 3Stage 1Stage 1
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004Chapter 19, Slide 38
�� Stage 3: NStage 3: Nblocksblocks = 1= 1(3)(3) B’flies/block:B’flies/block:
�� Stage 1: NStage 1: Nbtfbtf = 1= 1�� Stage 2: NStage 2: Nbtfbtf = 1= 1
WW00 --11
WW00 --11
WW00
WW22 --11
--11WW00
WW11 --11
WW33 --11
--11WW22
�� Decimation in time FFT:Decimation in time FFT:�� Number of stages = logNumber of stages = log22NN�� Number of blocks/stage = N/2Number of blocks/stage = N/2stagestage
�� Number of butterflies/block = 2Number of butterflies/block = 2stagestage--11
Example: 8 point FFTExample: 8 point FFT(1)(1) Number of stages:Number of stages:
�� NNstagesstages= 3= 3(2)(2) Blocks/stage:Blocks/stage:
�� Stage 1: NStage 1: Nblocksblocks = 4= 4�� Stage 2: NStage 2: Nblocksblocks = 2= 2
FFT ImplementationFFT Implementation
WW00 --11
WW00 --11
WW --11
WW22 --11
--11WW00
WW00 --11
Stage 2Stage 2 Stage 3Stage 3Stage 1Stage 1
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004Chapter 19, Slide 39
�� Stage 3: NStage 3: Nblocksblocks = 1= 1(3)(3) B’flies/block:B’flies/block:
�� Stage 1: NStage 1: Nbtfbtf = 1= 1�� Stage 2: NStage 2: Nbtfbtf = 2= 2
WW00 --11
WW00 --11
WW00
WW22 --11
--11WW00
WW11 --11
WW33 --11
--11WW22
�� Decimation in time FFT:Decimation in time FFT:�� Number of stages = logNumber of stages = log22NN�� Number of blocks/stage = N/2Number of blocks/stage = N/2stagestage
�� Number of butterflies/block = 2Number of butterflies/block = 2stagestage--11
Example: 8 point FFTExample: 8 point FFT(1)(1) Number of stages:Number of stages:
�� NNstagesstages= 3= 3(2)(2) Blocks/stage:Blocks/stage:
�� Stage 1: NStage 1: Nblocksblocks = 4= 4�� Stage 2: NStage 2: Nblocksblocks = 2= 2
FFT ImplementationFFT Implementation
WW00 --11
WW00 --11
WW --11
WW22 --11
--11WW00
WW00 --11
Stage 2Stage 2 Stage 3Stage 3Stage 1Stage 1
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004Chapter 19, Slide 40
�� Stage 3: NStage 3: Nblocksblocks = 1= 1(3)(3) B’flies/block:B’flies/block:
�� Stage 1: NStage 1: Nbtfbtf = 1= 1�� Stage 2: NStage 2: Nbtfbtf = 2= 2�� Stage 3: NStage 3: Nbtfbtf = 1= 1
WW00 --11
WW00 --11
WW00
WW22 --11
--11WW00
WW11 --11
WW33 --11
--11WW22
�� Decimation in time FFT:Decimation in time FFT:�� Number of stages = logNumber of stages = log22NN�� Number of blocks/stage = N/2Number of blocks/stage = N/2stagestage
�� Number of butterflies/block = 2Number of butterflies/block = 2stagestage--11
Example: 8 point FFTExample: 8 point FFT(1)(1) Number of stages:Number of stages:
�� NNstagesstages= 3= 3(2)(2) Blocks/stage:Blocks/stage:
�� Stage 1: NStage 1: Nblocksblocks = 4= 4�� Stage 2: NStage 2: Nblocksblocks = 2= 2
FFT ImplementationFFT Implementation
WW00 --11
WW00 --11
WW --11
WW22 --11
--11WW00
WW00 --11
Stage 2Stage 2 Stage 3Stage 3Stage 1Stage 1
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004Chapter 19, Slide 41
�� Stage 3: NStage 3: Nblocksblocks = 1= 1(3)(3) B’flies/block:B’flies/block:
�� Stage 1: NStage 1: Nbtfbtf = 1= 1�� Stage 2: NStage 2: Nbtfbtf = 2= 2�� Stage 3: NStage 3: Nbtfbtf = 2= 2
WW00 --11
WW00 --11
WW00
WW22 --11
--11WW00
WW11 --11
WW33 --11
--11WW22
�� Decimation in time FFT:Decimation in time FFT:�� Number of stages = logNumber of stages = log22NN�� Number of blocks/stage = N/2Number of blocks/stage = N/2stagestage
�� Number of butterflies/block = 2Number of butterflies/block = 2stagestage--11
Example: 8 point FFTExample: 8 point FFT(1)(1) Number of stages:Number of stages:
�� NNstagesstages= 3= 3(2)(2) Blocks/stage:Blocks/stage:
�� Stage 1: NStage 1: Nblocksblocks = 4= 4�� Stage 2: NStage 2: Nblocksblocks = 2= 2
FFT ImplementationFFT Implementation
WW00 --11
WW00 --11
WW --11
WW22 --11
--11WW00
WW00 --11
Stage 2Stage 2 Stage 3Stage 3Stage 1Stage 1
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004Chapter 19, Slide 42
�� Stage 3: NStage 3: Nblocksblocks = 1= 1(3)(3) B’flies/block:B’flies/block:
�� Stage 1: NStage 1: Nbtfbtf = 1= 1�� Stage 2: NStage 2: Nbtfbtf = 2= 2�� Stage 3: NStage 3: Nbtfbtf = 3= 3
WW00 --11
WW00 --11
WW00
WW22 --11
--11WW00
WW11 --11
WW33 --11
--11WW22
�� Decimation in time FFT:Decimation in time FFT:�� Number of stages = logNumber of stages = log22NN�� Number of blocks/stage = N/2Number of blocks/stage = N/2stagestage
�� Number of butterflies/block = 2Number of butterflies/block = 2stagestage--11
Example: 8 point FFTExample: 8 point FFT(1)(1) Number of stages:Number of stages:
�� NNstagesstages= 3= 3(2)(2) Blocks/stage:Blocks/stage:
�� Stage 1: NStage 1: Nblocksblocks = 4= 4�� Stage 2: NStage 2: Nblocksblocks = 2= 2
FFT ImplementationFFT Implementation
WW00 --11
WW00 --11
WW --11
WW22 --11
--11WW00
WW00 --11
Stage 2Stage 2 Stage 3Stage 3Stage 1Stage 1
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004Chapter 19, Slide 43
�� Stage 3: NStage 3: Nblocksblocks = 1= 1(3)(3) B’flies/block:B’flies/block:
�� Stage 1: NStage 1: Nbtfbtf = 1= 1�� Stage 2: NStage 2: Nbtfbtf = 2= 2�� Stage 3: NStage 3: Nbtfbtf = 4= 4
WW00 --11
WW00 --11
WW00
WW22 --11
--11WW00
WW11 --11
WW33 --11
--11WW22
�� Decimation in time FFT:Decimation in time FFT:�� Number of stages = logNumber of stages = log22NN�� Number of blocks/stage = N/2Number of blocks/stage = N/2stagestage
�� Number of butterflies/block = 2Number of butterflies/block = 2stagestage--11
FFT ImplementationFFT Implementation
WW00 --11
WW00 --11
WW00 --11
WW22 --11
WW00
--11WW00
--11WW00
WW11 --11
WW00
--11WW22
--11
Stage 2Stage 2 Stage 3Stage 3Stage 1Stage 1
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004Chapter 19, Slide 44
WW00 --11 WW22 --11
--11WW00
WW33 --11
--11WW22
Twiddle Factor IndexTwiddle Factor Index N/2 = 4N/2 = 4
Start IndexStart Index 00 00 00Input IndexInput Index 11 22 44
FFT ImplementationFFT Implementation
WW00 --11
WW00 --11
WW00 --11
WW22 --11
WW00
--11WW00
--11WW00
WW11 --11
WW00
--11WW22
--11
Stage 2Stage 2 Stage 3Stage 3Stage 1Stage 1
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004Chapter 19, Slide 45
Twiddle Factor IndexTwiddle Factor Index N/2 = N/2 = 44 44/2 = 2/2 = 2
Start IndexStart Index 00 00 00Input IndexInput Index 11 22 44
WW00 --11 WW22 --11
--11WW00
WW33 --11
--11WW22
FFT ImplementationFFT Implementation
WW00 --11
WW00 --11
WW00 --11
WW22 --11
WW00
--11WW00
--11WW00
WW11 --11
WW00
--11WW22
--11
Stage 2Stage 2 Stage 3Stage 3Stage 1Stage 1
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004Chapter 19, Slide 46
Twiddle Factor IndexTwiddle Factor Index N/2 = 4N/2 = 4 44/2 =/2 = 22 22/2 = 1/2 = 1
Start IndexStart Index 00 00 00Input IndexInput Index 11 22 44
WW00 --11 WW22 --11
--11WW00
WW33 --11
--11WW22
FFT ImplementationFFT Implementation
WW00 --11
WW00 --11
WW00 --11
WW22 --11
WW00
--11WW00
--11WW00
WW11 --11
WW00
--11WW22
--11
Stage 2Stage 2 Stage 3Stage 3Stage 1Stage 1
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004Chapter 19, Slide 47
Start IndexStart Index 00Input IndexInput Index 11
Twiddle Factor IndexTwiddle Factor Index N/2 = 4N/2 = 4 44/2 = 2/2 = 2 22/2 = 1/2 = 1
Indicies UsedIndicies Used WW00 WW00
WW22
WW00
WW11
WW22
WW33
0022
0044
WW00 --11 WW22 --11
--11WW00
WW33 --11
--11WW22
FFT ImplementationFFT Implementation
�� The most important aspect of converting The most important aspect of converting the FFT diagram to ‘C’ code is to the FFT diagram to ‘C’ code is to calculate the upper and lower indices of calculate the upper and lower indices of each butterfly:each butterfly:
GS = N/4; GS = N/4; /* Group step initial value *//* Group step initial value */step = 1;step = 1; /* Initial value *//* Initial value */NB = N/2;NB = N/2; /* NB is a constant *//* NB is a constant */
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004Chapter 19, Slide 48
NB = N/2;NB = N/2; /* NB is a constant *//* NB is a constant */
for (k=N; k>1; k>>1)for (k=N; k>1; k>>1) /* Repeat this loop for each stage *//* Repeat this loop for each stage */{{
for (j=0; j<N; j+=GS)for (j=0; j<N; j+=GS) /* Repeat this loop for each block *//* Repeat this loop for each block */{{
for (n=j; n<(j+GSfor (n=j; n<(j+GS--1); n+=step)1); n+=step) /* Repeat this loop for each butterfly *//* Repeat this loop for each butterfly */{{
upperindex = n;upperindex = n;lowerindex = n+step;lowerindex = n+step;
}}}}/* Change the GS and step for the next stage *//* Change the GS and step for the next stage */
GS = GS << 1;GS = GS << 1;step = step << 1;step = step << 1;
}}
FFT ImplementationFFT Implementation
�� How to declare and access twiddle factors:How to declare and access twiddle factors:(1)(1) How to declare the twiddle factors:How to declare the twiddle factors:
struct {struct {short real; // 32767 * cos (2*pi*n) short real; // 32767 * cos (2*pi*n) --> Q15 format> Q15 formatshort imag; // 32767 * sin (2*pi*n) short imag; // 32767 * sin (2*pi*n) --> Q15 format> Q15 format
} w[] = { 32767,0,} w[] = { 32767,0,32767,32767,--201, 201, ......
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004Chapter 19, Slide 49
};};
short temp_real, temp_imag;short temp_real, temp_imag;
temp_real = w[i].real;temp_real = w[i].real;temp_imag = w[i].imag;temp_imag = w[i].imag;
(2)(2) How to access the twiddle factors:How to access the twiddle factors:
FFT ImplementationFFT Implementation
Links:Links:�� Project location: Project location:
�� \\CD ROM 2004CD ROM 2004\\DSP Code 6711 UpdateDSP Code 6711 Update\\Chapter 19 Chapter 19 -- Fast Fourier Fast Fourier TransformTransform\\FFT DIF _in C_Fixed pointFFT DIF _in C_Fixed point\\fft_bios.pjtfft_bios.pjt
�� \\CD ROM 2004CD ROM 2004\\DSP Code for DSK6416DSP Code for DSK6416\\Chapter 19 Chapter 19 -- Fast Fourier Fast Fourier TransformTransform\\FFT DIF _in C_Fixed pointFFT DIF _in C_Fixed point\\fft_project.pjtfft_project.pjt
�� \\CD ROM 2004CD ROM 2004\\DSP Code for DSK6713DSP Code for DSK6713\\Chapter 19 Chapter 19 -- Fast Fourier Fast Fourier
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004Chapter 19, Slide 50
�� \\CD ROM 2004CD ROM 2004\\DSP Code for DSK6713DSP Code for DSK6713\\Chapter 19 Chapter 19 -- Fast Fourier Fast Fourier TransformTransform\\FFT DIF _in C_Fixed pointFFT DIF _in C_Fixed point\\fft_project.pjtfft_project.pjt
�� Laboratory sheet: Laboratory sheet: FFTLabSheet.pdfFFTLabSheet.pdf
FFT test on the DSK6713FFT test on the DSK6713
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004Chapter 19, Slide 51
FFT test on the DSK6416FFT test on the DSK6416
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004Chapter 19, Slide 52
Chapter 19Chapter 19Fast Fourier Transform (FFT)Fast Fourier Transform (FFT)
(Theory and Implementation)(Theory and Implementation)-- End End --