You are on page 1of 54

Chapter 19

Fast Fourier Transform (FFT)


(Theory and Implementation)

Learning Objectives

Chapter 19, Slide 2

DFT algorithm.
Conversion of DFT to FFT algorithm.
Implementation of the FFT algorithm.

Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004

DFT Algorithm

The Fourier transform of an analogue


signal x(t) is given by:
X

jt

x
t
e
dt

The Discrete Fourier Transform (DFT) of


a discrete-time signal x(nT) is given by:
N 1

X k xn e

2
nk
N

n 0

Chapter 19, Slide 3

Where:

k 0,1, N 1
xnT xn
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004

DFT Algorithm

If we let:

2
N

X k

then:

WN

N 1

xnW

nk
N

n 0

Sampled signal
2

Amplitude

1
0
-1
-2

20

40

60
80
Sample
Frequency Domain

100

120

Magnitude

0.8
0.6
0.4
0.2
0

Chapter 19, Slide 4

0.1

0.2
0.3
Normalised Frequency

0.4

0.5

Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004

DFT Algorithm
X k

N 1

x[n] = input
xnWNnk

n 0

X[k] = frequency bins


W

= twiddle factors

X(0)

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

X(1)

= x[0]WN0 + x[1]WN1*1 ++ x[N-1]WN1*(N-1)


:

X(k)

= x[0]WN0 + x[1]WNk*1 ++ x[N-1]WNk*(N-1)


:

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

Note: For N samples of x we have N frequencies


representing the signal.
Chapter 19, Slide 5

Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004

Performance of the DFT Algorithm

The DFT requires N2 (NxN) complex


multiplications:

The DFT also requires (N-1)*N complex


additions:

Chapter 19, Slide 6

Each X(k) requires N complex


multiplications.
Therefore to evaluate all the values of the
DFT ( X(0) to X(N-1) ) N2 multiplications are
required.

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

120

120

Number of Additions

Number of Multiplications

Performance of the DFT Algorithm

100
80
60
40
20

100
80
60
40
20
0

0
0

Number of Samples

Chapter 19, Slide 7

10

10

Number of Samples

Can the number of computations required


be reduced?
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004

DFT FFT

Chapter 19, Slide 8

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

DFT FFT
X k

N 1

xnWNnk ; 0 k N 1

n 0

[1]

x[n] = x[0], x[1], , x[N-1]

Lets divide the sequence x[n] into even


and odd sequences:

Chapter 19, Slide 9

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

DFT FFT

Equation 1 can be rewritten as:


X k

N
1
2

x2nW

2 nk
N

n 0

N
1
2

x2n 1W

2 n 1k
N

[2]

n 0

Since:
WN2 nk e

2
2 nk
N

2
nk
N 2

WN2 n 1k WNk W Nnk

W Nnk

Then:
X k

N
1
2

n 0

x2nW Nnk WNk


2

n 0

Y k WNk Z k
Chapter 19, Slide 10

N
1
2

x2n 1W Nnk
2

Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004

DFT FFT

The result is that an N-point DFT can be


divided into two N/2 point DFTs:
X k

N 1

xnW

nk
N

; 0 k N 1

N-point DFT

n 0

Where Y(k) and Z(k) are the two N/2


point DFTs operating on even and odd
samples respectively:
X k

N
1
2

n 0

x1 nW Nnk WNk
2

Y k WNk Z k
Chapter 19, Slide 11

N
1
2

n 0

x2 nW Nnk
2

Two N/2point DFTs

Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004

DFT FFT

Periodicity and symmetry of W can be


exploited to simplify the DFT further:
X k

N
1
2

x1 nW Nnk W Nk

n 0

N
1
2

x2 nW Nnk

n 0

[3]

X k
2

Or:
And:

WN

N
2

N
n k
x1 n W N 2
n 0
2

WN
2

Chapter 19, Slide 12

N
1
2

N
2

2
k
N

2 N
N 2

2
k
N 2

e
j

N
1
2
N
k
WN 2
x2

n 0

2
k
N

2 N
N 2 2

e
2
k
N 2

