Chapter 19Chapter 19Fast Fourier Transform (FFT)Fast Fourier Transform (FFT)(Theory and Implementation)(Theory and Implementation)
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 19, Slide 2
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 2004
Chapter 19, Slide 3
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 a discrete-time signal x(nT) is given The Discrete Fourier Transform (DFT) of a discrete-time signal x(nT) is given by:by:
Where:Where:
1
0
2N
n
nkNj
enxkX
nxnTxNk
1,1,0
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 19, Slide 4
0 20 40 60 80 100 120-2
-1
0
1
2Sampled signal
Sample
Am
plitu
de
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
If we let:If we let: NNj
We
2
then:then:
1
0
N
n
nkNWnxkX
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 19, Slide 5
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-1]W +…+ x[N-1]WNN0*(N-1)0*(N-1)
X(1) X(1) = x[0]W= x[0]WNN00 + x[1]W + x[1]WNN
1*11*1 +…+ x[N-1]W +…+ x[N-1]WNN1*(N-1)1*(N-1)
::
X(k) X(k) = x[0]W= x[0]WNN00 + x[1]W + x[1]WNN
k*1k*1 +…+ x[N-1]W +…+ x[N-1]WNNk*(N-1)k*(N-1)
::
X(N-1)X(N-1) = x[0]W= x[0]WNN00 + x[1]W + x[1]WNN (N-1)*1(N-1)*1 +…+ x[N-1]W +…+ x[N-1]WNN (N-1)(N-1)(N-1)(N-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.
x[n] x[n] = input= inputX[k] X[k] = frequency bins= frequency binsWW = twiddle factors= twiddle factors
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 19, Slide 6
Performance of the DFT AlgorithmPerformance of the DFT Algorithm The DFT requires NThe DFT requires N2 2 (NxN) complex multiplications: (NxN) complex multiplications:
Each X(k) requires N complex multiplications.Each X(k) requires N complex multiplications. Therefore to evaluate all the values of the DFT ( X(0) to X(N-1) ) NTherefore to evaluate all the values of the DFT ( X(0) to X(N-1) ) N22 multiplications are required. multiplications are required.
The DFT also requires (N-1)*N complex additions:The DFT also requires (N-1)*N complex additions: Each X(k) requires N-1 additions.Each X(k) requires N-1 additions. Therefore to evaluate all the values of the DFT (N-1)*N additions are required.Therefore to evaluate all the values of the DFT (N-1)*N additions are required.
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 19, Slide 7
Performance of the DFT AlgorithmPerformance of the DFT Algorithm
0
20
40
60
80
100
120
0 1 2 3 4 5 6 7 8 9 10
Number of Samples
Num
ber
of M
ultip
licat
ions
0
20
40
60
80
100
120
0 1 2 3 4 5 6 7 8 9 10
Number of Samples
Num
ber
of A
dditi
ons
Can the number of computations required Can the number of computations required be reduced?be reduced?
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 19, Slide 8
DFT DFT FFT FFT A large amount of work has been devoted to reducing the A large amount of work has been devoted to reducing the
computation time of a DFT.computation time of a DFT. This has led to efficient algorithms which are known as This has led to efficient algorithms which are known as
the Fast Fourier Transform (FFT) algorithms.the Fast Fourier Transform (FFT) algorithms.
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 19, Slide 9
DFT DFT FFT FFT
x[n] = x[0], x[1], …, x[N-1]x[n] = x[0], x[1], …, x[N-1]
10 ;1
0
NkWnxkXN
n
nkN [1][1]
Lets divide the sequence x[n] into even and odd sequences:Lets divide the sequence x[n] into even and odd sequences: x[2n] x[2n] = x[0], x[2], …, x[N-2]= x[0], x[2], …, x[N-2] x[2n+1] x[2n+1] = x[1], x[3], …, x[N-1]= x[1], x[3], …, x[N-1]
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 19, Slide 10
nkN
nkNjnk
Njnk
N
W
eeW
2
22
222
1
2
0
12
12
0
2 122
N
n
knN
N
n
nkN WnxWnxkX
DFT DFT FFT FFT
[2][2]
Equation 1 can be rewritten as:Equation 1 can be rewritten as:
Since:Since:
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:
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 19, Slide 11
kZWkY
WnxWWnxkX
kN
N
n
nkN
kN
N
n
nkN
12
0 22
12
0 21
DFT DFT FFT FFT
The result is that an N-point DFT can be divided The result is that an N-point DFT can be divided into two N/2 point DFT’s:into two N/2 point DFT’s:
10 ;1
0
NkWnxkXN
n
nkN N-point DFTN-point DFT
Where Y(k) and Z(k) are the two N/2 point DFTs Where Y(k) and Z(k) are the two N/2 point DFTs operating on even and odd samples respectively:operating on even and odd samples respectively:
Two N/2-Two N/2-point DFTspoint DFTs
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 19, Slide 12
12
0
2
222
12
0
2
21
12
0 22
12
0 21
2
N
n
Nkn
N
NkN
N
n
Nkn
N
N
n
nkN
kN
N
n
nkN
WnxWWnxNkX
WnxWWnxkX
DFT DFT FFT FFT
PeriodicityPeriodicity and and symmetrysymmetry of W can be exploited to of W can be exploited to simplify the DFT further:simplify the DFT further:
Or:Or:
And:And:
kN
kNjjk
NjN
Njk
NjNk
N WeeeeeW
222
222
kN
kNjN
Njk
NjNk
N WeeeW2
22
222
22
2
2
[3][3]
: Symmetry: Symmetry
: Periodicity: Periodicity
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 19, Slide 13
DFT DFT FFT FFT
Symmetry and periodicity:Symmetry and periodicity:
WW880 0 == WW88
88
WW881 1 = W= W88
99
WW8822
WW8844
WW8833
WW8866
WW8877WW88
55
WWNNk+N/2 k+N/2 == - -WWNN
kk
WWN/2N/2k+N/2 k+N/2 == WWN/2N/2
kk
WW88k+4 k+4 == - -WW88
kk
WW88k+8 k+8 == WW88
kk
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 19, Slide 14
kZWkY
WnxWWnxNkX
kN
N
n
nkN
kN
N
n
nkN
12
0 22
12
0 212
DFT DFT FFT FFT
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 2004
Chapter 19, Slide 15
12
,0 ;2
12
,0 ;
NkkZWkYNkX
NkkZWkYkX
kN
kN
DFT DFT FFT FFT
Y(k) and WY(k) and WNNk k Z(k) only need to be calculated once and used for both equations.Z(k) only need to be calculated once and used for both equations.
Note: the calculation is reduced from 0 to N-1 to 0 to (N/2 - 1).Note: the calculation is reduced from 0 to N-1 to 0 to (N/2 - 1).
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 19, Slide 16
DFT DFT FFT FFT
Y(k) and Z(k) can also be divided into N/4 point Y(k) and Z(k) can also be divided into N/4 point DFTs using the same process shown above:DFTs using the same process shown above:
kVWkUNkY
kVWkUkY
kN
kN
2
2
4
kQWkPNkZ
kQWkPkZ
kN
kN
2
2
4
The process continues until we reach 2 point The process continues until we reach 2 point DFTs.DFTs.
12
,0 ;2
12
,0 ;
NkkZWkYNkX
NkkZWkYkX
kN
kN
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 19, Slide 17
DFT DFT FFT FFT
Illustration of the first decimation in time FFT.Illustration of the first decimation in time FFT.
y[0]y[0]y[1]y[1]y[2]y[2]
y[N-2]y[N-2]
N/2 point N/2 point DFTDFT
x[0]x[0]x[2]x[2]x[4]x[4]
x[N-2]x[N-2]
N/2 point N/2 point DFTDFT
x[1]x[1]x[3]x[3]x[5]x[5]
x[N-1]x[N-1]
z[0]z[0]z[1]z[1]z[2]z[2]
z[N/2-1]z[N/2-1]
X[N/2] = y[0]-WX[N/2] = y[0]-W00z[0]z[0]-1-1
X[0] = y[0]+WX[0] = y[0]+W00z[0]z[0]
WW00 X[N/2+1] = y[1]-WX[N/2+1] = y[1]-W11z[1]z[1]-1-1
X[1] = y[1]+WX[1] = y[1]+W11z[1]z[1]
WW11
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 19, Slide 18
FFT ImplementationFFT Implementation
Calculation of the output of a ‘butterfly’:Calculation of the output of a ‘butterfly’:U’=UU’=Urr’+jU’+jUii’ = X(k)’ = X(k)
L’=LL’=Lrr’+jL’+jLii’ = X(k+N/2)’ = X(k+N/2)
Y(k) = UY(k) = Urr+jU+jUii
WWNNkkZ(k) =Z(k) = (L (Lrr+jL+jLii)(W)(Wrr+jW+jWii))
-1-1
Different methods are available for calculating the outputs U’ and L’.Different methods are available for calculating the outputs U’ and L’. The best method is the one with the least number of multiplications and additions.The best method is the one with the least number of multiplications and additions.
Key:Key: U = UpperU = Upper r = realr = realL = LowerL = Lower i = imaginaryi = imaginary
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 19, Slide 19
FFT ImplementationFFT Implementation
Calculation of the output of a ‘butterfly’:Calculation of the output of a ‘butterfly’:
iiriirrririr WLWjLWjLWLjWWjLL
U’=UU’=Urr’+jU’+jUii’’
L’=LL’=Lrr’+jL’+jLii’’
UUrr+jU+jUii
(L(Lrr+jL+jLii)(W)(Wrr+jW+jWii))-1-1
iriirriirr
irriiriirr
UWLWLjUWLWLjUUWLWLjWLWLU
riiriiirrr
riiriirrir
WLWLUjWLWLUWLWLjWLWLjUUL
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 19, Slide 20
FFT ImplementationFFT Implementation Calculation of the output of a ‘butterfly’:Calculation of the output of a ‘butterfly’:
To further minimise the number of operations (* To further minimise the number of operations (* and +), the following are calculated only once:and +), the following are calculated only once:
temp1 = Ltemp1 = LrrWWrr temp2 = Ltemp2 = LiiWWii temp3 = Ltemp3 = LrrWWii temp4 = Ltemp4 = LiiWWrr
temp1_2 = temp1 - temp2temp1_2 = temp1 - temp2 temp3_4 = temp3 + temp4temp3_4 = temp3 + temp4
UUrr’ ’ = temp1 - temp2 + U= temp1 - temp2 + Urr = temp1_2 + U= temp1_2 + Urr
UUii’ ’ = temp3 + temp4 + U= temp3 + temp4 + Uii = temp3_4 + U= temp3_4 + Uii
LLrr’ ’ = U= Urr - temp1 + temp2 - temp1 + temp2 = U= Urr - temp1_2 - temp1_2
LLii’ ’ = U= Uii - temp3 - temp4 - temp3 - temp4 = U= Uii - temp3_4 - temp3_4
U’=UU’=Urr’+jU’+jUii’ = (L’ = (Lr r WWr r - L- Li i WWi i + U+ Urr)+j(L)+j(Lr r WWi i + L+ Li i WWr r + U+ Uii))
L’=LL’=Lrr’+jL’+jLii’ = (U’ = (Ur r - L- Lr r WWr r + L+ Li i WWii)+j(U)+j(Ui i - L- Lr r WWi i - L- Li i WWrr))
UUrr+jU+jUii
(L(Lrr+jL+jLii)(W)(Wrr+jW+jWii))-1-1
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 19, Slide 21
FFT Implementation (Butterfly Calculation)FFT Implementation (Butterfly Calculation)
Converting the butterfly calculation into ‘C’ code:Converting the butterfly calculation into ‘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);
temp1_2 = temp1 - temp2;temp1_2 = temp1 - 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 - temp3_4;y[lower].imag = y[upper].imag - temp3_4;y[lower].real = y[upper].real - temp1_2;y[lower].real = y[upper].real - temp1_2;
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 19, Slide 22
FFT ImplementationFFT Implementation To efficiently implement the FFT algorithm a few observations are made:To efficiently implement the FFT algorithm a few observations are made:
Each stage has the same number of butterflies (number of butterflies = N/2, N is number of points).Each stage has the same number of butterflies (number of butterflies = N/2, N is number of points). The number of DFT groups per stage is equal to (N/2The number of DFT groups per stage is equal to (N/2stagestage).). The difference between the upper and lower leg is equal to 2The difference between the upper and lower leg is equal to 2stage-1stage-1.. The number of butterflies in the group is equal to 2The number of butterflies in the group is equal to 2stage-1stage-1..
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 19, Slide 23
FFT ImplementationFFT Implementation
WW00 -1-1
WW00 -1-1
WW00 -1-1
WW00 -1-1
WW22 -1-1
WW00
-1-1WW00
WW22 -1-1
-1-1WW00
WW11 -1-1
WW00
WW33 -1-1
-1-1WW22
-1-1
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 = 2stage-1stage-1
Example: 8 point FFTExample: 8 point FFT
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 19, Slide 24
FFT ImplementationFFT Implementation
WW00 -1-1
WW00 -1-1
WW00 -1-1
WW00 -1-1
WW22 -1-1
WW00
-1-1WW00
WW22 -1-1
-1-1WW00
WW11 -1-1
WW00
WW33 -1-1
-1-1WW22
-1-1
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 = 2stage-1stage-1
Example: 8 point FFTExample: 8 point FFT(1)(1) Number of stages:Number of stages:
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 19, Slide 25
FFT ImplementationFFT Implementation
WW00 -1-1
WW00 -1-1
WW00 -1-1
WW00 -1-1
WW22 -1-1
WW00
-1-1WW00
WW22 -1-1
-1-1WW00
WW11 -1-1
WW00
WW33 -1-1
-1-1WW22
-1-1
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 = 2stage-1stage-1
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 2004
Chapter 19, Slide 26
Example: 8 point FFTExample: 8 point FFT(1)(1) Number of stages:Number of stages:
NNstagesstages = 2 = 2
FFT ImplementationFFT Implementation
WW00 -1-1
WW00 -1-1
WW00 -1-1
WW00 -1-1
WW22 -1-1
WW00
-1-1WW00
WW22 -1-1
-1-1WW00
WW11 -1-1
WW00
WW33 -1-1
-1-1WW22
-1-1
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 = 2stage-1stage-1
Stage 2Stage 2Stage 1Stage 1
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 19, Slide 27
Example: 8 point FFTExample: 8 point FFT(1)(1) Number of stages:Number of stages:
NNstagesstages = 3 = 3
FFT ImplementationFFT Implementation
WW00 -1-1
WW00 -1-1
WW00 -1-1
WW00 -1-1
WW22 -1-1
WW00
-1-1WW00
WW22 -1-1
-1-1WW00
WW11 -1-1
WW00
WW33 -1-1
-1-1WW22
-1-1
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 = 2stage-1stage-1
Stage 2Stage 2 Stage 3Stage 3Stage 1Stage 1
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 19, Slide 28
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 -1-1
WW00 -1-1
WW00 -1-1
WW00 -1-1
WW22 -1-1
WW00
-1-1WW00
WW22 -1-1
-1-1WW00
WW11 -1-1
WW00
WW33 -1-1
-1-1WW22
-1-1
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 = 2stage-1stage-1
Stage 2Stage 2 Stage 3Stage 3Stage 1Stage 1
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 19, Slide 29
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 -1-1
WW00 -1-1
WW00 -1-1
WW00 -1-1
WW22 -1-1
WW00
-1-1WW00
WW22 -1-1
-1-1WW00
WW11 -1-1
WW00
WW33 -1-1
-1-1WW22
-1-1
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 = 2stage-1stage-1
Stage 2Stage 2 Stage 3Stage 3Stage 1Stage 1
Block 1Block 1
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 19, Slide 30
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 -1-1
WW00 -1-1
WW00 -1-1
WW00 -1-1
WW22 -1-1
WW00
-1-1WW00
WW22 -1-1
-1-1WW00
WW11 -1-1
WW00
WW33 -1-1
-1-1WW22
-1-1
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 = 2stage-1stage-1
Stage 2Stage 2 Stage 3Stage 3Stage 1Stage 1
Block 1Block 1
Block 2Block 2
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 19, Slide 31
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 -1-1
WW00 -1-1
WW00 -1-1
WW00 -1-1
WW22 -1-1
WW00
-1-1WW00
WW22 -1-1
-1-1WW00
WW11 -1-1
WW00
WW33 -1-1
-1-1WW22
-1-1
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 = 2stage-1stage-1
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 2004
Chapter 19, Slide 32
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 -1-1
WW00 -1-1
WW00 -1-1
WW00 -1-1
WW22 -1-1
WW00
-1-1WW00
WW22 -1-1
-1-1WW00
WW11 -1-1
WW00
WW33 -1-1
-1-1WW22
-1-1
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 = 2stage-1stage-1
Stage 2Stage 2 Stage 3Stage 3Stage 1Stage 1
Block 1Block 1
Block 2Block 2
Block 3Block 3
Block 4Block 4
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 19, Slide 33
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 -1-1
WW00 -1-1
WW00 -1-1
WW00 -1-1
WW22 -1-1
WW00
-1-1WW00
WW22 -1-1
-1-1WW00
WW11 -1-1
WW00
WW33 -1-1
-1-1WW22
-1-1
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 = 2stage-1stage-1
Stage 2Stage 2 Stage 3Stage 3Stage 1Stage 1
Block 1Block 1
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 19, Slide 34
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 -1-1
WW00 -1-1
WW00 -1-1
WW00 -1-1
WW22 -1-1
WW00
-1-1WW00
WW22 -1-1
-1-1WW00
WW11 -1-1
WW00
WW33 -1-1
-1-1WW22
-1-1
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 = 2stage-1stage-1
Stage 2Stage 2 Stage 3Stage 3Stage 1Stage 1
Block 1Block 1
Block 2Block 2
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 19, Slide 35
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 Stage 3: NStage 3: Nblocksblocks = 1 = 1
FFT ImplementationFFT Implementation
WW00 -1-1
WW00 -1-1
WW00 -1-1
WW00 -1-1
WW22 -1-1
WW00
-1-1WW00
WW22 -1-1
-1-1WW00
WW11 -1-1
WW00
WW33 -1-1
-1-1WW22
-1-1
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 = 2stage-1stage-1
Stage 2Stage 2 Stage 3Stage 3Stage 1Stage 1
Block 1Block 1
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 19, Slide 36
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 Stage 3: NStage 3: Nblocksblocks = 1 = 1
(3)(3) B’flies/block:B’flies/block: Stage 1:Stage 1:
FFT ImplementationFFT Implementation
WW00 -1-1
WW00 -1-1
WW00 -1-1
WW00 -1-1
WW22 -1-1
WW00
-1-1WW00
WW22 -1-1
-1-1WW00
WW11 -1-1
WW00
WW33 -1-1
-1-1WW22
-1-1
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 = 2stage-1stage-1
Stage 2Stage 2 Stage 3Stage 3Stage 1Stage 1
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 19, Slide 37
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 Stage 3: NStage 3: Nblocksblocks = 1 = 1
(3)(3) B’flies/block:B’flies/block: Stage 1: NStage 1: Nbtfbtf = 1 = 1
FFT ImplementationFFT Implementation
WW00 -1-1
WW00 -1-1
WW00 -1-1
WW00 -1-1
WW22 -1-1
WW00
-1-1WW00
WW22 -1-1
-1-1WW00
WW11 -1-1
WW00
WW33 -1-1
-1-1WW22
-1-1
Stage 2Stage 2 Stage 3Stage 3Stage 1Stage 1
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 = 2stage-1stage-1
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 19, Slide 38
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 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
FFT ImplementationFFT Implementation
WW00 -1-1
WW00 -1-1
WW00 -1-1
WW00 -1-1
WW22 -1-1
WW00
-1-1WW00
WW22 -1-1
-1-1WW00
WW11 -1-1
WW00
WW33 -1-1
-1-1WW22
-1-1
Stage 2Stage 2 Stage 3Stage 3Stage 1Stage 1
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 = 2stage-1stage-1
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 19, Slide 39
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 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
FFT ImplementationFFT Implementation
WW00 -1-1
WW00 -1-1
WW00 -1-1
WW00 -1-1
WW22 -1-1
WW00
-1-1WW00
WW22 -1-1
-1-1WW00
WW11 -1-1
WW00
WW33 -1-1
-1-1WW22
-1-1
Stage 2Stage 2 Stage 3Stage 3Stage 1Stage 1
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 = 2stage-1stage-1
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 19, Slide 40
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 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
FFT ImplementationFFT Implementation
WW00 -1-1
WW00 -1-1
WW00 -1-1
WW00 -1-1
WW22 -1-1
WW00
-1-1WW00
WW22 -1-1
-1-1WW00
WW11 -1-1
WW00
WW33 -1-1
-1-1WW22
-1-1
Stage 2Stage 2 Stage 3Stage 3Stage 1Stage 1
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 = 2stage-1stage-1
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 19, Slide 41
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 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
FFT ImplementationFFT Implementation
WW00 -1-1
WW00 -1-1
WW00 -1-1
WW00 -1-1
WW22 -1-1
WW00
-1-1WW00
WW22 -1-1
-1-1WW00
WW11 -1-1
WW00
WW33 -1-1
-1-1WW22
-1-1
Stage 2Stage 2 Stage 3Stage 3Stage 1Stage 1
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 = 2stage-1stage-1
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 19, Slide 42
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 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
FFT ImplementationFFT Implementation
WW00 -1-1
WW00 -1-1
WW00 -1-1
WW00 -1-1
WW22 -1-1
WW00
-1-1WW00
WW22 -1-1
-1-1WW00
WW11 -1-1
WW00
WW33 -1-1
-1-1WW22
-1-1
Stage 2Stage 2 Stage 3Stage 3Stage 1Stage 1
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 = 2stage-1stage-1
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 19, Slide 43
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 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
FFT ImplementationFFT Implementation
WW00 -1-1
WW00 -1-1
WW00 -1-1
WW00 -1-1
WW22 -1-1
WW00
-1-1WW00
WW22 -1-1
-1-1WW00
WW11 -1-1
WW00
WW33 -1-1
-1-1WW22
-1-1
Stage 2Stage 2 Stage 3Stage 3Stage 1Stage 1
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 = 2stage-1stage-1
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 19, Slide 44
FFT ImplementationFFT Implementation
WW00 -1-1
WW00 -1-1
WW00 -1-1
WW00 -1-1
WW22 -1-1
WW00
-1-1WW00
WW22 -1-1
-1-1WW00
WW11 -1-1
WW00
WW33 -1-1
-1-1WW22
-1-1
Stage 2Stage 2 Stage 3Stage 3Stage 1Stage 1
Twiddle Factor IndexTwiddle Factor Index N/2 = 4N/2 = 4
Start IndexStart Index 00 00 00Input IndexInput Index 11 22 44
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 19, Slide 45
FFT ImplementationFFT Implementation
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 -1-1
WW00 -1-1
WW00 -1-1
WW00 -1-1
WW22 -1-1
WW00
-1-1WW00
WW22 -1-1
-1-1WW00
WW11 -1-1
WW00
WW33 -1-1
-1-1WW22
-1-1
Stage 2Stage 2 Stage 3Stage 3Stage 1Stage 1
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 19, Slide 46
FFT ImplementationFFT Implementation
Twiddle Factor IndexTwiddle Factor Index N/2 = 4N/2 = 4 44 /2 =/2 = 2 2 22 /2 = 1/2 = 1
Start IndexStart Index 00 00 00Input IndexInput Index 11 22 44
WW00 -1-1
WW00 -1-1
WW00 -1-1
WW00 -1-1
WW22 -1-1
WW00
-1-1WW00
WW22 -1-1
-1-1WW00
WW11 -1-1
WW00
WW33 -1-1
-1-1WW22
-1-1
Stage 2Stage 2 Stage 3Stage 3Stage 1Stage 1
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 19, Slide 47
FFT ImplementationFFT Implementation
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 = 1Indicies UsedIndicies Used WW00 WW00
WW22
WW00
WW11
WW22
WW33
0022
0044
WW00 -1-1
WW00 -1-1
WW00 -1-1
WW00 -1-1
WW22 -1-1
WW00
-1-1WW00
WW22 -1-1
-1-1WW00
WW11 -1-1
WW00
WW33 -1-1
-1-1WW22
-1-1
Stage 2Stage 2 Stage 3Stage 3Stage 1Stage 1
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 19, Slide 48
FFT ImplementationFFT Implementation The most important aspect of converting the FFT diagram to ‘C’ The most important aspect of converting the FFT diagram to ‘C’
code is to calculate the upper and lower indices of each butterfly:code is to calculate the upper and lower indices of 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 */
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+GS-1); n+=step)for (n=j; n<(j+GS-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;
}}
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 19, Slide 49
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) -> Q15 formatshort real; // 32767 * cos (2*pi*n) -> Q15 formatshort imag; // 32767 * sin (2*pi*n) -> Q15 formatshort imag; // 32767 * sin (2*pi*n) -> Q15 format
} w[] = { 32767,0,} w[] = { 32767,0, 32767,-201, 32767,-201,
......};};
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:
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 19, Slide 50
FFT ImplementationFFT ImplementationLinks:Links: Project location: Project location:
\CD ROM 2004\DSP Code 6711 Update\Chapter 19 - Fast Fourier Transform\FFT DIF _in C_Fixed point\fft_bios.pjt\CD ROM 2004\DSP Code 6711 Update\Chapter 19 - Fast Fourier Transform\FFT DIF _in C_Fixed point\fft_bios.pjt \CD ROM 2004\DSP Code for DSK6416\Chapter 19 - Fast Fourier Transform\FFT DIF _in C_Fixed point\fft_project.pjt\CD ROM 2004\DSP Code for DSK6416\Chapter 19 - Fast Fourier Transform\FFT DIF _in C_Fixed point\fft_project.pjt \CD ROM 2004\DSP Code for DSK6713\Chapter 19 - Fast Fourier Transform\FFT DIF _in C_Fixed point\fft_project.pjt\CD ROM 2004\DSP Code for DSK6713\Chapter 19 - Fast Fourier Transform\FFT DIF _in C_Fixed point\fft_project.pjt
Laboratory sheet: Laboratory sheet: FFTLabSheet.pdfFFTLabSheet.pdf
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 19, Slide 51
FFT test on the DSK6713FFT test on the DSK6713
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 19, Slide 52
FFT test on the DSK6416FFT test on the DSK6416
Chapter 19Chapter 19Fast Fourier Transform (FFT)Fast Fourier Transform (FFT)(Theory and Implementation)(Theory and Implementation)
- End -- End -
Top Related