You are on page 1of 53

Chapter 19

Fast Fourier Transform (FFT)


(Theory and Implementation)
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004 Chapter 19, Slide 2
Learning Objectives
DFT algorithm.
Conversion of DFT to FFT algorithm.
Implementation of the FFT algorithm.
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004 Chapter 19, Slide 3
DFT Algorithm
The Fourier transform of an analogue
signal x(t) is given by:
( ) ( )
}
+

= dt e t x X
t je
e
The Discrete Fourier Transform (DFT) of
a discrete-time signal x(nT) is given by:


Where:
( ) | |

=
1
0
2
N
n
nk
N
j
e n x k X
t
( ) | | n x nT x
N k
=
= 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
2
Sampled signal
Sample
A
m
p
l
i
t
u
d
e
0 0.1 0.2 0.3 0.4 0.5
0
0.2
0.4
0.6
0.8
1
Frequency Domain
Normalised Frequency
M
a
g
n
i
t
u
d
e
DFT Algorithm
If we let:


N
N
j
W e =

t 2
then: ( ) | |

=
=
1
0
N
n
nk
N
W n x k X
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004 Chapter 19, Slide 5
DFT Algorithm
( ) | |

=
=
1
0
N
n
nk
N
W n x k X
X(0) = x[0]W
N
0
+ x[1]W
N
0*1
++ x[N-1]W
N
0*(N-1)

X(1) = x[0]W
N
0
+ x[1]W
N
1*1
++ x[N-1]W
N
1*(N-1)

:
X(k) = x[0]W
N
0
+ x[1]W
N
k*1
++ x[N-1]W
N
k*(N-1)

:
X(N-1) = x[0]W
N
0
+ x[1]W
N

(N-1)*1
++ x[N-1]W
N

(N-1)(N-1)

Note: For N samples of x we have N frequencies
representing the signal.
x[n] = input
X[k] = frequency bins
W = twiddle factors
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004 Chapter 19, Slide 6
Performance of the DFT Algorithm
The DFT requires N
2
(NxN) complex
multiplications:
Each X(k) requires N complex
multiplications.
Therefore to evaluate all the values of the
DFT ( X(0) to X(N-1) ) N
2
multiplications are
required.
The DFT also requires (N-1)*N complex
additions:
Each X(k) requires N-1 additions.
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 Algorithm
0
20
40
60
80
100
120
0 1 2 3 4 5 6 7 8 9 10
Number of Samples
N
u
m
b
e
r

o
f

M
u
l
t
i
p
l
i
c
a
t
i
o
n
s
0
20
40
60
80
100
120
0 1 2 3 4 5 6 7 8 9 10
Number of Samples
N
u
m
b
e
r

o
f

A
d
d
i
t
i
o
n
s
Can the number of computations required
be reduced?
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004 Chapter 19, Slide 8
DFT FFT
A large amount of work has been devoted
to reducing the computation time of a
DFT.
This has led to efficient algorithms which
are known as the Fast Fourier Transform
(FFT) algorithms.
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004 Chapter 19, Slide 9
DFT FFT
x[n] = x[0], x[1], , x[N-1]
( ) | | 1 0 ;
1
0
s s =

=
N k W n x k X
N
n
nk
N
[1]
Lets divide the sequence x[n] into even
and odd sequences:
x[2n] = x[0], x[2], , x[N-2]
x[2n+1] = x[1], x[3], , x[N-1]
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004 Chapter 19, Slide 10
nk
N
nk
N
j
nk
N
j
nk
N
W
e e W
2
2
2
2
2
2
=
= =

t
t
( ) | | | |
( )


=
+

=
+ + =
1
2
0
1 2
1
2
0
2
1 2 2
N
n
k n
N
N
n
nk
N
W n x W n x k X
DFT FFT
[2]
Equation 1 can be rewritten as:
Since:
( ) nk
N
k
N
k n
N
W W W
2
1 2
=
+
( ) | | | |
( ) ( ) k Z W k Y
W n x W W n x k X
k
N
N
n
nk
N
k
N
N
n
nk
N
+ =
+ + =


=