N
n k
n W N 2
2

2
k
N

W Nk

WNk

: Symmetry

: Periodicity

Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004

DFT FFT
Symmetry and periodicity:

W86
W8 5

W87

W84
W8

W80 = W88
3

W8

1=

W8

WNk+N/2 = -WNk
WN/2k+N/2 = WN/2k
W8k+4 = -W8k

W8k+8 = W8k

W82

Chapter 19, Slide 13

Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004

DFT FFT

Finally by exploiting the symmetry and


periodicity, Equation 3 can be written as:
N
1
2

N
1
2

X k x1 nW Nnk WNk x2 nW Nnk


2 n 0

n0
2
2

[4]

Y k WNk Z k

Chapter 19, Slide 14

Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004

DFT FFT
N
k 0, 1
2

N
k
X k Y k WN Z k ; k 0, 1
2

X k Y k WNk Z k ;

Y(k) and WNk 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).

Chapter 19, Slide 15

Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004

DFT FFT
N
k 0, 1
2

N
k
X k Y k WN Z k ; k 0, 1
2

X k Y k WNk Z k ;

Y(k) and Z(k) can also be divided into N/4


point DFTs using the same process shown
above:
Y k U k W Nk V k
2

Y k U k W Nk V k
4

Z k Pk W Nk Qk
2

Z k Pk W Nk Qk
4

The process continues until we reach 2


point DFTs.

Chapter 19, Slide 16

Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004

DFT FFT
x[0]
x[2]
x[4]

N/2 point
DFT

x[N-1]

X[0] = y[0]+W0z[0]
X[1] = y[1]+W1z[1]

y[N-2]

x[N-2]

x[1]
x[3]
x[5]

y[0]
y[1]
y[2]

N/2 point
DFT

z[0]
z[1]
z[2]

W0
W1

-1
-1

X[N/2] = y[0]-W0z[0]
X[N/2+1] = y[1]-W1z[1]

z[N/2-1]

Illustration of the first decimation in time


FFT.

Chapter 19, Slide 17

Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004

FFT Implementation

Calculation of the output of a butterfly:


Y(k) =

WNkZ(k) = (Lr+jLi)(Wr+jWi)

Key:

U=Ur+jUi = X(k)

Ur+jUi

-1

L=Lr+jLi = X(k+N/2)

U = Upper

r = real

L = Lower

i = imaginary

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.

Chapter 19, Slide 18

Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004

FFT Implementation

Calculation of the output of a butterfly:


Ur+jUi

U=Ur+jUi

(Lr+jLi)(Wr+jWi)

L=Lr+jLi

-1

Lr jLi Wr jWi LrWr jLrWi jLiWr LiWi


U LrWr LiWi j LrWi LiWr U r jU i
LrWr LiWi U r j LrWi LiWr U i

L U r jU i LrWr LiWi j LrWi LiWr


U r LrWr LiWi j U i LrWi LiWr

Chapter 19, Slide 19

Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004

FFT Implementation

Calculation of the output of a butterfly:


U=Ur+jUi = (Lr Wr - Li Wi + Ur)+j(Lr Wi + Li Wr + Ui)

Ur+jUi
(Lr+jLi)(Wr+jWi)

-1

L=Lr+jLi = (Ur - Lr Wr + Li Wi)+j(Ui - Lr Wi - Li Wr)

To further minimise the number of


operations (* and +), the following are
calculated only once:
temp1 = LrWr

temp2 = LiWi

temp1_2 = temp1 - temp2

temp3 = LrWi

temp4 = LiWr

temp3_4 = temp3 + temp4

Ur = temp1 - temp2 + Ur = temp1_2 + Ur


Ui = temp3 + temp4 + Ui = temp3_4 + Ui
Lr = Ur - temp1 + temp2 = Ur - temp1_2
Li = Ui - temp3 - temp4
Chapter 19, Slide 20

= Ui - temp3_4

Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004

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;

Chapter 19, Slide 21

Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004

FFT Implementation

To efficiently implement the FFT


algorithm a few observations are made:

Chapter 19, Slide 22

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/2stage).
The difference between the upper and lower
leg is equal to 2stage-1.
The number of butterflies in the group is
equal to 2stage-1.

Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004

FFT

Chapter 19, Slide 23

Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004

FFT Implementation
Example: 8 point FFT
W0

W0

W0

W0

-1

-1

W0

-1

W2

-1

-1

W0

-1

W0

-1

W1

-1

W0

-1

W2

-1

W2

-1

W3

-1

Decimation in time FFT:

Chapter 19, Slide 24

Number of stages = log2N


Number of blocks/stage = N/2stage
Number of butterflies/block = 2stage-1
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004

FFT Implementation
Example: 8 point FFT
(1) Number of stages:
W0

W0

W0

W0

-1

-1

W0

-1

W2

-1

-1

W0

-1

W0

-1

W1

-1

W0

-1

W2

-1

W2

-1

W3

-1

Decimation in time FFT:

Chapter 19, Slide 25

Number of stages = log2N


Number of blocks/stage = N/2stage
Number of butterflies/block = 2stage-1
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004

FFT Implementation
Stage 1

W0

W0

W0

W0

Example: 8 point FFT


(1) Number of stages:
Nstages = 1

-1

-1

W0

-1

W2

-1

-1

W0

-1

W0

-1

W1

-1

W0

-1

W2

-1

W2

-1

W3

-1

Decimation in time FFT:

Chapter 19, Slide 26

Number of stages = log2N


Number of blocks/stage = N/2stage
Number of butterflies/block = 2stage-1
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004

FFT Implementation
Stage 1

W0

W0

W0

W0

Stage 2

Example: 8 point FFT


(1) Number of stages:
Nstages = 2

-1

-1

W0

-1

W2

-1

-1

W0

-1

W0

-1

W1

-1

W0

-1

W2

-1

W2

-1

W3

-1

Decimation in time FFT:

Chapter 19, Slide 27

Number of stages = log2N


Number of blocks/stage = N/2stage
Number of butterflies/block = 2stage-1
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004

FFT Implementation
Stage 1

W0

W0

W0

W0

Stage 2

Stage 3

Example: 8 point FFT


(1) Number of stages:
Nstages = 3

-1

-1

W0

-1

W2

-1

-1

W0

-1

W0

-1

W1

-1

W0

-1

W2

-1

W2

-1

W3

-1

Decimation in time FFT:

Chapter 19, Slide 28

Number of stages = log2N


Number of blocks/stage = N/2stage
Number of butterflies/block = 2stage-1
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004

FFT Implementation
Stage 1

W0

W0

W0

W0

Stage 2

Stage 3

Example: 8 point FFT


(1) Number of stages:
Nstages = 3
(2) Blocks/stage:
Stage 1:

-1

-1

W0

-1

W2

-1

-1

W0

-1

W0

-1

W1

-1

W0

-1

W2

-1

W2

-1

W3

-1

Decimation in time FFT:

Chapter 19, Slide 29

Number of stages = log2N


Number of blocks/stage = N/2stage
Number of butterflies/block = 2stage-1
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004

FFT Implementation
Stage 1

Stage 2

Stage 3

Example: 8 point FFT


(1) Number of stages:
Nstages = 3
(2) Blocks/stage:
Stage 1: Nblocks = 1

Block 1
W0

W0

W0

W0

-1

-1

W0

-1

W2

-1

-1

W0

-1

W0

-1

W1

-1

W0

-1

W2

-1

W2

-1

W3

-1

Decimation in time FFT:

Chapter 19, Slide 30

Number of stages = log2N


Number of blocks/stage = N/2stage
Number of butterflies/block = 2stage-1
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004

FFT Implementation
Stage 1

Stage 2

Stage 3

Example: 8 point FFT


(1) Number of stages:
Nstages = 3
(2) Blocks/stage:
Stage 1: Nblocks = 2

Block 1
W0

-1

Block 2
W0

W0

W0

-1

W0

-1

W2

-1

-1

W0

-1

W0

-1

W1

-1

W0

-1

W2

-1

