Professional Documents
Culture Documents
Chapter 19
Chapter 19
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 xt e jt dt
n 0
Where: k 0,1, N 1
xnT xn
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 xnWNnk
n0
Chapter 19, Slide 4 Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
DFT Algorithm
x[n] = input
N 1
X k xnWNnk X[k] = frequency bins
n0
W = twiddle factors
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
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-j2n/N = e-j2(n+N)/N WN n = WNn+N
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 = 10 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
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
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
Since:
2 2
j 2 nk j nk
WN2 nk e N
e N 2
WN2 n 1k WNk W Nnk
W Nnk 2
2
Then: N
1
N
1
2 2
X k x2 n
W nk
N W k
N x2 n 1W 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 xnWNnk ; 0 k N 1 N-point DFT
n0
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 nW Nnk WNk n 0
x2 nW 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 nW Nnk WNk x2 nW Nnk
2 2
2 n0 2 n0 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
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
N N
Y k U k W Nk V k Z k Pk W Nk Qk
4 2 4 2
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)
(Lr+jLi)(Wr+jWi) L’=Lr’+jLi’
-1
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)
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
W0 -1
W0 -1 W2 -1
W0 -1
W0 -1 W1 -1
W0
W0 -1 W2 -1
W0 -1 W2 -1 W3 -1
W0 -1 W2 -1
W0 -1
W0 -1 W1 -1
W0
W0 -1 W2 -1
W0 -1 W2 -1 W3 -1
W0 -1 W2 -1
W0 -1
W0 -1 W1 -1
W0
W0 -1 W2 -1
W0 -1 W2 -1 W3 -1
W0 -1 W2 -1
W0 -1
W0 -1 W1 -1
W0
W0 -1 W2 -1
W0 -1 W2 -1 W3 -1
W0 -1 W1 -1
W0
W0 -1 W2 -1
W0 -1 W2 -1 W3 -1
W0 -1 W1 -1
W0
W0 -1 W2 -1
W0 -1 W2 -1 W3 -1
W0 -1 W1 -1
W0
W0 -1 W2 -1
W0 -1 W2 -1 W3 -1
W0 -1 W1 -1
W0
W0 -1 W2 -1
W0 -1 W2 -1 W3 -1
W0 -1 W1 -1
W0
W0 -1 W2 -1
Block 4
W0 -1 W2 -1 W3 -1
W0 -1 W2 -1 W3 -1
W0 -1 W2 -1 W3 -1
W0 -1 W2 -1 W3 -1
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
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
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
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
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,
...
};
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
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 -