=
1
2
0
2
1
2
0
2
1 2 2
Then:
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004 Chapter 19, Slide 11
( ) | | | |
( ) ( ) k Z W k Y
W n x W W n x k X
k
N
N
n
nk
N
k
N
N
n
nk
N
+ =
+ =


=

=
1
2
0
2
2
1
2
0
2
1
DFT FFT
The result is that an N-point DFT can be
divided into two N/2 point DFTs:
( ) | | 1 0 ;
1
0
s s =

=
N k W n x k X
N
n
nk
N
N-point DFT
Where Y(k) and Z(k) are the two N/2
point DFTs operating on even and odd
samples respectively:
Two N/2-
point DFTs
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004 Chapter 19, Slide 12
( ) | | | |
| | | |

=
|
.
|

\
|
+
+

=
|
.
|

\
|
+

=
+ =
|
.
|

\
|
+
+ =
1
2
0
2
2
2
2
1
2
0
2
2
1
1
2
0 2
2
1
2
0 2
1
2
N
n
N
k n
N
N
k
N
N
n
N
k n
N
N
n
nk
N
k
N
N
n
nk
N
W n x W W n x
N
k X
W n x W W n x k X

DFT FFT
Periodicity and symmetry of W can be
exploited to simplify the DFT further:
Or:

And:
k
N
k
N
j
j
k
N
j
N
N
j k
N
j
N
k
N
W e e e e e W = = = =

+
t
t
t t t 2 2
2
2 2
2
k
N
k
N
j
N
N
j k
N
j
N
k
N
W e e e W
2
2
2
2 2
2
2
2
2
2
= = =

+
t t t
[3]
: Symmetry
: Periodicity
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004 Chapter 19, Slide 13
DFT FFT
Symmetry and periodicity:
W
8
0
=

W
8
8
W
8
1
= W
8
9
W
8
2

W
8
4

W
8
3

W
8
6

W
8
7
W
8
5

W
N
k+N/2
=
-
W
N
k
W
N/2
k+N/2
=

W
N/2
k
W
8
k+4
=
-
W
8
k
W
8
k+8
=

W
8
k
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004 Chapter 19, Slide 14
| | | |
( ) ( ) k Z W k Y
W n x W W n x
N
k X
k
N
N
n
nk
N
k
N
N
n
nk
N
=
= |
.
|

\
|
+


=

=
1
2
0
2
2
1
2
0
2
1
2
DFT FFT
Finally by exploiting the symmetry and
periodicity, Equation 3 can be written as:
[4]
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004 Chapter 19, Slide 15
( ) ( ) ( )
( ) ( )
|
.
|

\
|
= =
|
.
|

\
|
+
|
.
|

\
|
= + =
1
2
, 0 ;
2
1
2
, 0 ;
N
k k Z W k Y
N
k X
N
k k Z W k Y k X
k
N
k
N

DFT FFT
Y(k) and W
N
k
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).
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004 Chapter 19, Slide 16
DFT FFT
Y(k) and Z(k) can also be divided into N/4
point DFTs using the same process shown
above:
( ) ( ) ( )
( ) ( ) k V W k U
N
k Y
k V W k U k Y
k
N
k
N
2
2
4
= |
.
|

\
|
+
+ =
( ) ( ) ( )
( ) ( ) k Q W k P
N
k Z
k Q W k P k Z
k
N
k
N
2
2
4
= |
.
|

\
|
+
+ =
The process continues until we reach 2
point DFTs.
( ) ( ) ( )
( ) ( )
|
.
|

\
|
= =
|
.
|

\
|
+
|
.
|

\
|
= + =
1
2
, 0 ;
2
1
2
, 0 ;
N
k k Z W k Y
N
k X
N
k k Z W k Y k X
k
N
k
N

Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004 Chapter 19, Slide 17
DFT FFT
Illustration of the first decimation in time
FFT.
y[0]
y[1]
y[2]
y[N-2]
N/2 point
DFT
x[0]
x[2]
x[4]
x[N-2]
N/2 point
DFT
x[1]
x[3]
x[5]
x[N-1]
z[0]
z[1]
z[2]
z[N/2-1]
X[N/2] = y[0]-W
0
z[0]
-1
X[0] = y[0]+W
0
z[0]
W
0
X[N/2+1] = y[1]-W
1
z[1]
-1
X[1] = y[1]+W
1
z[1]
W
1

Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004 Chapter 19, Slide 18
FFT Implementation
Calculation of the output of a butterfly:
U=U
r
+jU
i
= X(k)
L=L
r
+jL
i
= X(k+N/2)
Y(k) = U
r
+jU
i

