Thông tin tài liệu
ț The fast Fourier transform using radix-2 and radix-4
ț Decimation or decomposition in frequency and in time
ț Programming examples
The fast Fourier transform (FFT) is an efficient algorithm that is used for con-
verting a time-domain signal into an equivalent frequency-domain signal, based
on the discrete Fourier transform (DFT). A real-time programming example is
included with a main C program that calls an FFT assembly function.
6.1 INTRODUCTION
The discrete Fourier transform converts a time-domain sequence into an equiva-
lent frequency-domain sequence. The inverse discrete Fourier transform per-
forms the reverse operation and converts a frequency-domain sequence into an
equivalent time-domain sequence. The fast Fourier transform (FFT) is a very ef-
ficient algorithm technique based on the discrete Fourier transform, but with
fewer computations required. The FFT is one of the most commonly used oper-
ations in digital signal processing to provide a frequency spectrum analysis
[1–6]. Two different procedures are introduced to compute an FFT: the decima-
tion-in-frequency and the decimation-in-time. Several variants of the FFT have
been used, such as the Winograd transform [7,8], the discrete cosine transform
(DCT) [9], and the discrete Hartley transform [10–12]. Programs based on the
DCT, FHT, and the FFT are available in [9].
6.2 DEVELOPMENT OF THE FFT ALGORITHM WITH RADIX-2
The FFT reduces considerably the computational requirements of the discrete
Fourier transform (DFT). The DFT of a discrete-time signal x(nT) is
165
6
Fast Fourier Transform
Digital Signal Processing: Laboratory Experiments Using C and the TMS320C31 DSK
Rulph Chassaing
Copyright © 1999 John Wiley & Sons, Inc.
Print ISBN 0-471-29362-8 Electronic ISBN 0-471-20065-4
X(k) =
Α
N – 1
n = 0
x(n) W
nk
k = 0, 1, , N – 1 (6.1)
where the sampling period T is implied in x(n) and N is the frame length. The
constants W are referred to as twiddle constants or factors, which represent the
phase, or
W = e
– j2/N
(6.2)
and is a function of the length N. Equation (6.1) can be written for k = 0, 1, ,
N – 1, as
X(k) = x(0) + x(1)W
k
+ x(2)W
2k
+ + x(N – 1)W
(N–1)k
(6.3)
This represents a matrix of N × N terms, since X(k) needs to be calculated for N
values of k. Since (6.3) is an equation in terms of a complex exponential, for
each specific k there are approximately N complex additions and N complex
multiplications. Hence, the computational requirements of the DFT can be very
intensive, especially for large values of N.
The FFT algorithm takes advantage of the periodicity and symmetry of the
twiddle constants to reduce the computational requirements of the FFT. From
the periodicity of W
W
k+N
= W
k
(6.4)
and, from the symmetry of W
W
k+N/2
=
–
W
k
(6.5)
Figure 6.1 illustrates the properties of the twiddle constants W for N = 8. For ex-
ample, let k = 2, and note that from (6.4), W
10
= W
2
, and from (6.5), W
6
=
–
W
2
.
166
Fast Fourier Transform
FIGURE 6.1 Periodicity and symmetry of twiddle constant W.
For a radix-2 (base 2), the FFT decomposes an N-point DFT into two (N/2)-
point or smaller DFT’s. Each (N/2)-point DFT is further decomposed into two
(N/4)-point DFT’s, and so on. The last decomposition consists of (N/2) two-
point DFT’s. The smallest transform is determined by the radix of the FFT. For a
radix-2 FFT, N must be a power or base of two, and the smallest transform or
the last decomposition is the two-point DFT. For a radix-4, the last decomposi-
tion is a four-point DFT.
6.3 DECIMATION-IN-FREQUENCY FFT ALGORITHM
WITH RADIX-2
Let a time-domain input sequence x(n) be separated into two halves:
a) x(0), x(1), , x
– 1
(6.6)
and
b)
, x
+ 1
, , x(N – 1) (6.7)
Taking the DFT of each set of the sequence in (6.6) and (6.7),
X(k) =
Α
(N/2) – 1
n = 0
x(n)W
nk
+
Α
N – 1
n = N/2
x(n)W
nk
(6.8)
Let n = n + N/2 in the second summation of (6.8), X(k) becomes
X(k) =
Α
(N/2) – 1
n = 0
x(n)W
nk
+ W
kN/2
Α
(N/2) – 1
n = 0
x
n +
W
nk
(6.9)
where W
kN/2
is taken out of the second summation because it is not a function of
n. Using,
W
kN/2
= e
–jk
= (e
–j
)
k
= (cos – jsin )
k
= (
–
1)
k
in (6.9), X(k) becomes
X(k) =
Α
(N/2) – 1
n = 0
΄
x(n) + (–1)
k
x
n +
΅
W
nk
(6.10)
Because (–1)
k
= 1 for even k and –1 for odd k, (6.10) can be separated for even
and odd k, or
N
ᎏ
2
N
ᎏ
2
N
ᎏ
2
N
ᎏ
2
N
ᎏ
2
6.3 Decimation-in-Frequency FFT Algorithm with Radix-2 167
for even k: X(k) =
Α
(N/2) – 1
n = 0
΄
x(n) + x
n +
΅
W
nk
(6.11)
for odd k: X(k) =
Α
(N/2) – 1
n = 0
΄
x(n) – x
n +
΅
W
nk
(6.12)
Substituting k = 2k for even k, and k = 2k + 1 for odd k, (6.11) and (6.12) can be
written as, for k = 0, 1, , (N/2) – 1,
X(2k) =
Α
(N/2) – 1
n = 0
΄
x(n) + x
n +
΅
W
2nk
(6.13)
x(2K + 1) =
Α
(N/2) – 1
n = 0
΄
x(n) – x
n +
΅
W
n
W
2nk
(6.14)
Because the twiddle constant W is a function of the length N, it can be repre-
sented as W
N
. Then, W
N
2
can be written as W
N /2
. Let
a(n) = x(n) + x(n + N/2) (6.15)
b(n) = x(n) – x(n + N/2) (6.16)
Equations (6.13) and (6.14) can be more clearly written as two (N/2)-point
DFT’s, or
X(2k) =
Α
(N/2) – 1
n = 0
a(n)W
N/2
nk
(6.17)
X(2k + 1) =
Α
(N/2) – 1
n = 0
b(n)W
N
n
W
N/2
nk
(6.18)
Figure 6.2 shows the decomposition of an N-point DFT into two (N/2)-point
DFT’s, for N = 8. As a result of the decomposition process, the X’s in Figure 6.2
are even in the upper half and they are odd in the lower half. The decomposition
process can now be repeated such that each of the (N/2)-point DFT’s is further
decomposed into two (N/4)-point DFT’s, as shown in Figure 6.3, again using
N = 8 to illustrate.
The upper section of the output sequence in Figure 6.2 yields the sequence
X(0) and X(4) in Figure 6.3, ordered as even. X(2) and X(6) from Figure 6.3 rep-
resent the odd values. Similarly, the lower section of the output sequence in Fig-
ure 6.2 yields X(1) and X(5), ordered as the even values, and X(3) and X(7) as
the odd values. This scrambling is due to the decomposition process. The final
N
ᎏ
2
N
ᎏ
2
N
ᎏ
2
N
ᎏ
2
168
Fast Fourier Transform
order of the output sequence X(0), X(4), . . . in Figure 6.3 is shown to be scram-
bled. The output needs to be resequenced or reordered. A special instruction us-
ing indirect addressing with bit-reversal, introduced in Chapter 2 in conjunction
with circular buffering, is available on the TMS320C3x to reorder such a se-
quence. The output sequence X(k) represents the DFT of the time sequence x(n).
This is the last decomposition, since we have now a set of (N/2) two-point
DFT’s, the lowest decomposition for a radix-2. For the two-point DFT, X(k) in
(6.1) can be written as
6.3 Decimation-in-Frequency FFT Algorithm with Radix-2 169
FIGURE 6.2 Decomposition of N-point DFT into two (N/2)-point DFT’s, for N = 8.
FIGURE 6.3 Decomposition of two (N/2)-point DFT’s into four (N/4)-point DFT’s, for
N = 8.
X(k) =
Α
1
n = 0
x(n)W
nk
k = 0, 1 (6.19)
or
X(0) = x(0)W
0
+ x(1)W
0
= x(0) + x(1) (6.20)
X(1) = x(0)W
0
+ x(1)W
1
= x(0) – x(1) (6.21)
since W
1
= e
–j2/2
=
–
1. Equations (6.20) and (6.21) can be represented by the
flow graph in Figure 6.4, usually referred to as a butterfly. The final flow graph
of an eight-point FFT algorithm is shown in Figure 6.5. This algorithm is re-
ferred as decimation-in-frequency (DIF) because the output sequence X(k) is
decomposed (decimated) into smaller subsequences, and this process continues
through M stages or iterations, where N = 2
M
. The output X(k) is complex with
both real and imaginary components, and the FFT algorithm can accomodate
either complex or real input values.
The FFT is not an approximation of the DFT. It yields the same result as the
DFT with less computations required. This reduction becomes more and more
important with higher-order FFT.
There are other FFT structures that have been used to illustrate the FFT. An
alternative flow graph to the one shown in Figure 6.5 can be obtained with or-
dered output and scrambled input.
An eight-point FFT is illustrated through an exercise as well as through a
programming example. We will see that flow graphs for higher-order FFT (larg-
er N) can readily be obtained.
Exercise 6.1 Eight-Point FFT Using Decimation-in-Frequency
Let the input x(n) represent a rectangular waveform, or x(0) = x(1) = x(2) = x(3)
= 1, and x(4) = x(5) = x(6) = x(7) = 0. The eight-point FFT flow graph in Figure
6.5 can be used to find the output sequence X(k), k = 0, 1, , 7. With N = 8,
four twiddle constants need to be calculated, or
170
Fast Fourier Transform
FIGURE 6.4 Two-point FFT butterfly.
W
0
= 1
W
1
= e
–j2/8
= cos(/4) – jsin(/4) = 0.707 – j0.707
W
2
= e
–j4/8
=
–
j
W
3
= e
–j6/8
=
–
0.707 – j0.707
The intermediate output sequence can be found after each stage.
1. At stage 1:
x(0) + x(4) = 1 Ǟ xЈ(0)
x(1) + x(5) = 1 Ǟ xЈ(1)
x(2) + x(6) = 1 Ǟ xЈ(2)
x(3) + x(7) = 1 Ǟ xЈ(3)
[x(0) – x(4)]W
0
= 1 Ǟ xЈ(4)
[x(1) – x(5)]W
1
= 0.707 – j0.707 Ǟ xЈ(5)
[x(2) – x(6)]W
2
= –j Ǟ xЈ(6)
[x(3) – x(7)]W
3
= –0.707 – j0.707 Ǟ xЈ(7)
where xЈ(0), xЈ(1), , xЈ(7) represent the intermediate output sequence after
the first iteration that becomes the input to the second stage.
2. At stage 2:
6.3 Decimation-in-Frequency FFT Algorithm with Radix-2 171
FIGURE 6.5 Eight-point FFT flow graph using decimation-in-frequency.
xЈ(0) + xЈ(2) = 2 Ǟ xЈЈ(0)
xЈ(1) + xЈ(3) = 2 Ǟ xЈЈ(1)
[xЈ(0) – xЈ(2)]W
0
= 0 Ǟ xЈЈ(2)
[xЈ(1) – xЈ(3)]W
2
= 0 Ǟ xЈЈ(3)
xЈ(4) + xЈ(6) = 1 – j Ǟ xЈЈ(4)
xЈ(5) + xЈ(7) = (0.707 – j0.707) + (–0.707 – j0.707) = –j1.41 Ǟ xЈЈ(5)
[xЈ(4) – xЈ(6)]W
0
= 1 + j Ǟ xЈЈ(6)
[xЈ(5) – xЈ(7)]W
2
= –j1.41 Ǟ xЈЈ(7)
The resulting intermediate, second-stage output sequence xЈЈ(0), xЈЈ(1), ,
xЈЈ(7) becomes the input sequence to the third stage.
3. At stage 3:
X(0) = xЈЈ(0) + xЈЈ(1) = 4
X(4) = xЈЈ(0) – xЈЈ(1) = 0
X(2) = xЈЈ(2) + xЈЈ(3) = 0
X(6) = xЈЈ(2) – xЈЈ(3) = 0
X(1) = xЈЈ(4) + xЈЈ(5) = (1 – j) + (–j1.41) = 1 – j2.41
X(5) = xЈЈ(4) – xЈЈ(5) = 1 + j0.41
X(3) = xЈЈ(6) + xЈЈ(7) = (1 + j) + (–j1.41) = 1 – j0.41
X(7) = xЈЈ(6) – xЈЈ(7) = 1 + j2.41
We now use the notation of X’s to represent the final output sequence. The val-
ues X(0), X(1), , X(7) form the scrambled output sequence. These results can
be verified with an FFT function available with the MATLAB software package
described in Appendix B. We will show soon how to reorder the output se-
quence and plot the output magnitude.
Exercise 6.2 Sixteen-Point FFT
Given x(0) = x(1) = = x(7) = 1, and x(8) = x(9) = = x(15) = 0, which rep-
resents a rectangular input sequence. The output sequence can be found using
the 16-point flow graph shown in Figure 6.6. The intermediate output results af-
ter each stage are found in a similar manner to the previous example. Eight
twiddle constants W
0
, W
1
, , W
7
need to be calculated for N = 16.
Verify the scrambled output sequence X’s as shown in Figure 6.6. Reorder
this output sequence and take its magnitude. Verify the plot in Figure 6.7, which
172
Fast Fourier Transform
173
FIGURE 6.6 16-point FFT flow graph using decimation-in-frequency.
represents a sinc function. The output X(8) represents the magnitude at the
Nyquist frequency. These results can be verified with an FFT function available
with MATLAB, described in Appendix B.
6.4 DECIMATION-IN-TIME FFT ALGORITHM WITH RADIX-2
Whereas the decimation-in-frequency (DIF) process decomposes an output se-
quence into smaller subsequences, the decimation-in-time (DIT) is another
process that decomposes the input sequence into smaller subsequences. Let
the input sequence be decomposed into an even sequence and an odd se-
quence, or
x(0), x(2), x(4), , x(2n)
and
x(1), x(3), x(5), , x(2n + 1)
We can apply (6.1) to these two sequences to obtain
X(k) =
Α
(N/2) – 1
n = 0
x(2n)W
2nk
+
Α
(N/2) – 1
n = 0
x(2n + 1)W
(2n+1)k
(6.22)
Using W
N
2
= W
N/2
in (6.22)
X(k) =
Α
(N/2) – 1
n = 0
x(2n)W
N/2
nk
+ W
N
k
Α
(N/2) – 1
n = 0
x(2n + 1)W
N/2
nk
(6.23)
174
Fast Fourier Transform
FIGURE 6.7 Output magnitude for 16-point FFT.
[...]... programming example, the results are stored in memory, and can be verified It illustrates a complex FFT with N = 8, using a decimation-in-frequency procedure with radix-2 Figure 6.12 shows the main program FFT 8C. C in C code that calls a generic FFT function FFT .C, also in C code The input sequence, specified in the main program, represents a rectangular sequence, x(0) = = x(3) = 1000 + j0 and x(4)= = x(7)... The program TWIDGEN .C (on disk) generates the twiddle constants for a complex FFT It is to be compiled with Turbo C+ + or Borland C+ + The resulting file TWIDDLE.H con- /*FFT 8C. C - 8-POINT COMPLEX FFT PROGRAM CALLS FFT .C */ #include “complex.h” /*complex structure definition */ extern void FFT(); /*FFT function */ volatile int *out_addr=(volatile int *)0x809802; /*out addr*/ main() { COMPLEX y[8]={1000,0,1000,0,1000,0,1000,0,... general complex FFT The input must be real The resulting output is still complex In this case, computational requirements can be reduced The real-valued input FFT can be executed in about half the time as the more general complex FFT 188 Fast Fourier Transform Figure 6.14 shows a listing of the C program FFT8MC .C that calls a real-valued FFT function FFT_RL.ASM in TMS32 0C3 x code (on the accompanying... lower_leg, similar calculations are performed to obtain the final output from stage 3 4 The last section in the FFT function performs the bit-reversal procedure and produces a proper sequencing of the output data If you have the floating-point tools, compile each program, then link them with the linker command file FFT 8C. CMD (on the accompanying disk) to create the executable file FFT 8C. OUT (also on the... program SINEGEN .C that generates twiddle constants needs to be compiled using Turbo C+ + or Borland C+ + 1 Implement a 16-point complex FFT Modify the main C program FFT 8C. C in Example 6.1 using 16 sets of input samples with COMPLEX y[16] and n = 16, in the program No changes are required in the generic FFT function FFT .C or in the header file TWIDDLE.H that contains the twiddle constants With a rectangular... 0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0}; /*rectangular input*/ int i, n = 8; FFT(y,n); /*calls generic FFT function*/ for (i = 0; i . program FFT 8C. C
in C code that calls a generic FFT function FFT .C, also in C code. The input
sequence, specified in the main program, represents a rectangular. file TWIDDLE.H con-
184
Fast Fourier Transform
/*FFT 8C. C - 8-POINT COMPLEX FFT PROGRAM. CALLS FFT .C */
#include “complex.h” /*complex structure definition
Ngày đăng: 26/01/2014, 14:20
Xem thêm: Tài liệu DSP phòng thí nghiệm thử nghiệm bằng cách sử dụng C và DSK TMS320C31 (P6) pdf, Tài liệu DSP phòng thí nghiệm thử nghiệm bằng cách sử dụng C và DSK TMS320C31 (P6) pdf