Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 61

Fast Fourier Transform (FFT)

(Theory and Implementation)


Learning Objectives
 DFT algorithm.
 Conversion of DFT to FFT algorithm.
 Implementation of the FFT algorithm.

Chapter 19, Slide 2 Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
DFT Algorithm
 The Fourier transform of an analogue
signal x(t) is given by:

X     xt e  jt dt


 The Discrete Fourier Transform (DFT) of


a discrete-time signal x(nT) is given by:
N 1 2
X k    xne
j nk
N

n 0

 Where: k  0,1, N  1
xnT   xn

Chapter 19, Slide 3 Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
DFT Algorithm
2 N 1
j
 If we let: e N
 WN then: X k    xnWNnk
n0

Chapter 19, Slide 4 Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
DFT Algorithm
x[n] = input
N 1
X k    xnWNnk X[k] = frequency bins
n0
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:
 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.
 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.
Chapter 19, Slide 6 Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Performance of the DFT Algorithm

120 120
Number of Multiplications

Number of Additions
100 100
80 80

60 60
40 40

20 20
0 0
0 1 2 3 4 5 6 7 8 9 10 0 1 2 3 4 5 6 7 8 9 10
Number of Samples Number of Samples

 Can the number of computations required


be reduced?

Chapter 19, Slide 7 Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
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.
 FFT is an algorithm to convert a time domain signal
to DFT efficiently.
 FFT is not unique. Many algorithms are available.
 Each algorithm has merits and demerits.
 In each algorithm, depending on the sequence
needed at the output, the input is regrouped.
 The groups are decided by the number of samples.

Chapter 19, Slide 8 Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
FFTs
 The purpose of this series of lectures is to
learn the basics of FFT algorithms.
 Algorithms having number of samples 2N,
where N is an integer is most preferred.
 8 point radix-2 FFT by decimation is used
from learning point of view.
 Radix-x: here ‘x’ represents number of
samples in each group made at the first
stage. They are generally equal.
 We shall study radix-2 and radix-3.
Chapter 19, Slide 9 Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Radix-2: DIT or, DIF
Radix-2 is the first FFT algorithm. It was proposed by
Cooley and Tukey in 1965.
Though it is not the efficient algorithm, it lays
foundation for time-efficient DFT calculations.
The next slide shows the saving in time required for
calculations with radix-2.
The algorithms appear either in
(a) Decimation In Time (DIT), or,
(b) Decimation In Frequency (DIF).
DIT and DIF, both yield same complexity and results.
They are complementary.
We shall stress on 8 to radix 2 DIT FFT.
Chapter 19, Slide 10 Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Relationship between exponential forms and
twiddle factors (W) for Periodicity = N
Sr. Exponential form Symbolic form
No.
01 e-j2n/N = e-j2(n+N)/N WN n = WNn+N

02 e-j2(n+N/2)/N = - e-j2n/N WNn+N/2= - WNn

03 e-j2k = e-j2Nk/N = 1 WNN+K = 1

04 e-j2(2/N) = e-j2/(N/2) WN2 = WN/2

Chapter 19, Slide 11 Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Values of various twiddles WNn for
length N=8
n WNn = e(-j2)(n/N) Remarks
0 1 = 10 WN 0
1 (1-j)/√2 = 1 -45 WN 1
2 -j = 1 -90 WN 2
3 - (1+j)/√2 = 1-135 WN 3
4 -1 = 1 -180 WN 4 = -WN 0
5 - (1-j)/√2 = 1 -225 WN 5 = -WN 1
6 j = 1 90 WN 6 = -WN 2
7 (1+j)/√2 = 1 45 WN 7 = -WN 3
Chapter 19, Slide 12 Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
FOR 8 point DFT: N=8
 The system Matrix is:
W80x0 W80x1 W80x2 W80x3 W80x4 W80x5 W80x6 W80x7

W81x0 W81x1 W81x2 W81x3 W81x4 W81x5 W81x6 W81x7

W82x0 W82x1 W82x2 W82x3 W82x4 W82x5 W82x6 W82x7

W83x0 W83x1 W83x2 W83x3 W83x4 W83x5 W83x6 W83x7

W84x0 W84x1 W84x2 W84x3 W84x4 W84x5 W84x6 W84x7