W
N
k
Z(k) = (L
r
+jL
i
)(W
r
+jW
i
)

-1
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.
Key: U = Upper r = real
L = Lower i = imaginary
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004 Chapter 19, Slide 19
FFT Implementation
Calculation of the output of a butterfly:
( )( )
i i r i i r r r i r i r
W L W jL W jL W L jW W jL L + + = + +
U=U
r
+jU
i

L=L
r
+jL
i

U
r
+jU
i

(L
r
+jL
i
)(W
r
+jW
i
)

-1
( ) ( ) | | | |
( ) ( )
i r i i r r i i r r
i r r i i r i i r r
U W L W L j U W L W L
jU U W L W L j W L W L U
+ + + + =
+ + + + = '
( ) ( ) ( ) | |
( ) ( )
r i i r i i i r r r
r i i r i i r r i r
W L W L U j W L W L U
W L W L j W L W L jU U L
+ + =
+ + + = '
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004 Chapter 19, Slide 20
FFT Implementation
Calculation of the output of a butterfly:
To further minimise the number of
operations (* and +), the following are
calculated only once:
temp1 = L
r
W
r
temp2 = L
i
W
i
temp3 = L
r
W
i
temp4 = L
i
W
r
temp1_2 = temp1 - temp2

temp3_4 = temp3 + temp4

U
r
= temp1 - temp2 + U
r
= temp1_2 + U
r

U
i
= temp3 + temp4 + U
i
= temp3_4 + U
i

L
r
= U
r
- temp1 + temp2 = U
r
- temp1_2
L
i
= U
i
- temp3 - temp4 = U
i
- temp3_4

U=U
r
+jU
i
= (L
r
W
r
- L
i
W
i
+ U
r
)+j(L
r
W
i
+ L
i
W
r
+ U
i
)
L=L
r
+jL
i
= (U
r
- L
r
W
r
+ L
i
W
i
)+j(U
i
- L
r
W
i
- L
i
W
r
)
U
r
+jU
i

(L
r
+jL
i
)(W
r
+jW
i
)

-1
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004 Chapter 19, Slide 21
FFT Implementation (Butterfly Calculation)
Converting the butterfly calculation into
C code:
temp1 = (y[lower].real * WR);
temp2 = (y[lower].imag * WI);
temp3 = (y[lower].real * WI);
temp4 = (y[lower].imag * WR);

temp1_2 = temp1 - temp2;
temp3_4 = temp 3 + temp4;

y[upper].real = temp1_2 + y[upper].real;
y[upper].imag = temp3_4 + y[upper].imag;
y[lower].imag = y[upper].imag - temp3_4;
y[lower].real = y[upper].real - temp1_2;

Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004 Chapter 19, Slide 22
FFT Implementation
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).
The number of DFT groups per stage is equal
to (N/2
stage
).
The difference between the upper and lower
leg is equal to 2
stage-1
.
The number of butterflies in the group is
equal to 2
stage-1
.
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004 Chapter 19, Slide 23
FFT Implementation
W
0
-1
W
0
-1
W
0
-1
W
0
-1
W
2
-1
W
0

-1 W
0

W
2
-1
-1 W
0

W
1
-1
W
0

W
3
-1
-1 W
2

-1
Decimation in time FFT:
Number of stages = log
2
N
Number of blocks/stage = N/2
stage

Number of butterflies/block = 2
stage-1

Example: 8 point FFT
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004 Chapter 19, Slide 24
FFT Implementation
W
0
-1
W
0
-1
W
0
-1
W
0
-1
W
2
-1
W
0

-1 W
0

W
2
-1
-1 W
0

W
1
-1
W
0

W
3
-1
-1 W
2

-1
Decimation in time FFT:
Number of stages = log
2
N
Number of blocks/stage = N/2
stage

Number of butterflies/block = 2
stage-1

