You are on page 1of 64

Lecture 4: FIR and IIR Filter Realization

Marc Moonen Dept. E.E./ESAT, K.U.Leuven marc.moonen@esat.kuleuven.be www.esat.kuleuven.be/scd/

DSP-II

p. 1

Filter Design/Realization
Step-1 : define filter specs
(pass-band, stop-band, optimization criterion,)

Step-2 : derive optimal transfer funcion


FIR or IIR Lecture-3

Step-3 : filter realization (block scheme/flow graph)


direct form realizations, lattice realizations, Lecture-4

Step-4 : filter implementation (software/hardware)


finite word-length issues, question: implemented filter = designed filter ?

ALARI/DSP Marc Moonen - Version 2011

Lecture-4 : FIR and IIR Filter Realization

p. 2

Lecture 4 : Filter Realizations

FIR Filter Realizations IIR Filter Realizations


PS: We will assume real-valued filter coefficients

ALARI/DSP Marc Moonen - Version 2011

Lecture-4 : FIR and IIR Filter Realization

p. 3

FIR Filter Realizations


FIR Filter Realization =Construct (realize) LTI system (with delay elements, adders and multipliers), such that I/O behavior is given by..

y[ k ] ! b0 .u[k ]  b1.u[k  1]  ...  bN .u[k  N ]


Several possibilities exist 1. Direct form 2. Transposed direct form 3. Lattice (LPC lattice) 4. Lossless lattice PS: Frequency-domain realization: see part filter banks
ALARI/DSP Marc Moonen - Version 2011 Lecture-4 : FIR and IIR Filter Realization p. 4

FIR Filter Realizations


1. Direct form
u[k] u[k-1] u[k-2] u[k-3] u[k-4]