W85x0 W85x1 W85x2 W85x3 W85x4 W85x5 W85x6 W85x7

W86x0 W86x1 W86x2 W86x3 W86x4 W86x5 W86x6 W86x7

W87x0 W87x1 W87x2 W87x0 W87x4 W87x5 W87x6 W87x7


Chapter 19, Slide 13 Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
The characteristic matrix of 8-point
DFT is:
1 1 1 1 1 1 1 1 
 
1 1  j ( 1  j) ( 1  j) 1  j 
j 1 j
 2 2 2 2 
1 j 1 j 1 j 1 j

 
1 ( 1  j)
j
1  j
1
1  j
j
( 1  j) 
 2 2 2 2 
 
1 1 1 1
1 1 1 1

 ( 1  j) 1  j 1  j ( 1  j) 
j 1
1 2 2 2
j
2 
 
1 j 1 j 1 j 1 j 
 1  j ( 1  j) ( 1  j) ( 1  j) 
1 j 1 j 
 2 2 2 2 

Chapter 19, Slide 14 Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
DFT and its Inverse
Conversion in system matrices of DFT and IDFT obtained by
replacing by j by –j..

1 1 1 1 1 1 1 1   1 1 1 1 1 1 1 1 
   
1 1  j j
( 1  j)
1
( 1  j)
j
1 j   1 1 j
j 
1 j
1 
1 j
j
1  j 
 2 2 2 2   2 2 2 2 
1 j 1 j 1 j 1 j
  1 j 1 j 1 j 1 j

   
1 ( 1  j) j
1 j
1
1 j
j
( 1  j)   1 
1 j
j
1 j
1
1 j
j 
1  j 
 2 2 2 2  1  2 2 2 2 
    
1 1 1 1 1 1 1 1
1 1 1 1
 8
 1 1 1 1

 ( 1  j) 1 j 1 j ( 1  j)   1 j 1 j 1 j 1  j 
j 1  1 j 
1 2 2 2
j
2   1 2
j
2 2 2 
   
1 j 1 j 1 j 1 j   1 j 1 j 1 j 1 j 
 1 j ( 1  j) ( 1  j) ( 1  j)   1 j 1 j 1 j 1  j 
1 j 1 j   1 j  1  j 
 2 2 2 2   2 2 2 2 

DFT Effective IDFT


Chapter 19, Slide 15
determinant
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
DFT  FFT
N 1
X k    xnWNnk ; 0  k  N  1 [1]
n0

x[n] = x[0], x[1], …, x[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]

Chapter 19, Slide 16 Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 19, Slide 17 Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
DFT  FFT
 Equation 1 can be rewritten as:
N N
1 1

X k    x2nWN2nk   x2n  1WN2n 1k


2 2
[2]
n 0 n 0

 Since:
2 2
j 2 nk j nk
WN2 nk  e N
e N 2
WN2 n 1k  WNk  W Nnk
 W Nnk 2
2

 Then: N
1
N
1
2 2
X k    x2 n 
W nk
N  W k
N  x2 n  1W nk
N
n 0 2 n 0 2

 Y k   WNk Z k 
Chapter 19, Slide 18 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 DFT’s:
N 1
X k    xnWNnk ; 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:
N N
1 1
2 2
X k   x 
1 N N
n 
W nk
 W k
x 
2 Nn 
W nk
Two N/2-
n 0 2 n 0 2 point DFTs
 Y k   WNk Z k 

Chapter 19, Slide 19 Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
DFT  FFT
 Periodicity and symmetry of W can be
exploited to simplify the DFT further:
N N
1 1
2 2
X k   n 0
x1 nW Nnk  WNk  n 0
x2 nW Nnk [3]
2 2

N N
1  N 1  N
n k   n k  
 N 2 2
   
N
k
X k    x1 n W N 2   WN 2 x2 n W N 2 
 2 n 0 2 n 0 2

N 2 2 N 2 2
Or: WN
k
2
e
j
N
k
e
j
N 2
e
j
N
k
e  j
 e
j
N
k
 WNk : Symmetry

N 2 2 N 2
k j k j j k
And: WN 2
e N 2
e N 2 2
e N 2
 W Nk : Periodicity