Example: 8 point FFT
(1) Number of stages:
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004 Chapter 19, Slide 25
FFT Implementation
W
0
-1
W
0
-1
W
0
-1
W
0
-1
W
2
-1
W
0

-1 W
0

W
2
-1
-1 W
0

W
1
-1
W
0

W
3
-1
-1 W
2

-1
Decimation in time FFT:
Number of stages = log
2
N
Number of blocks/stage = N/2
stage

Number of butterflies/block = 2
stage-1

Example: 8 point FFT
(1) Number of stages:
N
stages
= 1
Stage 1
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004 Chapter 19, Slide 26
Example: 8 point FFT
(1) Number of stages:
N
stages
= 2
FFT Implementation
W
0
-1
W
0
-1
W
0
-1
W
0
-1
W
2
-1
W
0

-1 W
0

W
2
-1
-1 W
0

W
1
-1
W
0

W
3
-1
-1 W
2

-1
Decimation in time FFT:
Number of stages = log
2
N
Number of blocks/stage = N/2
stage

Number of butterflies/block = 2
stage-1

Stage 2 Stage 1
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004 Chapter 19, Slide 27
Example: 8 point FFT
(1) Number of stages:
N
stages
= 3
FFT Implementation
W
0
-1
W
0
-1
W
0
-1
W
0
-1
W
2
-1
W
0

-1 W
0

W
2
-1
-1 W
0

W
1
-1
W
0

W
3
-1
-1 W
2

-1
Decimation in time FFT:
Number of stages = log
2
N
Number of blocks/stage = N/2
stage

Number of butterflies/block = 2
stage-1

Stage 2 Stage 3 Stage 1
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004 Chapter 19, Slide 28
Example: 8 point FFT
(1) Number of stages:
N
stages
= 3
(2) Blocks/stage:
Stage 1:
FFT Implementation
W
0
-1
W
0
-1
W
0
-1
W
0
-1
W
2
-1
W
0

-1 W
0

W
2
-1
-1 W
0

W
1
-1
W
0

W
3
-1
-1 W
2

-1
Decimation in time FFT:
Number of stages = log
2
N
Number of blocks/stage = N/2
stage

Number of butterflies/block = 2
stage-1

Stage 2 Stage 3 Stage 1
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004 Chapter 19, Slide 29
Example: 8 point FFT
(1) Number of stages:
N
stages
= 3
(2) Blocks/stage:
Stage 1: N
blocks
= 1
FFT Implementation
W
0
-1
W
0
-1
W
0
-1
W
0
-1
W
2
-1
W
0

-1 W
0

W
2
-1
-1 W
0

W
1
-1
W
0

W
3
-1
-1 W
2

-1
Decimation in time FFT:
Number of stages = log
2
N
Number of blocks/stage = N/2
stage

Number of butterflies/block = 2
stage-1

Stage 2 Stage 3 Stage 1
Block 1
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004 Chapter 19, Slide 30
Example: 8 point FFT
(1) Number of stages:
N
stages
= 3
(2) Blocks/stage:
Stage 1: N
blocks
= 2
FFT Implementation
W
0
-1
W
0
-1
W
0
-1
W
0
-1
W
2
-1
W
0

-1 W
0

W
2
-1
-1 W
0

W
1
-1
W
0

W
3
-1
-1 W
2

-1
Decimation in time FFT:
Number of stages = log
2
N
Number of blocks/stage = N/2
stage

Number of butterflies/block = 2
stage-1

Stage 2 Stage 3 Stage 1
Block 1
Block 2
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004 Chapter 19, Slide 31
Example: 8 point FFT
(1) Number of stages:
N
stages
= 3
(2) Blocks/stage:
Stage 1: N
blocks
= 3
FFT Implementation
W
0
-1
W
0
-1
W
0
-1
W
0
-1
W
2
-1
W
0

-1 W
0

W
2
-1
-1 W
0

W
1
-1
W
0

W
3
-1
-1 W
2

-1
Decimation in time FFT:
Number of stages = log
2
N
Number of blocks/stage = N/2
stage

Number of butterflies/block = 2
stage-1