(
bo x y[k] + + b1 x

(
b2 x

(
b3 x

(
b4 x

y[ k ] ! b0 .u[k ]  b1.u[k  1]  ...  bN .u[k  N ]


ALARI/DSP Marc Moonen - Version 2011 Lecture-4 : FIR and IIR Filter Realization p. 5

FIR Filter Realizations


2. Transposed direct form
Starting point is direct form : u[k] u[k-1] u[k-2] u[k-3] u[k-4] b4 x x

(
bo x y[k] + + b1 x

(
b2 x

(
b3

`Retiming = select subgraph (shaded)


remove one delay element on all inbound arrows add one delay element on all outbound arrows
ALARI/DSP Marc Moonen - Version 2011 Lecture-4 : FIR and IIR Filter Realization p. 6

FIR Filter Realizations


`Retiming : results in... u[k] u[k-1] u[k-2] u[k-3]

(
bo x y[k] + + b1 x b2 x

(
b3 x

(
b4 x

(=different software/hardware, same i/o-behavior)


ALARI/DSP Marc Moonen - Version 2011 Lecture-4 : FIR and IIR Filter Realization p. 7

FIR Filter Realizations


`Retiming : repeated application results in...
u[k] bo x y[k] + b1 x b2 x b3 x b4 x

i.e. `transposed direct form


(=different software/hardware, same i/o-behavior)
ALARI/DSP Marc Moonen - Version 2011 Lecture-4 : FIR and IIR Filter Realization p. 8

FIR Filter Realizations


3. Lattice form
Derived from combined realization of
H ( z) : y[k ] ! b0 .u[k ]  b1.u[k  1]  ...  bN .u[k  N ]

with `flipped version of H(z)


~ H ( z ) ! z  N . H ( z 1 ) : ~[k ] ! b .u[k ]  b .u[k  1]  ...  b .u[k  N ] y N N 1 0

Reversed (real-valued) coefficient vector results in... 2 2 ~ ~ ~ 1 H ( z ) j[ ! H ( z ).H ( z ) j[ ! ... ! H ( z ) z !e j[


z !e z !e

i.e.

- same magnitude response - different phase response


Lecture-4 : FIR and IIR Filter Realization p. 9

ALARI/DSP Marc Moonen - Version 2011

FIR Filter Realizations


Hence starting point is u[k] u[k-1] u[k-2] u[k-3] u[k-4]

(
b4 x x ~ y[k] y[k] + + b3 bo + + x

(
b2 x b1 + + x

(
b1 x b2 + + x x

(
bo b3 x x

b4

ALARI/DSP Marc Moonen - Version 2011

Lecture-4 : FIR and IIR Filter Realization

p. 10

FIR Filter Realizations


y ~[ k ] b4 y[k ] ! b 0
b4 With O 0 ! b 0
y ~[ k ] 1 y[ k ] ! O 0 1 ! O 0 b'0 ! b0,

b3 b1

b2 b2

b1 b3

b0 T u .? [ k ]...u[ k  N ]A b4

(assume b0 { 0)

, if O 0 { 1 this can be rewritten as


(ps: find fix for case bo=0)

O 0 0 b'3 b'2 b'1 b'0 T u .? [k ]...u[ k  N ]A 1 b'0 b'1 b'2 b'3 0 O 0 z 1 0 b'3 b'2 b'1 b'0 T u . . .? [ k ]...u[ k  N  1]A 1 0 1 b'0 b'1 b'2 b'3 b1  O 0b3 b2  O 0b2 b3  O 0b1 b'1 ! , b'2 ! , b'3 ! 2 2 2 1 O0 1 O0 1 O0

ALARI/DSP Marc Moonen - Version 2011

`sloppy notation : FIR and IIR Filter Realization Lecture-4

p. 11

FIR Filter Realizations


This is equivalent to... u[k] u[k-2] u[k-2] u[k-3]

(
~ y[k] + x ko y[k] + x b3 x b2 x bo + + + + x

(
b1 x b1 + + x

(
bo x b2 x x b3

Now repeat procedure for shaded graph


(=same structure as the one we started from)
Lecture-4 : FIR and IIR Filter Realization p. 12

ALARI/DSP Marc Moonen - Version 2011

FIR Filter Realizations


explain Repeated application results in `lattice form ~ y[k] bo + x ko y[k] + x + x + x u[k]

+ x

(
k1

+ x

(
k2 x

+ x

(
k3 x

(= different software/hardware, same i/o-behavior)


ALARI/DSP Marc Moonen - Version 2011 Lecture-4 : FIR and IIR Filter Realization p. 13

FIR Filter Realizations


Lattice form :
Also known as `LPC Lattice (`linear predictive coding lattice) Kis are so-called `reflection coefficients Every set of bis corresponds to a set of Kis, and vice versa. Procedure for computing Kis from bis corresponds to the well-known `Schur-Cohn stability test (from control theory): problem = for a given polynomial B(z), how do we find out if all the zeros of B(z) are stable (i.e. lie inside unit circle) ? solution = from bis, compute reflection coefficients Kis (following procedure on previous slides). Zeros are (proven to be) stable if and only if all reflection coefficients statisfy |Ki|<1 !
ALARI/DSP Marc Moonen - Version 2011 Lecture-4 : FIR and IIR Filter Realization p. 14

FIR Filter Realizations


Procedure (page 11) breaks down if |Ki|=1 is encountered. Means at least one root of B(z) lies on or outside the unit circle (cfr Schur-Cohn). Then have to select other realization (direct form, lossless lattice, ) for B(z). Lattice form is often applied to `minimum phase filters, i.e. filter with only stable zeros (roots of B(z) strictly inside unit circle). Then design procedure never breaks down. Lattice form not overly relevant at this point, but sets stage for similar derivations that lead to more relevant realizations (read on)
ALARI/DSP Marc Moonen - Version 2011 Lecture-4 : FIR and IIR Filter Realization p. 15

FIR Filter Realizations


4. Lossless lattice :
Derived from combined realization of H(z)
H ( z) : y[k ] ! b0 .u[k ]  b1.u[k  1]  ...  bN .u[k  N ] ~ ~ ~ ~ ~ ~ ~ ~[k ] ! b .u[k ]  b .u[k  1]  ...  b .u[k  N ] y 0 1 N

with
~ ~ H ( z) :

which is such that

~ 1 ~ ~ ~ H ( z ). H ( z )  H ( z ). H ( z ) ! 1
1

(*)

PS : interpretation ? (see next slide) PS : may have to scale H(z) to achieve this (why?) (scaling omitted here)
ALARI/DSP Marc Moonen - Version 2011 Lecture-4 : FIR and IIR Filter Realization p. 16

FIR Filter Realizations


PS : Interpretation ? When evaluated on the unit circle, formula (*) is equivalent to (for filters with real-valued coefficients)
2 ~ ~  H ( z) z !e

1
j[

H ( z ) z ! e j[

!1

~ j[ 2 ~ H (e ) H (e )
j[ 2

T

~ ~ H (z ) and H ( z ) are `power complementary i.e. (= form a 1-input/2-output `lossless system, see also below)
ALARI/DSP Marc Moonen - Version 2011 Lecture-4 : FIR and IIR Filter Realization p. 17

FIR Filter Realizations


PS : How is ~ 1 ~ ~ ~ H ( z ). H ( z ) ! 1  H ( z ). H ( z 1 )      
R( z)

~ ~ H ( z ) computed ?

Note that if `a is a root of R(z), then `1/a is also a root of R(z). Hence can factorize R(z) as ~ ~ 1 ~ ~ ~ ~ 1 H ( z ).H ( z ) ! ( z  ai )( z  ai ) H ( z ) ! ( z 1  ai )
i i

Note that ais can be selected such that all of them lie inside the ~ ~ unit circle. Then H ( z ) is a minimum-phase FIR filter. This is referred to as spectral factorization,
ALARI/DSP Marc Moonen - Version 2011

~ ~ H (z)

=spectral factor.
p. 18

Lecture-4 : FIR and IIR Filter Realization

FIR Filter Realizations


Starting point is u[k] u[k-1] u[k-2] u[k-3] u[k-4]

(
~ ~ b0 ~ ~ b1

(
~ ~ b2

(
~ ~ b3

(
x
~ ~ b4

x x ~ ~ y[k] y[k] + + bo

x x + + b1

x x + + b2

x x b4

x b3 + +

ALARI/DSP Marc Moonen - Version 2011

Lecture-4 : FIR and IIR Filter Realization

p. 19

FIR Filter Realizations


~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~[ k ] y T b b1 b2 b3 b4 ! 0 u .? [ k ]...u[ k  N ]A y[ k ] b0 b1 b2 b3 b4 From (*) (page 16), it follows that (prove it) ~ ~ ~ ~ b b ~ ~ ~ ~ b0 .b4  b0 .b4 ! 0 0 B 4 b0 b4

Hence there exists a theta_0 such that


~ ~[k ] cos U 0 y ! y[ k ] sin U 0 cos U 0 ! sin U 0  sin U 0 0 cos U 0 b'0  sin U 0 z 1 . cos U 0 0 ~ ~ b '0 b'1 ~ ~ b '1 b'2 ~ b ' 0 ~ 0 . 1 b '0 ~ ~ b '2 b'3 ~ ~ b '1 b'1 ~ ~ T b '3 u .? [k ]...u[k  N ]A 0 ~ ~ ~ ~ T b '2 b '3 u .? [k ]...u[k  N  1]A b'2 b'3
p. 20

ALARI/DSP Marc Moonen - Version 2011

`sloppy notation : FIR and IIR Filter Realization Lecture-4

FIR Filter Realizations


This is equivalent to... u[k] u[k-2] u[k-2] u[k-3]

(
~ ~ y[k]
cosU 0

(
x x x b1 + + + +

(
x x b2 x b3

x x

(
sinU 0  sinU 0

x bo + +

y[k] + x
cosU 0

Now shaded graph can again be proven to be power complementary system (Why ? Intuition? Hint: page 23).

Hence can repeat procedure


ALARI/DSP Marc Moonen - Version 2011 Lecture-4 : FIR and IIR Filter Realization p. 21

FIR Filter Realizations


Repeated application results in `lossless lattice explain u[k]

~ ~ y[k]

cosU 0

cosU1

cosU 2

cosU3

cosU 4

x x

(
sinU 0

x x x

(
sinU1

x x x

(
sinU 2

x x x

(
sinU 3  sinU 3

y[k]

x + x
cosU 0

 sinU 0

 sinU1

 sinU 2

x
cosU1

x
cosU 2

x
cosU 3

x
sin U 4

ALARI/DSP Marc Moonen - Version 2011

Lecture-4 : FIR and IIR Filter Realization

p. 22

FIR Filter Realizations


Lossless lattice :
also known as `paraunitary lattice
(see also Lecture 6)

each 2-input/2-output section is based on an orthogonal transformation, which preserves norm/energy/power


OUT1 cosU OUT ! sin U 2  sin U IN1 . ( IN1 )2  ( IN 2 ) 2 ! (OUT1 )2  (OUT2 ) 2 cosU IN 2

i.e. forms a 2-input/2-output `lossless system. Overall system is realized as cascade of lossless sections, hence is itself also `lossless (see also next slides)
ALARI/DSP Marc Moonen - Version 2011 Lecture-4 : FIR and IIR Filter Realization p. 23

FIR Filter Realizations


~ y[k] State-space description
Example 2nd-order system :
y[k]
cosU 0 x2 [k ]
cosU1 x1[k ] cosU 2

u[k]

+ +

x x x x

+ +

x x x x

verify!

R                x1[k  1] 0 0 0 1 x [k  1] 1 0 2~ 0 0 0 cos U1 ~[k ] ! 0 1 . y 0 0 cos U 0 sin U 0 0 0 y[ k ] 0 0  sin U cosU 0  sin U 0 0 1

 0 0 0 0 sin U1 1 . 1 0 0 0 cos U1 0

    0 sin U 2 x [k ] 0 0 1 . x [ k ] 1 0 2 u[k ] 0 cos U 2

!!

1 0 0 R T . R ! 0 1 0 0 0 1

hence

x1[ k 1] x2 [ k 1] ~ ~[ k ] y y[ k ]

2 2 x1[ k ] ! x [ k ] u2[ k ]

- R is `realization matrix (A-B-C-D-matrix) for 1-input/2-output system - R is orthogonal ! Orthogonality implies `losslessness (see next slide)
ALARI/DSP Marc Moonen - Version 2011 Lecture-4 : FIR and IIR Filter Realization p. 24

FIR Filter Realizations


Orthogonality of R implies `losslessness :
assume initial internal state is x1[0], x2[0] (2nd order example) input sequence is u[0],u[1],u[2],,u[L] ~ ~ ~ ~ corresponding output sequences are y[0],y[1], and y[0],y[1],... then orthogonality implies that `energy in initial states + inputs = `energy in final states + outputs
2 x12 [0]  x2 [0]  u 2 [0]  u 2 [1]  ...  u 2 [ L]

~2 ~ [0]  ...  ~ 2 [ L] ~ ! x [ L  1]  x [ L  1]  y [0]  ...  y [ L]  y y


2 1 2 2 2 2

Equivalent transfer function based property (L=infinity) is


H ( z ) z ! e j[
2 2 ~ ~  H ( z) z !e
j[

!1

i.e. H(z) is `embedded in 1-input/2-output lossless system (see page 17)


Lecture-4 : FIR and IIR Filter Realization p. 25

ALARI/DSP Marc Moonen - Version 2011

FIR Filter Realizations


PS : Relevance of lattice realizations : robustness

example :
o = original transfer function + = transfer function after 8-bit truncation of lattice filter parameters - = transfer function after 8-bit truncation of direct-form coefficients (bis)

PS : A 2x2 orthogonal transformation (rotation) may be implemented in


hardware based on a so-called `CORDIC (`COR for CO-ordinate Rotation) architecture, which is more efficient (and more robust) than a multiply-add based implementation
ALARI/DSP Marc Moonen - Version 2011 Lecture-4 : FIR and IIR Filter Realization p. 26

FIR Filter Realizations


PS : can be generalized to 1-input M-output lossless systems
(will be used in part II on filter banks) (compare to page 22 !)

~ ~ y[k] M=3 +
cosU1

cosU 2

U1 ,U 2

U 3 ,U 4

U 5 ,U 6

u[k]
(

x x x
sin U 2  sinU 2

~ y[k]

x x x

+
 sinU1

sin U1 cosU 2

y[k] + x
cosU1

~ 1 ~ ~ ~ 1 ~ ~ explain/derive! H ( Marc Moonen - Version ( z ALARI/DSP z ).H ( z )  H ( z ).H 2011)  H ( z ).H ( z ) ! 1 Lecture-4 : FIR and IIR Filter Realization
1

p. 27

IIR Filter Realizations


Construct LTI system such that I/O behavior is given by..
B ( z ) b0  b1 z 1  ...  bN z  N H ( z) ! ! A( z ) 1  a1 z 1  ...  a N z  N

Several possibilities exist 1. Direct form 2. Transposed direct form PS: Parallel and cascade realization 3. Lattice-ladder form 4. Lossless lattice PS: State space realizations
ALARI/DSP Marc Moonen - Version 2011 Lecture-4 : FIR and IIR Filter Realization p. 28

IIR Filter Realizations


1. Direct form
Starting point is

B ( z ) b0  b1 z 1  ...  bN z  N H ( z) ! ! A( z ) 1  a1 z 1  ...  a N z  N

u[k]

-a1 -a2 -a3 -a4 x x x x


( ( ( ( ( ( ( (

1 A( z )

bo x y[k]
ALARI/DSP Marc Moonen - Version 2011

b1 x +

b2 x +

b3 x +

b4 x

B (z )

Lecture-4 : FIR and IIR Filter Realization

p. 29

IIR Filter Realizations


which is equivalent to... u[k] + + + +

-a1 -a2 -a3 -a4 x x x x


( ( ( (

1 A( z )

bo Direct form B(z) y[k] + x

b1 x +

b2 x +

b3 x +

b4 x

B(z )

PS : If all a_i=0 (i.e. H(z) is FIR), then this reduces to a direct form FIR
ALARI/DSP Marc Moonen - Version 2011 Lecture-4 : FIR and IIR Filter Realization p. 30

IIR Filter Realizations


-State-space description: u[k] + +
-a1

+
-a2

+
-a3 -a4

x1[k  1]  a1  a2  a3  a3 x1[k ] 1 x [k  1] 1 0 0 0 x2 [k ] 0  .u[k ] 2 ! . x3[k  1] 0 1 0 0 x3 [k ] 0 x4 [k  1] 0 0 1 0 x4 [k ] 0 x1[k ] x [k ] y[k ] ! ?b1  a1.b0 b2  a2 .b0 b3  a3 .b0 b4  a4 .b0 A 2  b0 .u[k ] . x 3 [ k ] x4 [k ]

x
x1[k]

x
x2[k]

x
x3[k]

x
x4[k]

(
bo b1

(
b2

(
b3

(
b4

x +

x +

x +

x +

y[k]

-N delay elements (=minimum number =max of numerator and


denominator polynomial order = max(p,q))

-2N+1 multipliers, 2N adders (=minimum number)


ALARI/DSP Marc Moonen - Version 2011 Lecture-4 : FIR and IIR Filter Realization p. 31

IIR Filter Realizations


2. Transposed direct form Starting point is u[k] bo x + +
B ( z ) b0  b1 z 1  ...  bN z  N ! H ( z) ! A( z ) 1  a1 z 1  ...  a N z  N

b1

x + +

b2

x + +

b3

x + +

b4

B (z )

-a1 -a2 -a3 -a4 x x x x y[k]


ALARI/DSP Marc Moonen - Version 2011

1 A( z )
p. 32

Lecture-4 : FIR and IIR Filter Realization

IIR Filter Realizations


which is equivalent to... u[k]
( ( ( (

bo x +

b1 x +

b2 x +

b3 x +

b4 x

B(z )

-a1 -a2 -a3 -a4 x x x x y[k]


ALARI/DSP Marc Moonen - Version 2011

1 A( z )
p. 33

Lecture-4 : FIR and IIR Filter Realization

IIR Filter Realizations


Transposed direct form is obtained after retiming ... u[k] Transposed direct form B(z) bo b1 x x b2 x b3 x b4 x

B(z )

+ ( +

( +

( +

-a1 -a2 -a3 -a4 x x x x y[k]

1 A( z )

PS : If all a_i=0 (i.e. H(z) is FIR), then this reduces to a transposed direct form FIR
ALARI/DSP Marc Moonen - Version 2011 Lecture-4 : FIR and IIR Filter Realization p. 34

IIR Filter Realizations


- State-space description
x1[ k  1]  a1 x [k  1]  a 2 ! 2 x3 [k  1]  a3 x4 [k  1]  a4 1 0 0 0 0 1 0 0 0 x1[k ] b1  a1.b0 0 x2 [ k ] b2  a2 .b0 .  .u[ k ] 1 x3 [ k ] b3  a3 .b0 0 x4 [ k ] b4  a4 .b0

u[k]
bo

b1

b2

b3

b4

x1[k ] x [ k ] y[k ] ! ? 0 0 0A 2  b0 .u[ k ] 1 . x3 [ k ] x4 [ k ]

x1[k] + ( -a1

x2[k] x3[k] x4[k] + ( + ( + (

-a2

-a3

-a4

A C

B A ! D Direct form C

B D Transposed direct form

y[k]

i.e. direct forms state space matrices are `transpose of each other (which justifies the name `transposed dir.form).
ALARI/DSP Marc Moonen - Version 2011 Lecture-4 : FIR and IIR Filter Realization p. 35

IIR Filter Realizations


PS: Parallel & Cascade Realization
Parallel real. obtained from partial fraction decomposition, e.g. for simple poles:
N1 N2 B( z ) Ei K 1  H i z 1 H ( z) ! ! c0   1 1 A( z )  J N z 2 i !1 1  F i z i !1 1  I 1 z

u[k]

+ +

similar for the case of multiple poles each term realized in, e.g., direct form transmission zeros are realized iff signals from different sections exactly cancel out. =Problem in finite word-length implementation
ALARI/DSP Marc Moonen - Version 2011 Lecture-4 : FIR and IIR Filter Realization

y[k]

p. 36

IIR Filter Realizations


PS: Parallel & Cascade Realization
Cascade realization obtained from pole-zero factorization of H(z) e.g. for N even:
N /2 1  E i .z 1  F i .z 2 B( z ) H (z) ! ! b0 . 1 A( z )  H i .z  2 i !1 1  K i . z

u[k]

y[k]

similar for N odd each section realized in, e.g., direct form second-order sections are called `bi-quads

ALARI/DSP Marc Moonen - Version 2011

Lecture-4 : FIR and IIR Filter Realization

p. 37

IIR Filter Realizations


Cascade realization is non-unique:
- multiple ways of pairing poles and zeros - multiple ways of ordering sections in cascade u[k]

``Pairing procedure :
y[k] - pairing of little importance in high-precision (e.g. floating point implementation), but important in fixed-point implementation (with short word-lengths) - principle = pair poles and zeros to produce a frequency response for each section that is as flat as possible (i.e. ratio of max. to min. magnitude response close to unity) - obtained by pairing each pole to a zero as close to it as possible - procedure : start with pole pair nearest to the unit circle, and pair this to nearest complex zeros. remove pole-zero pair, and repeat, etc.
ALARI/DSP Marc Moonen - Version 2011 Lecture-4 : FIR and IIR Filter Realization p. 38

IIR Filter Realizations


3. Lattice-ladder form
Derived from combined realization of
B( z ) b0  b1 z 1  ...  bN z  N H (z) ! ! A( z ) 1  a1 z 1  ...  a N z  N
~ A( z ) a N  a N 1 z 1  ...  1.z  N ~ with... H ( z ) ! ! A( z ) 1  a1 z 1  ...  a N z  N

- numerator polynomial is denominator polynomial with reversed coefficient vector (see also page 9) ~ - hence H ( z ) is an `all-pass (=`SISO lossless) filter :
z ! e j[ ALARI/DSP Marc Moonen - Version 2011 2 ~ H ( z)

~ 2 A( z )

A( z ) z !e j[

z ! e j[ 2

!1
Lecture-4 : FIR and IIR Filter Realization p. 39

IIR Filter Realizations


Starting point is

u[k]

+ a1 x

+ a2 x

+ a3 x a4 x

x[k] a4 x ~ y[k] y[k]

a3 x a2 x a1 x 1 x x b1 x b2 x b0 x b3 x b4 + + + + + + +
p. 40

ALARI/DSP Marc Moonen - Version 2011

Lecture-4 : FIR and IIR Filter Realization

IIR Filter Realizations


This is equivalent to prove it !

u[k]

x
cosU 0 sinU 0

+ a1  a 4.a3 1  a 4.a 4

+ x
a 2  a 4.a 2 1  a 4.a 4

+ x
a3  a 4.a1 1  a 4.a 4

x[k-1]

x
b0

 sinU 0

(
a 2  a 4.a 2 1  a 4.a 4

(
x
a1  a 4.a3 1  a 4.a 4

(
x x +

a3  a 4.a1 1  a 4.a 4

1
b3  b0.a3 1  a 4.a 4

x x b4  b0.a4
1  a 4.a 4

x +

cosU 0

x b1 b0.a1
1  a 4.a 4

x b2  b0.a2
1  a 4.a 4

~ y[k] y[k] +

+ +

+ +

+
p. 41

ALARI/DSP Marc Moonen - Version 2011

a4 ( sin U 0 ! ! k0 1

Lecture-4 : FIR and IIR Filter Realization

IIR Filter Realizations


Right-hand part has the same structure as what we started from, hence procedure can be repeated. Repeated application leads to `lattice-ladder form

u[k]

x +
cosU 0 sinU 0

x
bo

 sinU 0

x x

x ~ y[k] y[k] + +

cosU 0

ALARI/DSP Marc Moonen - Version 2011

Lecture-4 : FIR and IIR Filter Realization

p. 42

IIR Filter Realizations


Lattice-Ladder form :
Kis are `reflection coefficients Procedure for computing Kis (=sin(theta_i) !) from ais again corresponds to `Schur-Cohn stability test (cfr. supra): all zeros of A(z) are stable (i.e. lie inside unit circle) iff all reflection coefficients statisfy |Ki|<1 (i=1,,N-1) (ps: procedure breaks down if |Ki|=1 is encountered) Orthogonal transformations correspond to 2-input/2-output `lossless sections
OUT1 cosU OUT !  sin U 2 sin U IN1 2 2 2 2 . IN ( IN1 )  ( IN 2 ) ! (OUT1 )  (OUT2 ) cosU 2

see next slide


ALARI/DSP Marc Moonen - Version 2011 Lecture-4 : FIR and IIR Filter Realization p. 43

IIR Filter Realizations


State-space description
Example: 2nd-order system:
                 R  0 0  sin U1 cos U1 0 x1[k ] x1[k  1] 1 x [k  1] ! 0  sin U cos U . cos U sin U1 0. x2 [k ] 0 0 1 2 ~[k ] 0 cos U y sin U 0 0 0 1 u[k ] 0 and E y[k ] ! ? 2 E1 x1[k ] E 0 A x2 [k ] . u[k ] 1 0 0 R T .R ! 0 1 0 0 0 1

verify!

!!
~
p. 44

- R is `realization matrix (A-B-C-D-matrix) for u[k] -> y[k] (SISO) - R is orthogonal (R^T.R=I), which implies `losslessness , i.e. 2 ~ (cfr. page 39) H ( z) !1
z ! e j[

ALARI/DSP Marc Moonen - Version 2011

Lecture-4 : FIR and IIR Filter Realization

IIR Filter Realizations


PS : Note that the all-pass part corresponds to A(z) (i.e. N angles theta_i correspond to N coefficients a_i), while the ladder part corresponds to B(z). If all a_i=0 (i.e. H(z) is FIR), then all theta_i=0, hence the all-pass part reduces to a delay line, and the lattice-ladder form reduces to a direct-form FIR. PS : `All-pass part (SISO u[k]->y[k]) is known as `Gray-Markel structure

in x out

x +
cosU 0

sinU 0  sinU 0

cosU 0

+ x
Lecture-4 : FIR and IIR Filter Realization p. 45

ALARI/DSP Marc Moonen - Version 2011

IIR Filter Realizations


4. Lossless-lattice :
Derived from combined realization of (possibly rescaled, as on page 16)
B ( z ) b0  b1 z 1  ...  bN z  N H ( z) ! ! A( z ) 1  a1 z 1  ...  a N z  N

with...

~ C ( z ) c0  c1 z 1  ...  c N .z  N ~ H ( z) ! ! A( z ) 1  a1 z 1  ...  a N z  N

- numerator polynomial is C(z) is such that ~ 1 ~ ~ ~ 1 H ( z ). H ( z )  H ( z ). H ( z ) ! 1 B( z ). B( z 1 )  C ( z ).C ( z 1 ) ! A( z ). A( z 1 ) i.e.


~ ~ H ( z)

and H (z ) are `power complementary


Lecture-4 : FIR and IIR Filter Realization

(p.17-18)
p. 46

ALARI/DSP Marc Moonen - Version 2011

IIR Filter Realizations


`Lossless-lattice :
similar derivation (but more complicated -hence skipped) leads to

u[k]
cos] 0

x +
cosU 0

 sinU 0

+ ~ y[k] y[k]

x x x
sin] 0
 sin] 0

x
cosU 0

cos] N sin] N

k0 ! sinU 0

x x

+ x

x
cos] 0

ALARI/DSP Marc Moonen - Version 2011

Lecture-4 : FIR and IIR Filter Realization

p. 47

IIR Filter Realizations


Orthogonal transformations correspond to (3-input 3-output) `lossless sections
OUT1 . . . IN1 OUT ! . . .. IN 2 2 OUT3 . . . IN 3 ( IN1 ) 2  ( IN 2 ) 2  ( IN 3 ) 2 ! (OUT1 ) 2  (OUT2 ) 2  (OUT3 ) 2

State-space description with orthogonal realization matrix R (try it) implies overall lossless characteristic, i.e.
H ( z ) z ! e j[
2 2 ~ ~  H ( z) z !e
j[

!1

(cfr. Page 46)

PS : If all a_i=0 (i.e. H(z) is FIR), then all theta_i=0 and then this reduces to FIR lossless lattice PS : If all phi_i=0, then this reduces to (retimed) Gray-Markel structure
ALARI/DSP Marc Moonen - Version 2011 Lecture-4 : FIR and IIR Filter Realization

p. 48

IIR Filter Realizations


PS : can be generalized to 1-input M-output lossless systems
(=combine p.27 & p.47 !)

u[k] ~ ~ y[k] + ~ y[k]


cosU1

x +
cosU 0

cosU 2

 sinU 0

x x x
sin U 2
 sinU 2

x
cosU 0

k0 ! sinU 0

+ x x

x x x

+
 sin U1

sin U1 cosU 2

y[k] + x

x
Lecture-4 : FIR and IIR Filter Realization p. 49

cosU ALARI/DSP Marc Moonen - 1Version 2011

IIR Filter Realizations


State-space Realizations :
State-space description:
x[k  1] ! A.x[k ]  B.u[k ] y[k ] ! C.x[k ]  D.u[k ]

State-space realization = realization such that all the elements of A,B,C,D are the multiplier coefficients in the structure A u[k] C ( B +
N

y[k]

Example: (transposed) direct form is NOT a state-space realization, cfr. elements (bi-bo.ai) in B or C (page 31 & 35)
ALARI/DSP Marc Moonen - Version 2011 Lecture-4 : FIR and IIR Filter Realization p. 50

IIR Filter Realizations


Example: bi-quad `coupled realization
- direct form realization of bi-quad (2nd order IIR) may be unsatisfactory, e.g. for short word-lengths and poles near z=1 or z=-1 (see lecture-4) - alternative realization:

L
u[k]

1  E i .z 1  F i .z 2 H i ( z) ! 1  K i .z 1  H i .z  2

+ +
Q Q

O
P

state space description : +


y[k]
Q x1[ k ] 1 x1[ k  1] L ! .  .u[ k ] x [k  1] 2  Q L x2 [ k ] 0 x [k ] y[k ] ! ? P A 1  u[ k ] . O x2 [ k ]

poles : L s j.Q
ALARI/DSP Marc Moonen - Version 2011 Lecture-4 : FIR and IIR Filter Realization p. 51

IIR Filter Realizations


State-space description/realization is non-unique:
any non-singular matrix T transforms A,B,C,D into an alternative state-space description/realization

~ ~ A B T 1 ~ ~ ~[k  1] ! A.~[k ]  B.u[k ] ~ ~ ! x x C D 0 with ~~ ~ ~[ k ] ! T 1.x[ k ] y[k ] ! C .x [k ]  D.u[k ] x

0 A . 1 C

B T . 0 D

0 1

State-space realization with orthogonal realization matrix is referred to as `orthogonal filter : A B R! C D RT .R ! R.R T ! I Relevance : implementation aspects
ALARI/DSP Marc Moonen - Version 2011 Lecture-4 : FIR and IIR Filter Realization p. 52

Addendum: Filter Implementation


The finite word-length problem :
So far assumed all signals/coefficients (=numbers) are represented exactly and arithmetic operations can be performed to an infinite precision. In practice, numbers can be represented only to a finite precision, and arithmetic operations are subject to errors (truncation/rounding/...) Issues: - quantization of filter coefficients - quantization & overflow in arithmetic operations We consider fixed-point filter implementations, with a `short word-length.
ALARI/DSP Marc Moonen - Version 2011 Lecture-4 : FIR and IIR Filter Realization p. 53

Filter Implementation : Coefficient Quantization


In signal processors with a `sufficiently long word-length, e.g. with 16 bits (=4 decimal digits) or 24 bits (=7 decimal digits) precision, or with floating-point representations and arithmetic, finite word-length issues are less relevant. The coefficient quantization problem : Filter design in Matlab (e.g.) provides filter coefficients to 15 decimal digits (such that filter meets specifications) For implementation, need to quantize coefficients to the word length used for the implementation. As a result, implemented filter may fail to meet specifications ??
ALARI/DSP Marc Moonen - Version 2011 Lecture-4 : FIR and IIR Filter Realization p. 54

Filter Implementation : Coefficient Quantization


Coefficient quantization effect on pole locations : example : 2nd-order system (e.g. for cascade realization)
1  E i .z 1  F i .z 2 H i ( z) ! 1  K i .z 1  H i .z  2

`triangle of stability : denominator polynomial is stable (i.e. roots inside unit circle) iff coefficients lie inside triangle

Hi
1 -2 -1 2

Ki

proof: apply Schur-Cohn stability test (cfr. supra). Stable iff all |ki|<1.
ALARI/DSP Marc Moonen - Version 2011 Lecture-4 : FIR and IIR Filter Realization p. 55

Filter Implementation : Coefficient Quantization


example (continued) :
with 5 bits per coefficient, all possible `quantized pole positions are...
forK i ! 2 : 0.1250 : 2 forH i ! 1 : 0.0625 : 1 plot(roots) end
0 1 .5 1 0 .5

end
- 0 .5 -1 - 1 .5 - 1 .5

-1

- 0 .5

0 .5

1 .5

Low density of `quantized pole locations at z=1, z=-1, hence problem for narrow-band LP and HP filters (cfr. supra).
ALARI/DSP Marc Moonen - Version 2011 Lecture-4 : FIR and IIR Filter Realization p. 56

Filter Implementation : Coefficient Quantization


example (continued) :
possible remedy: `coupled realization poles are L s j.Q where L, Q are realized/quantized hence `quantized pole locations are (5 bits) :

L
u[k]

1 .5 1

+ +
Q Q

O
P

0 .5 0

y[k]

-0.5 -1 -1.5 -1.5

-1

-0.5

0 .5

1 .5

ALARI/DSP Marc Moonen - Version 2011

Lecture-4 : FIR and IIR Filter Realization

p. 57

Filter Implementation : Coefficient Quantization


Coefficient quantization effect on pole locations : example : higher-order systems (first-order analysis)
polynomial : 1  a1 .z 1  a2 .z 2  ...  a N .z  N roots are : p1 , p2 ,..., p N `quantized' polynomial : 1  a1.z 1  a2 .z  2  ...  a N .z  N `quantized' roots are : p1 , p2 ,..., p N
N pm  k pm  pm }  .( ak  ak ) k !1 ( p m  pl ) N l {m

-> tightly spaced poles (e.g. for narrow band filters) imply high sensitivity of pole locations to coefficient quantization -> hence preference for low-order systems (parallel/cascade)
ALARI/DSP Marc Moonen - Version 2011 Lecture-4 : FIR and IIR Filter Realization p. 58

Coefficient Quantization
PS: Coefficient quantization in lossless lattice realizations,
o = original transfer function + = transfer function after 8-bit 8truncation of lossless lattice filter coefficients - = transfer function after 8-bit 8truncation of direct-form directcoefficients (bis)

In lossless lattice, all coefficients are sines and cosines, hence all values between 1 and +1, i.e. `dynamic range and coefficient quantization error well under control.
ALARI/DSP Marc Moonen - Version 2011 Lecture-4 : FIR and IIR Filter Realization p. 59

Filter Implementation : Arithmetic Operations


Finite word-length effects in arithmetic operations:
In linear filters, have to consider additions & multiplications

Addition:
if, two B-bit numbers are added, the result has (B+1) bits.

Multiplication:
if a B1-bit number is multiplied by a B2-bit number, the result has (B1+B2-1) bits. For instance, two B-bit numbers yield a (2B-1)-bit product Typically (especially so in an IIR (feedback) filter), the result of an addition/multiplication has to be represented again as a B-bit number (e.g. B=B). Hence have to remove most significant bits and/or least significant bits
ALARI/DSP Marc Moonen - Version 2011 Lecture-4 : FIR and IIR Filter Realization p. 60

Filter Implementation : Arithmetic Operations


Option-1: Most significant bits (MSBs)
If the result is known to be upper bounded such that 1 or more MSBs are always redundant, these MSBs can be dropped without loss of accuracy. Dropping MSBs leads to better usage of available wordlength, hence better SNR. This implies we have to monitor potential overflow (=dropping MSBs that are non-redundant), and possibly introduce additional scaling to avoid overflow.

Option-2 : Least significant bits (LSBs)


Rounding/truncation/ to B bits introduces quantization noise. The effect of quantization noise is usually analyzed in a statistical manner. Quantization, however, is a deterministic non-linear effect, which may give rise to limit cycle oscillations.
ALARI/DSP Marc Moonen - Version 2011 Lecture-4 : FIR and IIR Filter Realization p. 61

Filter Implementation : Arithmetic Operations

zero-input limit cycle oscillations :


Example: y[k] = -0.625.y[k-1]+u[k] 4-bit rounding arithmetic input u[k]=0, y[0]=3/8 output y[k] = 3/8, -1/4, 1/8, -1/8, 1/8, -1/8, 1/8, -1/8, 1/8,..

=oscillations in the absence of input (u[k]=0)


ALARI/DSP Marc Moonen - Version 2011 Lecture-4 : FIR and IIR Filter Realization p. 62

Filter Implementation : Arithmetic Operations


Example: y[k] = -0.625.y[k-1]+u[k] 4-bit truncation (instead of rounding) input u[k]=0, y[0]=3/8 output y[k] = 3/8, -1/4, 1/8, 0, 0, 0,.. (no limit cycle!) Example: y[k] = 0.625.y[k-1]+u[k] 4-bit rounding input u[k]=0, y[0]=3/8 output y[k] = 3/8, 1/4, 1/8, 1/8, 1/8, 1/8,.. Example: y[k] = 0.625.y[k-1]+u[k] 4-bit truncation input u[k]=0, y[0]=-3/8 output y[k] = -3/8, -1/4, -1/8, -1/8, -1/8, -1/8,..

Conclusion: weird, weird, weird, !


ALARI/DSP Marc Moonen - Version 2011 Lecture-4 : FIR and IIR Filter Realization p. 63

Filter Implementation : Arithmetic Operations


Limit cycle oscillations are clearly unwanted (e.g. may be audible in speech/audio applications) Limit cycle oscillations can only appear if the filter has feedback. Hence FIR filters cannot have limit cycle oscillations. Mathematical analysis is very difficult. Truncation i.o. rounding often helps to avoid limit cycles (e.g. magnitude truncation, where absolute value of quantizer output is never larger than absolute value of quantizer input (`passive quantizer)). Some filter structures can be made limit cycle free, e.g. coupled realization, lattice filters, .
ALARI/DSP Marc Moonen - Version 2011 Lecture-4 : FIR and IIR Filter Realization p. 64

You might also like