2 2
Chapter 19, Slide 20 Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
DFT  FFT
 Symmetry and periodicity:

W86
W8 5 W87
WNk+N/2 = -WNk
WN/2k+N/2 = WN/2k
W84 W80 = W88
W8k+4 = -W8k
W8k+8 = W8k
W8 3 W81 = W89
W82

Chapter 19, Slide 21 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 N
1 1
 N
X  k     x1 nW Nnk  WNk  x2 nW Nnk
2 2

 2  n0 2 n0 2
[4]
 Y k   WNk Z k 

Chapter 19, Slide 22 Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
DFT  FFT
N 
X k   Y k   WNk Z k ; k  0,   1
2 
 N N 
X  k    Y k   WNk Z k ; k  0,  1
 2 2 

 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 23 Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
DFT  FFT
N 
X k   Y k   WNk Z k ; k  0,   1
2 
 N N 
X  k    Y k   WNk Z k ; k  0,  1
 2 2 

 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  Z k   Pk   W Nk Qk 
2 2

 N  N
Y  k    U k   W Nk V k  Z  k    Pk   W Nk Qk 
 4 2  4 2

 The process continues until we reach 2


point DFTs.
Chapter 19, Slide 24 Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
DFT  FFT

x[0] y[0] X[0] = y[0]+W0z[0]


x[2] y[1] X[1] = y[1]+W1z[1]
x[4] N/2 point y[2]
DFT
x[N-2] y[N-2]

x[1] z[0] X[N/2] = y[0]-W0z[0]


x[3] z[1] W0 -1 X[N/2+1] = y[1]-W1z[1]
x[5] N/2 point z[2] W1 -1
DFT
x[N-1] z[N/2-1]

 Illustration of the first decimation in time


FFT.

Chapter 19, Slide 25 Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
FFT Implementation
 Calculation of the output of a ‘butterfly’:
Y(k) = Ur+jUi U’=Ur’+jUi’ = X(k)

WNkZ(k) = (Lr+jLi)(Wr+jWi) L’=Lr’+jLi’ = X(k+N/2)


-1
Key: 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 26 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 27 Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
FFT Implementation
 Calculation of the output of a ‘butterfly’:
Ur+jUi U’=Ur’+jUi’ = (Lr Wr - Li Wi + Ur)+j(Lr Wi + Li Wr + Ui)

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


-1
 To further minimise the number of
operations (* and +), the following are
calculated only once:
temp1 = LrWr temp2 = LiWi temp3 = LrWi temp4 = LiWr
temp1_2 = temp1 - temp2 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 = Ui - temp3_4
Chapter 19, Slide 28 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 29 Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
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/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.

Chapter 19, Slide 30 Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
FFT Implementation
Example: 8 point FFT

W0 -1

W0 -1

W0 -1 W2 -1

W0 -1

W0 -1 W1 -1
W0
W0 -1 W2 -1

W0 -1 W2 -1 W3 -1

 Decimation in time FFT:


 Number of stages = log2N
 Number of blocks/stage = N/2stage
 Number of butterflies/block = 2stage-1
Chapter 19, Slide 31 Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
FFT Implementation
Example: 8 point FFT
(1) Number of stages:
W0 -1

W0 -1

W0 -1 W2 -1

W0 -1

W0 -1 W1 -1
W0
W0 -1 W2 -1

W0 -1 W2 -1 W3 -1

 Decimation in time FFT:


 Number of stages = log2N
 Number of blocks/stage = N/2stage
 Number of butterflies/block = 2stage-1
Chapter 19, Slide 32 Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
FFT Implementation
Stage 1
Example: 8 point FFT
(1) Number of stages:
W0 -1
 Nstages = 1
W0 -1

W0 -1 W2 -1

W0 -1

W0 -1 W1 -1
W0
W0 -1 W2 -1

W0 -1 W2 -1 W3 -1

 Decimation in time FFT:


 Number of stages = log2N
 Number of blocks/stage = N/2stage
 Number of butterflies/block = 2stage-1
Chapter 19, Slide 33 Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
FFT Implementation
Stage 1 Stage 2
Example: 8 point FFT
(1) Number of stages:
W0 -1
 Nstages = 2
W0 -1