Stage 2 Stage 3 Stage 1
Block 1
Block 2
Block 3
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004 Chapter 19, Slide 32
Example: 8 point FFT
(1) Number of stages:
N
stages
= 3
(2) Blocks/stage:
Stage 1: N
blocks
= 4
FFT Implementation
W
0
-1
W
0
-1
W
0
-1
W
0
-1
W
2
-1
W
0

-1 W
0

W
2
-1
-1 W
0

W
1
-1
W
0

W
3
-1
-1 W
2

-1
Decimation in time FFT:
Number of stages = log
2
N
Number of blocks/stage = N/2
stage

Number of butterflies/block = 2
stage-1

Stage 2 Stage 3 Stage 1
Block 1
Block 2
Block 3
Block 4
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004 Chapter 19, Slide 33
Example: 8 point FFT
(1) Number of stages:
N
stages
= 3
(2) Blocks/stage:
Stage 1: N
blocks
= 4
Stage 2: N
blocks
= 1
FFT Implementation
W
0
-1
W
0
-1
W
0
-1
W
0
-1
W
2
-1
W
0

-1 W
0

W
2
-1
-1 W
0

W
1
-1
W
0

W
3
-1
-1 W
2

-1
Decimation in time FFT:
Number of stages = log
2
N
Number of blocks/stage = N/2
stage

Number of butterflies/block = 2
stage-1

Stage 2 Stage 3 Stage 1
Block 1
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004 Chapter 19, Slide 34
Example: 8 point FFT
(1) Number of stages:
N
stages
= 3
(2) Blocks/stage:
Stage 1: N
blocks
= 4
Stage 2: N
blocks
= 2
FFT Implementation
W
0
-1
W
0
-1
W
0
-1
W
0
-1
W
2
-1
W
0

-1 W
0

W
2
-1
-1 W
0

W
1
-1
W
0

W
3
-1
-1 W
2

-1
Decimation in time FFT:
Number of stages = log
2
N
Number of blocks/stage = N/2
stage

Number of butterflies/block = 2
stage-1

Stage 2 Stage 3 Stage 1
Block 1
Block 2
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004 Chapter 19, Slide 35
Example: 8 point FFT
(1) Number of stages:
N
stages
= 3
(2) Blocks/stage:
Stage 1: N
blocks
= 4
Stage 2: N
blocks
= 2
Stage 3: N
blocks
= 1
FFT Implementation
W
0
-1
W
0
-1
W
0
-1
W
0
-1
W
2
-1
W
0

-1 W
0

W
2
-1
-1 W
0

W
1
-1
W
0

W
3
-1
-1 W
2

-1
Decimation in time FFT:
Number of stages = log
2
N
Number of blocks/stage = N/2
stage

Number of butterflies/block = 2
stage-1

Stage 2 Stage 3 Stage 1
Block 1
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004 Chapter 19, Slide 36
Example: 8 point FFT
(1) Number of stages:
N
stages
= 3
(2) Blocks/stage:
Stage 1: N
blocks
= 4
Stage 2: N
blocks
= 2
Stage 3: N
blocks
= 1
(3) Bflies/block:
Stage 1:

FFT Implementation
W
0
-1
W
0
-1
W
0
-1
W
0
-1
W
2
-1
W
0

-1 W
0

W
2
-1
-1 W
0

W
1
-1
W
0

W
3
-1
-1 W
2

-1
Decimation in time FFT:
Number of stages = log
2
N
Number of blocks/stage = N/2
stage

Number of butterflies/block = 2
stage-1

Stage 2 Stage 3 Stage 1
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004 Chapter 19, Slide 37
Example: 8 point FFT
(1) Number of stages:
N
stages
= 3
(2) Blocks/stage:
Stage 1: N
blocks
= 4
Stage 2: N
blocks
= 2
Stage 3: N
blocks
= 1
(3) Bflies/block:
Stage 1: N
btf
= 1
FFT Implementation
W
0
-1
W
0
-1
W
0
-1
W
0
-1
W
2
-1
W
0

-1 W
0

W
2
-1
-1 W
0

W
1
-1
W
0

W
3
-1
-1 W
2

-1
Stage 2 Stage 3 Stage 1
Decimation in time FFT:
Number of stages = log
2
N
Number of blocks/stage = N/2
stage

