You are on page 1of 89

Unit III

FIR Filter Design


Syllabus

Structures of FIR – Linear phase FIR filter –


Fourier Series - Filter design using windowing
techniques (Rectangular Window, Hamming
Window, Hanning Window), Frequency sampling
techniques – Finite word length effects in digital
Filters: Errors, Limit Cycle, Noise Power Spectrum.
Ideal Filters
One of the reasons why we design a filter is to remove disturbances
SIGNAL s(n) x(n) y ( n )  s ( n)
 Filter

v(n)
NOISE

We discriminate between signal and noise in terms of the frequency


spectrum
Y (F )
S (F )
V (F )

 F0 F0 F
F0  F0 F0 F
Conditions for Non-Distortion
Problem: ideally we do not want the filter to distort the signal we want
to recover.
x(t )  s (t ) y (t )  As(t  T ) Same shape as s(t),
IDEAL just scaled and
2 FILTER 2 delayed.
1.5
1.5

1 1

0.5 0.5

0 0

-0.5 -0.5

-1 -1

-1.5 -1.5

-2 -2
0 200 400 600 800 1000 0 200 400 600 800 1000

Consequence on the Frequency Response:

constant | H (F ) |
 Ae  j 2FT if F is in the passband
H (F )  
F 0 otherwise
linear
 H (F )

F
For real time implementation we also want the filter to be causal, ie.

h ( n)

 
h(n)  0 for n  0
 
  since
  
  n 
y (n)   h(k )x(n k )
k 0
past values only

FACT (Bad News!): by the Paley-Wiener Theorem, if h(n) is causal and with finite
energy,


 ln H ( ) d   

ie H ( ) cannot be zero on an interval, therefore it cannot be ideal.

2

1  2
log H ( )  log(0)     log H ( ) d  
1
Characteristics of Non Ideal Digital Filters
| H ( ) | IDEAL

p  Positive freq. only

NON IDEAL
Two Classes of Digital Filters:
a) Finite Impulse Response (FIR), non recursive, of the form

y (n)  h(0) x(n)  h(1) x(n  1)  ...  h( N ) x(n  N )

With N being the order of the filter.


Advantages: always stable, the phase can be made exactly linear, we can
approximate any filter we want;
Disadvantages: we need a lot of coefficients (N large) for good performance;

b) Infinite Impulse Response (IIR), recursive, of the form

y (n)  a1 y (n  1)  ...  a N y (n  N )  b0 x(n)  b1 x(n  1)  ...  bN x(n  N )

Advantages: very selective with a few coefficients;


Disadvantages: non necessarily stable, non linear phase.
Digital Filter Structures
• The convolution sum description of an LTI
discrete-time system be used , can in principle,
to implement the system
• For an IIR finite-dimensional system this
approach is not practical as here the impulse
response is of infinite length
• However, a direct implementation of the IIR
finite-dimensional system is practical
Digital Filter Structures
• Here the input-output relation involves a finite
sum of products:
y[n]  kN1 d k y[n  k ]  kM0 pk x[ n  k ]

• On the other hand, an FIR system can be


implemented using the convolution sum
which is a finite sum of products:
y[n]  kN0 h[k ] x[n  k ]
Digital Filter Structures
• The actual implementation of an LTI digital
filter can be either in software or hardware
form, depending on applications.

• In either case, the signal variables and the


filter coefficients cannot represented with
finite precision
Block Diagram Representation
• In the time domain, the input-output relations
of an LTI digital filter is given by the
convolution sum

y[n]  k   h[k ] x[n  k ]
or, by the linear constant coefficient difference
equation
N M
y[n]  k 1 d k y[n  k ]  k 0 pk x[n  k ]
Block Diagram Representation
• For the implementation of an LTI digital
filter, the input-output relationship must be
described by a valid computational
algorithm
• To illustrate what we mean by a
computational algorithm, consider the
causal first-order LTI digital filter shown
below
Block Diagram Representation
• The filter is described by the difference
equation
y[n]   d1 y[ n  1]  p0 x[n]  p1x[n  1]
• Using the above equation we can compute
y[n] for n  0 knowing the initial condition
y[1]and the input x[n] for n  1:
Block Diagram Representation

y[0]   d1 y[ 1]  p0 x[0]  p1x[1]