W0 -1 W2 -1

W0 -1

W0 -1 W1 -1
W0
W0 -1 W2 -1

W0 -1 W2 -1 W3 -1

 Decimation in time FFT:


 Number of stages = log2N
 Number of blocks/stage = N/2stage
 Number of butterflies/block = 2stage-1
Chapter 19, Slide 34 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:
W0 -1
 Nstages = 3
W0 -1

W0 -1 W2 -1

W0 -1

W0 -1 W1 -1
W0
W0 -1 W2 -1

W0 -1 W2 -1 W3 -1

 Decimation in time FFT:


 Number of stages = log2N
 Number of blocks/stage = N/2stage
 Number of butterflies/block = 2stage-1
Chapter 19, Slide 35 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:
W0 -1
 Nstages = 3
W0 -1
(2) Blocks/stage:
W0 -1 W2 -1
 Stage 1:
W0 -1

W0 -1 W1 -1
W0
W0 -1 W2 -1

W0 -1 W2 -1 W3 -1

 Decimation in time FFT:


 Number of stages = log2N
 Number of blocks/stage = N/2stage
 Number of butterflies/block = 2stage-1
Chapter 19, Slide 36 Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
FFT Implementation
Stage 1 Stage 2 Stage 3
Example: 8 point FFT
Block 1 (1) Number of stages:
W0 -1
 Nstages = 3
W0 -1
(2) Blocks/stage:
W0 -1 W2 -1
 Stage 1: Nblocks = 1
W0 -1

W0 -1 W1 -1
W0
W0 -1 W2 -1

W0 -1 W2 -1 W3 -1

 Decimation in time FFT:


 Number of stages = log2N
 Number of blocks/stage = N/2stage
 Number of butterflies/block = 2stage-1
Chapter 19, Slide 37 Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
FFT Implementation
Stage 1 Stage 2 Stage 3
Example: 8 point FFT
Block 1 (1) Number of stages:
W0 -1
 Nstages = 3
W0 -1
Block 2 (2) Blocks/stage:
W0 -1 W2 -1
 Stage 1: Nblocks = 2
W0 -1

W0 -1 W1 -1
W0
W0 -1 W2 -1

W0 -1 W2 -1 W3 -1

 Decimation in time FFT:


 Number of stages = log2N
 Number of blocks/stage = N/2stage
 Number of butterflies/block = 2stage-1
Chapter 19, Slide 38 Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
FFT Implementation
Stage 1 Stage 2 Stage 3
Example: 8 point FFT
Block 1 (1) Number of stages:
W0 -1
 Nstages = 3
W0 -1
Block 2 (2) Blocks/stage:
W0 -1 W2 -1
 Stage 1: Nblocks = 3
Block 3 W0 -1

W0 -1 W1 -1
W0
W0 -1 W2 -1

W0 -1 W2 -1 W3 -1

 Decimation in time FFT:


 Number of stages = log2N
 Number of blocks/stage = N/2stage
 Number of butterflies/block = 2stage-1
Chapter 19, Slide 39 Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
FFT Implementation
Stage 1 Stage 2 Stage 3
Example: 8 point FFT
Block 1 (1) Number of stages:
W0 -1
 Nstages = 3
W0 -1
Block 2 (2) Blocks/stage:
W0 -1 W2 -1
 Stage 1: Nblocks = 4
Block 3 W0 -1

W0 -1 W1 -1
W0
W0 -1 W2 -1
Block 4
W0 -1 W2 -1 W3 -1

 Decimation in time FFT:


 Number of stages = log2N
 Number of blocks/stage = N/2stage
 Number of butterflies/block = 2stage-1
Chapter 19, Slide 40 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:
W0 -1
Block 1  Nstages = 3
W0 -1
(2) Blocks/stage:
W0 -1 W2 -1
 Stage 1: Nblocks = 4
W0 -1
 Stage 2: Nblocks = 1
W0 -1 W1 -1
W0
W0 -1 W2 -1

W0 -1 W2 -1 W3 -1

 Decimation in time FFT:


 Number of stages = log2N
 Number of blocks/stage = N/2stage
 Number of butterflies/block = 2stage-1