Number of butterflies/block = 2
stage-1

Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004 Chapter 19, Slide 38
Example: 8 point FFT
(1) Number of stages:
N
stages
= 3
(2) Blocks/stage:
Stage 1: N
blocks
= 4
Stage 2: N
blocks
= 2
Stage 3: N
blocks
= 1
(3) Bflies/block:
Stage 1: N
btf
= 1
Stage 2: N
btf
= 1
FFT Implementation
W
0
-1
W
0
-1
W
0
-1
W
0
-1
W
2
-1
W
0

-1 W
0

W
2
-1
-1 W
0

W
1
-1
W
0

W
3
-1
-1 W
2

-1
Stage 2 Stage 3 Stage 1
Decimation in time FFT:
Number of stages = log
2
N
Number of blocks/stage = N/2
stage

Number of butterflies/block = 2
stage-1

Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004 Chapter 19, Slide 39
Example: 8 point FFT
(1) Number of stages:
N
stages
= 3
(2) Blocks/stage:
Stage 1: N
blocks
= 4
Stage 2: N
blocks
= 2
Stage 3: N
blocks
= 1
(3) Bflies/block:
Stage 1: N
btf
= 1
Stage 2: N
btf
= 2
FFT Implementation
W
0
-1
W
0
-1
W
0
-1
W
0
-1
W
2
-1
W
0

-1 W
0

W
2
-1
-1 W
0

W
1
-1
W
0

W
3
-1
-1 W
2

-1
Stage 2 Stage 3 Stage 1
Decimation in time FFT:
Number of stages = log
2
N
Number of blocks/stage = N/2
stage

Number of butterflies/block = 2
stage-1

Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004 Chapter 19, Slide 40
Example: 8 point FFT
(1) Number of stages:
N
stages
= 3
(2) Blocks/stage:
Stage 1: N
blocks
= 4
Stage 2: N
blocks
= 2
Stage 3: N
blocks
= 1
(3) Bflies/block:
Stage 1: N
btf
= 1
Stage 2: N
btf
= 2
Stage 3: N
btf
= 1
FFT Implementation
W
0
-1
W
0
-1
W
0
-1
W
0
-1
W
2
-1
W
0

-1 W
0

W
2
-1
-1 W
0

W
1
-1
W
0

W
3
-1
-1 W
2

-1
Stage 2 Stage 3 Stage 1
Decimation in time FFT:
Number of stages = log
2
N
Number of blocks/stage = N/2
stage

Number of butterflies/block = 2
stage-1

Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004 Chapter 19, Slide 41
Example: 8 point FFT
(1) Number of stages:
N
stages
= 3
(2) Blocks/stage:
Stage 1: N
blocks
= 4
Stage 2: N
blocks
= 2
Stage 3: N
blocks
= 1
(3) Bflies/block:
Stage 1: N
btf
= 1
Stage 2: N
btf
= 2
Stage 3: N
btf
= 2
FFT Implementation
W
0
-1
W
0
-1
W
0
-1
W
0
-1
W
2
-1
W
0

-1 W
0

W
2
-1
-1 W
0

W
1
-1
W
0

W
3
-1
-1 W
2

-1
Stage 2 Stage 3 Stage 1
Decimation in time FFT:
Number of stages = log
2
N
Number of blocks/stage = N/2
stage

Number of butterflies/block = 2
stage-1

Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004 Chapter 19, Slide 42
Example: 8 point FFT
(1) Number of stages:
N
stages
= 3
(2) Blocks/stage:
Stage 1: N
blocks
= 4
Stage 2: N
blocks
= 2
Stage 3: N
blocks
= 1
(3) Bflies/block:
Stage 1: N
btf
= 1
Stage 2: N
btf
= 2
Stage 3: N
btf
= 3
FFT Implementation
W
0
-1
W
0
-1
W
0
-1
W
0
-1
W
2
-1
W
0

-1 W
0

W
2
-1
-1 W
0

W
1
-1
W
0

W
3
-1
-1 W
2

-1
Stage 2 Stage 3 Stage 1
Decimation in time FFT:
Number of stages = log
2
N
Number of blocks/stage = N/2
stage

