Download as pdf or txt
Download as pdf or txt
You are on page 1of 28

Digital Signal Processing

Implementation of
Discrete-Time Systems
Overview
• Introduction
• Structures of FIR Filters
• Structures of IIR Filters
• Comparison Between FIR and IIR Filters
Introduction
• For a given LSI system with a rational system function like
𝑏0 + 𝑏1 𝑧 −1
𝐻 𝑧 =
1 + 𝑎1 𝑧 −1
the input and output are related by the linear constant
coefficient difference equation (LCCDE)
*𝑦 𝑛 = −𝑎1 𝑦 𝑛 − 1 + 𝑏0 𝑥 𝑛 + 𝑏1 𝑥(𝑛 − 1)
• This system can be directly implemented as follows

𝑏0
𝑥(𝑛) + 𝑦(𝑛)

z-1 z-1
𝑏1 −𝑎1

*first-order difference equation


Introduction
• However, note that this system may also be implemented with
the following pair of coupled difference equations:
𝑤 𝑛 = −𝑎1 𝑤 𝑛 − 1 + 𝑥 𝑛
𝑦 𝑛 = 𝑏0 𝑤 𝑛 + 𝑏1 𝑤(𝑛 − 1)

𝑤(𝑛) 𝑏0
𝑥(𝑛) + + 𝑦(𝑛)

z-1
−𝑎1 𝑏1

A digital filter structure is said to be canonic if the number of delays in the block
diagram representation is equal to the order , Otherwise, it is a noncanonic structure
Introduction
• This second implementation requires only one memory location
to store 𝑤(𝑛 − 1), whereas the first implementation requires
two memory locations, one to store 𝑥(𝑛 − 1) and one to store
𝑦(𝑛 − 1).
• The previous example illustrates that there is more than one
way to implement a system and that the amount of
computation and/or memory required depends on the
implementation.
• In addition, the implementation may affect the sensitivity of the
filter to coefficient quantization and the amount of round-off
noise that appears at the output of the filter.
Structures of FIR Filters
• Finite Impulse Response (FIR) filters (also known as
nonrecursive filters) have a system function of the form:
𝑀

𝐻(𝑧) = 𝑏0 + 𝑏1 𝑧 −1 + ⋯ + 𝑏𝑀 𝑧 𝑀 = ෍ 𝑏𝑛 𝑧 −𝑛
𝑛=0
• Hence the impulse response has finite-duration and is given by
𝑏𝑛 0≤𝑛≤𝑀
ℎ(𝑛) = ቊ
0 elsewhere

• The difference equation representation is (all X(n))

𝑦(𝑛) = 𝑏0 𝑥(𝑛) + 𝑏1 𝑥(𝑛 − 1) + ⋯ + 𝑏𝑀 𝑥(𝑛 − 𝑀)

• Filter order is 𝑀, while filter length is 𝑀 + 1 samples.

H(z) for FIR with M = 2 ???


Structures of FIR Filters
FIR filters can have one of the following four structures:

• Direct form: In this form the difference equation is


implemented directly as given in the previous equation.

• Cascade form: In this form the system function 𝐻 𝑧 is factored


into second-order factors, which are then implemented in a
cascade connection.

• Linear-phase form: When an FIR filter has a linear phase


response, its impulse response exhibits certain symmetry
conditions. In this form we exploit these symmetry relations to
reduce multiplications by about half.
Structures of FIR Filters
Direct Form

• In this form, the difference equation of the FIR filter is


implemented as a tapped delay line since there are no
feedback paths.
• Note that this structure requires 𝑀 + 1 multiplications, 𝑀
additions, and 𝑀 delays. However, if there are some symmetries
in the unit sample response, it may be possible to reduce the
number of multiplications.
Signal flow graph
x(n-0), x(n-1) x(n-2), x(n-3), x(n-4)

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] Note: h(0)= b0, h(1)=……..
Direct Form

• Direct form derived from the difference equation

𝑦(𝑛) = 𝑏0 𝑥(𝑛) + 𝑏1 𝑥(𝑛 − 1) + 𝑏2 𝑥(𝑛 − 2) + 𝑏3 𝑥(𝑛 − 3) + 𝑏4 𝑥(𝑛 − 4)

Block diagram
Structures of FIR Filters
Cascade Form
• The system function of an FIR filter can be expressed as a
product of second-order sections (sos) called biquads:
H ( z ) = b0 + b1 z −1 + + bM z − M
 b1 −1 bM − M 
= b0 1 + z + + z 
 b0 b0 
K
= b0  (1 + Bk1 z −1 + Bk 2 z −2 ); K =  M / 2 
k =1

Signal flow graph

Each factor is a Direct Form. M=6, K=3


Cascade Form

Cascade form derived from the system function H(z)


H(z)=G H1(z) H2(z) H3(z) H4(z)

Each of these second-order systems can be realized using the direct-form structure,
example H1(z)=(1−2.5321 z-1 + z-2)
Structures of FIR Filters **
Linear-phase FIR Filters

FIR filters can have an exact linear-phase response (i.e., phase


response is a linear function of frequency ω).

The structure of this type of filters is called linear-phase form.


Linear-phase filters are desirable in many applications to minimize
distortion.
FIR systems with impulse responses satisfying the condition
ℎ 𝑛 = ±ℎ 𝑀 − 𝑛 , 0≤𝑛≤𝑀
have linear-phase response, where
• the plus sign implies a symmetric response and
• the negative sign implies an anti-symmetric response.
Structures of FIR Filters
Linear-phase FIR Filters