W2

-1

W3

-1

Decimation in time FFT:

Chapter 19, Slide 31

Number of stages = log2N


Number of blocks/stage = N/2stage
Number of butterflies/block = 2stage-1
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004

FFT Implementation
Stage 1

Stage 2

Stage 3

Example: 8 point FFT


(1) Number of stages:
Nstages = 3
(2) Blocks/stage:
Stage 1: Nblocks = 3

Block 1
W0

-1

Block 2
W0

-1

W0

-1

W2

-1

Block 3
W0

W0

-1

W0

-1

W0

-1

W1

-1

W0

-1

W2

-1

W2

-1

W3

-1

Decimation in time FFT:

Chapter 19, Slide 32

Number of stages = log2N


Number of blocks/stage = N/2stage
Number of butterflies/block = 2stage-1
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004

FFT Implementation
Stage 1

Stage 2

Stage 3

Example: 8 point FFT


(1) Number of stages:
Nstages = 3
(2) Blocks/stage:
Stage 1: Nblocks = 4

Block 1
W0

-1

Block 2
W0

-1

W0

-1

W2

-1

Block 3
W0

-1

W0

Block 4
W0

-1

W0

-1

W1

-1

W0

-1

W2

-1

W2

-1

W3

-1

Decimation in time FFT:

Chapter 19, Slide 33

Number of stages = log2N


Number of blocks/stage = N/2stage
Number of butterflies/block = 2stage-1
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004

FFT Implementation
Stage 1

Block 1

W0

W0

W0

W0

Stage 2

Stage 3

Example: 8 point FFT


(1) Number of stages:
Nstages = 3
(2) Blocks/stage:
Stage 1: Nblocks = 4
Stage 2: Nblocks = 1

-1

-1

W0

-1

W2

-1

-1

W0

-1

W0

-1

W1

-1

W0

-1

W2

-1

W2

-1

W3

-1

Decimation in time FFT:

Chapter 19, Slide 34

Number of stages = log2N


Number of blocks/stage = N/2stage
Number of butterflies/block = 2stage-1
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004

FFT Implementation
Stage 1

Block 1

W0

W0

Block 2

W0

W0

Stage 2

Stage 3

Example: 8 point FFT


(1) Number of stages:
Nstages = 3
(2) Blocks/stage:
Stage 1: Nblocks = 4
Stage 2: Nblocks = 2

-1

-1

W0

-1

W2

-1

-1

W0

-1

W0

-1

W1

-1

W0

-1

W2

-1

W2

-1

W3

-1

Decimation in time FFT:

Chapter 19, Slide 35

Number of stages = log2N


Number of blocks/stage = N/2stage
Number of butterflies/block = 2stage-1
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004

FFT Implementation
Stage 1

W0

Block 1

W0

W0

W0

Stage 2

Stage 3

Example: 8 point FFT


(1) Number of stages:
Nstages = 3
(2) Blocks/stage:
Stage 1: Nblocks = 4
Stage 2: Nblocks = 2
Stage 3: Nblocks = 1

-1

-1

W0

-1

W2

-1

-1

W0

-1

W0

-1

W1

-1

W0

-1

W2

-1

W2

-1

W3

-1

Decimation in time FFT:

Chapter 19, Slide 36

Number of stages = log2N


Number of blocks/stage = N/2stage
Number of butterflies/block = 2stage-1
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004

FFT Implementation
Stage 1

W0

W0

W0

W0

Stage 2

Stage 3

Example: 8 point FFT


(1) Number of stages:
Nstages = 3
(2) Blocks/stage:
Stage 1: Nblocks = 4
Stage 2: Nblocks = 2
Stage 3: Nblocks = 1
(3) Bflies/block:
Stage 1:

-1

-1

W0

-1

W2

-1

-1

W0

-1

W0

-1

W1

-1

W0

-1

W2

-1

W2

-1

W3

-1

Decimation in time FFT:

Chapter 19, Slide 37

Number of stages = log2N


Number of blocks/stage = N/2stage
Number of butterflies/block = 2stage-1
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004