y[1]   d1 y[0]  .p0 x[1]  p1x[0]
..
y[ 2] .  d1 y[1]  p0 x[ 2]  p1x[1]
..
• We can continue this calculation for any value
of the time index n we desire
Basic Building Blocks
• The computational algorithm of an LTI
digital filter can be conveniently
represented in block diagram form using
the basic building blocks shown below
A
x[n]  y[n]
x[n] y[n]

w[n]
Multiplier
Adder
x[n] x[n]

x[n] z 1 y[n]
x[n]

Unit delay Pick-off node


Basic Building Blocks
Advantages of block diagram representation
(1) Easy to write down the computational
algorithm by inspection
(2) Easy to analyze the block diagram to
determine the explicit relation between the
output and input
Basic Building Blocks
(3) Easy to manipulate a block diagram to derive
other “equivalent” block diagrams yielding
different computational algorithms
(4) Easy to determine the hardware
requirements
(5) Easier to develop block diagram
representations from the transfer function
directly
Analysis of Block Diagrams

• Example - Consider the single-loop feedback


structure shown below

• The output E(z) of the adder is


E ( z )  X ( z )  G2 ( z )Y ( z )
• But from the figure
Y ( z )  G1 ( z ) E ( z )
Analysis of Block Diagrams
• Eliminating E(z) from the previous two
equations we arrive at
[1  G1 ( z )G2 ( z )]Y ( z )  G1 ( z ) X ( z )
which leads to
Y ( z) G1 ( z )
H ( z)  
X ( z ) 1  G1 ( z )G2 ( z )
Analysis of Block Diagrams
• Example - Analyze the cascaded lattice
structure shown below where the z-
dependence of signal variables are not shown
for brevity
Analysis of Block Diagrams
• The output signals of the four adders are given
by W  X S
1 2
W2  W1   S1
W3  S1  W2
Y  W1   S2
• From the figure we observe
S2  z 1W3
S1  z 1W2
Analysis of Block Diagrams
• Substituting the last two relations in the
first four equations we get
W1  X   z 1W3
W2  W1   z 1W2
W3  z 1W2  W2
Y   W1   z 1W3
• From the second equation we get and from
the third equation we get
W2  W1 /(1  z 1 )
W3  (  z 1 )W2
Analysis of Block Diagrams
• Combining the last two equations we get
  z 1
W3  1 W3
1 z
• Substituting the above equation in
W1  X   z 1W3 , Y  W1   z 1W3
we finally arrive at

Y   (  ) z 1  z  2
H ( z)  
X 1  (  ) z 1  z  2
The Delay-Free Loop Problem
• Analysis of this structure yields
u[n]  w[n]  y[n]
y[n]  B (v[n]  Au[n])
which when combined results in
y[n]  B v[n]  A( w[n]  y[n]) 
• The determination of the current value
of y[n] requires the knowledge of the same
value
Canonic and Noncanonic Structures

• A digital filter structure is said to be canonic


if the number of delays in the block
diagram representation is equal to the
order of the transfer function
• Otherwise, it is a noncanonic structure
Canonic and Noncanonic Structures

• The structure shown below is noncanonic as it


employs two delays to realize a first-order
difference equation

y[n]   d1 y[n  1]  p0 x[n]  p1x[n  1]


Equivalent Structures
• Two digital filter structures are defined to be
equivalent if they have the same transfer
function
• We describe next a number of methods for
the generation of equivalent structures
• However, a fairly simple way to generate an
equivalent structure from a given realization is
via the transpose operation
Equivalent Structures
Transpose Operation
(1) Reverse all paths
(2) Replace pick-off nodes by adders, and vice
versa
(3) Interchange the input and output nodes
– All other methods for developing equivalent
structures are based on a specific algorithm for
each structure
Basic FIR Digital Filter Structures

• A causal FIR filter of order N is characterized


by a transfer function H(z) given by
N n
H ( z )  n 0 h[n]z
which is a polynomial in z 1
• In the time-domain the input-output relation
of the above FIR filter is given by
N
y[n]  k 0 h[k ]x[n  k ]
Direct Form FIR Digital Filter Structures

• An FIR filter of order N is characterized by


N+1 coefficients and, in general, require N+1
multipliers and N two-input adders
• Structures in which the multiplier coefficients
are precisely the coefficients of the transfer
function are called direct form structures
Direct Form FIR Digital Filter Structures

• A direct form realization of an FIR filter can be


readily developed from the convolution sum
description as indicated below for N = 4
Direct Form FIR Digital Filter Structures

• An analysis of this structure yields


