dsp_foehu - lec 07 - digital filters

74
رَ ـدْ ـقِ ن،،، لماننا نصدق اْ قِ ن رَ دLECTURE ( 07 ) Digital Filters Assist. Prof. Amr E. Mohamed

Upload: amr-e-mohamed

Post on 21-Apr-2017

227 views

Category:

Engineering


1 download

TRANSCRIPT

Page 1: DSP_FOEHU - Lec 07 - Digital Filters

درنقنصدق اننالما،،، نـقـدر

LECTURE (07)

Digital Filters

Assist. Prof. Amr E. Mohamed

Page 2: DSP_FOEHU - Lec 07 - Digital Filters

Agenda

Introduction

Linear Time-Invariant Filters

Recursive and non-Recursive Filters

Filtering, Convolution and Correlation Operations

Filter Structures

Design of FIR Filters

Design of Filterbanks

Design of IIR Filters

Issues in the Design and Implementation of a Digital Filter

2

Page 3: DSP_FOEHU - Lec 07 - Digital Filters

Introduction

Filters are a basic component of all signal processing andtelecommunication systems.

Filters are widely employed in signal processing and communicationsystems in applications such as channel equalization, noisereduction, radar, audio processing, video processing, biomedicalsignal processing, and analysis of economic and financial data.

The primary functions of filters are one of the followings:

To confine a signal into a prescribed frequency band as in low-pass,high-pass, and band-pass filters.

To decompose a signal into two or more sub-bands as in filter-banks,graphic equalizers, sub-band coders, frequency multiplexers.

To modify the frequency spectrum of a signal as in telephone channelequalization and audio graphic equalizers.

To model the input-output relationship of a system such astelecommunication channels, human vocal tract, and music synthesizers.

3

Page 4: DSP_FOEHU - Lec 07 - Digital Filters

Linear Time-Invariant Digital Filters

Linear time-invariant (LTI) filters are a class of filters whose output is a

linear combination of the input signal samples and whose

coefficients do not vary with time.

The linear property ≡ the principle of superposition.

The time-invariant implies that the filter coefficients and hence its

frequency response is fixed and does not vary with time.

In the time domain the input-output relationship of a discrete-time

linear filter is given by the following linear difference equation:

M

k

k

N

k