FFT Implementation
Stage 1

W0

W0

W0

W0

Stage 2

Stage 3

Example: 8 point FFT


(1) Number of stages:
Nstages = 3
(2) Blocks/stage:
Stage 1: Nblocks = 4
Stage 2: Nblocks = 2
Stage 3: Nblocks = 1
(3) Bflies/block:
Stage 1: Nbtf = 1

-1

-1

W0

-1

W2

-1

-1

W0

-1

W0

-1

W1

-1

W0

-1

W2

-1

W2

-1

W3

-1

Decimation in time FFT:

Chapter 19, Slide 38

Number of stages = log2N


Number of blocks/stage = N/2stage
Number of butterflies/block = 2stage-1
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004

FFT Implementation
Stage 1

W0

W0

W0

W0

Stage 2

Stage 3

-1

-1

W0

-1

W2

-1

-1

W0

-1

W0

-1

W1

-1

W0

-1

W2

-1

W2

-1

W3

-1

Decimation in time FFT:

Chapter 19, Slide 39

Example: 8 point FFT


(1) Number of stages:
Nstages = 3
(2) Blocks/stage:
Stage 1: Nblocks = 4
Stage 2: Nblocks = 2
Stage 3: Nblocks = 1
(3) Bflies/block:
Stage 1: Nbtf = 1
Stage 2: Nbtf = 1

Number of stages = log2N


Number of blocks/stage = N/2stage
Number of butterflies/block = 2stage-1
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004

FFT Implementation
Stage 1

W0

W0

W0

W0

Stage 2

Stage 3

-1

-1

W0

-1

W2

-1

-1

W0

-1

W0

-1

W1

-1

W0

-1

W2

-1

W2

-1

W3

-1

Decimation in time FFT:

Chapter 19, Slide 40

Example: 8 point FFT


(1) Number of stages:
Nstages = 3
(2) Blocks/stage:
Stage 1: Nblocks = 4
Stage 2: Nblocks = 2
Stage 3: Nblocks = 1
(3) Bflies/block:
Stage 1: Nbtf = 1
Stage 2: Nbtf = 2

Number of stages = log2N


Number of blocks/stage = N/2stage
Number of butterflies/block = 2stage-1
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004

FFT Implementation
Stage 1

Stage 2

Stage 3

Example: 8 point FFT


(1) Number of stages:
W
-1
Nstages = 3
W
-1
(2) Blocks/stage:
W
-1
W
-1
Stage 1: Nblocks = 4
W
-1
Stage 2: Nblocks = 2
W
-1
W
-1
W
Stage 3: Nblocks = 1
W
W
-1
-1
(3) Bflies/block:
W
-1
W
-1
W
-1
Stage 1: Nbtf = 1
Stage 2: Nbtf = 2
Decimation in time FFT:
Stage 3: Nbtf = 1
Number of stages = log2N
0

Chapter 19, Slide 41

Number of blocks/stage = N/2stage


Number of butterflies/block = 2stage-1
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004

FFT Implementation
Stage 1

Stage 2

Stage 3

Example: 8 point FFT


(1) Number of stages:
W
-1
Nstages = 3
W
-1
(2) Blocks/stage:
W
-1
W
-1
Stage 1: Nblocks = 4
W
-1
Stage 2: Nblocks = 2
W
-1
W
-1
W
Stage 3: Nblocks = 1
W
W
-1
-1
(3) Bflies/block:
W
-1
W
-1
W
-1
Stage 1: Nbtf = 1
Stage 2: Nbtf = 2
Decimation in time FFT:
Stage 3: Nbtf = 2
Number of stages = log2N
0

Chapter 19, Slide 42

Number of blocks/stage = N/2stage


Number of butterflies/block = 2stage-1
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004

FFT Implementation
Stage 1

Stage 2

Stage 3

Example: 8 point FFT