y[n]  h[0]x[n]  h[1]x[n  1]  h[2]x[n  2]
 h[3]x[n  3]  h[4]x[n  4]
which is precisely of the form of the
convolution sum description
• The direct form structure shown on the
previous slide is also known as a tapped delay
line or a transversal filter
Direct Form FIR Digital Filter Structures

• The transpose of the direct form structure


shown earlier is indicated below

• Both direct form structures are canonic with


respect to delays
Cascade Form FIR Digital Filter
Structures
• A higher-order FIR transfer function can also
be realized as a cascade of second-order FIR
sections and possibly a first-order section
• To this end we express H(z) as
H ( z )  h[0]k 1(1  1k z 1   2 k z  2 )
K
where N if N is even, and N 1 if N is
K K
odd, with 2 2
2K  0
Cascade Form FIR Digital Filter
Structures
• A cascade realization for N = 6 is shown below

• Each second-order section in the above


structure can also be realized in the
transposed direct form
Polyphase FIR Structures
• The polyphase decomposition of H(z) leads to
a parallel form structure
• To illustrate this approach, consider a causal
FIR transfer function H(z) with N = 8:

H ( z )  h[0]  h[1]z 1  h[2]z  2  h[3]z 3  h[4]z  4


 h[5]z 5  h[6]z 6  h[7]z 7  h[8]z 8
Polyphase FIR Structures

• H(z) can be expressed as a sum of two


terms, with one term containing the even-
indexed coefficients and the other
containing the odd-indexed coefficients:
2 4 6 8
H ( z )  (h[0]  h[2]z  h[4]z  h[6]z  h[8]z )
 (h[1]z 1  h[3]z 3  h[5]z 5  h[7]z 7 )
2 4 6 8
 (h[0]  h[2]z  h[4]z  h[6]z  h[8]z )
 z 1(h[1]  h[3]z  2  h[5]z 4  h[7]z 6 )
Polyphase FIR Structures
• By using the notation
1 2 3 4
E0 ( z )  h[0]  h[2]z  h[4]z  h[6]z  h[8]z
1 2 3
E1( z )  h[1]  h[3]z  h[5]z  h[7]z
we can express H(z) as

H ( z )  E0 ( z 2 )  z 1E1( z 2 )
Polyphase FIR Structures
• In a similar manner, by grouping the terms in
the original expression for H(z), we can
reexpress it in the form
3 1 3 2 3
H ( z )  E0 ( z )  z E1( z )  z E2 ( z )
where now
1 2
E0 ( z )  h[0]  h[3]z  h[6]z
1 2
E1( z )  h[1]  h[4]z  h[7]z
E2 ( z )  h[2]  h[5]z 1  h[8]z  2
Polyphase FIR Structures
• The decomposition of H(z) in the form
2 1 2
H ( z )  E0 ( z )  z E1( z )
or
H ( z )  E0 ( z 3 )  z 1E1( z 3 )  z  2 E2 ( z 3 )
is more commonly known as the polyphase
decomposition
Polyphase FIR Structures
• In the general case, an L-branch polyphase
decomposition of an FIR transfer function of
order N is of the form
L 1  m L
H ( z )  m 0 z Em ( z )
where
( N 1) / L
m
Em ( z )   h[ Ln  m]z
n 0
with h[n]=0 for n > N
Polyphase FIR Structures
• Figures below show the 4-branch, 3-branch,
and 2-branch polyphase realization of a
transfer function H(z)

• Note: The expression


Em (z ) for the polyphase
components are different in each case
Polyphase FIR Structures
• The subfilters Em ( z L ) in the polyphase
realization of an FIR transfer function are also
FIR filters and can be realized using any
methods described so far
• However, to obtain a canonic realization of the
overall structure, the delays in all subfilters
must be shared
Polyphase FIR Structures
• Figure below shows a canonic realization of
a length-9 FIR transfer function obtained
using delay sharing
Linear-Phase FIR Structures
• The symmetry (or antisymmetry) property of
a linear-phase FIR filter can be exploited to
reduce the number of multipliers into almost
half of that in the direct form
implementations
• Consider a length-7 Type 1 FIR transfer
function with a symmetric impulse response:
1 2 3
H ( z )  h[0]  h[1]z  h[2]z  h[3]z
4 5 6
 h[2]z  h[1]z  h[0]z
Linear-Phase FIR Structures

• Rewriting H(z) in the form