Using these conditions on the impulse response, it is possible to obtain


direct form structures that reduce the number of multiplications by
almost half. There are four such possible (but similar) structures:

Length
Type Sequence, 𝒉(𝒏)
(𝑴 + 𝟏)

Type 1 symmetric odd

Type 2 symmetric even

Type 3 anti-symmetric odd

Type 4 anti-symmetric even


Structures of FIR Filters
Linear-phase FIR Filters

• Type 1: Odd • Type 2: Even


symmetric symmetric
• Length = 7 • Length = 6
• Order = 6 • Order = 5

• Type 3: Odd • Type 4: Even


antisymmetric antisymmetric
• Length = 7 • Length = 6
• Order = 6 • Order = 5
Structures of FIR Filters
Linear-phase Form

• Type 1: odd-symmetric
• Length (M +1) = 7
• requires 4 multipliers, whereas a
direct form requires 7 multipliers
• See next slide

• Type 2: even-symmetric
• Length (M +1) = 8
• requires 4 multipliers, whereas a
direct form requires 8 multipliers

Similar savings occurs in the


realization of Type 3 and Type 4
Structures of FIR Filters
• 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
• Example 1: Consider a length-7 Type 1 FIR
transfer function with a symmetric impulse
response:
H ( z ) = h[0] + h[1]z −1 + h[2]z − 2 + h[3]z −3

+ h[2]z − 4 + h[1]z −5 + h[0]z −6


Structures of FIR Filters

• 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
• Example 2: 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
• Note: The Type 1 linear-phase structure for a
length-7 FIR filter requires 4 multipliers, whereas
a direct form realization requires 7 multipliers

• The Type 2 linear-phase structure for a length-8


FIR filter requires 4 multipliers, whereas a direct
form realization requires 8 multipliers
Structures of IIR Filters
• Infinite Impulse Response (IIR) filters (also known as recursive
filters) are characterized by infinite-duration impulse response.
• The system function of an IIR filter is given by
M

B( z )  n
b z −n
b0 + b1 z −1 +  + bM z − M
H ( z) = = n =0
= −1 −N
; a0 = 1
A( z ) N
1 + a1 z +  + a N z
 n
a z −n

n =0

• The order of such an IIR filter is 𝑁.


• The difference equation representation of an IIR filter is (X &Y)
M N
y (n) =  bm x(n − m) −  am y (n − m)
m =0 m =1
Structures of IIR Filters
Direct Form I

• As the name suggests, the difference equation is implemented


as given using delays, multipliers, and adders.
• For the purpose of illustration, Let 𝑀 = 𝑁 = 2
𝑦(𝑛) = 𝑏0 𝑥(𝑛) + 𝑏1 𝑥(𝑛 − 1) + 𝑏2 𝑥(𝑛 − 2) − 𝑎1 𝑦(𝑛 − 1) − 𝑎2 𝑦(𝑛 − 2)

x(n) b0 y(n)
-1
z1/z z-1
-a1 1/z
b1

z1/z
-1
-a2
-1
z
1/z
b2

H1(z) H2(z)
Structures of IIR Filters
Direct Form II
• Using the commutative law of the convolution we can
interchange the two sections in Direct Form I
x(n) b0 y(n)

-1
z1/z z-1
1/z
-a1 b1
z-1 z-1
1/z
-a2 1/z b2

H2(z) H1(z)

x(n) b0 y(n)
z -1
-a1 1/z
b1

z -1
-a2 1/z b2

H(z)
Structures of IIR Filters
Cascade Form
• In this form the system function 𝐻(𝑧) is written as a product of
second-order IIR sections (sos) called biquads.
• This is done by factoring the numerator and denominator
polynomials into their respective roots and then combining
either a complex conjugate root pair or any two real roots into
second-order polynomials.
x(n) b0 y(n)
1/z 1/z
-A1,1 B1,1 -A2,1 B2,1

-A1,2 1/z -A2,2 1/z


B1,2 B2,2
Cascade form structure for 𝑁 = 4
Structures of IIR Filters
Parallel Form
• In this form the system function 𝐻(𝑧) is written as a sum of
second-order (biquad) IIR sections using partial fraction
expansion.
• Outputs of these sections are summed up to form filter output.
• Each biquad section is implemented in direct form II.

C0
B1,0
+
-A1,1 1/z B1,1
x(n) -A1,2 y(n)
1/z +
B2,0
-A2,1 1/z B2,1
-A2,2 1/z
Structures of IIR Filters
Matlab Functions
Comparison Between FIR and IIR Filters
FIR Filters IIR Filters
Finite length Infinite Length
No feedback Has feedback
Always stable May be unstable
Not analog equivalent Analog equivalent

Linear phase response Nonlinear phase response


Less efficient More efficient
(large number of coefficients) (fewer number of coefficients and
hence fewer memory locations,
multiplications and additions)

The choice between FIR or IIR depends mainly on the application


Matlab Commands
residuez z-transform partial-fraction expansion
sos2tf Convert digital filter second-order section data to transfer function form
tf2sos Convert digital filter transfer function data to second-order sections form
tf2zp Convert transfer function filter parameters to zero-pole-gain form
zp2tf Convert zero-pole-gain filter parameters to transfer function form
zp2sos Convert zero-pole-gain filter parameters to second-order sections form
sos2zp Convert digital filter second-order section parameters to zero-pole-gain
form

You might also like