(1) Number of stages:
W
-1
Nstages = 3
W
-1
(2) Blocks/stage:
W
-1
W
-1
Stage 1: Nblocks = 4
W
-1
Stage 2: Nblocks = 2
W
-1
W
-1
W
Stage 3: Nblocks = 1
W
W
-1
-1
(3) Bflies/block:
W
-1
W
-1
W
-1
Stage 1: Nbtf = 1
Stage 2: Nbtf = 2
Decimation in time FFT:
Stage 3: Nbtf = 3
Number of stages = log2N
0

Chapter 19, Slide 43

Number of blocks/stage = N/2stage


Number of butterflies/block = 2stage-1
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004

FFT Implementation
Stage 1

Stage 2

Stage 3

Example: 8 point FFT


(1) Number of stages:
W
-1
Nstages = 3
W
-1
(2) Blocks/stage:
W
-1
W
-1
Stage 1: Nblocks = 4
W
-1
Stage 2: Nblocks = 2
W
-1
W
-1
W
Stage 3: Nblocks = 1
W
W
-1
-1
(3) Bflies/block:
W
-1
W
-1
W
-1
Stage 1: Nbtf = 1
Stage 2: Nbtf = 2
Decimation in time FFT:
Stage 3: Nbtf = 4
Number of stages = log2N
0

Chapter 19, Slide 44

Number of blocks/stage = N/2stage


Number of butterflies/block = 2stage-1
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004

FFT Implementation
Stage 1

W0

-1

W0

-1

W0

Chapter 19, Slide 45

Stage 3

-1

W0

Start Index
Input Index
Twiddle Factor Index

Stage 2

-1

0
1

W0

-1

W2

-1

W0

W0

-1

W1

-1

W0

-1

W2

-1

W2

-1

W3

-1

0
2

0
4

N/2 = 4

Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004

FFT Implementation
Stage 1

W0

-1

W0

-1

W0

Chapter 19, Slide 46

Stage 3

-1

W0

Start Index
Input Index
Twiddle Factor Index

Stage 2

-1

0
1
N/2 = 4

W0

-1

W2

-1

W0

W0

-1

W1

-1

W0

-1

W2

-1

W2

-1

W3

-1

0
2

0
4

4 /2 = 2

Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004

FFT Implementation
Stage 1

W0

-1

W0

-1

W0

Chapter 19, Slide 47

Stage 3

-1

W0

Start Index
Input Index
Twiddle Factor Index

Stage 2

-1

0
1
N/2 = 4

W0

-1

W2

-1

W0

W0

-1

W1

-1

W0

-1

W2

-1

W2

-1

W3

-1

0
2
4 /2 = 2

0
4
2 /2 = 1

Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004

FFT Implementation
Stage 1

W0

Stage 3

-1

W0

-1

W0

-1

W0

Start Index
Input Index
Twiddle Factor Index
Indicies Used

Stage 2

-1

0
1
N/2 = 4
W0

W0

-1

W2

-1

W0

W0

-1

W1

-1

W0

-1

W2

-1

W2

-1

W3

-1

0
2

0
4

4 /2 = 2
W0

2 /2 = 1

W2

W1

W0
W2
W3

Chapter 19, Slide 48

Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004

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;
step = 1;
NB = N/2;

/* Group step initial value */


/* Initial value */
/* NB is a constant */

for (k=N; k>1; k>>1)


/*
{
for (j=0; j<N; j+=GS)
/*
{
for (n=j; n<(j+GS-1); n+=step) /*
{
upperindex = n;
lowerindex = n+step;
}
}
/* Change the GS and step for the next

Repeat this loop for each stage */


Repeat this loop for each block */
Repeat this loop for each butterfly */

stage */

GS = GS << 1;
step = step << 1;
}
Chapter 19, Slide 49

Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004

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,
...
};

(2) How to access the twiddle factors:


short temp_real, temp_imag;
temp_real = w[i].real;
temp_imag = w[i].imag;

Chapter 19, Slide 50

Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004

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

Chapter 19, Slide 51

Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004

FFT test on the DSK6713

Chapter 19, Slide 52

Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004

FFT test on the DSK6416

Chapter 19, Slide 53

Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004

Chapter 19
Fast Fourier Transform (FFT)
(Theory and Implementation)
- End -

You might also like