k knxbknyany01

)()()(

4

Page 5: DSP_FOEHU - Lec 07 - Digital Filters

Linear Time-Invariant Digital Filters (Cont.)

Where {𝑎𝑘 , 𝑏𝑘} are the filter coefficients, and the output 𝑦(𝑛) is a linear

combination of the previous 𝑁 output samples [𝑦(𝑛 − 1), … , 𝑦(𝑛 − 𝑁)], the present

input sample 𝑥(𝑛) and the previous 𝑀 input samples [𝑥(𝑛 − 1),… , 𝑥(𝑛 − 𝑀)].

The characteristic of a filter is completely determined by its coefficients

{𝑎𝑘 , 𝑏𝑘}.

For a time-invariant filter the coefficients {𝑎𝑘 , 𝑏𝑘} are constants calculated

to obtain a specified frequency response.

M

k

k

N

k

k knxbknyany01

)()()(

5

Page 6: DSP_FOEHU - Lec 07 - Digital Filters

Linear Time-Invariant Digital Filters (Cont.)

The filter transfer function, obtained by taking the z-transform of

the general difference equation, is given by:

𝐻 𝑧 = 𝑘=1𝑀 𝑏𝑘𝑧

−𝑘

1 + 𝑘=1𝑁 𝑎𝑘𝑧

−𝑘

The frequency response of this filter can be obtained from by

substituting the frequency variable 𝑒𝑗𝜔 for the 𝑧 variable, 𝑧 = 𝑒𝑗𝜔, as

𝐻 𝑒𝑗𝜔 = 𝑘=1𝑀 𝑏𝑘𝑒

−𝑗𝜔𝑘

1 + 𝑘=1𝑁 𝑎𝑘𝑒

−𝑗𝜔𝑘

6

Page 7: DSP_FOEHU - Lec 07 - Digital Filters

Linear Time-Invariant Digital Filters (Cont.)

The transfer function of the LTI filter is the ratio of two polynomials in

the variable 𝑧 and may be written in a cascade form as

𝐻 𝑧 = 𝐻1(𝑧)𝐻2(𝑧)

where 𝐻1(𝑧) is the transfer function of a feed-forward, all-zero, filter

given by

𝐻1 𝑧 =

𝑘=1

𝑀

𝑏𝑘𝑧−𝑘

and 𝐻2(𝑧) is the transfer function of a feedback, all-pole, recursive

filter given by

𝐻2 𝑧 =1

1 + 𝑘=1𝑁 𝑎𝑘𝑧

−𝑘

7

Page 8: DSP_FOEHU - Lec 07 - Digital Filters

Linear Time-Invariant Digital Filters (Cont.)

Filter Order

The order of a discrete-time filter is the highest discrete-time delay used in

the input-output equation of the filter.

For Example, For the following Equations

the filter order is the larger of the values of N or M.

For continuous-time filters the filter order is the order of the highest

differential term used in the input-output equation of the filter.

M

k

k

N

k

k knxbknyany01

)()()(

8

Page 9: DSP_FOEHU - Lec 07 - Digital Filters

Linear Time-Invariant Digital Filters (Cont.)

The block diagram

implementation of the

linear time-invariant

filter.

9

Page 10: DSP_FOEHU - Lec 07 - Digital Filters

Non-Recursive or Finite Impulse Response (FIR) Filters A non-recursive filter has no feedback and its input-output relation is given by

𝑦 𝑛 =

𝑘=0

𝑀

𝑏𝑘 𝑥(𝑛 − 𝑘)

The output y(n) of a non-recursive filter is a function only of the input signal x(m).

The response of such a filter to an impulse consists of a finite sequence of M+1 samples,

where M is the filter order.

Hence, the filter is known as a Finite-Duration Impulse Response (FIR) filter.

Other names for a non-recursive filter include all-zero filter, feed-forward filter or

moving average (MA) filter a term usually used in statistical signal processing literature.

10

Page 11: DSP_FOEHU - Lec 07 - Digital Filters

Recursive or Infinite Impulse Response (IIR) Filters

A recursive filter has feedback from output to input, and in general its output is afunction of the previous output samples and the present and past inputsamples as described by the following equation:

𝑦 𝑛 =

𝑘=0

𝑀

𝑏𝑘 𝑥(𝑛 − 𝑘) −

𝑘=1

𝑁

𝑎𝑘 𝑦(𝑛 − 𝑘)

In theory, when a recursive filter is excited by an impulse, the output persistsforever.

Thus a recursive filter is also known as an Infinite Duration Impulse Response (IIR)filter.

Other names for an IIR filter include feedback filters, pole-zero filters and auto-regressive-moving-average (ARMA) filter a term usually used in statistical signalprocessing literature.

It has a number of poles corresponding to the roots of the denominator polynomial andit may also have a number of zeros corresponding to the roots of the numeratorpolynomial.

11

Page 12: DSP_FOEHU - Lec 07 - Digital Filters

FIR vs IIR

The main difference between IIR filters and FIR filters is that

An IIR filter is more compact in that it can usually achieve a prescribed

frequency response with a smaller number of coefficients than an FIR filter.

A smaller number of filter coefficients imply less storage requirements and

faster calculation and a higher throughput. Therefore, generally IIR filters

are more efficient in memory and computational requirements than FIR

filters.

However, it must be noted that an FIR filter is always stable, whereas an IIR

filter can become unstable (for example if the poles of the IIR filter are

outside the unit circle) and care must be taken in design of IIR filters to

ensure stability.

Also, All IIR filter have Non-Linear Phase, while the FIR can be designed to

be Linear Phase filter or Non-Linear Phase.

12

Page 13: DSP_FOEHU - Lec 07 - Digital Filters

Filter Structures: Direct, Cascade and Parallel Forms

13

Page 14: DSP_FOEHU - Lec 07 - Digital Filters

Discussed: How to design digital filters

How do you implement them in practice?

In a double-precision floating-point world – no problem

No constraints simple architecture is possible

14

Page 15: DSP_FOEHU - Lec 07 - Digital Filters

Introduction

|||| ,1

)(1

1

10 azaz

zbbzH

)1()()( 10 nuabnuabnh nn

)1()()1()( 10 nxbnxbnayny

)1()()1()( 10 nxbnxbnayny Computable

Noncomputable

15

Discussed: How to design digital filters

How do you implement them in practice?

In a double-precision floating-point world – no problem

No constraints: simple architecture is possible

Example:

Page 16: DSP_FOEHU - Lec 07 - Digital Filters

Basic Operations

Addition

Multiplication

Delay

+x1(n)

x2(n)

x1(n) + x2(n)

x(n)a ax(n)

x(n)x(n1)z1

16

Page 17: DSP_FOEHU - Lec 07 - Digital Filters

Example

x(n) +

+

b

a1

z1

z1

a2

y(n)

y(n1)

y(n2)

17

)()2()1()( 21 nbxnyanyany Constraints:

speed constraints

power constraints

Reduce total number of operations

In particular, multiplications mighttake longer than additions & takesmore power reduce their number

Fixed-point arithmetic takes much less area cheaper, faster

The area of a fixed-point parallelmultiplier is proportional to theproduct of the coefficient and datawordlengths reduce data or coefficient wordlengths

Page 18: DSP_FOEHU - Lec 07 - Digital Filters

Higher-Order Difference Equations

M

k

k

N

k

k knxbknyany01

)()()(

N

k

k

k

M

k

k

k

za

zb

zH

1

1

1

)(

M

k

k

N

k

k knxbknyany01

)()()(

18

Page 19: DSP_FOEHU - Lec 07 - Digital Filters

Block Diagram Representation (Direct Form I)

M

k

k

N

k

k knxbknyany01

)()()(

+

z1

z1

+

z1

+

b0

b1

bM1

bM

x(n)

x(n1)

x(n2)

x(nM)

+

z1

z1

+

z1

+

a1

aN1

aN

y(n)

y(n1)

y(n2)

y(nM)

v(n)

19

Page 20: DSP_FOEHU - Lec 07 - Digital Filters

Block Diagram Representation (Direct Form I)

+

z1

z1

+

z1

+

b0

b1

bM1

bM

x(n)

x(n1)

x(n2)

x(nM)

+

z1

z1

+

z1

+

a1

aN1

aN

y(n)

y(n1)

y(n2)

y(nM)

v(n)

M

k

k

k zbzH0

1 )(

N

k

k

k za

zH

1

2

1

1)(

Implementing zeros

Implementing poles

20

Page 21: DSP_FOEHU - Lec 07 - Digital Filters

Block Diagram Representation (Direct Form I)

+

z1

z1

+

z1

+

b0

b1

bM1

bM

x(n)

x(n1)

x(n2)

x(nM)

+

z1

z1

+

z1

+

a1

aN1

aN

y(n)

y(n1)

y(n2)

y(nM)

v(n)

M

k

k

k zbzH0

1 )(

N

k

k

k za

zH

1

2

1

1)(

N

k

k

k

M

k

k

k

za

zbzHzHzH

1

0

21

1

1)()()(

21

Page 22: DSP_FOEHU - Lec 07 - Digital Filters

Block Diagram Representation (Direct Form I)

+

z1

z1

+

z1

+

b0

b1

bM1

bM

x(n)

x(n1)

x(n2)

x(nM)

+

z1

z1

+

z1

+

a1

aN1

aN

y(n)

y(n1)

y(n2)

y(nM)

v(n)

How many Adders?How many multipliers?How many delays?

22

Page 23: DSP_FOEHU - Lec 07 - Digital Filters

Block Diagram Representation (Direct Form I)

The direct-form structure provides a convenient method for the

implementation of FIR filters. However, for IIR filters the direct-

form implementation is not normally used due to problems with

the design and operational stability of direct-form IIR filters.

23

Page 24: DSP_FOEHU - Lec 07 - Digital Filters

Block Diagram Representation (Direct Form II)

+

z1

z1

+

z1

+

b0

b1

bN1

bN

x(n)+

z1

z1

+

z1

+

a1

aN1

aN

y(n)

w(n1)

w(n2)

w(nN)

w(n)

AssumeM = N

24

Page 25: DSP_FOEHU - Lec 07 - Digital Filters

Block Diagram Representation (Direct Form II)

+

z1

z1

+

z1

+

b0

b1

bN1

bN

x(n)+

z1

z1

+

z1

+

a1

aN1

aN

y(n)

w(n1)

w(n2)

w(nN)

w(n)

AssumeM = N

)()()(1

nxknwanwN

k

k

)()()(0

nwknxbnyM

k

k

M

k

k

k zbzH0

1 )(

N

k

k

k za

zH

1

2

1

1)(

25

Page 26: DSP_FOEHU - Lec 07 - Digital Filters

Block Diagram Representation (Direct Form II)

+

z1

z1

+

z1

+

b0

b1

bN1

bN

x(n)+

z1

z1

+

z1

+

a1

aN1

aN

y(n)

w(n1)

w(n2)

w(nN)

w(n)

AssumeM = N

M

k

k

k zbzH0

1 )(

N

k

k

k za

zH

1

2

1

1)(

M

k

k

kN

k

k

k

zb

za

zHzHzH0

1

12

1

1)()()(

Implementing poles

Implementing zeros

26

Page 27: DSP_FOEHU - Lec 07 - Digital Filters

Block Diagram Representation (Direct Form II)

+

z1

z1

+

z1

+

b0

b1

bN1

bN

x(n)+

z1

z1

+

z1

+

a1

aN1

aN

y(n)

w(n1)

w(n2)

w(nN)

w(n)

AssumeM = N

How many Adders?How many multipliers?How many delays?

27

Page 28: DSP_FOEHU - Lec 07 - Digital Filters

Block Diagram Representation (Canonic Direct Form)

+

+

+

b0

b1

bN1

bN

x(n)+

z1

z1

+

z1

+

a1

aN1

aN

y(n)

AssumeM = N

How many Adders?How many multipliers?How many delays? Max (M,N)

28

Page 29: DSP_FOEHU - Lec 07 - Digital Filters

Parallel Filter Structure An alternative to the cascade implementation described in the previous

section is to express the filter transfer function H(z), using the partialfraction method, in a parallel form as parallel sum of a number ofsecond order and first order terms as

where in general the filter is assumed to have 𝑁1 complex conjugatepoles, 𝑁1 real zeros, and 𝑁2 real poles and 𝐾 is a constant.

29

21

11

12

2

1

1

1

10

11)(

N

k k

k

N

k kk

kk

za

e

zaza

zeeKzH

N

k

k

k

M

k

k

k

za

zb

zH

1

1

1

)(

21

1

)()(NN

k

k zHKzH

Page 30: DSP_FOEHU - Lec 07 - Digital Filters

Parallel Filter Structure (Cont.)

30

Page 31: DSP_FOEHU - Lec 07 - Digital Filters

Example 3: Parallel Structure of IIR Filter

Consider the following transfer function

Partial fraction expansion leads to

parallel structure with 3 branches

31

Page 32: DSP_FOEHU - Lec 07 - Digital Filters

Example 4: Parallel Structure of IIR Filter

Consider the following transfer function

The denominator admits 3 roots: 0.0655 ± 0.5755j and 0.0492

Recombine the two conjugate roots and by partial fraction expansion

32

Page 33: DSP_FOEHU - Lec 07 - Digital Filters

General Procedure to Obtain a Parallel Structure

Decompose 𝐻(𝑧) using a partial fraction expansion

Combine any pair of complex conjugate poles to obtain real-valued

elements 𝐻𝑖(𝑧)

Optional: Combine such elements further if beneficial

Remark: Typically we limit ourselves to second-order sections

33

Page 34: DSP_FOEHU - Lec 07 - Digital Filters

Main Characteristics of the Parallel Structure

Simple to implement

Sometimes has an advantage over the cascade realization in terms of

internally generated quantization noise, not much though (no

amplification of errors over various stages).

Errors of coefficient quantization of 𝐻𝑖(𝑧) affects zeros of 𝐻(𝑧) longer

coefficient wordlengths required to ensure stability.

Zeros on the unit circle in the overall transfer function are not

preserved no saving of multipliers can be obtained for filters having

such zeros.

34

Page 35: DSP_FOEHU - Lec 07 - Digital Filters

Cascade Filter Structure The cascade implementation of a filter is obtained by expressing

the filter transfer function H(z) in a factorized form as

where G is the filter gain and the poles (𝑝𝑘𝑠) and zeros (𝑧𝑘𝑠) are either

complex conjugate pairs or real-valued.35

N

k

k

k

M

k

k

k

za

zb

zH

1

1

1

)(

21

21

1

1*11

1

1

1*11

1

)1)(1()1(

)1)(1()1(

)(N

k

kk

N

k

k

M

k

kk

M

k

k

zpzpzp

zzzzzz

GzH

Page 36: DSP_FOEHU - Lec 07 - Digital Filters

Cascade Filter Structure (Cont.)

Each bracketed term in the previous Equation is the z-transfer function

of a first or second order IIR filter:

𝐻1 𝑧 = 𝐺

𝑘=1

𝐾

𝐻𝑘 𝑧

36

2nd OrderSystem

2nd OrderSystem

1st OrderSystem

1st OrderSystem

Page 37: DSP_FOEHU - Lec 07 - Digital Filters

Cascade Filter Structure (Cont.)

Realization of an IIR cascade structure from second order sections.

37

Page 38: DSP_FOEHU - Lec 07 - Digital Filters

Example 1: Cascade Structure

The following transfer function was considered

Decompose as

cascade structure with 2 sections

38

Page 39: DSP_FOEHU - Lec 07 - Digital Filters

Example 2: Cascade Structure

Consider the following transfer function

The denominator admits 3 roots: 0.0655 ± 0.5755j and 0.0492

Recombine the two conjugate roots and decompose

cascade structure with 2 sections

39

Page 40: DSP_FOEHU - Lec 07 - Digital Filters

General Procedure to Obtain Cascade Structure

Compute the poles and zeros of 𝐻(𝑧)

Combine any pair of complex conjugate poles to obtain real-valued

elements 𝐻𝑖(𝑧)

Optional: Combine such elements further if beneficial

Remark: Typically we limit ourselves to second-order sections

40

Page 41: DSP_FOEHU - Lec 07 - Digital Filters

Sensitivity to coefficient quantisation

The filter coefficients are quantized

errors in coefficient value cause errors in pole and zero positions and,

hence, filter response

Example: Consider a filter with four poles at z = - 0.9 (close to unit

circle but stable)

41

Page 42: DSP_FOEHU - Lec 07 - Digital Filters

Example: Sensitivity to coefficient quantisation

Direct form filter would have the following denominator polynomial inits transfer function:

Cascade of four first-order sections:

Assume an error of -0.06

Direct: error -0.06 to the third coefficient, i.e. 4.86 → 4.8 roots of theresulting polynomial are -1.5077, -0.7775 ± 0.4533j, -0.5372 Filter unstable!

Cascade: error -0.06 to 0.9, i.e. 0.9 → 0.84 Not big deal!

Cascade has much lower sensitivity to coefficient quantization smallerchange, only one root affected

42

Page 43: DSP_FOEHU - Lec 07 - Digital Filters

Useful Tips

Each complex root, with its inevitable conjugate, can be implemented

by a single second-order section

Consider a root at 𝑟𝑒𝑗𝜔 and its conjugate 𝑟𝑒−𝑗𝜔

the real-coefficient second-order polynomial

If interested in placing zeros

If interested in placing poles

43

Page 44: DSP_FOEHU - Lec 07 - Digital Filters

Filters with Zeros on the Unit Circle

Many filters (FIR and IIR) have zeros on the unit circle

Biquadratic section with 𝑟𝑒𝑗𝜔 and its conjugate 𝑟𝑒−𝑗𝜔

no multiplication required - very used in practice

Implementing a high-order filter with many zeros on the unit circle as a

cascade of biquadratic sections requires fewer total multiplications

than a direct form implementation

44

Page 45: DSP_FOEHU - Lec 07 - Digital Filters

Linear Phase FIR Filters

45

Page 46: DSP_FOEHU - Lec 07 - Digital Filters

Linear Phase FIR Filters

It takes a finite time before the input to a filter propagates through the

filter and appears at the output. A delay of T seconds in time domain

appears as a phase change of 𝑒−𝑗2𝜋𝑇 in frequency domain. The time

delay, or phase change, caused by a filter depends on the type of the

filter (e.g. linear/nonlinear, FIR/IIR) and its impulse response.

An FIR filter of order M, with M+1 coefficients, has a time delay

of M/2 samples.

A theorem: “if h(n) represents the impulse response of a discrete time

system, a necessary and sufficient condition for linear phase is that

h(n) have finite duration N, and that it is symmetric about its

midpoint”.

For a causal FIR filter whose impulse response begins at zero and ends

at N-1, h(n) satisfies

ℎ(𝑛) = ℎ(𝑁 − 1 − 𝑛) 𝑓𝑜𝑟 𝑛 = 0, 1, 2, … ,𝑁 − 146

Page 47: DSP_FOEHU - Lec 07 - Digital Filters

Linear Phase FIR Filters (Cont.)

47

ℎ(𝑛) = ℎ(𝑁 − 1 − 𝑛) 𝑓𝑜𝑟 𝑛 = 0, 1, 2,… ,𝑁 − 1

Page 48: DSP_FOEHU - Lec 07 - Digital Filters

Linear Phase FIR Filters (Cont.)

For the case where N is even,

Let m= N-1-n in the second sum, gives:

48

Page 49: DSP_FOEHU - Lec 07 - Digital Filters

Linear Phase FIR Filters (Cont.) But from symmetry, h(N-1-m) = h(m), and the summation can be reversed to give

49

Page 50: DSP_FOEHU - Lec 07 - Digital Filters

Linear Phase FIR Filters (Cont.)

For N an odd number, a similar derivation leads to:

50

Page 51: DSP_FOEHU - Lec 07 - Digital Filters

Finite-Precision Number Representation and Quantization

51

Page 52: DSP_FOEHU - Lec 07 - Digital Filters

Finite-Precision Number Representation

In a computer, numbers are represented as combinations of a finite

number of binary digits, or bits that take values of 0 and 1

Bits are usually organized into bytes containing 8 bits or words (16 bits,

32 bits)

Two forms are used to represent numbers on a digital computer:

fixed-point

floating-point

52

Page 53: DSP_FOEHU - Lec 07 - Digital Filters

Fixed-point representation

The magnitude of the number is expressed in powers of 2, with the

binary point separating positive and negative exponents B bits number

representation, value (B,A)

Number range

Example: a B = 12 bit number with A = 2 bits before the binary point is

in the range -2048/1024 to +2047/1024 inclusive

All values are quantised to integer multiples of the LSB53

Page 54: DSP_FOEHU - Lec 07 - Digital Filters

Overflow

If the result of any calculation in the filter exceeds its number range

overflow occurs.

By default, a value slightly greater than the maximum representable

positive number becomes a large negative number, and vice versa.

This is called wraparound; the resulting error is huge.

In IIR filters it can result in very large amplitude "overflow oscillations".

54

Page 55: DSP_FOEHU - Lec 07 - Digital Filters

Strategies to avoid overflow

Two strategies exist

scaling - to ensure that values can never (or hardly ever) overflow

saturation arithmetic - to ensure that if overflow occurs its effects are

greatly reduced

55

Page 56: DSP_FOEHU - Lec 07 - Digital Filters

Saturation arithmetic

First, the results of all calculations are to full precision.

For example, the addition of 2 (B,A) values results in a (B +1,A +1) value;

the multiplication of a (B,A) value by a (C,D) value results in a (B+C-1,A+D-

1) value.

Then, the higher order bits of the true result are processed to detect

overflow.

• If overflow occurs, the maximum possible positive

value or minimum possible negative value is returned

56

Page 57: DSP_FOEHU - Lec 07 - Digital Filters

Saturation arithmetic (Cont.)

Instead of merely masking the true result to a (B,A), overflow is

detected and the maximum possible positive value or minimum possible

negative value is returned.

Some DSP ICs incorporate saturation arithmetic hardware

57

Page 58: DSP_FOEHU - Lec 07 - Digital Filters

Scaling

Assume that the input to a filter is bounded by 𝑥(𝑛) < 𝐶

Then its output is bounded by

where ℎ(𝑘) is its impulse response

𝑘=−∞∞ ℎ(𝑘) is known as the 𝑙1 𝑛𝑜𝑟𝑚 of the filter impulse response,

easy to compute numerically

58

Page 59: DSP_FOEHU - Lec 07 - Digital Filters

𝑙1scaling

Bounded input bounded output

𝑥(𝑛) < 𝐶 𝑘=−∞∞ ℎ(𝑘)

If the maximum permissible output magnitude is D, overflow cannot

occur provided we scale the output by𝐷

𝑘=−∞∞ ℎ(𝑘)

However if we reduce the magnitude of signals,

The ratio of signal power to quantization noise power becomes smaller

Scaling worsens the noise performance of the filter

59

Page 60: DSP_FOEHU - Lec 07 - Digital Filters

Alternative scaling

The input signal which gives rise to the largest possible output is

unlikely to occur in practice, so a less conservative scaling approach is

often used

𝑙2 scaling

frequency – response scaling

For both saturation arithmetic is still needed as overflow is still possible

60

Page 61: DSP_FOEHU - Lec 07 - Digital Filters

𝑙2 scaling

Choose less conservative scaling based on the scale factor

𝐷

𝐶 𝑘=−∞∞ ℎ(𝑘)

which is the root mean square impulse response and this is known as 𝑙2scaling

61

Page 62: DSP_FOEHU - Lec 07 - Digital Filters

Frequency-response scaling

Suppose frequency response of the filter is 𝐺(𝑒𝑗𝜔)

a sine wave of frequency ω and peak amplitude 𝐶 at the input

gives a sine wave of peak amplitude 𝐶 𝐺(𝑒𝑗𝜔) at the output

To prevent overflow of a single sine wave use scaling factor

𝐷

𝐶max𝜔𝐺(𝑒𝑗𝜔)

62

Page 63: DSP_FOEHU - Lec 07 - Digital Filters

Application of scaling to cascade and parallel realizations

At each step, you must compute the impulse response or frequencyresponse from the input of the overall filter to the point of interest,taking account of all scaling already included up to that point.

The scaling at section inputs may implemented using simple binaryshifts (by using the next smaller power of 2), or by incorporating it intothe FIR coefficient scaling of the preceding section.

For a parallel realization, scaling is computed independently for eachsection, but all section outputs must be scaled by the same amount, sothe overall scaling of each section must be made the same.

Finally scaling is applied to the final adder(s) which add together theoutputs of the parallel sections.

63

Page 64: DSP_FOEHU - Lec 07 - Digital Filters

Roundoff (quantization) noise generation

The output of a multiplier has more bits than its inputs (for example, a

16 by 16 two's complement multiplier outputs a 31-bit two's

complement value).

To store the output it has to be (re)quantized (low order bits have to be

thrown away)

An error called quantization noise or roundoff noise is added at that point

The noise variance at the multiplier output, assuming rounding is used,

is 𝑞2 /12, where 𝑞 is the LSB size after quantization. (The same as for

quantization of analogue signals.)

64

Page 65: DSP_FOEHU - Lec 07 - Digital Filters

Roundoff (quantisation) noise assumptions

It is often assumed that the quantization noise at each multiplier output

is white (independent from sample to sample).

It is also assumed that it is independent between multipliers, so that

the noise variances ("powers") add.

(The assumption of whiteness is actually a very poor model if the signal

is narrowband, but it is reasonable for large amplitude wideband

signals. The assumption of independence can also be a poor model.)

65

Page 66: DSP_FOEHU - Lec 07 - Digital Filters

Roundoff (quantisation) noise in FIR and IIR filters

As a result:

The quantization noise from the multipliers of an FIR filter therefore

adds white noise directly to the output signal

In IIR filters, the white quantization noise from the feedback

multipliers filter is fed to the input of the filter, so the resulting noise

spectrum at the filter output is coloured. Its spectrum is proportional

to the square of the filter's frequency response magnitude.

66

Page 67: DSP_FOEHU - Lec 07 - Digital Filters

Roundoff (quantisation) noise

Roundoff noise level is affected by data wordlengths, filter response,

filter structure and (to an extent) by section ordering in cascade

structures.

Further details are in specialist texts.

Remark. DSP ICs, and some VLSI filters, provide an accumulator store of

longer wordlength than the data wordlength (e.g. a 32-bit accumulator

for a 16-bit DSP). The multiplier outputs are accumulated at the longer

wordlength, and then the accumulator output is only quantized once.

This approach significantly reduces roundoff noise.

67

Page 68: DSP_FOEHU - Lec 07 - Digital Filters

Limit cycles

Zero-input limit cycles are self-sustaining oscillations, caused by the roundingof the results of computations.

Example: consider the second-order filter

This is a stable second order IIR filter with complex poles at 𝑗0.9.

If rounding to the nearest LSB is used at the output of the multiplier, then when 𝑦(𝑛

− 2) = ±1; ± 2; ± 3; or ± 4𝐿𝑆𝐵, the computation 0.9𝑦(𝑛 − 2) will give the result

± 1; ± 2; ± 3; 𝑜𝑟 ± 4𝐿𝑆𝐵 respectively.

Hence a limit cycle of the form 𝑦(𝑛) = 4; 0;−4; 0; 4; 0;−4; 0 (or the same pattern

with 3,2, or 1) may occur.

Effectively, the reason is that the rounding non-linearity has increased the feedback

gain to 1, turning the system into an oscillator. 68

Page 69: DSP_FOEHU - Lec 07 - Digital Filters

Limit cycles

Limit cycles are troublesome in some applications, especially with short

data wordlengths, where the limit cycle may be relatively large. With

the longer wordlengths of DSP ICs, it is often possible to ignore limit

cycles.

Solutions:

One solution is to quantize toward 0 (truncation) instead of rounding the

multiplier output. But the extra roundoff noise due to truncation may

require the data wordlength to be increased by 1 or 2 bits.

Another solution is to use certain forms of digital filters (such as Wave

filters) which do not support limit cycles. However these are

computationally more expensive.

69

Page 70: DSP_FOEHU - Lec 07 - Digital Filters

Deadbands Consider a simple digital low-pass filter such as is commonly used for smoothing:

𝑦 𝑛 = 𝑦 𝑛 − 1 + 𝛼 𝑥 𝑛 − 𝑦(𝑛 − 1) = 1 − 𝛼 𝑦 𝑛 − 1 + 𝛼𝑥(𝑛)

The transfer function is

𝐻 𝑧 =𝛼

1 − (1 − 𝛼)𝑧−1

This has unit gain at zero frequency (z = 1), and a pole at 1 – α.

The time constant is approximately 1/α samples, for α<<1

If 𝛼 𝑥 𝑛 − 𝑦(𝑛 − 1) < 0.5𝐿𝑆𝐵 then the multiplier output will round to zero, and

the filter output will therefore remain constant.

Hence a constant output known as the deadband, arises. It can be up to (0.5/α)LSB

If, for example, (1/α)=10000 to give a time constant of 10000 samples, then the

size of the LSB of the internal arithmetic must be 5000 times smaller than the

permissible size of the deadband. This implies 13 extra bits (since 212 = 4096).

70

Page 71: DSP_FOEHU - Lec 07 - Digital Filters

Coefficient quantization

In a previous section we showed that the cascade form is much less

sensitive to coefficient quantization than a high order direct form filter.

(This is also true of the parallel form.)

If the filter has zeros on the unit circle and is implemented using a

second-order section, the cascade realization has the advantage that

these zeros stay on the unit circle (because a coefficient b2 = 1 is

unaffected by quantization), although their frequencies may be altered.

71

Page 72: DSP_FOEHU - Lec 07 - Digital Filters

Coefficient quantization

A traditional way to study the relative merits of different filter

structures was to analyze the sensitivity of the frequency response

magnitude to random (often Gaussian) perturbations of the coefficients,

and to use this as a measure of the likely sensitivity of a given structure

to coefficient quantization.

Various structures, including Lattice and Wave filters, give even lower

sensitivity to coefficient quantization than the cascade realization.

However, they generally require a substantially increased number of

multipliers. For a specific filter design, you should compute the actual

filter response with quantized coefficients, and then modify it if

necessary.

72

Page 73: DSP_FOEHU - Lec 07 - Digital Filters

Coefficient quantization

In dedicated hardware, such as custom ICs, where there are significant

benefits from reducing coefficient wordlengths, discrete optimization

can be used to search for the finite-wordlength filter with the closest

response to a given specification.

Some discrete optimization algorithms, including Genetic Algorithms

and Simulated Annealing, are available in software libraries

73

Page 74: DSP_FOEHU - Lec 07 - Digital Filters

74