Chapter 19, Slide 41 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:
W0 -1
Block 1  Nstages = 3
W0 -1
(2) Blocks/stage:
W0 -1 W2 -1
 Stage 1: Nblocks = 4
W0 -1
 Stage 2: Nblocks = 2
W0 -1
Block 2 W1 -1
W0
W0 -1 W2 -1

W0 -1 W2 -1 W3 -1

 Decimation in time FFT:


 Number of stages = log2N
 Number of blocks/stage = N/2stage
 Number of butterflies/block = 2stage-1
Chapter 19, Slide 42 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:
W0 -1
 Nstages = 3
W0 -1
(2) Blocks/stage:
W0 -1 W2 -1
Block 1  Stage 1: Nblocks = 4
W0 -1
 Stage 2: Nblocks = 2
W0 -1 W1 -1
W0
 Stage 3: Nblocks = 1
W0 -1 W2 -1

W0 -1 W2 -1 W3 -1

 Decimation in time FFT:


 Number of stages = log2N
 Number of blocks/stage = N/2stage
 Number of butterflies/block = 2stage-1
Chapter 19, Slide 43 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:
W0 -1
 Nstages = 3
W0 -1
(2) Blocks/stage:
W0 -1 W2 -1
 Stage 1: Nblocks = 4
W0 -1
 Stage 2: Nblocks = 2
W0 -1 W1 -1
W0
 Stage 3: Nblocks = 1
W0 -1 W2 -1
(3) B’flies/block:
W0 -1 W2 -1 W3 -1
 Stage 1:
 Decimation in time FFT:
 Number of stages = log2N
 Number of blocks/stage = N/2stage
 Number of butterflies/block = 2stage-1
Chapter 19, Slide 44 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:
W0 -1
 Nstages = 3
W0 -1
(2) Blocks/stage:
W0 -1 W2 -1
 Stage 1: Nblocks = 4
W0 -1
 Stage 2: Nblocks = 2
W0 -1 W1 -1
W0
 Stage 3: Nblocks = 1
W0 -1 W2 -1
(3) B’flies/block:
W0 -1 W2 -1 W3 -1
 Stage 1: Nbtf = 1
 Decimation in time FFT:
 Number of stages = log2N
 Number of blocks/stage = N/2stage
 Number of butterflies/block = 2stage-1
Chapter 19, Slide 45 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:
W0 -1
 Nstages = 3
W0 -1
(2) Blocks/stage:
W0 -1 W2 -1
 Stage 1: Nblocks = 4
W0 -1
 Stage 2: Nblocks = 2
W0 -1 W1 -1
W0
 Stage 3: Nblocks = 1
W0 -1 W2 -1
(3) B’flies/block:
W0 -1 W2 -1 W3 -1
 Stage 1: Nbtf = 1
 Decimation in time FFT:  Stage 2: Nbtf = 1

 Number of stages = log2N


 Number of blocks/stage = N/2stage
 Number of butterflies/block = 2stage-1
Chapter 19, Slide 46 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:
W0 -1
 Nstages = 3
W0 -1
(2) Blocks/stage:
W0 -1 W2 -1
 Stage 1: Nblocks = 4
W0 -1
 Stage 2: Nblocks = 2
W0 -1 W1 -1
W0
 Stage 3: Nblocks = 1
W0 -1 W2 -1
(3) B’flies/block:
W0 -1 W2 -1 W3 -1
 Stage 1: Nbtf = 1
 Decimation in time FFT:  Stage 2: Nbtf = 2

 Number of stages = log2N


 Number of blocks/stage = N/2stage
 Number of butterflies/block = 2stage-1
Chapter 19, Slide 47 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 0
 Nstages = 3
W -1 0
(2) Blocks/stage:
W -1 W 0 -1 2
 Stage 1: Nblocks = 4
W -1
 Stage 2: Nblocks = 2
0

W -1 0 W -1
 Stage 3: Nblocks = 1
W 1
0

W -1 W -1
(3) B’flies/block:
0 2

W -1 W 0 -1 W -12 3

 Stage 1: Nbtf = 1
 Decimation in time FFT:  Stage 2: Nbtf = 2

 Number of stages = log2N  Stage 3: Nbtf = 1

 Number of blocks/stage = N/2stage


 Number of butterflies/block = 2stage-1
