Download - DSP-3 (FFT) (S)
-
7/31/2019 DSP-3 (FFT) (S)
1/17
DSP-3 (FFT) 1 of 17 Dr. Ravi Billa
Digital Signal Processing 3 December 26, 2009
III. Fast Fourier transform
2007 Syllabus: Fast Fourier Transform (FFT) Radix-2 decimation in time and decimation in
frequency FFT Algorithms, Inverse FFT, and FFT for composite N.
Contents:3.1 Introduction
3.2 Radix-2 decimation-in-time FFT (Cooley-Tukey)3.3 Radix-2 decimation-in-frequency FFT (Sande-Tukey)
3.4 Inverse DFT using the FFT algorithm
3.5 *Decimation-in-time algorithm forN= 4 (Cooley-Tukey formulation)
3.6 *Decimation-in-frequency algorithm forN= 4 (Sande-Tukey formulation)3.7 FFT with general radix
w.jntuworld.com
www.jntuworld.com
-
7/31/2019 DSP-3 (FFT) (S)
2/17
DSP-3 (FFT) 2 of 17 Dr. Ravi Billa
3.1 Introduction
For a finite-duration sequencex(n) of lengthN, the DFT sum may be written as
X(k) =
1
0
)(N
n
nk
NWnx , k= 0, 1, ,N1
where NW =Nje /2 . There are a total ofNvalues ofX(.) ranging fromX(0) toX(N1). The
calculation ofX(0) involves no multiplications at all since every product term involves 0NW =
0je = 1. Further, the first term in the sum always involves 0NW or0je = 1 and therefore does
not require a multiplication. EachX(.) calculation other thanX(0) thus involves (N1) complex
multiplications. And eachX(.) involves (N1) complex additions. Since there areNvalues ofX(.)
the overall DFT requires 2)1( N complex multiplications andN(N1) complex additions. For
largeNwe may round these off to 2N complex multiplications and the same number of complexadditions.
Each complex multiplication is of the form
(A + jB) (C + jD) = (ACBD) + j(BC + AD)
and therefore requires four real multiplications and two real additions. Each complex addition isof the form
(A + jB) + (C + jD) = (A + C) + j(B + D)
and requires two real additions. Thus the computation of all Nvalues of the DFT requires 4N2
real multiplications and 4 2N (= 2 2N + 2 2N ) real additions.
Efficient algorithms which reduce the number of multiply-and-add operations are known
by the name offast Fourier transform (FFT). The Cooley-Tukey and Sande-Tukey FFT
algorithms exploit the following properties of the twiddlefactor (phase factor), WN=Nje /2
(the factor
Nj
e
/2
is called theN
th
principal root of 1):
1. Symmetry property 2N
k
NW
= kNW
2. Periodicity property NkNW = kNW
To illustrate, for the case ofN= 8, these properties result in the following relations:
0
8W =4
8W = 11
8W =5
8W =2
1 j
2
8W =6
8W =j3
8W =7
8W =
2
1 j
The use of these properties reduces the number of complex multiplications fromN2
to
NN
2log2
(actually the number of multiplications is less than this because several of the
multiplications by rNW are really multiplications by 1 or jand dont count); and the number of
complex additions are reduced from 2N to NN 2log . Thus, with each complex multiplication
requiring four real multiplications and two real additions and each complex addition requiringtwo real additions, the computation of allNvalues of the DFT requires
w.jntuworld.com
www.jntuworld.com
-
7/31/2019 DSP-3 (FFT) (S)
3/17
DSP-3 (FFT) 3 of 17 Dr. Ravi Billa
Number of real multiplications = 4
N
N2log
2= NN 2log2
Number of real additions = NN 2log2 + 2
N
N2log
2= NN 2log3
We can get a rough comparison of the speed advantage of an FFT over a DFT by
computing the number of multiplications for each since these are usually more time consuming
than additions. For instance, forN= 8 the DFT, using the above formula, would need 82
= 64
complex multiplications, but the radix-2 FFT requires only 12 (= 8log28
2 = 4 x 3).
Number of multiplications: DFT vs. FFT
No. of points
N
No. of complex multiplications No. of real multiplications
DFT FFT DFT FFT
32 1024 80 4096 320
128 16384 448 65536 1792
1024 1048576 5120 4194304 20480
We consider first the case where the lengthNof the sequence is an integral power of 2,
that is,N = 2
where is an integer. These are called radix-2 algorithms of which the
decimation-in-time (DIT) version is also known as the Cooley-Tukey algorithm and the
decimation-in-frequency (DIF) version is also known as the Sande-Tukey algorithm. We
show first how the algorithms work; their derivation is given later.
For a radix of (r= 2), the elementary computation (EC) known as the butterfly consists
of a single complex multiplication and two complex additions.
If the number of points,N, can be expressed asN= mr , and if the computation algorithm
is carried out by means of a succession ofr-point transforms, the resultant FFT is called a radix-ralgorithm. In a radix-rFFT, an elementary computation consists of an r-point DFT followed
by the multiplication of the rresults by the appropriate twiddle factor. The number ofECsrequired is
Cr= Nr
Nrlog
which decreases as rincreases. Of course, the complexity of anECincreases with increasing r.
Forr= 4, theECrequires three complex multiplications and several complex additions.
Suppose that we desire anN-point DFT whereNis a composite number that can befactored into the product of integers
N=N1 N2 Nm
If, for instance,N = 64 and m = 3, we might factorNinto the product 64 = 4 x 4 x 4, and the 64-point transform can be viewed as a three-dimensional 4 x 4 x 4 transform.
IfNis a prime number so that factorization ofNis not possible, the original signal can bezero-paddedand the resulting new composite number of points can be factored.
w.jntuworld.com
www.jntuworld.com
-
7/31/2019 DSP-3 (FFT) (S)
4/17
DSP-3 (FFT) 4 of 17 Dr. Ravi Billa
3.2 Radix-2 decimation-in-time FFT (Cooley-Tukey)
Procedure and important points
1. The number of input samples isN = 2
where is an integer.2. The input sequence is shuffled through bit-reversal. The index n of the sequencex(n) is
expressed in binary and then reversed.
3. The number of stages in the flow graph is given by = N2log .
4. Each stage consists ofN/2 butterflies.5. Inputs/outputs for each butterfly are separated as follows:
Separation = 2m1
samples where m = stage index, stages being numbered from
left to right (that is, m = 1 for stage 1, m = 2 for stage 2 etc.).
This amounts to separation increasing from left to right in the order 1, 2, 4, ,N/2.
6. The number of complex additions = NN 2log and the number of complex multiplications
is NN
2log2
.
7. The elementary computation block in the flow graph, called the butterfly, is shown here.
This is an in-place calculation in that the outputs (A +B kNW ) and (ABk
NW ) can be
computed and stored in the same locations asA andB.
A +Bk
NW
AB kNW k
NW
A
B
Separation of 1
Separation of 2
Separation of 4
Stage 1 Stage 2 Stage 3
w.jntuworld.com
www.jntuworld.com
-
7/31/2019 DSP-3 (FFT) (S)
5/17
DSP-3 (FFT) 5 of 17 Dr. Ravi Billa
Example 3.2.1 [2002] Radix-2, 8-point, decimation-in-time FFT for the sequence
n 0 1 2 3 4 5 6 7
x(n) = {1, 2 3 4 4 3 2 1}
Solution The twiddle factors are
0
8W = 11
8W =8/2je = 4/je =
2
1j
2
1
2
8W = 28/2je = 2/
je =j 38W = 38/2je = 4/3
je =2
1j
2
1
One of the elementary computations is shown below:
The signal flow graph follows:
A +B kNW
= 14 =3
ABk
NW = 1 + 4 = 5
0
8W= 1
A
= 1
B
=4
0
8W
2
8W
1
8W
3
8W
2
8W
0
8W
2
8W
0
8W
0
8W
0
8W
0
8W
08W
000 000 x(0) = 1 X(0) = 0
001 100 x(4) =4
111 111 x(7) =1
110 011 x(3) = 4
101 101 x(5) =3
100 001 x(1) = 2
010 010 x(2) = 3
011 110 x(6) =2
X(7) =
X(6) =
X(5) =
X(4) =
X(1) =
X(2) =
X(3) =
Stage 3 Bit-reversed
order
Natural
orderStage 2 Stage 1
w.jntuworld.com
www.jntuworld.com
-
7/31/2019 DSP-3 (FFT) (S)
6/17
DSP-3 (FFT) 6 of 17 Dr. Ravi Billa
8-point FFT using DIT
Results of the first stage
Input Stage 1 Stage 2 Stage 3 (Output)
1 1 + (4) . 1 =3
4 1(4) . 1 = 5
3 3 + (2) . 1 = 1
2 3(2) . 1 = 5
2 2 + (3) . 1 =1
3 2(3) . 1 = 5
4 4 + (1) . 1 = 3
1 4(1) . 1 = 5
Results of the second stage
Input Stage 1 Stage 2 Stage 3 (Output)
1 3 3 + 1 . 1 =2
4 5 5 + 5 . (j) = 5 4/2je
3 1 31 . 1 =4
2 5 55 . (j) = 5 4/2
je 2 1 1 + 3 . 1 = 2
3 5 5 + 5 . (j) = 5 4/2 je
4 3 13 . 1 =4
1 5 55 . (j) = 5 4/2je
Results of the third stage
Input Stage 1 Stage 2 Stage 3 (Output)
1 3 2 2 + 2 . 1 = 0
4 5 5 4/2je 5 4/2
je + 5 4/2je . 4/je = 5j12.07
3 1 4 4 + (4) . (j) =4 + j4 = 4 4/32 je
2 5 5 4/2 je 5 4/2 je + 5 4/2 je . 4/3je = 5j 2.07
2 1 2 22 . 1 =4
3 5 5 4/2je 5 4/2
je 5 4/2je . 4/je = 5 + j2.07
4 3 4 4(4) . (j) =4j4 = 4 4/32je
1 5 5 4/2je 5 4/2
je 5 4/2je . 4/3je = 5 + j12.07
The DFT isX(k) = {0, (5j12.07), (4 + j4), (5j2.07),4, (5 + j2.07), (4j4), (5 + j12.07)}
The MATLAB program:
x = [1, 2, 3, 4, -4, -3, -2, -1], X = fft(x)
w.jntuworld.com
www.jntuworld.com
-
7/31/2019 DSP-3 (FFT) (S)
7/17
DSP-3 (FFT) 7 of 17 Dr. Ravi Billa
3.3 Radix-2 decimation-in-frequency FFT (Sande-Tukey)
Procedure and important points
1. The number of input samples isN = 2
where is an integer.2. The input sequence is in natural order; the output is in bit-reversed order.
3. The number of stages in the flow graph is given by = N2log .
4. Each stage consists ofN/2 butterflies.5. Inputs/outputs for each butterfly are separated in the reverse order from that of the DIT.
The separation decreasesfrom left to rightin the orderN/2, , 4, 2, 1.
6. The number of complex additions = NN 2log and the number of complex multiplications
is NN
2log2
.
7. The basic computation block in the flow graph of the DIF FFT is the butterfly shown
here. This is an in-place calculation in that the two outputs (A + B) and (A B) kNW can
be computed and stored in the same locations asA andB.
A +B
(AB) kNW
k
NW A
B
w.jntuworld.com
www.jntuworld.com
-
7/31/2019 DSP-3 (FFT) (S)
8/17
DSP-3 (FFT) 8 of 17 Dr. Ravi Billa
Example 3.3.1 [Cf. Example 2.1] Radix-2, 8-point, decimation-in-frequency FFT for the
sequence
n 0 1 2 3 4 5 6 7
x(n) = {1, 2 3 4 4 3 2 1}
Solution The twiddle factors are the same as in the DIT FFT done earlier (both being 8-point
DFTs):
0
8W = 11
8W =8/2je =
2
1 j2
1
2
8W = 28/2je = 2/
je =j3
8W = 38/2je = 4/3
je =2
1j
2
1
One of the elementary computations is shown below:
The signal flow graph follows:
X(7) =
A +B
= 14 =3
(AB) kNW
= (1 + 4) 1 = 5
0
8W = 1A
= 1
B
=4
2
8W
1
8W
0
8W
0
8W 0
8W
2
8W
0
8W
0
8W 0
8W
2
8W
0
8W
3
8W
x(0) = 1
Natural
order Stage 1 Stage 2 Stage 3
x(7) =1
x(6) =2
x(5) =3
x(4) =4
x(3) = 4
x(2) = 3
x(1) = 2
X(0) =
Bit-reversed
order
X(4) =
X(2) =
X(6) =
X(1) =
X(5) =
X(3) =
w.jntuworld.com
www.jntuworld.com
-
7/31/2019 DSP-3 (FFT) (S)
9/17
DSP-3 (FFT) 9 of 17 Dr. Ravi Billa
8-point FFT using DIF
Results of the first stage
Input Stage 1 Stage 2 Stage 3 (Output)
1 1 + (4) =3
2 2 + (3) =1
3 3 + (2) = 1
4 4 + (1) = 3
4 (1(4)) 1 = 5
3 (2(3)) 4/je = 5 4/je
2 (3(2)) (j) =j5
1 (4(1)) 4/3je = 5 4/3je
Results of the second stage
Input Stage 1 Stage 2 Stage 3 (Output)
1 3 3 + 1 =2
2 1 1 + 3 = 2
3 1 (31) 1 =4
4 3 (13) (j) = j44 5 5 + (j5) = 5 4/2 je
3 5 4/je 5 4/je + 5 4/3je =j5 2
2 j5 (5(j5)) 1 = 5 4/2je
1 5 4/3je (5 4/je 5 4/3je ) (j) =j5 2
Results of the third stage
Input Stage 1 Stage 2 Stage 3 (Output)
1 3 2 2 + 2 = 0
2 1 2 (22) 1 =4
3 1 4 4 + j4 =4 + j4 = 4 4/32je
4 3 j4 (4j4) 1 =4j4 = 4 4/32 je
4 5 5 4/2 je 5 4/2 je + (j5 2 ) = 5j12.07
3 5 4/je j5 2 (5 4/2 je (j5 2 )) 1 = 5 + j2.07
2 j5 5 4/2 je 5 4/2 je + (j5 2 ) = 5j2.07
1 5 4/3je j5 2 (5 4/2je (j5 2 )) 1 = 5 + j12.07
The DFT isX(k) = {0, (5j12.07), (4 + j4), (5j2.07),4, (5 + j2.07), (4j4), (5 + j12.07)}
The MATLAB progarm is the same as shown in Example 1.
w.jntuworld.com
www.jntuworld.com
-
7/31/2019 DSP-3 (FFT) (S)
10/17
DSP-3 (FFT) 10 of 17 Dr. Ravi Billa
(DIT Template)
The elementary computation (Butterfly):
The signal flow graph:
A +B kNW
AB kNW kNW
A
B
w.jntuworld.com
www.jntuworld.com
-
7/31/2019 DSP-3 (FFT) (S)
11/17
DSP-3 (FFT) 11 of 17 Dr. Ravi Billa
(DIF Template)
The elementary computation (Butterfly):
The signal flow graph:
A +B
(AB) kNW
k
NW A
B
w.jntuworld.com
www.jntuworld.com
-
7/31/2019 DSP-3 (FFT) (S)
12/17
DSP-3 (FFT) 12 of 17 Dr. Ravi Billa
16-point DIF FFT
w.jntuworld.com
www.jntuworld.com
-
7/31/2019 DSP-3 (FFT) (S)
13/17
DSP-3 (FFT) 13 of 17 Dr. Ravi Billa
3.4 Inverse DFT using the FFT algorithm
The inverse DFT of anN-point sequence {X(k), k= 1, 2, , (N1)} is defined as
x(n) =N
1
1
0
)(N
k
nk
NWkX , n= 0, 1, ,N1
where WN=Nje /2 . Take the complex conjugate ofx(n) and multiply byNto get
Nx
*
(n) =
1
0
*
)(
N
k
nk
NWkX
The right hand side of the above equation is simply the DFT of the sequenceX*(k) and can be
computed by using any FFT algorithm. The desired output sequence is then found by taking the
conjugate of the result and dividing byN
x(n) =N
1
*1
0
* )(
N
k
nk
NWkX
w.jntuworld.com
www.jntuworld.com
-
7/31/2019 DSP-3 (FFT) (S)
14/17
DSP-3 (FFT) 14 of 17 Dr. Ravi Billa
Example 3.4.1 Given the DFT sequenceX(k) = {0, (1j), j, (2+j), 0, (2j),j, (1+j)} obtain the
IDFTx(n) using the DIF FFT algorithm.
Solution This is an 8-point IDFT. The 8-point twiddle factors are, as calculated earlier,
0
8W = 11
8W =8/2je =
2
1j
2
1
2
8W = 28/2je = 2/
je =j 38W = 38/2je =
4/3je =2
1j
2
1
The elementary computation (Butterfly) is shown below:
The signal flow graph follows:
A +B
(AB) kNW
k
NW A
B
X*(0) = 0
Natural
order Stage 1 Stage 2 Stage 3
X*(7) =
X
*
(6) = j
X*(5) =
X*(4) = 0
X*(3) =
X*(2) =j
X*(1) =
8 x*(0) =
Bit-reversed
order
8 x*(4) =
8 x*(2) =
8 x*(6) =
8 x*(1) =
8 x*(5) =
8 x*(3) =
8 x*(7) =
0
8W
w.jntuworld.com
www.jntuworld.com
-
7/31/2019 DSP-3 (FFT) (S)
15/17
DSP-3 (FFT) 15 of 17 Dr. Ravi Billa
8-point IDFT using DIF FFT
Results of the first stage
Input
X*(k)
Stage 1 Stage 2 Stage 3 (Output)
0 0 + 0 = 0
1+j 1+j + 2+j = 1+j2
j j + j = 0
2j 2j + (1j) = 1j2
0 (00) 1 = 0
2+j (1+j(2+j)) 4/je =3 4/je
j (jj) (j) =2
1j (2j(1j)) 4/3je = 3 4/3je
Results of the second stage
Input Stage 1 Stage 2 Stage 3 (Output)
0 0 0 + 0 = 0
1+j 1+j2 1+j2 + 1j2 = 2
j 0 (00) 1 = 02j 1j2 (1+j2(1j2)) (j) = 4
0 0 0 + (2) =2
2+j 3 4/je 3 4/je + 3 4/3je =3 2
j 2 (0(2)) 1 = 2
1j 3 4/3je (3 4/je 3 4/3je ) (j) = 3 2
Results of the third stage
Input Stage 1 Stage 2 Stage 3 (Output)
0 0 0 0 + 2 = 2 8x*(0)
1+j 1+j2 2 (02) 1 =2 8x
*
(4)j 0 0 0 + 4 = 4 8x*(2)
2j 1j2 4 (04) 1 =4 8x*(6)
0 0 2 2 + (3 2 ) =6.24 8x*(1)
2+j 3 4/je 3 2 (2(3 2 )) 1 = 2.24 8x*(5)
j 2 2 2 + 3 2 = 6.24 8x (3)
1j 3 4/3je 3 2 (23 2 ) 1 =2.24 8x
*(7)
The output at stage 3 gives us the values )(8 * nx in bit-reversed order:
orderrevbitnx )(8 * = {2,2, 4,4,6.24, 2.24, 6.24,2.24}
The IDFT is given by arranging the data in normal order, taking the complex conjugate of the
sequence and dividing by 8:
ordernormal
nx )(8 * = {2,6.24, 4, 6.24,2, 2.24,4,2.24}
w.jntuworld.com
www.jntuworld.com
-
7/31/2019 DSP-3 (FFT) (S)
16/17
DSP-3 (FFT) 16 of 17 Dr. Ravi Billa
x(n) =
4
1,
8
24.6,2
1,
8
24.6,
4
1,
8
24.2,
2
1,
8
24.2
x(n) = {0.25,0.78, 0.5, 0.78,0.25, 0.28,0.5,0.28}
Note Because of the conjugate symmetry of {X(k)}, we should expect the sequence {x(n)} to bereal-valued.
The MATLAB program:
X = [0, (-1-j), j, (2+j), 0, (2-j), -j, (-1+j)], x = ifft(X)
Example 3.4.2 [2002] Given the DFT sequenceX(k) = {0, (1j), j, (2+j), 0, (2j), (1+j),j}
obtain the IDFTx(n) using the DIF FFT algorithm.
Solution There is no conjugate symmetry in {X(k)}. Using MATLAB
X = [0, 1-1j, 1j, 2+1j, 0, 2-1j, -1+1j, -1j]
x = ifft(X)The IDFT is
x(n) = {0.5, (-0.44 + 0.037i), (0.375 - 0.125i), (0.088 + 0.14i), (-0.75 + 0.5i),(0.44 + 0.21i), (-0.125 - 0.375i), (-0.088 - 0.39i)}
w.jntuworld.com
www.jntuworld.com
-
7/31/2019 DSP-3 (FFT) (S)
17/17
DSP-3 (FFT) 17 of 17 Dr Ravi Billa
3.7 FFT with general radix
As mentioned in the introduction, if the number of points, N, can be expressed asN= mr , and if
the computation algorithm is carried out by means of a succession ofr-point transforms, the
resultant FFT is called a radix-ralgorithm. In a radix-rFFT, an elementary computation (EC)
consists of an r-point DFT followed by the multiplication of the rresults by the appropriatetwiddle factor. The number ofECs required is
Cr= Nr
Nrlog
which decreases as rincreases.
Of course, the complexity of anECincreases with increasing r. Forr= 2, theEC(the
butterfly) consists of a single complex multiplication and two complex additions; forr= 4, theECrequires three complex multiplications and several complex additions.
Suppose that we desire anN-point DFT whereNis a composite number that can be
factored into the product of integers
N=N1 N2 Nm
If, for instance,N = 64 and m = 3, we might factorNinto the product 64 = 4 x 4 x 4, and the 64-point transform can be viewed as a three-dimensional 4 x 4 x 4 transform.
IfNis a prime number so that factorization ofNis not possible, the original signal can be
zero-paddedand the resulting new composite number of points can be factored.We illustrate in the table below the situation forN= 64. Since 64 = 2
6, we can have a
radix-2 FFT; alternatively, since 64 = 43, we can also have a radix-4 FFT.
N= 64 = 26
= 43
= 82
Radix-2 Radix-4 Radix-8
No. of stages 64log2 = 6 64log4 = 3 64log8 = 2
No. ofECs per stage 64/2 = 32 64/4 = 16 64/8 = 8
w.jntuworld.com