Number of butterflies/block = 2
stage-1

Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004 Chapter 19, Slide 43
Example: 8 point FFT
(1) Number of stages:
N
stages
= 3
(2) Blocks/stage:
Stage 1: N
blocks
= 4
Stage 2: N
blocks
= 2
Stage 3: N
blocks
= 1
(3) Bflies/block:
Stage 1: N
btf
= 1
Stage 2: N
btf
= 2
Stage 3: N
btf
= 4
FFT Implementation
W
0
-1
W
0
-1
W
0
-1
W
0
-1
W
2
-1
W
0

-1 W
0

W
2
-1
-1 W
0

W
1
-1
W
0

W
3
-1
-1 W
2

-1
Stage 2 Stage 3 Stage 1
Decimation in time FFT:
Number of stages = log
2
N
Number of blocks/stage = N/2
stage

Number of butterflies/block = 2
stage-1

Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004 Chapter 19, Slide 44
FFT Implementation
W
0
-1
W
0
-1
W
0
-1
W
0
-1
W
2
-1
W
0

-1 W
0

W
2
-1
-1 W
0

W
1
-1
W
0

W
3
-1
-1 W
2

-1
Stage 2 Stage 3 Stage 1
Twiddle Factor Index N/2 = 4
Start Index 0 0 0
Input Index
1 2 4
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004 Chapter 19, Slide 45
FFT Implementation
Twiddle Factor Index N/2 = 4 4 /2 = 2
Start Index 0 0 0
Input Index
1 2 4
W
0
-1
W
0
-1
W
0
-1
W
0
-1
W
2
-1
W
0

-1 W
0

W
2
-1
-1 W
0

W
1
-1
W
0

W
3
-1
-1 W
2

-1
Stage 2 Stage 3 Stage 1
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004 Chapter 19, Slide 46
FFT Implementation
Twiddle Factor Index N/2 = 4 4 /2 = 2 2 /2 = 1
Start Index 0 0 0
Input Index
1 2 4
W
0
-1
W
0
-1
W
0
-1
W
0
-1
W
2
-1
W
0

-1 W
0

W
2
-1
-1 W
0

W
1
-1
W
0

W
3
-1
-1 W
2

-1
Stage 2 Stage 3 Stage 1
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004 Chapter 19, Slide 47
FFT Implementation
Start Index 0
Input Index
1
Twiddle Factor Index N/2 = 4 4 /2 = 2 2 /2 = 1
Indicies Used W
0
W
0
W
2


W
0
W
1

W
2

W
3


0
2
0
4
W
0
-1
W
0
-1
W
0
-1
W
0
-1
W
2
-1
W
0

-1 W
0

W
2
-1
-1 W
0

W
1
-1
W
0

W
3
-1
-1 W
2

-1
Stage 2 Stage 3 Stage 1
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004 Chapter 19, Slide 48
FFT Implementation
The most important aspect of converting
the FFT diagram to C code is to calculate
the upper and lower indices of each
butterfly:
GS = N/4; /* Group step initial value */
step = 1; /* Initial value */
NB = N/2; /* NB is a constant */

for (k=N; k>1; k>>1) /* Repeat this loop for each stage */
{
for (j=0; j<N; j+=GS) /* Repeat this loop for each block */
{
for (n=j; n<(j+GS-1); n+=step) /* Repeat this loop for each butterfly */
{
upperindex = n;
lowerindex = n+step;
}
}
/* Change the GS and step for the next stage */

GS = GS << 1;
step = step << 1;
}

Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004 Chapter 19, Slide 49
FFT Implementation
How to declare and access twiddle factors:
(1) How to declare the twiddle factors:
struct {
short real; // 32767 * cos (2*pi*n) -> Q15 format
short imag; // 32767 * sin (2*pi*n) -> Q15 format
} w[] = { 32767,0,
32767,-201,
...
};
short temp_real, temp_imag;

temp_real = w[i].real;
temp_imag = w[i].imag;
(2) How to access the twiddle factors:
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004 Chapter 19, Slide 50
FFT Implementation
Links:
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 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



Laboratory sheet: FFTLabSheet.pdf
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004 Chapter 19, Slide 51
FFT test on the DSK6713
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004 Chapter 19, Slide 52
FFT test on the DSK6416
Chapter 19
Fast Fourier Transform (FFT)
(Theory and Implementation)
- End -

You might also like