1. DIRECT COMPUTATION
2. RADIX-2 FFT
3. DECIMATION-IN-TIME FFT
4. FLOWGRAPHS
5. BIT REVERSAL PERMUTATION
6. COMPLEXITY
7. DECIMATION-IN-FREQUENCY FFT
UNIT - IDISCRETE FOURIER TRANSFORMS (DFT)
THE FFT
A fast Fourier transform (FFT) is any fast algorithm for computing
the DFT. The development of FFT algorithms had a tremendous
impact on computational aspects of signal processing and applied
science. The DFT of an N -point signal
x[n], 0 ≤ n ≤ N − 1
is defined as
X[k] =N−1∑n=0
x[n]W−knN , 0 ≤ k ≤ N − 1
where
WN = ej2πN = cos
(2π
N
)+ j sin
(2π
N
)is the principal N -th root of unity.
DIRECT DFT COMPUTATION
Direct computation of X[k] for 0 ≤ k ≤ N − 1 requires
(N − 1)2 complex multiplications
N(N − 1) complex additions
RADIX-2 FFT
The radix-2 FFT algorithms are used for data vectors of lengths
N = 2K . They proceed by dividing the DFT into two DFTs of
length N/2 each, and iterating. There are several types of radix-
2 FFT algorithms, the most common being the decimation-in-time
(DIT) and the decimation-in-frequency (DIF). This terminology will
become clear in the next sections.
Preliminaries
The development of the FFT will call on two properties of WN .
The first property is:
W 2N = WN/2
which is derived as
W 2N = e−j
2πN ·2
= e−j2πN/2
= WN/2.
More generally, we have
W 2nkN = W nk
N/2.
The second property is:
Wk+N
2
N = −W kN
which is derived as
Wk+N
2
N = ej2πN (k+N
2 )
= ej2πN k · ej
2πN (N2 )
= ej2πN k · ejπ
= −ej2πN k
= −W kN
DECIMATION-IN-TIME FFT
Consider an N -point signal x[n] of even length. The derivation of
the DIT radix-2 FFT begins by splitting the sum into two parts
— one part for the even-indexed values x[2n] and one part for the
odd-indexed values x[2n + 1]. Define two N/2-point signals x1[n]
and x2[n] as
x0[n] = x[2n]
x1[n] = x[2n+ 1]
for 0 ≤ n ≤ N/2− 1. The DFT of the N -point signal x[n] can be
written as
X[k] =N−1∑n=0n even
x[n]W−nkN +
N−1∑n=0n odd
x[n]W−nkN
which can be written as
X[k] =
N/2−1∑n=0
x[2n]W−2nkN +
N/2−1∑n=0
x[2n+ 1]W−(2n+1)kN
=
N/2−1∑n=0
x0[n]W−2nkN +
N/2−1∑n=0
x1[n]W−(2n+1)kN
=
N/2−1∑n=0
x0[n]W−2nkN +W−k
N ·N/2−1∑n=0
x1[n]W−2nkN
=
N/2−1∑n=0
x0[n]W−nkN/2 +W−k
N ·N/2−1∑n=0
x1[n]W−nkN/2
where we used the first identity above. Recognizing that the N2 -pont
DFT of x0[n] and x1[n] are given by
X0[k] = DFTN2x0[n] =
N/2−1∑n=0
x0[n]W−nkN/2
X1[k] = DFTN2x1[n] =
N/2−1∑n=0
x1[n]W−nkN/2
DIT FFT (2)
we obtain the equation
X[k] = X0[k] +W−kN ·X1[k].
The signal x0[n] is an N/2-point signal, so its DFT is also an N/2-
point signal. When k is taken outside the range 0 ≤ k ≤ N/2− 1
the DFT coefficients are periodic with a period of N/2:
X0[k] = X0[〈k〉N/2] or X0[k] = X0[k +N/2],
and likewise for X1[k]
X1[k] = X1[〈k〉N/2] or X1[k] = X1[k +N/2].
For example, if N = 8, then
X[0] = X0[0] + 1 ·X1[0]
X[1] = X0[1] +W−18 ·X1[1]
X[2] = X0[2] +W−28 ·X1[2]
X[3] = X0[3] +W−38 ·X1[3]
X[4] = X0[0] +W−48 ·X1[0]
X[5] = X0[1] +W−58 ·X1[1]
X[6] = X0[2] +W−68 ·X1[2]
X[7] = X0[3] +W−78 ·X1[3].
Using Wk+N
2
N = −W kN derived earlier, we obtain for this example
X[0] = X0[0] + 1 ·X1[0]
X[1] = X0[1] +W−18 ·X1[1]
X[2] = X0[2] +W−28 ·X1[2]
X[3] = X0[3] +W−38 ·X1[3]
X[4] = X0[0]− 1 ·X1[0]
X[5] = X0[1]−W−18 ·X1[1]
X[6] = X0[2]−W−28 ·X1[2]
X[7] = X0[3]−W−38 ·X1[3].
DIT FFT (3)
With this modification, the DFT coefficients X2[k] need only be
multiplied by W−k8 for 1 ≤ k ≤ N/2 − 1, incurring N/2 − 1
multiplications.
In general, one has
X[k] = X0[k] +W−kN ·X1[k] for 0 ≤ k ≤ N
2− 1 (1)
X[k +N
2] = X0[k]−W−k
N ·X1[k] for 0 ≤ k ≤ N
2− 1 (2)
The multipliers W kN are known as twiddle factors.
The Matlab code fragment illustrates this relation for N = 8:
>> x = [82 44 62 79 92 74 18 41]’;
>>
>> % "decimate" x(n) in time:
>> x0 = x(1:2:8);
>> x1 = x(2:2:8);
>>
>> % Take the half-length DFTs:
>> X0 = fft(x0);
>> X1 = fft(x1);
>>
>> % define constants
>> i = sqrt(-1);
>> N = 8;
>> W = exp(2*pi/N*i);
>> k = [0:N/2-1]’;
>>
>> X0+W.^(-k).*X1
ans =
492
-58.083 - 49.657i
94 + 2i
38.083 + 38.343i
>>
>> X0-W.^(-k).*X1
ans =
16
38.083 - 38.343i
94 - 2i
-58.083 + 49.657i
>> % verify that this gives the DFT of x(n):
>> fft(x)
ans =
492
-58.083 - 49.657i
94 + 2i
38.083 + 38.343i
16
38.083 - 38.343i
94 - 2i
-58.083 + 49.657i
FLOWGRAPHS
If N/2 can be further divided by 2, then this same procedure can
be used to calculated the N/2-point DFTs. It is useful to illustrate
the radix-2 FFT algorithm with a flowgraph, as developed here.
The expression above shows how an N -point DFT can be computed
using two N/2-point DFTs. After taking the two N/2-point DFTs
it only remains to multiply the result of the second DFT with the
terms W kN and to combine the results by adding and subtracting.
The flowgraph for the sum and difference operation is called the
butterfly. This unit will be used as a shorthand notation for the
sum and difference, to simplify the flowgraphs for the FFT.
a
b
a+b
a−b
The decimation-in-time FFT for an 8-point DFT consists of
1. 2 4-point DFT computations,
2. the twiddle factors,
3. butterflies
FLOWGRAPHS (2)
We order the input so the even-indexed terms come first.
x[7]
x[5]
x[3]
x[1]
x[6]
x[4]
x[2]
x[0]
X[7]
X[6]
X[5]
X[4]
X[3]
X[2]
X[1]
X[0]
W8−3
W8−2
W8−1
4−PT DFT
4−PT DFT
The decomposition of the N -point DFT into two N2 -point DFTs
can be repeated (provided N is divisible by 4).
x[7]
x[3]
x[5]
x[1]
x[6]
x[2]
x[4]
x[0]
X[7]
X[6]
X[5]
X[4]
X[3]
X[2]
X[1]
X[0]
W8−3
W8−2
W8−1
W4−1
W4−1
2−PT DFT
2−PT DFT
2−PT DFT
2−PT DFT
FULL FLOWGRAPH
The 2-point DFT is simply a butterfly (sum/difference), so the final
FFT has 3 stages.
x[7]
x[3]
x[5]
x[1]
x[6]
x[2]
x[4]
x[0]
X[7]
X[6]
X[5]
X[4]
X[3]
X[2]
X[1]
X[0]
W8−3
W8−2
W8−1
W4−1
W4−1
Remarks
1. This FFT algorithm can be implemented in-place.
2. The number of stages is log2N . Because each stages has
a complexity of order N , the overall complexity is of order
N log2N .
3. In the DIT flowgraph the signal x(n) is bit-reversed.
BIT REVERSAL PERMUTATION
Notice that the input for the full DIT radix-2 FFT flowgraph is
permuted.
Before the in-place implementation of the DIT FFT algorithm can
be done, it is necessarily to first shuffle the the sequence x(n)
according to this permutation.
The required permutation corresponds to reversing the binary rep-
resentation of the index.
n binary bit-rev n’
0 000 000 0
1 001 100 4
2 010 010 2
3 011 110 6
4 100 001 1
5 101 101 5
6 110 011 3
7 111 111 7
COMPLEXITY
To determine the arithmetic complexity of this algorithm for com-
puting the DFT, let Ac(N) and Mc(N) denote respectively the
number of complex additions and multiplications for computing the
DFT of an N -point complex sequence x[n]. Let N be a power of
2, N = 2K . Then, according to the procedure above, one has
Ac(N) = 2Ac(N/2) +N
Mc(N) = 2Mc(N/2) +N
2− 1
as N complex additions and N2 − 1 complex multiplications are
required to put the two N/2-point DFTs together. Note that a
2-point DFT is simply a sum and difference:
X[0] = x[0] + x[1]
X[1] = x[0]− x[1].
Hence, the starting conditions are Ac(2) = 2 and Mc(2) = 0. Then
solving the recursive equation yields
Ac(N) = N log2N complex additions.
Similarly, one has a formula for complex multiplications:
Mc(N) =N
2log2N −N + 1 complex multiplications.
A single complex multiplication can be performed with 4 real mul-
tiplications and 2 real additions. A single complex addition can be
performed with 2 real additions. Therefore,
Mr(N) = 4 ·Mc(N)
Ar(N) = 2 ·Mc(N) + 2 · Ac(N)
which gives
Mr(N) = 2N log2N − 4N + 4
Ar(N) = 3N log2N − 2N + 2
COMPLEXITY (2)
In fact, this number can be reduced by a more careful examination of
the multipliers W kN (the twiddle factors). In particular, the numbers
1, -1, j, and −j will be among the twiddle factors W kN , when k
is a multiple of N/4 — and so those multiplications need not be
performed. Taking this into account one can reduce the number of
multiplications a bit more.
The advantage of the efficient algorithm for computing the DFT is a
reduction from an arithmetic complexity of N 2 for direct calculation
to a complexity of N log2N . This is a fundamental improvement
in the complexity, and historically it led to many new developments
in signal processing that would not have otherwise been possible or
practical. Due to its fundamental speed-up in calculating the DFT,
the efficient algorithm for its computation is called the Fast Fourier
Transform or FFT.
DECIMATION-IN-FREQUENCY FFT
Consider an N -point signal x[n] of even length. The derivation of
the DIF radix-2 FFT begins by splitting the DFT coefficients X[k]
in to even- and odd- indexed values. The even values X[2k] are
given by:
X[2k] =N−1∑n=0
x[n]W−2knN
=N−1∑n=0
x[n]W−knN/2 .
Splitting this sum into the first N/2 and second N/2 terms gives
X[2k] =
N2 −1∑n=0
x[n]W−knN/2 +
N−1∑n=N
2
x[n]W−knN/2
=
N2 −1∑n=0
x[n]W−knN/2 +
N2 −1∑n=0
x[n+N
2]W
−k(n+N2 )
N/2
=
N2 −1∑n=0
x[n]W−knN/2 +
N2 −1∑n=0
x[n+N
2]W−kn
N/2
=
N2 −1∑n=0
(x[n] + x[n+
N
2]
)W−kn
N/2
= DFTN2
x[n] + x[n+
N
2]
.
That is, the even DFT values X[2k] for 0 ≤ 2 k ≤ N − 1 are given
by the N2 -point DFT of the N
2 -point signal x[n] + x[n+N/2].
DIF FFT (2)
Similarly, the odd values X[2k + 1] are given by:
X[2k + 1] =N−1∑n=0
x[n]W−(2k+1)nN
=N−1∑n=0
x[n]W−nN W−2kn
N
=N−1∑n=0
x[n]W−nN W−kn
N/2 .
Splitting this sum into the first N/2 and second N/2 terms gives
X[2k + 1] =
N2 −1∑n=0
x[n]W−nN W−kn
N/2 +N−1∑n=N
2
x[n]W−nN W−kn
N/2
=
N2 −1∑n=0
x[n]W−nN W−kn
N/2 +
N2 −1∑n=0
x[n+N
2]W
−(n+N2 )
N W−k(n+N
2 )
N/2
=
N2 −1∑n=0
x[n]W−nN W−kn
N/2 −N2 −1∑n=0
x[n+N
2]W−n
N W−knN/2
=
N2 −1∑n=0
(x[n]− x[n+
N
2]
)W−n
N W−knN/2
= DFTN2
W−n
N
(x[n]− x[n+
N
2]
).
That is, the odd DFT values X[2k+1] for 0 ≤ 2 k+1 ≤ N−1 are
given by the N2 -point DFT of the N
2 -point signal W−nN (x[n]− x[n+N/2]).
DIF FLOWGRAPHS
The DIF radix-2 FFT algorithm is illustrated by the
x[7]
x[6]
x[5]
x[4]
x[3]
x[2]
x[1]
x[0]
X[7]
X[5]
X[3]
X[1]
X[6]
X[4]
X[2]
X[0]
W8−3
W8−2
W8−1
4−PT DFT
4−PT DFT
x[7]
x[6]
x[5]
x[4]
x[3]
x[2]
x[1]
x[0]
X[7]
X[3]
X[5]
X[1]
X[6]
X[2]
X[4]
X[0]
W8−3
W8−2
W8−1
W4−1
W4−1
2−PT DFT
2−PT DFT
2−PT DFT
2−PT DFT
FULL DIF FLOWGRAPH
x[7]
x[6]
x[5]
x[4]
x[3]
x[2]
x[1]
x[0]
X[7]
X[3]
X[5]
X[1]
X[6]
X[2]
X[4]
X[0]
W8−3
W8−2
W8−1
W4−1
W4−1
The DIT and DIF radix-2 FFT algorithms are very similar.
1. The DIT and DIF radix-2 FFT algorithms have the same com-
plexity.
2. Both can be implemented in-place.
3. For the DIT FFT, x[n] is in bit-reversed order, X[k] is in
normal order. For the DIF FFT, X[k] is in bit-reversed order,
x[n] is in normal order.
The DIT FFT algorithm requires a bit-reversal prior to the in-place
flowgraph, while the DIF FFT algorithm requires a bit-reversal after
the in-place flowgraph.
Other FFT algorithms
Other FFT algorithms include the Cooley-Tukey FFT which can be
used whenever the length of the data vector can be factored as
N = N1 ·N2.
In addition, there is a class of FFT algorithms that apply only when
the factors N1 and N2 are relatively prime (when their greatest
common divisor is 1). Those algorithms, called Prime Factor FFTs,
avoid the multiplications by twiddle factors. They require fewer
multiplications, but are more complicated to program.
Operation Counts of the MATLAB fft Command
With early versions of MATLAB, we could measure the number
of flops (floating point operations) of many MATLAB commands.
(That ability is no longer available in current versions of MATLAB).
Using an earlier version of MATLAB, we measured the flops used
by the fft command for lengths 2 ≤ N ≤ 512. We made a plot of
the number of flops versus the length N using plot(n,f,’.’) to
prevent MATLAB from connecting the dots. The result is shown
below:
0 50 100 150 200 250 300 350 400 450 5000
0.5
1
1.5
2
2.5x 10
6
N
Flops
Close up:
0 5 10 15 20 25 30 35 40 45 500
0.2
0.4
0.6
0.8
1
1.2
1.4
1.6
1.8
2x 10
4
N
Flops
The graphs show the number of floating point operations (flops)
incurred by the MATLAB fft command. This graph was done with
version 5.2 of MATLAB. Version 6 will give different flop counts
(improved flops counts for some values of N).
1. The lengths for which the fft command is slowest are the
prime lengths. For these lengths, the fft command simply
computes the DFT directly using no fast algorithm. For the
direct computation of the DFT, we know the flops are propor-
tional to N 2, and that is evident in the graph.
2. The second top line corresponds to lengths that are N =
2 · prime. For these lengths the fft command decomposes
the DFT into two DFTs each of length N/2. Likewise for
other composite lengths.
3. For powers of 2, the implementation of the fft command
can use a pure radix-2 FFT algorithm, which is carefully pro-
grammed for maximum efficiency. The fft command is sig-
nificantly more efficient for powers of 2 than for other lengths.
The following MATLAB code was used for this problem.
f = zeros(1,512);
for n = 1:512
x = rand(1,n);
flops(0);
X = fft(x);
f(n) = flops;
end
figure(1), clf
plot(1:512,f,’.’)
xlabel(’N’)
title(’Flops’)
axis([0 512 0 2.5e6])
print -deps fftflops_a
figure(2), clf
plot(1:512,f,’.’)
xlabel(’N’)
title(’Flops’)
axis([0 50 0 2.0e4])
print -deps fftflops_b
• A digital filter, ( )jH e ω , with infinite impulse response (IIR), can be
designed by first transforming it into a prototype analog filter ( )cH jΩ andthen design this analog filter using a standard procedure. Once the analogfilter is properly designed, it is then mapped back to the discrete-timedomain to obtain a digital filter that meets the specifications.
The commonly used analog filters are
1. Butterworth filters – no ripples at all,2. Chebychev filters - ripples in the passband OR in the stopband, and3. Elliptical filters - ripples in BOTH the pass and stop bands.
The design of these filters are well documented in the literature.
A disadvantage of IIR filters is that they usually have nonlinear phase.Some minor signal distortion is a result.
• There are two main techniques used to design IIR filters:
1. The Impulse Invariant method, and2. The Bilinear transformation method.
UNIT - II Design of IIR Filters
• In the impulse invariant method, the impulse response of the digital filter,[ ]h n , is made (approximately) equal to the impulse response of an analog
filter, ( )ch t , evaluated at dt nT= , where dT is an (abitrary) sampling period.Specifically
[ ] ( )d c dh n T h nT=
• From our discussion in Chapter 2,
( ) 2jc
k d d
kH e H j j
T Tω ω π∞
=−∞
= +
∑
and aliasing would occur if ( )cH jΩ is not bandlimited to / dTπ (in rad/s).
If ( )cH jΩ is bandlimited to / dTπ , then
( ) ( )/jc dH e H j Tω ω= .
In this case, it is straight forward to specify the prototype analog filter.
However, all the commonly used prototype analog filters used in theimpulse invariant design method are indeed non-bandlimited. So there isaliasing. However, the aliasing can be minimized if we over-design theanalog filter (especially in the stop band).
• The picture below illustrates the design procedure. We first specify thedigital filter as shown in the first diagram. Then we map the digital
The Impulse Invariant Method
frequency ω onto the analog frequency / dTωΩ = and make
( ) ( )dj TcH j H e ΩΩ = = . Notice from the diagram that we can only control
the magnitude of the responses because of the nature of the analog filtersused.
Digital filter specifications
Prototype analog filter
11 δ−
1
( )jH e ω
ω
pωsω π
2δ
11 δ−
1
( )cH jΩ
Ωp
dT
ωs
dT
ω
dT
π
2δ
• Let ( )cH s be the Laplace transform of ( )ch t , where the complex number
s jσ= + Ω
is the Laplace domain variable. Assuming ( )cH s has only single-orderpoles ks , then
1
( )N
kc
k k
AH s
s s=
=−∑
This implies
1 0
( )0 0
kN s t
kkc
A e th t
t=
≥= <
∑,
( )1
1
[ ] ( )
[ ]
[ ]
k d
k d
d c d
Ns nT
d kk
N ns Tk d
k
h n T h nT
T A e u n
A T e u n
=
=
=
=
=
∑
∑,
and
( )
( )0 1
1
1 0
11
( ) [ ]
1
k d
k d
k d
n
n
N ns T nk d
n k
N ns Tk d
k n
Nk d
s Tk
H z h n z
A T e z
A T z e
A T
z e
∞−
=−∞
∞−
= =
∞−
= =
−=
=
=
=
=−
∑
∑∑
∑ ∑
∑
• It is observed that the pole k k ks jσ= + Ω in the s-plane is mapped into thepole
k d
k d k d
s Tk
T j T
p e
e eσ Ω
=
=
in the z-plane. If all the ks ’s are on the left half of the s-plane, i.e.
0, 1,2,...,k k Nσ < = , then all the kp ’s are within the unit-circle in the z-plane (i.e. 1kp < ). This means that a stable analog filter always yields astable digital filter with the impulse invariant method.
• It should be emphasized that
dsTz e≠
in general.
• Example : Design a digital low pass IIR filter with the followingspecificiations:
( )( )
0.89125 1, 0 0.2
0.17783, 0.3
j
j
H e
H e
ω
ω
ω π
π ω π
≤ ≤ ≤ ≤
≤ ≤ ≤
Use the impulse invariant technique and an analog Butterworth filter.Assume 1dT = and that there is minimal aliasing.
Solution
- with 1dT = , this means ωΩ = , and ( )( ) jcH j H e ΩΩ = . Consequently, the
specifications of the analog prototype filter are
( )( )
0.89125 1, 0 0.2
0.17783, 0.3c
c
H j
H j
π
π
≤ Ω ≤ ≤ Ω ≤
Ω ≤ ≤ Ω
Notice that we did not specify an upperlimit for the stopband frequency.
- The magnitude square response of a Butterword filter of order N is
( )2
2
1( )1
c
c NH jΩΩ
Ω =+
where cΩ is the 3-dB frequency of the filter. It is observed that themagnitude square response decreases monotonically with frequency.The larger N is, the closer the Butterworth filter is to an ideal low passfilter.
The term ( )aH jΩ in this figure is the same as our ( )cH jΩ
- The 3-dB frequency and the filter order N are solutions of the twosimultaneous equations:
2 2
2 2
0.2 11
.89125
0.3 11
.17783
N
c
N
c
π
π
+ = Ω
+ = Ω
The exact results are 5.8858N = and .70474cΩ = . After rounding, wehave 6N = and .7032cΩ = . This latter set of results means the passbandrequirement is met exactly at 0.2pω π= and met with margin at
0.3sω π= . Specifically, ( 0.3 ) 0.1700 0.17783cH j π = < .
- The next step is to find the poles of the Butterworth filter. Note that
( )2
1( ) ( )
1c
c c Ns
j
H s H s
Ω
− = +
has 2N poles whose locations in the s-plane are depicted in the diagrambelow.
Mathematically, these poles are
20.7032exp ( 1) ; 1,2,...,2
12 2 12kr j k k Nπ π π = + + − =
Half of these poles are the poles of the Butterworth filter. Specificallywe choose those kr ’s on the left-half s-plane to be the poles of ( )cH s .Consequently the poles of ( )cH s are
0.182 0.679
0.497 0.497
0.679 0.182
j
j
j
− ±− ±− ±
The poles of the corresponding digital filter are
0.649 0.524
0.535 0.2900.499 0.092
j
j
j
±±±
- The transfer function of the Butterworth filter is
( )
( ) ( )( )
66
61
1
2 2 2
6
1
1( )
1
0.12093
0.3640 0.4945 0.9945 0.4945 1.3585 0.4945
cc
kk
kk
k
k k
H ss s ss
s s s s s s
A
s s
=
=
=
Ω= =
−−
=+ + + + + +
=−
∏∏
∑
where the kA s are the partial fraction expansion coefficients.
- The transfer function of the digital filter ( )H z is (remember 1dT = )
11
1 1
1 2 1 2
1
1 2
( )1
0.2871 0.4466 2.1428 1.1455
1 1.2971 0.6949 1 1.0691 0.36991.8557 0.6303
1 0.9972 0.2570
k
Nk
sk
AH z
z e
z z
z z z zz
z z
−=
− −
− − − −
−
− −
=−
− − += +− + − +
−+− +
∑
- If Matlab is used to design the above prototype analog filter, first set
10
Wp=0.2 0.62832Ws=0.3 0.94248
Rp=20log (0.89125) 1
Rs=20log10(0.17783) 15
ππ
==
= −= −
Then issue the Matlab command
[N,Wn]=buttord(Wp,Ws,Rp,Rs,'s')
Matlab with return the filter order in N and its 3db frequency cΩ in thevariable Wn. The results I got is N=6, Wp=0.70866. The latter result isslightly different from 0.7032cΩ = .
The poles of the corresponding Butterworth filter can be obtained byissuing the Matlab command
[Z,P,K]=butter(N,Wn,'s')
where the array Z contains the zeros, the array P contains all the poles,and the variable K is the gain. The poles I obtained for this example are
-6.8451e-001 +1.8341e-001i-6.8451e-001 -1.8341e-001i-5.0109e-001 +5.0109e-001i-5.0109e-001 -5.0109e-001i-1.8341e-001 +6.8451e-001i-1.8341e-001 -6.8451e-001i
which are slightly different from those in the text.
Finally use the matlab command ‘impinvar” to convert the analogprototype filter into a corresponding digital filter.
• Example : Repeat the last example using a Chebyshev filter.
- The magnitude square response of a N-th order Chebyshev filter with aripple parameter of ε is
( )2
2 2
1( )
1c
c
N
H jVε Ω
Ω
Ω =+ ,
where ( )NV x is the N-th order Chebysheve polynomial, defined as
( )1( ) cos cosNV x N x−=
For example, 0 ( ) 1V x = , 1( )V x x= , 22 ( ) 2 1V x x= − . In general,
1 1( ) 2 ( ) ( )N N NV x xV x V x+ −= −
- It is observed that when x is between 0 and unity, ( )NV x varies between0 and unity. However, when x is greater than 1, 1cos x− is imaginaryand so ( )NV x behaves like a hyperbolic cosine and consequentlyincreases monotonically for x greater than unity. Consequently, themagnitude response of a Chebyshev filter looks like the following(correction: replace 1 ε− by 21/ 1 ε+ )
- We will design a Chebyshev filter such that the passband requirement ismet exactly at 0.2πΩ = . Consequently, 0.2c πΩ = and
22
10.89125 , or 0.50885
1ε
ε= =
+ .
- To determine the filter order N, we calculate 2(0.3 )cH π for different
values of N and pick the smallest N that exceeds the specification. Notethat the requirement is (0.3 ) 0.17783cH π ≤ or
2(0.3 ) 0.031624cH π ≤ . It canbe shown that
2
2
3, (0.3 ) 0.04551
4, (0.3 ) 0.00694
c
c
N H
N H
π
π
= =
= =
Consequently the filter order is N=4.
- The poles of the Chebyshev filter lie on an ellipse in the s-plane withminor axis caΩ and major axis cbΩ , where
( )1/ 1/10.3646
2N Na α α −= − = ,
( )1/ 1/1 1.06442
N Nb α α −= + = ,
and1 21 4.1702α ε ε− −= + + = .
The equation of this ellipse is given by
2 2
2 2 2 2 1c ca b
σ Ω+ =Ω Ω
where s jσ= + Ω is the complex s variable. In addition to the aboveellipse, we defined the major circle as the circle centered at 0s = andwith a radius cbΩ . Similarly, the minor circle is the circle centered at
0s = and with a radius caΩ
To locate the poles, we first identify the points on the major and minorcircles that are equally spaced in angle with a spacing of / Nπ andarranged in such a way that the points are symmetrically located withrespect to the imaginary axis (but never fall on the imaginary axis) and apoint occurs on the real axis for N odd but not for N even.
The poles of a Chebyshev filter fall on the above ellipse with theordinate specified by the points identified on the major circle and theabscissa specified by the points identified on the minor circle.
The diagram below illustrates how the poles can be located for the caseN=3.
An example for finding the poles of a Chebyshev filter with N=3.
It should be emphasized that only poles on the left-half plane are used inthe transfer function of the filter.
- Once all the 4 poles, 1 2 3 4, , ,s s s s , are found, the transfer function of theChebyshev filter can be written as (please verify)
( )( )
4
14 2 22
1
1 0.038286( )
0.4233 0.1103 0.1753 0.38941 ( )
kk
c
kk
s
H ss s s ss sε
=
=
= =+ + + ++ −
∏
∏
The magnitude and phase of this transfer function are shown below
- If you use Matlab to determine this filter, first set
10
Wp=0.2 0.62832Ws=0.3 0.94248
Rp=20log (0.89125) 1
Rs=20log10(0.17783) 15
ππ
==
= −= −
and then issue the Matlab command
[N,Wn]=cheb1ord(Wp,Ws,Rp,Rs,'s')
Finally complete the filter design by issuing the command
[Z,P,K]=cheby1(N,-Rp,Wn,’s’)
The zeros of the filter will be returned in the array Z, the poles stored inP, and the gain stored in K. What I found for the poles were
-2.1166e-001 +2.5593e-001i-2.1166e-001 -2.5593e-001i-8.7673e-002 +6.1788e-001i-8.7673e-002 -6.1788e-001I
and the gain was K=0.038286. There are no zeros. These results agreewith those obtained through analysis.
- The transfer function of the corresponding digital IIR filter is
1 1
1 2 1 2
0.08327 0.0239 0.08327 0.0246( )
1 1.5658 0.6549 1 1.4934 0.8392z z
H zz z z z
− −
− − − −
+ −= +− + − +
- It is interesting to point out the Chebyshev filter has a lower order thanthe Butterworth filter in the last example.
• In the impulse invariant method, aliasing occurs when the prototype analogfilter is transformed back into the digital filter. To reduce the distortionintroduced by aliasing, we start off by tightening the specifications on thedigital filter. This is somewhat cumbersome and may lead to severaliterations before the “optimal” filter is found.
• Aliasing occurs because points in the Ω axis separated by 2 / dTπ aremapped into the same digital frequency ω . In the Bilinear transformationmethod, there is a one-to-one correspondence between Ω and ω . Soaliasing is avoided in transforming the prototype analog filter back into thedigital filter.
Since ω is limited to [ , ]π π− but Ω varies from −∞ to +∞ , it becomes clearthat Ω must be compressed when it is mapped to ω . In other word,Bilinear transformation is non-linear in nature.
• Let ( )cH s be the transfer function of the protype analog filter. The transferfunction ( )H z of the digital filter is obtained by substituting
1
1
2 11d
zs
T z
−
−
−=
+
into the expression of ( )cH s . In other word
1
1
2 1( )
1cd
zH z H
T z
−
−
−= +
The Bilinear Transformation Method
• The Bilinear transformation can be written alterantively as:
( ) ( )
( )
1 1
1 1
1
2
2
1 2 1 , or
2 2 , or
2 2 , or
2 , or
2
1
1
d
d
d
d d
d d
d
d
sT
sT
z sT z
sT z sT z
sT z sT
sTz
sT
− −
− −
−
+ = −
+ = −
+ = −
+=−
+=−
• If s jσ= + Ω , where Ω is the analog frequency, then
( )( )
( ) ( ) ( ) ( ) ( ) ( ) ( ) ( )
2 2
2 2
2 2
2 2 2 2
2 2
2 2 2 2
1
1
1 exp arctan 1
1 exp arctan 1
exp
d d
d d
d d d d
d d d d
T T
T T
T T T T
T T T T
jz
j
j
j
z j
σ
σ
σ σ
σ σ
θ
Ω
Ω
Ω Ω
Ω Ω
+ +=
− −
+ + + = − + − −
=
where
( ) ( )( ) ( )
2 2
2 2
2 2
2 2
1
1
d d
d d
T T
T T
z
σ
σ
Ω
Ω
+ +=
− +and
( ) ( ) ( ) ( )2 2 2 2arctan 1 arctan 1d d d dT T T Tσ σθ Ω Ω = + + −
are respectively the magnitude and phase of z .
Observations:
1. When 0σ < , 1z < . So left-plane poles of ( )cH s will be mapped intopoles within the unit circle in the z-plane. In other word, a stableprototype analog filter will lead to a stable digital filter.
2. When 0σ = , 1z = . In other word, z lies on the unit circle and can bewritten as
(when =0)jz e ω σ=where
2arctan2
dTω θ
Ω ≡ =
represents the digital frequency. Alternatively, we can express theanalaog frequency Ω in terms of the digital frequency ω as
2tan
2dT
ω Ω =
The figure below illustrates the relationship between Ω and ω . It isclear that compression occurs in the mapping process.
These results indicate that the entire left-half s-plane is mapped into adisc of radius 1 in the z-plane.
• Example : Design a digital low pass filter with the following specifications
( )( )
0.89125 1, 0 0.2
0.17783, 0.3
j
j
H e
H e
ω
ω
ω π
π ω π
≤ ≤ ≤ ≤
≤ ≤ ≤
using the Bilinear transformation method and a Butterworth prototypefilter. Compare the results with those obtained through the impulseinvariant method.
Solution:
For simplicity, set 1dT = . So ( )2tan / 2ωΩ = . This means the digitalpassband and stopband frequencies,
0.2 , 0.3p sω π ω π= =
are mapped into the analog passband and stopband frequencies
( )( )
2tan / 2 0.64984,
2tan / 2 1.0191
p p
s s
ω
ω
Ω = =
Ω = =
The specifications of the prototype analog filter become
( )( )
0.89125 1, 0 0.64984
0.17783, 1.0191c
c
H j
H j
≤ Ω ≤ ≤ Ω ≤
Ω ≤ ≤ Ω ≤ ∞
Next we define the following Matlab variables
Rp=20log10(0.89125)=-1
Rs=20log10(0.17783)=-15
Wp=0.64984Ws=1.0191
and issue the command [N,Wn]=buttord(Wp,Ws,Rp,Rs,’s’). Matlab willreturn the order of the Butterworth filter in the variable N and the 3-dbfrequency in the variable Wn. It was found that
N=6
Wn=0.76627 c≡ Ω
To complete the design of the protoype Butterworth filter, we next issue theMatlab command [Z,P,K]=butter(N,Wn,’s’). The zeros of ( )cH s will thenbe returned in the array Z, the poles in the array P, and the filter gain (sameas N
cΩ ) in the variable K. It was found that there are no zeros, the poles are
-7.4016e-001 +1.9832e-001i-7.4016e-001 -1.9832e-001i-5.4183e-001 +5.4183e-001i-5.4183e-001 -5.4183e-001i-1.9832e-001 +7.4016e-001i-1.9832e-001 -7.4016e-001I
and the gain is 0.20243. Denoting the poles as 1 2 6, ,...,s s s , the transferfunction of the Butterworth filter is
( ) ( )( )
6
1
2 2 2
K( )
( )
0.20243
0.39665 0.58716 1.0837 0.58716 1.4803 0.58716
c
kk
H ss s
s s s s s s
=
=−
=+ + + + + +
∏
This result is very close to that in Example 7.3 of the Text. Compared tothe result obtained under the impulse invariant method, we observe anoticeable difference in ( )cH s .
Finally, the last step in the design exercise is to map the above transferfunction into a digital filter using Bilinear transformation, i.e.
1
1
1( ) 2
1c
zH z H
z
−
−
−= +
This can be done by using the Matlab command
[Zd,Pd,Kd]=bilinear(Z,P,K,1)
where Z, P, and K are same as before, 1 corresponds to the samplingfrequency 1/ dT , Zd is an array containing the zeros of ( )H z , Pd is the array
storing the poles of ( )H z , and Kd is the gain of ( )H z . The results Iobtained are:
Kd= 0.00073798
Zd=-1-1-1-1-1-1
Pd =4.5216e-001 +1.0510e-001i4.5216e-001 -1.0510e-001i5.0527e-001 +3.2087e-001i5.0527e-001 -3.2087e-001i6.3430e-001 +5.5026e-001i6.3430e-001 -5.5026e-001I
Calling the 6 zeros as 1 2 6, ,...,z z z and the 6 poles as 1 2 6, ,...,p p p . Then thetransfer function of the digital filter ( )H z can be written as
( )( )
( )( ) ( )
( )
6 1
16 1
1
61
1 2 1 2
1 2
1( ) Kd
1
0.00073798 1
1 1.2686 0.70512 1 1.0105 0.35826
1
1 0.90433 0.21550
kk
kk
z zH z
p z
z
z z z z
z z
−=
−=
−
− − − −
− −
−=
−
+= ×
− + − +
− +
∏∏
The result is once again close to that in Example 7-3 of the text.
• So far, we focus our discussion on the design of lowpass IIR filters. Howabout highpass, bandpass, and bandstop filters?
Frequency responses of lowpass, highpass, bandpass, and bandstop filters.
• The impulse invariant method will not be suitable for the highpass andbandstop filters because of heavy aliasing.
Frequency Transformation of Lowpass IIR Filters
• It is possible to get around the problem by first designing a digitalportotype lowpass filter and then perform an algebraic transformation onthe digital lowpass filter to obtain the desired frequency selective filter.
• The tranfer function of the digital prototype low pass filter is denoted by( )lpH p where p plays the same role as z , the conventional z -transform
variable.
The transfer function of the desired frequency selective filter is denoted by( )H z .
We want to find a relationship between p and z, denoted by
( )1 1p G z− −=such that
( ) ( )1 1( ) lp p G zH z H p − −=
=
It should be emphasized that the transformation relates 1p− to 1z− , not p toz. This is due to the fact that ( )lpH p is usually expressed as a function in
1p− instead of p.
• We want a stable, rational ( )lpH p be mapped into a stable rational ( )H z .Consequently, the requirements on the mapping function ( )1 1p G z− −= are:
1. ( )1G z− must be a rational function of 1z− .2. The inside of the unit circle in the p-plane is mapped into the inside of
the unit circle in the z-plane.
3. The unit circle in the p-plane is mapped into the unit circle in the z-plane. So if θ and ω are the frequency variables in the p-plane and thez-plane, then
( )j je G eθ ω− −=Consequently
( ) 1jG e ω− =and
( )jG e ωθ −= −R .
• The most general form of the function ( )1G z− that satisfies all the aboverequirements is:
( )1
1 11
1
; 11
Nk
kk k
zp G z
z
αα
α
−− −
−=
−= = ± <
−∏
By choosing appropiate values for N and the kα ’s, a variety of mappingscan be obtained.
• Low-pass to Low-pass transformation:
11
11z
pz
αα
−−
−
−=−
This means the relationship between θ and ω is
1
jj
j
ee
e
ωθ
ω
αα
−−
−
−=−
or
( ) ( )( ) ( )
( ) ( )2 2
2
11
1 1
2 1 cos( ) 1 sin( )
1+ 2 cos( )
jj
j
j j
j j
ee
e
e e
e e
j
θω
θ
θ θ
θ θ
αα
α α
α α
α α θ α θ
α α θ
−−
−
−
−
+=+
+ +=
+ +
+ + + −=
+
or
( )( )
2
2
1 sinarctan
2 1 cos
α θω
α α θ
− =
+ +
For a given pair of pθ and pω , the parameter α is
( )( )
sin / 2
sin / 2
p p
p p
θ ωα
θ ω
− = +
It can be shown that the absolute value of α is less than 1.
• Transformations from LP to LP, HP, BP, and BS filters are shown below:
The corresponding definitions of filter cutoff frequencies are shown in thenext page.
(a) low pass, (b) high pass, (c) bandpass, (d) bandstop.
• Example : The prototype low pass filter
( ) ( )1 4
1 2 1 2
0.001836(1 )( )
1 1.5548 0.6493 1 1.4996 0.8482lp
pH p
p p p p
−
− − − −
+=− + − +
satisfies
( )( )
0.89125 1, 0 0.2
0.17783, 0.3
j
j
H e
H e
θ
θ
θ π
π θ π
≤ ≤ ≤ ≤
≤ ≤ ≤
Determine the corresponding high pass filter that satisfies the requirements
( )0.89125 1; 0.6jH e ω π ω π≤ ≤ ≤ ≤
Solution:
The passband frequency of the high pass filter is 0.6pω π= and thepassband frequency of the digital prototype filter is 0.2pθ π= . So accordingto the design formula,
( )( )
2
2
cos0.38197
cos
p p
p p
θ ω
θ ωα
+
−= = −
This means
1 11
1 1
0.381971 1 0.38197z z
pz z
αα
− −−
− −
+ − += − =+ −
Consequently,
( ) ( )
( )( ) ( )
1 1 10.38197 / 1 0.38197
41
1 2 1 2
( ) ( )
0.02426 1
1 1.0416 0.4019 1 0.5661 0.7647
lp p z zH z H p
z
z z z z
− − −= − + −
−
− − − −
=
−=
− + − +
It should be pointed out that in actual design, the stopband frequency of thedigital prototype filter will be determined by the stopband frequency of thehigh pass (or desired) filter. We assume in this example that the stop bandfrequency of the high pass filter is mapped into 0.3sθ π= based on
0.38197.α = −
• The transfer function of an IIR filter can always be expressed as a ratio oftwo polynomials, i.e.
( )( )
( )B z
H zA z
= ,
where ( )A z and ( )B z are respectively polynomials of orders N and Min 1z− .
It is the denominator polynomial that makes the impulse response of thefilter infinitely long.
Implementation Structures for IIR Filters
• Different expressions for ( )A z , ( )B z , and ( )H z lead to differentimplementation structures. For example, if these two polynomials arewritten as
1
( ) 1N
kk
k
A z a z−
== − ∑
and
0
( )M
kk
k
B z b z−
== ∑ ,
then
0
1
( )1
Mk
kk
Nk
kk
b zH z
a z
−
=
−
=
=−
∑
∑ .
This means in the time domain, the input [ ]x n and the output [ ]y n of thefilter satisfies
1 0
[ ] [ ] [ ]N M
k kk k
y n a y n k b x n k= =
− − = −∑ ∑ ,
which is simply a linear constant coefficient different equation.
A a possible computational structure for [ ]y n is shown in the signal flowgraph in the next page. There, a branch with a transmittance of 1z− isequivalent to a delay of 1 sample, and a branch with a transmittance ia (or
jb ) implies a scaling of the signal at the originating node of that branch bythe constant ia (or jb ). As in any signal flow graph, the signal at any node,i.e. the node value, is the sum of products of the signal at an originatingnode and the corresponding branch transmittance.
The above computational structure is called the Direct Form Iimplementation of an IIR filter. Note that for simplicity, we assume thatthe order of the numerator and denominator polynomials are identical, i.e.N M= .
It is observed that the Direct Form I implementation structure requires2 1N + multiplications, 2N additions, and 2N delay elements.
• The number of delay elements can be reduced to N if we interchange thetwo sections in the Direct Form I structure. This leads us to the DirectForm II structure shown below.
• It is also possible to express the transfer function of an IIR filter in productform as
( ) ( )( )
( ) ( ) ( )
1 2
1 2
1 1 * 1
1 1
1 1 * 1
1 1
1 1 1( )
1 1 1
M M
k k kk kN N
k k kk k
f z g z g zH z C
c z d z d z
− − −
= =
− − −
= =
− − −=
− − −
∏ ∏
∏ ∏,
where C is a constant, the kf ‘s are the real zeros of the transfer function,the kg ‘s are the complex zeros (which always exist in conjugate pairs), the
kc ’s are the real poles, and the kd ’s are the complex poles (which alwaysexist in conjugate pairs).
Note that the products ( ) ( )1 * 11 1k kg z g z− −− − and ( )( )1 * 11 1k kd z d z− −− − are 2nd
order polynomials in 1z− with real coefficients.
For simplicity, we assume that 1 1 2N M K= = (K an integer) and 2 2N M= .This means we can combine pairs of real poles and combine pairs of realzeros and rewrite ( )H z as
( )1 2
0 1 21 2
1 1 2
1
1
( ),
s
s
Nk k k
k k k
N
kk
b b z b zH z
a z a z
H z
− −
− −=
=
+ +=
+ +
=
∏
∏where
1 20 1 2
1 21 2
( )1
k k kk
k k
b b z b zH z
a z a z
− −
− −
+ +=+ +
and
2sN K N= + .
This expression for the transfer function enables us to visualize the IIRfilter as the serial concatentation of sN subsystems. Subsequently it leadsto the Cascade implementation structure; see for example the case of
3sN = below.
• With the Cascade form implementation, the locations of the poles and zeroswill not change dramatically when the ija ’s and the ijb ’s are quantized (asin fixed point implementation). This is in contrast to the Direct formimplementation where the poles and zeros can change substantially becauseof quantization. This issue will be discussed in details in Chapter 7 of thelecture notes.
• If we express the transfer function as a partial fraction expansion, then
10 1
1 21 1 2
1
( )1
( ),
s
s
Nk k
k k k
N
kk
e e zH z
a z a z
G s
−
− −=
=
+=− −
=
∑
∑where
10 1
1 21 2
( )1
k kk
k k
e e zG s
a z a z
−
− −
+=− −
and all the polynomial coefficients are real.
The transfer function suggests that the IIR filter can be viewed as a “large”system comprising of sN parallel subsystems. The input to all thesubsystems is [ ]x n and the output of the IIR filter, [ ]y n , is the sum of the
[ ]ky n ’s , the individual outputs of the subsystems.
The figure below shows this parallel form of the IIR filter.
• The parallel form offers robustness against quantization error for the poles.The zeros, however, will be affected by the shifting of the poles in theindividual subsystems.
• Exercise: While it is straight forward to incorporate any given initialcondition of an IIR filter in the Direct Form I structure, it is not clear howthis can be done in the other structures. Is this a matter of great concern? Ifso, suggest how a given initial condition can be incorporated into the DirectForm II, the Cascade form, and the Parallel form.
UNIT- IIIDesign of FIR Filters
Frequency Response of Digital Filters
• Frequency response of digital Filter: H(eθ) = |H(eθ)|e−φ(θ)
– continuous function of θ with period 2π ⇒ H(eθ) = H[e(θ+m2π)]
• |H(eθ)| is the called the Magnitude function.
→ Magnitude functions are even functions ⇒ |H(eθ)| = |H(e−θ)|
• φ(θ) is called the Phase (lag) angle, φ(θ) , ∠H(eθ).
→ Phase functions are odd functions ⇒ φ(θ) = −φ(−θ)
• More convenient to use the magnitude squared and group delayfunctions than |H(eθ)| and φ(θ).
– Magnitude squared function: |H(eθ)|2 = H(z)H(z−1)∣
∣
z=eθ
– It is assumed that H(z) has real coefficients only.
– Group delay function τ(θ) = dφ(θ)dθ . Measure of the delay of the filter
response.
Digital Filter Frequency Response: Poles & Zeros
• Complex zeros zk and poles pk
occur in conjugate pairs.
• If zk = a is a real zero/poleof |H(eθ)|2 ⇒ z−1
k = a−1 isalso a real zero/pole.
• If zk = rkeθ is a
zero/pole of |H(eθ)|2 ⇒rke
−θ, ( 1rk
)eθ and ( 1rk
)e−θ
are also zeros/poles.
Occurs in pairs
Occurs with even multiplicity
with even multiplicityOccurs in conjugate pairs
Occurs in quadruples
z−plane
2
2
−2
−2
ℑz
ℜz
Digital Filters: Transfer Functions
• The problem of finding the transfer function of a filter is the problem ofuniversal function approximation. This is usually solved by involvingsome basis functions (Fourier, Chebyshev, ...). In our case, the basisfunctions will be polynomials or rational functions in z (or z−1.
• Finite Impulse Response (FIR) filter: Digital filter characterised bytransfer functions in the form of a polynomial
H(z) = a0 + a1z−1 + · · · + zmz−M
• Infinite Impulse Response (IIR) filter: characterised by transferfunctions in the form of a rational function
H(z) =
MP
i=0aiz
−i
NP
j=0bjz−j
= A(z−1)B(z−1)
Digital Filters: Transfer Functions Properties
• FIR filters are stable and causal.
• IIR filters are:
– Stable if all the poles of H(z) are within the unit circle– Causal if bL is the first non-zero coefficient in the denominator (i.e.
b0 = b1 = · · · = bL−1 = 0 and a0 = a1 = · · · = aL−1 = 0 .
• Causal filters are normally assumed, hence IIR filters are commonlywritten as:
H(z) =
MP
i=0aiz
−i
1+NP
j=1bjz−j
= A(z−1)B(z−1)
, b0 = 1
• We would ideally like to design filters with linear phase in thepassband - what about the phase in the stopband?
Digital Filters: Magnitude and Phase Characteristics
Phase Characteristics
Band−pass Filter All−pass Filter
Band−reject Filter
High−pass Filter
Low−pass Filter
θ rad2π
|H(eθ)|
π-π-2π
θ rad2π
|H(eθ)|
π-π-2π
-2π -π π
|H(eθ)|
2π θ rad
θ rad2π
|H(eθ)|
π-π-2π -2π -π π
|H(eθ)|
2π θ rad
-2π π 2π 3π-π
φ(θ)
θ rad
Design of All-pass Digital Filters
• An all-pass filter is an IIR filter with a constant magnitude function forall digital frequency values.
• For a transfer function H(z) to represent an all-pass filter is that forevery pole pk = rke
jθ, there is a corresponding zero zk = 1rk
ejθ. Thepoles and zeros will occur in conjugate pairs if θk 6= 0 or π.
• A digital filter H(z) obtained by cascade connection of multiple all-passfilters H1(z),H2(z) · · ·HN(z) sections is itself an all-pass filter, and canbe represented by
H(z) = H1(z)H2(z) · · ·HN(z)
So why do we need all-pass filters? They are phase-selective (asopposed to frequency selective) and are extremely useful in thedesign of DSP systems.
First order All-pass Digital Filter
• A typical first-order section of an all-pass digital filter has a transferfunction
H1(z) =z−1 − a
1 − az−1(1)
where a is real and to be stable, we must have |a| < 1.
a
Unit Circle
Re[z]
Im[z]
1/a
Figure 1: Pole-zero pattern of first order all-pass digital filter.
First- and Second-Order All-pass Digital Filter
The magnitude function is unity for all frequencies, as given by
|H1(ejθ)|2 =
∣
∣
e−jθ − a
1 − ae−jθ
∣
∣
2=
∣
∣
cos θ − a − j sin θ
1 − a cos θ + aj sin θ
∣
∣
2=
1 − 2a cos θ + a2
1 − 2a cos θ + a2= 1
A typical second-order section of an all-pass digital filter
H2(z) =1 − ( 2
rk) cos θkz
−1 + ( 1r2k)z−2
1 − 2rk cos θz−1 + r2kz
−2=
[1 − ( 1rk
)z−1ejθ][1 − ( 1rk
)z−1e−jθ]
[1 − rkz−1ejθ][1 − rkz−1e−jθ]
⊛ The poles are at p1,2 = rke±jθk and the zeros at z1,2 = 1
rke±jθk
For filter to be stable, |rk| < 1.
First- and Second-Order All-pass Digital Filter
X −θ
θ
r
1
Im[z]
Unit Circle
Re[z]
1/rX
Figure 2: Pole-zero pattern of a second order all-pass digital filter.
First order All-pass Digital Filter
The magnitude function is given by
|H2(ejθ)|2 = |
ejθ − ( 1rk
)ejθk
ejθ − rkejθk|2|
ejθ − ( 1rk
)e−jθk
ejθ − rke−jθk|2 (2)
where |ejθ−( 1
rk)ejθk
ejθ−rkejθk|2 = |
ejθ−( 1rk
)e−jθk
ejθ−rke−jθk|2 = r−2
k
Hence|H2(e
jθ)|2 = r−4k = c (3)
where c is a constant, implying that it represents an all-pass filter.
Design of FIR Digital Filter
The transfer function of FIR digital filter is in the form of
H(z) =
N−1X
n=0
h(n)z−n
(4)
where the impulse response is of length N .
The filter will have linear phase response if the FIR digital filter satisfies
h(n) = h(N − 1 − n) (5)
Design of FIR Digital Filter
for n = 0, 1, . . . , (N/2) − 1 if N is even, and for n = 0, 1, . . . , (N − 1)/2 if N is
odd. Indeed if N is odd, then (4) and (5) give
H(ejθ
) =N−1X
n=0
h(n)e−jnθ
=
N−32
X
n=0
[h(n)e−jnθ + h(N − 1 − n)e−j(N−1−n)θ] + h`N − 1
2
´
e−j˘
n−[(N−1)
2 ]¯
θ
=
N−32
X
n=0
h(n)[e−jnθ + e−j(N−1−n)θ] + h`N − 1
2
´
e−j˘
n−[(N−1)
2 ]¯
θ(6)
= e−j[(N−1)/2]θ˘
h(N − 1
2) +
N−32
X
n=0
h(n)[e−j
˘
n−[(N−1)
2 ]¯
θ+ e
j˘
n−[(N−1)
2 ]¯
θ]¯
= e−j[(N−1)/2]θ˘
h(N − 1
2) +
N−32
X
n=0
2h(n) cos [(n −N − 1
2)θ]
¯
(7)
Design of FIR Digital Filter
In similar way, (4) and (5), for even values of N , give
H(ejθ) = e−j[(N−1)/2]θ˘
(N2 −1)X
n=0
2h(n) cos [(n −N − 1
2)θ]
¯
(8)
In both cases, the phase φ(θ) of the FIR digital filter is given by
φ(θ) =N − 1
2θ (9)
which is linear for π < θ ≤ π.
The group delay function is
τ(θ) = φ′(θ) =
N − 1
2(10)
which is constant for π < θ ≤ π.
Constraints on zero-phase FIR filters
The zero locations of FIR filter are restricted to meet certain symmetry requirements due
to constraints imposed by (5). To see this, (4) is written as
H(z) = z−(N−1)
N−1X
n=0
h(n)zN−n−1
Let m = N − n − 1 be a new dummy variable, then (12) can be written as
H(z) = z−(N−1)N−1X
n=0
h(N − m − 1)zm
= z−(N−1)
N−1X
n=0
h(m)(z−1
)−m
(11)
= z−(N−1)
H(z−1
)
This means that zeros of H(z) are the zeros of H(z−1) except, perhaps, for the zeros at
origin.
Symmetry properties of digital FIR filters
• If zi = a is a real zero of H(z), then z−1i = a−1 is also a zero of H(z).
Unit Circle
a 1/a
Im[z]
Re[z]
Symmetry properties of digital FIR filters
• If zi = ejθi is a zero of H(z), where θi 6= 0 and θi 6= π, then z−1i = zi = e−jθi is
also a zero of H(z).
Unit Circle
Im[z]
Re[z]
Symmetry properties of digital FIR filters
• If zi = riejθi is a zero of H(z), where ri 6= 1, θi 6= 0 and θi 6= π, then
zi = rie−jθi and z−1
i = 1ri
e−jθi and z−1i = 1
riejθi are also zeros of H(z).
Re[z]
Unit Circle
Im[z]
θi
θi
Frequency sampling method
An FIR filter has equivalent DFT representation, given by
eH(k) =
N−1X
n=0
h(n)e[−
j2πnkN
](12)
where eH(k) is actually the uniformly spaced N-point sample sequence of the
frequency response of the digital filter. As a consequence, the impulse response
sequence h(n) and transfer function H(z) are given by
h(n) =1
N
N−1X
k=0
eH(k)e[j2πnk
N]
(13)
and
H(z) =1
N
N−1X
k=0
eH(k)1 − z−N
1 − z−1e[j2πk
N]
(14)
where equation (14) is the key to the design of FIR digital filter.
Example
Design a low-pass digital filter whose magnitude characteristics are shown in Figure. Find
an appropriate transfer function via a 16-point frequency sampling method.
k151050
0
1
Hd(ejθ), H(k)
2π θπ
Hd(ejθ)
Solution: In this case, the DFT sequence is given by
Example
eH(0) = eH(1) = eH(15) = 1
eH(k) = 0 for k = 2, 3, 4, . . . , 14 (15)
By using (14), the desired transfer function can be found
H(z) =1
16
ˆ
15X
k=0
(1 − z−16) eH(k)
1 − z−1ejkπ8
˜
=1 − z−16
16
ˆ 1
1 − z−1ej0π4
+1
1 − z−1ejπ8
+1
1 − z−1ej15π
8
˜
(16)
=1 − z−16
16
ˆ 1
1 − z−1+
2(1 − z−1 cos(π/8))
1 − 2z−1 cos(π/8) + z−2
˜
It can be be shown that the frequency response of (17) will be equal to the specifications
of (15) at the sampling frequencies θ = kπ8 for k = 0, 1, 2, . . . , 15.
The Windowing Method
• The Fourier series expansion of the frequency response of a digital filter, H(ejθ), is
given by
H(ejθ
) =
∞X
n=−∞
h(n)e−jθn
(17)
where
h(n) =1
2π
Z π
n=−π
H(ejθ
)ejθn
(18)
where h(n) is the impulse response of the digital filter.
• While the infinite series in (17) can be truncated to obtain the digital filter, the Gibbs
phenomenon states that the truncation will cause overshoots and ripples in the
desired frequency response.
• In the method of windowing, a finite weighting sequence w(n), called windows, is
used to obtain the finite impulse response hD(n), where
hD(n) = h(n)w(n)
where w(n) is w(n) = 0 for n > N and n < 0.
The Windowing Method
• Given the desired frequency response H(ejθ), which may be obtained bythe frequency sampling method.
• Find the associated impulse response sequence h(n) from 17 or byinverse z-transform of H(z), where H(z) is obtained from H(ejθ) byreplacing ejθ with z.
• Employ an appropriate window function w(n) to modify the sequenceh(n) to obtain the FIR digital filter’s impulse response sequencehD(n) = h(n)w(n).
The windowing method has the effect of smoothing out the ripples andovershoots in the original frequency response as shown in the figure for asimple window function
The Windowing Method
1|H(ejθ)|
πθ rad
1
π
|H(ejθ)|
θ rad
w(n) = 1 + cos2πn
Nfor 0 ≤ n ≤ N − 1
= 0 otherwise (19)
The Windowing Method: Some common window
functions
• Rectangular Window
w(n) = 1 for 0 ≤ n ≤ N − 1
= 0 otherwise (20)
• Bartlett Window or Triangular Window
w(n) =2n
N − 1for 0 ≤ n ≤ (N − 1)/2
= 2 −2n
N − 1for (N − 2)/2 ≤ n ≤ N − 1 (21)
= 0 elsewhere
where N is even.
The Windowing Method: Some common window
functions
• Hann Window
w(n) =1
2
[
1 − cos2πn
N − 1
]
for 0 ≤ n ≤ N − 1
= 0 elsewhere (22)
• Hamming Window
w(n) = 0.54 − 0.46 cos[ 2πn
N − 1
]
for 0 ≤ n ≤ N − 1
= 0 elsewhere (23)
The Windowing Method: Some common window
functions
• Blackman Window
w(n) = 0.42 − 0.5 cos[ 2πn
N − 1
]
+ 0.008 cos[ 4πn
N − 1
]
for 0 ≤ n ≤ N − 1
= 0 elsewhere (24)
• Kaiser Window
w(n) =I0
[
wa
√
(
N−12
)2−
(
n − N−12
)2]
I0
[
wa
(
N−12
)] for 0 ≤ n ≤ N − 1
= 0 elsewhere (25)
where I0(.) is a modified zeroth order Bassel function of the first kindand wa is a window shaper parameter.
Two Sinusoids in WGN:- Hamming window
x[n] = 0.1 sin(n ∗ 0.2π + Φ1) + sin(n ∗ 0.3π + Φ2) + w[n] N = 128
Hamming window w[n] = 0.54 − 0.46 cos(
2πn
N
)
0 0.2 0.4 0.6 0.8 1−30
−25
−20
−15
−10
−5
0
5
10
15
Frequency (units of pi)
Mag
nitu
de (
dB)
0 0.2 0.4 0.6 0.8 1−60
−50
−40
−30
−20
−10
0
10
20
Frequency (units of pi)
Mag
nitu
de (
dB)
Expexted value of periodogram Periodogram Using Hamming window
The Modified Periodogram
The periodogram of a process that is windowed with a general windoww[n] is called a modified periodogram and is given by:-
PM(ω) =1
NU
∣
∣
∣
∣
∣
∞∑
n=−∞
x[n]w[n]e−nω
∣
∣
∣
∣
∣
2
where N is the window length and U = 1N
∑N−1n=0 |w[n]|2 is a constant,
and is defined so that PM(ω) is asymptotically unbiased.
In Matlab:-
xw=x(n1:n2).*w/norm(w);
Pm=N * periodogram(xw);
where, for different windows
w=hanning(N); w=bartlett(N);w=blackman(n);
“Cosine–type windows”
Idea:- suppress sidelobes, perhaps sacrify the width of mainlobe
• Hann window
w = 0.5 * (1 - cos(2*pi*(0:m-1)’/(n-1)));
• Hamming window
w = (54 - 46*cos(2*pi*(0:m-1)’/(n-1)))/100;
• Blackman window
w = (42 - 50*cos(2*pi*(0:m-1)/(n-1)) +
+ 8*cos(4*pi*(0:m-1)/(n-1)))’/100;
Standard Window Functions:- Properties
Triangular window Hamming window
Hann window Blackman window
Some Comments on FIR digital Filter
• Unlike IIR filters, FIR filters can be designed to have linear phasecharacteristics.
• FIR filters are always stable.
• FIR filters are, however, computationally more expensive than IIR filtersand hence are called for to perform tasks not possible/or not practicalby IIR filters such as linear phase, and multirate filters.
UNIT - IVFINITE WORD LENGTH EFFECTS IN DSP
ABSTRACT
We know that computers store numbers not with infinite precision but rather in
some approximation that can be packed into a fixed number of bits or bytes, because of
which we are loosing some information. Our aim is to study the effect of loosing this
information on the response of digital filters. This effect we called Finite word length
effect.
There are number of effects of finite word length like overflow error in addition,
round off error in multiplication, effects of coefficient quantization, limit cycle, etc. This
paper talks about effects on response of IIR filters for the case of coefficient quantization.
Section 1 gives brief introduction to number system and shows why finite word
length effect occurs. Section 2 studies same phenomena from the view point of filters it
also includes results we have obtained.
We have studied effect of finite word length on the response of Butterworth low
pass IIR filter. Also we have studied effect of finite word length on the response of 4th
order IIR filter for direct form and parallel form realization. On the basis of results we
have concluded well known result that parallel form realization is better than direct form
realization.
1. INTRODUCTION
Computers store numbers not with infinite precision but rather in some
approximation that can be packed into a fixed number of bits or bytes. Almost all
computers allow the programmer a choice among several different such representations
or data types. Data types can differ in the number of bits utilized, but also in the more
fundamental respect of whether the stored number is represented in fixed-point or
floating-point format.
1.1 Fixed point representation
A number in fixed point representation is exact. Arithmetic between numbers in
fixed point representation is also exact, with the conditions that (i) the answer is not
outside the range of integers that can be represented, and (ii) that division is interpreted as
producing an integer result, throwing away any integer remainder. There are many
formats to represent fixed point numbers like, Sign-magnitude, One’s compliment and
Two’s compliment, etc.
A Real number can be represented with infinite precision in two’s complement
form as
∑∞
=
−+−=1
0 )(i
iim zbbXx
Where, Xm is an arbitrary scale factor and bi’s are either 0 or 1. The quantity b0 is referred
to as sign bit. If b0 = 0, then 0 ≤ x ≤ Xm and if b0 = 1, then Xm ≤ x < 0.
An arbitrary real number x would require an infinite number of bits for its exact
binary representation. If we use only a finite number of bits (B+1), then the
representation of above equation must be modified to
∑=
− =+−==B
iBm
iimB xXzbbXxQx
10 ˆ)(][ˆ
The resulting binary representation is quantized, so that the smallest difference
between numbers is
∆ = Xm2-B
The operation of quantizing number to (B + 1) bits can be implemented by
rounding or by truncation, but in either case quantization is a nonlinear memory less
operation. Figure 1.1 shows input - output relation for two’s complement rounding and
truncation, respectively, for the case of B = 2.
Figure 1.1 Nonlinear Relationship representing two’s complement (a) rounding and
(b) truncation for B = 2 [1]
In considering the effects of quantization, we often define quantization error as
e=QB[x] – x. For the case of two’s complement rounding, -∆/2 < e ≤ ∆/2, and for two’s
complement truncation, -∆ < e ≤ 0(Figure 1.2).
Figure 1.2 probability density function for quantization errors (a) Rounding (b)
Truncation. [1]
If a number is larger than Xm, a situation called overflow occurs. Figure 1.3 (a)
shows two’s complement quantizer, including the effect of regular two’s complement
arithmetic overflow. An alternative, which is called saturation overflow or clipping, is
shown in figure 1.3 (b). This method of handling overflow is generally implemented for
A/D conversion, and it sometimes is implemented in specialized DSP microprocessor for
addition of two’s complement numbers. With saturation overflow, the size of the error
does not increases abruptly when overflow occurs; however disadvantage of such
methods is that it voids the property of two’s complement-arithmetic that ‘If several
two’s-complement numbers whose sum would not overflow are added, then the result of
two’s-complement accumulation of these numbers is correct even though intermediate
sums might overflow”.
Figure 1.3 Two’s complement rounding (a) Natural Overflow (b) Saturation. [1]
1.2 Floating point representation
In floating-point representation (IEEE 754 standard), a number is represented
internally by a sign bit s, an exact integer exponent E, and an exact positive integer
mantissa M. Taken together these represent the number
fx Es .121 127 ∗∗−= −
where E is eight bit exponent (0 < E <255), s is sign bit ( 0 for positive and 1 for negative
) and f is 23 bit fraction )2
120( 23
23 −<< f . Floating point representations provide a
convenient means for maintaining wide dynamic range.
2. FINITE WORD LENGTH EFFECTS
Numerical quantization affects the implementation of linear time-invariant
discrete time system in several ways. Below we have given brief overview of some of
them.
• Parameter quantization in digital filters
In the realization of FIR and IIR filters hardware or in software on a general
purpose computer, the accuracy with which filter coefficients can be specified is limited
by word length of the computer. Since the coefficients used in implementing a given
filter are not exact, the poles and zeros of system function will be different from desired
poles and zeros. Consequently, we obtain a filter having a frequency response that is
different from the frequency response of the filter with unquantized coefficients. Also it
sometimes affects stability of filter.
• Round off noise in multiplication
As already explained when a signal is sampled or a calculation in the computer is
performed, the results must be placed in a register or memory location of fixed bit length.
Rounding the value to the required size introduces an error in the sampling or calculation
equal to the value of the lost bits, creating a nonlinear effect. Round off error is a
characteristic of computer hardware.
• Sampling/Digitization Error
There is another, different, kind of error that is a characteristic of the program or
algorithm used, independent of the hardware on which the program is executed. Many
numerical algorithms compute “discrete” approximations to some desired “continuous”
quantity. For example, an integral is evaluated numerically by computing a function at a
discrete set of points, rather than at “every” point. Or, a function may be evaluated by
summing a finite number of leading terms in its infinite series, rather than all infinity
terms. In cases like this, there is an adjustable parameter, e.g., the number of points or of
terms, such that the “true” answer is obtained only when that parameter goes to infinity.
Any practical calculation is done with a finite, but sufficiently large, choice of that
parameter. The difference between the true answer and the answer obtained in a practical
calculation is called the truncation error. Truncation error would persist even on a
hypothetical, “perfect” computer that had an infinitely accurate representation and no
round off error.
• Overflow in addition
Overflow in addition of two or more binary numbers occurs when the sum
exceeds the word size available in the digital implementation of the system.
• Limit cycles
Since quantization inherent in the finite precision arithmetic operations render the
system nonlinear, in recursive system these nonlinearities often cause periodic oscillation
to occur in the output, even when input sequence is zero or some nonzero value. Such an
oscillation in recursive systems are called limit cycles.
As explained in above paragraphs finite word length affects LTI system in many
ways. We have concentrated on effects due to coefficient quantization on filter response
and in that also on IIR filters. Later we have given brief overview of effects of coefficient
quantization in FIR system for the sack of completeness.
2.1 Effects of coefficient quantization in IIR system
When the parameters of a rational system function or corresponding difference
equation are quantized, the poles and zeros of the system move to the new position in the
z-plane, equivalently, the frequency response is perturbed from the original value.
The system function representation corresponding to both direct forms is
∑
∑
=
−
=
−
−= N
k
kk
M
k
kk
za
zbzH
1
0
1)(
The sets of coefficients ak and bk are ideal infinite-precision coefficients. If
we quantize these coefficients, we obtain the system function
∑
∑
=
−
=
−
−= N
k
kk
M
k
kk
za
zbzH
1
0
ˆ1
ˆ
)(ˆ
where âk = ak + ∆ak and bk = bk + ∆bk are the quantized coefficients that differ from
original coefficients by quantization by quantization error ∆ak and ∆bk.
Kaiser showed that if poles (or zeros) are tightly clustered it is possible that small
error in denominator (numerator) coefficient can cause large shifts of the poles and
(zeros) for direct form structure. Thus, if the poles (zeros) are tightly clustered,
corresponding narrow band pass filter or narrow-bandwidth low pass filter, then we can
express poles of the direct-form structure to be quite sensitive to quantization error in the
coefficients. Kaiser analysis also showed that the larger the number of clustered poles
(zeros), the greater is the sensitivity to quantization error.
The cascade and parallel form system function is consists of second order direct-
form systems. However, in both cases each pair of complex conjugate poles pair is
realized independently of all other poles. Thus, the error in a particular pole pair is
independent of its distance from the other poles of system function.
For the cascade form same arguments holds for the zeros, since they are realized
as independent second order factors. Thus cascade form is generally much less sensitive
to coefficient quantization than the equivalent direct-form realization.
∏+
=−−
−−
−−++
=2/)1(
12
21
1
22
110
1)(
N
k kk
kkk
zazazbzbbzH
The zeros of the parallel form structure are realized implicitly through combining
the quantized second order sections. Thus, particular zero is affected by quantization
error in the numerator and denominator coefficients of all the second order sections.
However for most practical filter the parallel form is also found to be much less sensitive
to coefficient quantization than the equivalent direct-form realization.
∑∑+
=−−
−−
=
−
−−+
+=2/)1(
12
21
1
110
0 1)(
N
k kk
kkNM
k
kk zaza
zeezCzH
In summery, because of the sensitivity to finite word length effect, the direct
forms are rarely used for implementing anything other than second - order structures.
Cascade and parallel structures are more often used.
2.1.1 What we did
Before jumping on to designing of filters and seeing finite word length effect let
us explain what we have did. Here we are not going to explain designing of filters or any
other filter designing fundamentals, one can refer any good book available for same[1][2].
But one should ask how we did quantization, so let us explain how we did quantization
and give some examples which show capability and limitation of our routine.
Our quantization routine is very simple and it basically performs following steps:
1) Take 32 bit floating point number between ranges 0 to 2.
2) Multiply it with 231 – 1 (if your numbers are between 0 to 1 then multiply it with
232 – 1) to get equivalent integer number stores it in 32 bit format
3) Shift above number required number of bits as per requirement to obtain N bits
representation of corresponding number (In a way make zero least significant
32 – N bits. So we have number which is still in 32 bits but least significant bits
removed).
4) Convert above number back into corresponding floating point number.
Quantization routine and examples
Below we have given out C program routine which takes as input floating point
number which we want to quantize and desire bit representation and gives as output
corresponding floating point number in desire bit representation.
float quant(float cof,int n) /*===================================================================== Routine that generates decimal equivalent of the binary representation of a decimal number with p bits for magnitude part obtained by rounding cof – floating point number in IEEE 754 standard ( No between 0 – 1 ) n - Bit representation I want….any number between 0 - 32 =====================================================================*/ unsigned long int icof=0,m; int sign = 1; float fract,quan; if(cof<0) //loop that stores sign of number sign = -1; cof = -1 * cof; //if number is negative make it positive
icof = ceil((pow(2,31) – 1) * cof); // Convert floating point no. // between 0 – 1 into corresponding // 32 bit integer representation // - kind of scaling
// ceil() is a function in C which // rounds of the numbers.
m = 32 - n; // m is the number position by
// which I need shift number to get // n bit representation
icof = icof >> m; icof = icof << m;
fract = (float)icof/(pow(2,31) – 1); // Convert integer number // back into floating point
quan = sign * fract; // put back sign return(quan);
Examples:
Before starting let’s see how much 1 bit represents (Note: below examples are considering numbers between range 0 to 1). :
10-685e431469961870807973752.3283064312
132 =
−
Input floating point number
Number of bit representation
Obtained floating point number
Comment
32 bits -1.0000000000
30 bits -1.0000000000
24 bits -0.9999999404
16 bits -0.9999847412
-0.9999999999
8 bits -0.9960937500
32 bits 0.4919821918 We are not using full dynamic range
30 bits 0.4919821918
24 bits 0.4919821620
16 bits 0.4919738770
0.4919822006
8 bits 0.4882812500
0.0000000001 32 bits 0.0000000002 Here it fails
2.1.2 Designing of Butterworth low pass filter using bilinear transformation
Let us start with fundamental steps needed to design Butterworth low pass filter
using bilinear transformation. Description is very brief just to give basic idea:
1) Determination of the analog filter’s edge frequencies. Use below equation
2tan2 ω
T=Ω
where is Analog frequency, T is sampling time period and Ω ω is digital
frequency.
2) Determination of order of the filter
⎟⎟⎠
⎞⎜⎜⎝
⎛ΩΩ
⎟⎟⎠
⎞⎜⎜⎝
⎛−−
=
1
2
21
22
log
1/11/1
log
21 δ
δ
N
Where N is filter order, 1δ and 2δ is Pass band and Stop band ripple respectively. 1Ω
and are filter edge frequencies. 2Ω
3) Determination of -3 dB cutoff frequency
Nc
21
21
1
11⎥⎦
⎤⎢⎣
⎡−
Ω=Ω
δ
4) The transfer function of Butterworth filter is usually written in the factored as given
below
∏= Ω+Ω+
Ω=
2/
122
2
)(N
k ckck
ck
csbsBsH N = 2, 4, 6, …
Or
∏−
= Ω+Ω+Ω
Ω+Ω
=2/)1(
122
2
0
0)(N
k ckck
ck
c
c
csbsB
csB
sH N = 3, 5, 7, …
Where bk and ck are given by
⎥⎦⎤
⎢⎣⎡ −
=N
kbk 2)12(sin2 π and 1=kc
The parameter Bk can be obtained from
∏=
=2/
1
N
kkBA , for even N
And
∏−
=
=2/)1(
1
N
kkBA , for odd N
5) Determination of H(z)
)1()1(2|)()(
+−
==
zz
Ts
sHzH
Filter parameters:
Pass band ripple: 0.99
Stop band ripple: 0.001
Pass band frequency: 1.2566
Stop band frequency: 1.885
Filter Order: 14 (so total seven 2nd order filters are there)
Cutoff Frequency: 1.672363
Filter coefficient:
Numerator coefficients are BB1-7 = 2ckB Ω
Denominator coefficients are bb1-7 = ckb Ω and cc1-7 = 2ckc Ω
Note: In above table don’t get confused by values of coefficients. It may seem they are going beyond range 0-2 but
actually it’s because of multiplication with cΩ term. See the equation of H(s)
Coefficient
Original Value
Quantized value – 24
bits
Quantized value – 16
bits
Quantized value – 12
bits
Quantized value – 8 bits
Quantized value – 5 bits
BB1-7 2.7967977483 2.7967977483 2.7966968725 2.7951660156 2.7951660156 2.6406250000
bb1 0.3744903875 0.3744902380 0.3744477993 0.3738861084 0.3657226563 0.3046875000
cc1-7 2.7967977483 2.7967977483 2.7966968725 2.7951660156 2.7951660156 2.6406250000
bb2 1.1046926835 1.1046926835 1.1046643881 1.1036987305 1.0971679688 1.0156250000
bb3 1.7795010259 1.7795010259 1.7794563742 1.7788162231 1.7763671875 1.7265625000
bb4 2.3650778886 2.3650778886 2.3649871908 2.3641357422 2.3641357422 2.2343750000
bb5 2.8320599592 2.8320599592 2.8319624346 2.8310852051 2.8212890625 2.7421875000
bb6 3.1570306704 3.1570306704 3.1569567900 3.1559906006 3.1478271484 3.0468750000
bb7 3.3236948360 3.3236948360 3.3235878469 3.3225250244 3.3176269531 3.1484375000
NOTE: In below figures red line is quantized response.
Fig 2.1 Response when coefficient quantized to 32 bits
Fig 2.2 Response when coefficient quantized to 24 bits
Fig 2.3 Response when coefficient quantized to 16 bits
Fig 2.4 Response when coefficient quantized to 12 bits
Fig 2.5 Response when coefficient quantized to 8 bits
Fig 2.6 Response when coefficient quantized to 5 bits
2.1.3 Designing of 4th order low pass filter and to show response of filter while direct
realization and parallel form realization
Direct form realization
0.323z3 + 0.4218z2 + 0.04278
H(z) = -----------------------------------------------------------
z4 – 0.5172z3 + 0.40619z2 – 0.1233z + 0.016533
Parallel form realization
-1.4509z2 + 0.2321z 1.4509z2 + 0.1848z
H(z) = --------------------------- + ----------------------------
z2 – 0.1310z + 0.3006 z2 – 0.3862z + 0.055
Filter Coefficient Direct Form Realization:
Coefficients
Original Value
Quantized value – 24 bits
Quantized value – 12 bits
Quantized value – 8 bits
Quantized value – 6 bits
Quantized value – 4 bits
b0 0.04278 0.0427799225 0.0424804688 0.0390625000 0.0312500000 0.0000000000
b1 0.4218 0.4217998981 0.4213867188 0.4140625000 0.4062500000 0.3750000000
b2 0.323 0.3229999542 0.3227539063 0.3203125000 0.3125000000 0.2500000000
a0 0.016533 0.0165328979 0.0161132813 0.0156250000 0.0000000000 0.0000000000
a1 -0.1233 -0.1232999563 -0.1230468750 -0.1171875000 -0.0937500000 0.0000000000
a2 0.40619 0.4061899185 0.4057617188 0.3984375000 0.3750000000 0.3750000000
a3 0.5172 -0.5171999931 -0.5170898438 -0.5156250000 -0.5000000000 -0.5000000000
a4 1.0 1.0000000000 1.0000000000 1.0000000000 1.0000000000 1.0000000000
Filter Coefficient parallel Form Realization:
Coefficients
Original Value
Quantized value – 24 bits
Quantized value – 12 bits
Quantized value – 8 bits
Quantized value – 6 bits
Quantized value – 4 bits
b10 -0.2321 -0.2320998907 -0.2319335938 -0.2265625000 -0.2187500000 -0.1250000000
b11 -1.4509 -1.4508999586 -1.4506835938 -1.4453125000 -1.4375000000 -1.3750000000
b20 0.1848
0.1847999096
0.1845703125
0.1796875000 0.1562500000 0.1250000000
b21 1.4509 1.4508999586 1.4506835938 1.4453125000 1.4375000000 1.3750000000
a10 0.3006 0.3005999327 0.3002929688 0.2968750000 0.2812500000 0.2500000000
a11 -0.1310 -0.1232999563 -0.1308593750 -0.1250000000 -0.1250000000 -0.1250000000
a12 1.0 1.0000000000 1.0000000000 1.0000000000 1.0000000000 1.0000000000
a20 0.055 0.0549999475 0.0546875000 0.0546875000 0.0312500000 0.0000000000
a21 -0.3862 -0.3861999512 -0.3857421875 -0.3828125000 -0.3750000000 -0.3750000000
a22 1.0 1.0000000000 1.0000000000 1.0000000000 1.0000000000 1.0000000000
Fig 2.7 Response when coefficient quantized to 24 bits (Direct form)
Fig 2.8 Response when coefficient quantized to 24 bits (Parallel form)
Fig 2.9 Response when coefficient quantized to 12 bits (Direct form)
Fig 2.10 Response when coefficient quantized to 12 bits (Parallel form)
Fig 2.11 Response when coefficient quantized to 8 bits (Direct form)
Fig 2.12 Response when coefficient quantized to 8 bits (Parallel form)
Fig 2.13 Response when coefficient quantized to 6 bits (Direct form)
Fig 2.14 Response when coefficient quantized to 6 bits (Parallel form)
Fig 2.15 Response when coefficient quantized to 4 bits (Direct form)
Fig 2.16 Response when coefficient quantized to 4 bits (Parallel form)
2.2 Effects of coefficient quantization in FIR system
For FIR system, we have to concerned with locations of zeros only, since for
causal FIR system all poles are at z = 0. Although we have just seen that direct form
structure should be avoided for high order IIR system, it turns out that direct form
structure is commonly used for FIR systems. To understand why this is so, we express
the system function for a direct form FIR system in the form
∑=
−=M
n
nznhzH0
][)(
Now suppose that the coefficients h[n] are quantized, resulting in a new set of
coefficients ĥ[n] = h[n] + ∆h[n]. The system function for quantized system is then
)()(][)(ˆ0
zHzHznhzHM
n
n ∆+== ∑=
−
Where
nM
nznhzH −
=∑∆=∆
0][)(
Thus, system function of the quantized system is linearly related to the quantization
errors in the impulse response coefficients.
If the zeros of H (z) are tightly clustered, then their locations will be highly
sensitive to quantization errors in the impulse response coefficients. The reason that
direct form FIR system is widely used is that for most linear phase FIR filters, the zeros
are more or less uniformly spread in the z-plane.
Designing of FIR low pass filter using Parks-McClellan design technique
Pass band ripple: 0.99
Stop band ripple: 0.001
Pass band frequency: 1.2566
Stop band frequency: 1.885
Fig 2.17 FIR quantization example (a) Log magnitude for unquantized case;
Approximation error for (b) unquantized case (c) 16 bit quantization [1]
Fig 2.17 (continued) Approximation error for (d) 14 bit quantization (e) 13 bit
quantization (f) 8 bit quantization [1]
CONCLUSION
Finite word length is inherent problem which occur due to finite bit representation
of number in digital representation. Effect of finite word lengths are Overflow in
addition, Limit cycles and Round off noise in multiplication. We have seen effect of
coefficient quantization on filter response. Also we have conclude that coupled form and
parallel form structure of filter realization are more secure against finite word length
effect as compare to direct form realization.
Although due to advanced in technology we have now available machine with 64
bit representation (which is almost infinite precision), but it’s still needs to be consider
due to rise of embedded technology and competitive market which needs low cost
product.
UNIT 5 – MULTIRATE SIGNAL PROCESSING
There is a requirement to process the various signals at different sampling rate e.g.,
Teletype, Facsimile, speech and video, etc., The discrete time systems that process data at more
than one sampling rate are known as multirate systems.
Example:
• High quality data acquisition and storage
• Audio and video signal processing
• Speech processing
• Narrow band filtering for ECG/EEG
• Transmultiplexers
Sampling rate conversion can be done in i) analog domain and ii) digital domain. In analog
domain using DAC the signal is converted into analog and then filtering is applied. Then the analog
signal is converted back to digital using ADC. In digital domain all processing is done with signal in
digital form.
In the first method, the new sampling rate doesn’t have any relationship with old sampling
rate. But major disadvantage is the signal distortion. So the digital domain sampling rate conversion
is preferred even then the new sampling rate depends on the old sampling rate.
The two basic operations in multirate signal processing are decimation and interpolation.
Decimation reduces that sampling rate, whereas interpolation increases the sampling rate.
Down sampling:
The sampling rate of a discrete time signal x(n) an be reduced by a factor M by taking every
Mth value of the signal.
The output signal y(n) is a downsampled signal of the input signal x(n) and can be
represented by
y(n) = x(Mn)
Example:
x(n) = 1, -1, 2, 4, 0, 3, 2, 1, 5, ….
if M = 2
y(n) = 1, 2, 0, 2, 5, ….
↓Mx(n) y(n) = x(Mn)
A downsampler
Up sampling:
The sampling rate of a discrete time signal can be increased by a factor L by placing L
equally spaced zeros between each pair of samples. Mathematically, upsampling is represented by
y(
Example:
x(n) = 1, 2, 4, -2, 3, 2, 1, …..
if L = 2
y(n) = x(n/2) = 1, 0, 2, 0, 4, 0,
In practice, the zero valued samples inserted by upsampler are replaced with appropriate
non-zero values using some type f filtering process. This process is called interpolation
Polyphase structure of Decimator:
The transfer function H(z) of the polyphase FIR filter is decomposed into M branches given
by
∑−
=
−=1
0
)()(M
m
M
m
m zpzzH
Where ∑+
=
−+=m
N
n
n
m zmMnhzp
1
0
)()(
The Z transform of an infinite sequence is given by
∑∞
−∞=
−=n
znhzH )()(
In this case H(z) an be decomposed into M
∑−
=
−=1
0
)(M
m
m
m pzzH
Where ∑∞
−∞=
=r
m rMhzp ()(
∑ ∑−
=
∞
−∞=
−=1
0
)(M
m r
mzzH
The sampling rate of a discrete time signal can be increased by a factor L by placing L
equally spaced zeros between each pair of samples. Mathematically, upsampling is represented by
±±=
=
otherwise
LLnL
nx
n
0
......2,,0)(
2, 3, 2, 1, …..
y(n) = x(n/2) = 1, 0, 2, 0, 4, 0, -2, 0, 3, 0, 2, 0, 1, …..
In practice, the zero valued samples inserted by upsampler are replaced with appropriate
zero values using some type f filtering process. This process is called interpolation
Polyphase structure of Decimator:
The transfer function H(z) of the polyphase FIR filter is decomposed into M branches given
n
The Z transform of an infinite sequence is given by
−n
In this case H(z) an be decomposed into M-branches as
)( Mz
−+ rzmrM )
−+ )( rMm zmrMh
The sampling rate of a discrete time signal can be increased by a factor L by placing L-1
equally spaced zeros between each pair of samples. Mathematically, upsampling is represented by
In practice, the zero valued samples inserted by upsampler are replaced with appropriate
zero values using some type f filtering process. This process is called interpolation.
The transfer function H(z) of the polyphase FIR filter is decomposed into M branches given
∑ ∑−
=
∞
−∞=
+−+=1
0
)()()(
M
m r
mrMzmrMhzH
)()( rpmMnhlet m=+
∑ ∑−
=
∞
−∞=
+−=1
0
)()()(M
m r
mrM
m zrpzH
∑ ∑−
=
∞
−∞=
+−=1
0
)()()()(M
m r
mrM
m zzXrpzY
∑ ∑−
=
∞
−∞=
+−=1
0
)]([)()(M
m r
m mrMnxrpny
)()( mrMxrxlet m +=
∑ ∑−
=
∞
−∞=
−=1
0
)()()(M
m r
mm rnxrpny
∑−
=
=1
0
)(*)()(M
m
mm nxnpny
∑−
=
=1
0
)()(M
m
m nyny
Where )(*)()( nxnpny mmm =
The operation )(*)( nxnp mm is known as polyphase convolution, and the overall process is
polyphase filtering. xm(n) is obtained first delaying x(n) by M units then downsampling by a factor M. Next
ym(n) can be obtained by convolving xm(n) with pm(n).
P0(n)↓M +
Z-1
P1(n)↓M +
Z-1
P2(n)↓M
x(n) y(n)x0(n)
x1(n)
x2(n)
Polyphase structure of a 3 branch decimator
The splitting of x(n) into the low rate sub sequence x0(n),x1(n)……..xM-1(n) is often
represented by a commutator. The input values x(n) enter the delay chain at high rate. Then the M
downsampler sends the group of M input values to M filters at time n=mM.
P0(n)↓M +
Z-1
P1(n)↓M +
Z-1
P2(n)↓M
x(n) y(n)x0(n)
x1(n)
x2(n)
Polyphase structure of a M branch decimator
+
PM-1(n)↓MxM-1(n)
P0(n) +
P1(n) +
P2(n)
x(n)
y(n)x0(n)
x1(n)
x2(n)
Polyphase decimator with a commutator
+
PM-1(n)xM-1(n)
Rate Fy = Fx/M
Rate Fx
m = 0
m = 1
m = 2
m = M-1
To produce the output y(0), the commutator must rotate in counter-clockwise direction
starting from m = M-1…… m=2, m=1, m=0 and give the input values x(-M+1)…..x(-2), x(-1), x(0) to
the filters pM-1(n)…….p2(n),p1(n),p0(n).
Polyphase structure of Interpolator:
By transposing the decimator structure, we can obtain the polyphase structure for
interpolator, which consists of a set of L sub filters connected in parallel.
Here the polyphase components of impulse response are give by
Pm(n) = h(nL+m) m = 0, 1, 2 …… L – 1
Where h(n) is the impulse response of anti-imaging filter. The output of L sub filters can be
represented as
1........2,1,0)()()( −== Lmnpnxny mm
By upsampling with a factor L and adding a delay z-m
the polyphase components are
produced from ym(n). These polyphase components are all added together to produce the output
signal y(n)
P0(n) ↑L +
Z-1
P1(n) ↑L +
Z-1
P2(n) ↑L
x(n) y(n)y0(n)
y1(n)
y2(n)
Polyphase structure of a M branch Interpolator
+
PM-1(n) ↑LyM-1(n)
Z-1
The output y(n) also can be obtained by combining the signals xm(n) using a commutator as
shown below
Multistage implementation of sampling rate conversion:
If the decimation factor M and/or interpolation factor L are much larger than unity, the
implementation of sampling rate conversion in a single stage is computationally inefficient.
Therefore for performing sampling rate conversion for either M>>1 and/or L>>1 the multistage
implementation is preferred.
If the interpolation factor L>>1, then express L into a product of positive integers as
∏=
=N
i
iLL1
Then each interpolator Li is implemented and cascaded to get N stages of interpolation and
filtering.
Similarly if the decimation factor M>>1 then express M into a product of positive integers as
∏=
=N
i
iMM1
Polyphase interpolator with a commutator
P0(n)
P1(n)
P2(n)
y(n)
x(n) y0(n)
y1(n)
y2(n)
PL-1(n)yL-1(n)
m = 0
m = 1
m = 2
m = M-1
↑L1 h1(n) ↑L h2(n) ↑L hN(n)x(n) y(n)
Fx Fy=LFx
L1Fx L1L2Fx
Each decimator Mi is implemented and cascaded to get N stages of filtering and decimators.
Implementation of narrowband LPF:
A narrowband LPF is characterized by a narrow passband and a narrow transition band. It
requires a very large number of coefficients. Due to high value of N it is susceptible to finite word
length effects. In addition the number of computations and memory locations required are very
high. So multirate approach of designing LPF overcomes this problem.
In the above diagram, the interpolator and decimator are in cascade. The filters h1(n) and
h2(n) in the decimator and interpolator are lowpass filters. The sampling frequency of the input
sequence is first reduced by a factor M then lowpass filtering is performed. Finally the original
sampling frequency of the filtered data is obtained using interpolator.
To meet the desired specifications of a narrow band LPF, the filters h1(n) and h2(n) are
identical, with passband ripple δp/2 and stopband ripple δs.
Filter bank:
• Analysis filter bank
• Synthesis filter bank
Analysis filter bank:
h1(n) ↓M1 h2(n) ↓M2 hN(n) ↓MN
x(n) y(n)
Fx Fy=Fx/M
Fx/M1Fx/M1M2
LPF
h1(n)↓M ↑M
LPF
h2(n)
x(n) y(n)
F F
F/M
X(z)H0(z) ↓M
H1(z) ↓M
H2(z) ↓M
HM-1(z) ↓M
U0(z)
U1(z)
U2(z)
UM-1(z)
• It consists of M sub-filters. The individual sub-filter Hk(z) is known as analysis bank.
• All the sub-filters are equally spaced in frequency and each have the same band width.
• The spectrum of the input signal X(ejω
) lies in the range 0 ≤ ω ≤ π.
• The filter bank splits the signal into number of subbands each having a band width of
π/M.
• The filter H0(z) is lowpass, H1(z) to HM-2(z) are bandpass and HM-1(z) is highpass.
• As the spectrum of signal is band limited to π/M, the sampling rate can be reduced by a
factor M. The downsampling moves all the subband signals into the baseband range 0 ≤
ω ≤ π/2.
Analysis filter bank:
The M channel synthesis filter bank is dual of M channel analysis filter bank. In this case
Um(z) is fed to an upsampler. The upsampling process produces the signal Um(zM
). These signals are
applied to filters Gm(z) and finally added to get the output signal )(zX∧
. The filters G0(z) to
GM-1(z) have the same characteristics as the analysis filters H0(z) to HM-1(z).
Subband coding filter bank:
If we combine the analysis filter band and synthesis filter band we obtain an M-channel
subband coding filter bank.
G0(z)↑M
G1(z)↑ M
G2(z)↑ M
GM-1(z)↑ M
U0(z)
U1(z)
U2(z)
UM-1(z)
+
+
+
)(zX∧
The analysis filter band splits the broadband input signal x(n) into M non-overlapping
frequency band signals X0(z), X1(z)……XM-1(z) of equal bandwidth. These outputs are coded and
transmitted. The synthesis filter bank is used to reconstruct output signal )(zX∧
which should
approximate the original signal. It has application in speech signal processing.
Quadrature Mirror Filter (QMF) Bank:
It is a two-channel subband coding filter bank with complementary frequency responses. It
consists of two sections
1. Analysis section
2. Synthesis section
X(z)H0(z) ↓M
H1(z) ↓M
H2(z) ↓M
HM-1(z) ↓M
G0(z)↑M
G1(z)↑M
G2(z)↑M
GM-1(z)↑M
+
+
+
)(zX∧
X(z)
H0(z) ↓2
H1(z) ↓2
G0(z)↑2
G1(z)↑ 2
+Y(z)
V0(z)
V1(z)
U0(z)
U1(z)
)(0 zV∧
)(1 zV∧
Analysis Section:
• The analysis section is a two channel analysis filter bank
• The signal x(n) is fed to a LPF H0(z) and a HPF H1(z) simultaneously. Hence the input signal
x(n) is decomposed into high frequency component and low frequency component
• Since the normalized frequency range is ω = 0 and ω = π, the cut off frequency of HPF and
LPF are chosen as π/2.
The output of low pass and high pass filters are
)()()(
)()()(
11
00
zHZXzV
andzHZXzV
=
= ……………1
Down sampling with M = 2, yields the subband signals
)()([2
1)(
)()([2
1)(
2
1
12
1
11
2
1
02
1
00
zVzVzU
andzVzVzU
−+=
−+=…………….2
Substitute equation 1 in equation 2
)()()()([2
1)(1
)()()()([2
1)(
2
1
12
1
2
1
12
1
2
1
02
1
2
1
02
1
0
zHzXzHzXzU
andzHzXzHzXzU
−−+=
−−+=
In matrix form
−
−
−=
)(
)(
)()(
)()(
2
1
)(1
)(
2
1
2
1
2
1
12
1
1
2
1
02
1
00
zX
zX
zHzH
zHzH
zU
zU……………….3
|H0(ejω)| |H1(e
jω)|1.0
0 π/2 π ω
Frequency response characteristics of signals
Lowpass Highpass
H0(z) H1(z)
π/2 πω
V0(z)
π/2 πω
U0(z)
π/2 πω
V1(z)
π/2 πω
U1(z)
π/2 πω
x(n) is a white noise input signal. The frequency spectra of V0(z) have two components one
is the original spectrum that depends on X(z1/2
) lies in the baseband and the other is periodic
repetition that is function of X(z-1/2
). The high pass signal U1(z) drops into the baseband 0 ≤ ω ≤ π
and is reversed in frequency. Since the filtered signals are not properly band limited to π, alias
signals appear in baseband.
Synthesis section:
The signals U0(z) and U1(z) are fed to the synthesis filter bank. Here the signals U0(z) and
U1(z) are upsampled and then passed through two filters G0(z) and G1(z) respectively. The filter
G0(z) is a lowpass filter and eliminates the image spectrum of U0(z) in the range π/2 ≤ ω ≤ π.
Meanwhile the highpass filter G1(z) eliminates most of the image spectra in the range 0 ≤ ω ≤ π/2.
As the frequency range of the two signals U0(z) and U1(z) overlap, the image spectra is not
completely eliminated.
The reconstructed output of the filter bank is
)()()()()( 1100 zVzGzVzGzY∧∧
+=
)()()()()( 2
11
2
00 zUzGzUzGzY += ……………….4
Where
)()(
)()(
2
11
2
00
zUzV
zUzV
=
=∧
∧
Equation 4 can be written in matrix form as
[ ]
=
)(
)()()()(
2
1
2
010
zU
zUzGzGzY
From equation 3
−
−
−=
)(
)(
)()(
)()(
2
1
)(1
)(
11
00
2
2
0
zX
zX
zHzH
zHzH
zU
zU
[ ]
−
−
−=
)(
)(
)()(
)()(
2
1)()()(
11
00
10zX
zX
zHzH
zHzHzGzGzY
)()]()()()([2
1)()]()()()([
2
1)( 11001100 zXzHzGzHzGzXzHzGzHzGzY −−+−++=
)()()()()( zXzAzXzTzY −+= …………5
Where
)]()()()([2
1)( 1100 zHzGzHzGzT +=
)]()()()([2
1)( 1100 zHzGzHzGzA −+−=
The function T(z) describes the transfer function of the filter and is called distortion transfer
function. The function A(z) is due to aliasing components.
Alias free filter bank:
To obtain an alias free filter bank, we can choose the synthesis filter such that A(z) = 0.
i.e., 0)]()()()([2
1)( 1100 =−+−= zHzGzHzGzA
0)()()()( 1100 =−+− zHzGzHzG
A simple sufficient condition for alias cancellation is
andzHzG )()( 10 −=
)()( 01 zHzG −−=
Then equation 5 becomes
)()()( zXzTzY =
Substituting ωjez = yields
)(|)(|
)()()(
)( ωωθω
ωωω
jjj
jjj
eXeeT
eXeTeY
=
=
If |)(| ωjeT is constant for all ‘ω’, there is no amplitude distortion. This condition is satisfied when
)( ωjeT is an all pass filter. In same way, if )( ωjeT have linear phase there is no phase distortion. This
condition is satisfied when βαωωθ +=)( for constant α and β. Therefore )( ωjeT need to be a linear
phase all pass filter to avoid any magnitude or phase distortion.
If an alias free QMF bank has no amplitude and phase distortion then it is called a perfect
reconstruction (PR) QMF bank. In such a case
)()( zXkzzY l−= and the output y(n) = kx(n-l).
i.e., the reconstructed output of a PRQMF bank is a scaled, delayed replica of the output.