Chapter 19, Slide 48 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 0
 Nstages = 3
W -1 0
(2) Blocks/stage:
W -1 W 0 -1 2
 Stage 1: Nblocks = 4
W -1
 Stage 2: Nblocks = 2
0

W -1 0 W -1
 Stage 3: Nblocks = 1
W 1
0

W -1 W -1
(3) B’flies/block:
0 2

W -1 W 0 -1 W -12 3

 Stage 1: Nbtf = 1
 Decimation in time FFT:  Stage 2: Nbtf = 2

 Number of stages = log2N  Stage 3: Nbtf = 2

 Number of blocks/stage = N/2stage


 Number of butterflies/block = 2stage-1
Chapter 19, Slide 49 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 0
 Nstages = 3
W -1 0
(2) Blocks/stage:
W -1 W 0 -1 2
 Stage 1: Nblocks = 4
W -1
 Stage 2: Nblocks = 2
0

W -1 0 W -1
 Stage 3: Nblocks = 1
W 1
0

W -1 W -1
(3) B’flies/block:
0 2

W -1 W 0 -1 W -12 3

 Stage 1: Nbtf = 1
 Decimation in time FFT:  Stage 2: Nbtf = 2

 Number of stages = log2N  Stage 3: Nbtf = 3

 Number of blocks/stage = N/2stage


 Number of butterflies/block = 2stage-1
Chapter 19, Slide 50 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 0
 Nstages = 3
W -1 0
(2) Blocks/stage:
W -1 W 0 -1 2
 Stage 1: Nblocks = 4
W -1
 Stage 2: Nblocks = 2
0

W -1 0 W -1
 Stage 3: Nblocks = 1
W 1
0

W -1 W -1
(3) B’flies/block:
0 2

W -1 W 0 -1 W -12 3

 Stage 1: Nbtf = 1
 Decimation in time FFT:  Stage 2: Nbtf = 2

 Number of stages = log2N  Stage 3: Nbtf = 4

 Number of blocks/stage = N/2stage


 Number of butterflies/block = 2stage-1
Chapter 19, Slide 51 Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
FFT Implementation
Stage 1 Stage 2 Stage 3

W0 -1

W0 -1

W0 -1 W2 -1

W0 -1
W0 -1 W1 -1
W0
W0 -1 W2 -1

W0 -1 W2 -1 W3 -1

Start Index 0 0 0
Input Index 1 2 4
Twiddle Factor Index N/2 = 4

Chapter 19, Slide 52 Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
FFT Implementation
Stage 1 Stage 2 Stage 3

W0 -1

W0 -1

W0 -1 W2 -1

W0 -1
W0 -1 W1 -1
W0
W0 -1 W2 -1

W0 -1 W2 -1 W3 -1

Start Index 0 0 0
Input Index 1 2 4
Twiddle Factor Index N/2 = 4 4/2 = 2

Chapter 19, Slide 53 Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
FFT Implementation
Stage 1 Stage 2 Stage 3

W0 -1

W0 -1

W0 -1 W2 -1

W0 -1
W0 -1 W1 -1
W0
W0 -1 W2 -1

W0 -1 W2 -1 W3 -1

Start Index 0 0 0
Input Index 1 2 4
Twiddle Factor Index N/2 = 4 4/2 = 2 2/2 = 1

Chapter 19, Slide 54 Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
FFT Implementation
Stage 1 Stage 2 Stage 3

W0 -1

W0 -1

W0 -1 W2 -1

W0 -1
W0 -1 W1 -1
W0
W0 -1 W2 -1

W0 -1 W2 -1 W3 -1

Start Index 0 0 0
Input Index 1 2 4
Twiddle Factor Index N/2 = 4 4/2 = 2 2/2 = 1
Indicies Used W0 W0 W0
W2 W1
W2
W3
Chapter 19, Slide 55 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; /* 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;
}

Chapter 19, Slide 56 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 57 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 58 Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
FFT test on the DSK6713

Chapter 19, Slide 59 Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
FFT test on the DSK6416

Chapter 19, Slide 60 Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 19
Fast Fourier Transform (FFT)
(Theory and Implementation)
- End -

You might also like