6 1 5
H ( z )  h[0](1  z )  h[1]( z  z )
2 4 3
 h[2]( z  z )  h[3]z
we obtain the realization shown below
Linear-Phase FIR Structures
• A similar decomposition can be applied to a
Type 2 FIR transfer function
• For example, a length-8 Type 2 FIR transfer
function can be expressed as
7 1 6
H ( z )  h[0](1  z )  h[1]( z  z )
2 5 3 4
 h[2]( z  z )  h[3]( z  z )
• The corresponding realization is shown on the
next slide
Linear-Phase FIR Structures

• Note: The Type 1 linear-phase structure for a


length-7 FIR filter requires 4 multipliers,
whereas a direct form realization requires 7
multipliers
Linear-Phase FIR Structures
• Note: The Type 2 linear-phase structure for a
length-8 FIR filter requires 4 multipliers,
whereas a direct form realization requires 8
multipliers
• Similar savings occurs in the realization of
Type 3 and Type 4 linear-phase FIR filters with
antisymmetric impulse responses
FIR Cascaded Lattice Structures

50
FIR Cascaded Lattice Structures

51
FIR Cascaded Lattice Structures

52
FIR Cascaded Lattice Structures

53
FIR Cascaded Lattice Structures

54
FIR Cascaded Lattice Structures

55
FIR Cascaded Lattice Structures

56
FIR Cascaded Lattice Structures

57
FIR Cascaded Lattice Structures

58
FIR Cascaded Lattice Structures

59
FIR Cascaded Lattice Structures

60
FIR Cascaded Lattice Structures

61
FIR Cascaded Lattice Structures

62
Filter Specification
|H(f)| pass-band stop-band

f c : cut-off frequency f s /2 f(norm)


(a)

|H(f)| pass-band transition band stop-band |H(f)|


(dB) (linear)
p 1   p

0 1
1   p

pass-band
-3
ripple

stop-band
ripple
s  s

f s /2 f(norm)
f sb : stop-band frequency
f c : cut-off frequency
f pb : pass-band frequency
(b)
Filter Design by Windowing
• Simplest way of designing FIR filters
• Method is all discrete-time no continuous-time involved
• Start with ideal frequency response
Hd  e    hd ne
 
j  jn
hd n 
1

2  
Hd  e j
 e jn
d
n  

• Choose ideal frequency response as desired response


• Most ideal impulse responses are of infinite length
h n FIR
• The easiest way to obtain a causal 0 filter
nM from ideal is
hn   d
 0 else

• More generally 1 0  n  M
hn  hd nwn where wn  
0 else
Windowing in Frequency Domain
• Windowed frequency response

He j

1

2  
Hd e  
j
W e 
j    
d

• The windowed version is smeared version of desired response

• If w[n]=1 for all n, then W(ej) is pulse train with 2 period


Properties of Windows
• Prefer windows that concentrate around DC in frequency
– Less smearing, closer approximation
• Prefer window that has minimal span in time
– Less coefficient in designed filter, computationally efficient
• So we want concentration in time and in frequency
– Contradictory requirements
• Example: Rectangular window
1  e  j  M  1   jM / 2 sin  M  1 / 2
   e
M
j  j n
We   e
n0 1  e  j sin  / 2
Rectangular Window
• Narrowest main lob
– 4/(M+1)
– Sharpest transitions
at discontinuities in
frequency
• Large side lobs
– -13 dB
– Large oscillation
around
discontinuities
• Simplest window
possible1 0  n  ( M  1)
w n  
0 else
Bartlett (Triangular) Window
• Medium main lob
– 8/M
• Side lobs
– -25 dB
• Hamming window
performs better
• Simple equation
 2n / M 0 n  M /2

w n  2  2n / M M /2 n  M
 0 else

Hanning Window
• Medium main lob
– 8/M
• Side lobs
– -31 dB
• Hamming window
performs better
• Same complexity
as Hamming
1   2n 
 1  cos  0  n  ( M  1)
w n   2   M  1 
 0 else
Hamming Window
• Medium main lob
– 8/M

• Good side lobs


– -41 dB

• Simpler than
Blackman
  2n 
0.54  0.46 cos  0  n  ( M  1)
w n    M 1

 0 else
Blackman Window
• Large main lob
– 12/M
• Very good side lobs
– -57 dB
• Complex equation
  2n   4n 
0.42  0.5 cos   0.08 cos  0  n  ( M  1)
w n    M 1  M 1

 0 else
Incorporation of Generalized Linear Phase
• Windows are designed with linear phase in mind
– Symmetric around M/2
wM  n 0  n  M
wn  
 0 else

• So their Fourier transform are of the form


   
W e j  We e j e  jM / 2  
where We e j is a real and even

• Will keep symmetry properties of the desired impulse response


• Assume symmetric desired response j
Hd e    H  e e
j
e
 j M / 2

• With symmetric window 


Ae e j

1

2  
He e   
j
W e 
j    
d

– Periodic convolution of real functions


Linear-Phase Lowpass filter
• Desired frequency
response
e  jM / 2
 
H e   
lp
j c

0
    c

• Corresponding
impulse response
sin c n  M / 2 
hlp n 
n  M / 2
• Desired response is
even symmetric, use
symmetric window
sin c n  M / 2 
hn  wn
n  M / 2
Window Method
• First stage of this method is to calculate the
coefficients of the ideal filter.
• This is calculated as follows:


1
hd  n    H   e j n
d
2 
c
1

j n
 1  e d
2  c

 2 f c sin  n c 
 for n  0
 n c
 2 fc for n  0
Window Method
• Second stage of this method is to select a window function
based on the passband or attenuation specifications, then
determine the filter length based on the required width of
the transition band.
Normalised Transition Stopband Attenuation
Window Type Passband Ripple(dB)
Width (f(Hz)) (dB)

0 .9
Rectangular 0.7416 21
N

3.1
Hanning 0.0546 44
N

3.3
Hamming 0.0194 53
N

5.5
Blackman 0.0017 74
N
2.93
   4.54
N 0.0274 50
Kaiser 5.71
   8.96
N 0.000275 90

Using the Hamming 3.3 3.3


N   8kHz  132
f 1.2  1.4  kHz
Window:
Window Method
• The third stage is to calculate the set of truncated or
windowed impulse response coefficients, h[n]:

N 1 N 1
 n for N  odd
h n   hd  n   W  n  for
2 2
N N for N  even
 n
2 2

 2n 
Where: W  n   0.54  0.46 cos 
 N 
for 66  n  66
 2n 
 0.54  0.46 cos 
 133 
Frequency sampling Method

The desired frequency response


M 1
Hd  e j
   d ,n
h e  j n
(11.23.1)
DTFT
n 0

can be specified by its frequency samples at equally spaced


(discrete) frequencies: 2
k   k   (11.23.2)
M
Where  M 1
 0,1,... ,M odd
2
k  (11.23.3)
 = 0:  = 0.5: 0,1,... M  2 ,M even
 2
2
2

0nooffset
/M
/M

/ M

  (11.23.4)
0.5offsetby M
 

Finite Wordlength Effects


• Quantization
eo (k ) Output

Q
ei (k )
Input

Q Q
  ei ,o (k ) 
2 2
Finite Word length Effects
• The pdf for e using rounding
1
Q

Q Q

2 2

Q 2
• Noise power 2 2 2
   e p (e).de  E{e }
or Q 2
2
2 Q
 
12
Limit-cycles; "Effective Pole"
Model; Deadband

• Observe that for H ( z )  1


(1  b1 z 1  b2 z  2 )
• instability occurs when b2  1
• i.e. poles are
• (i) either on unit circle when complex
• (ii) or one real pole is outside unit
circle.
• Instability under the "effective pole" model
is considered as follows
 

Finite Word length Effects


• In the time domain with H ( z )  Y ( z )
X ( z)

y (n)  x(n)  b1 y (n  1)  b2 y (n  2)

• With b2 for
1 instability we have
Q b2 y (n  2)indistinguishable
 from y (n  2)
• Where Q  is quantisation
 

Finite Word length Effects


• With rounding, therefore we have
b2 y (n  2)  0.5 y ( n  2)
are indistinguishable (for integers)
or b2 y (n  2)  0.5  y (n  2)
• Hence  0.5
y ( n  2) 
1  b2
• With both positive and negative numbers
 0.5
y ( n  2) 
1  b2
 

Finite Word length Effects


 0.5
• The range of integers
1  b2

constitutes a set of integers that cannot be


individually distinguished as separate or from the
asymptotic system behaviour.
• The band of integers  0.5 0.5 
  ,  
 1  b2 1  b2 
is known as the "deadband".
• In the second order system, under rounding, the
output assumes a cyclic set of values of the
deadband. This is a limit-cycle.

You might also like