25
EECS 247 Lecture 11: Digital Filters © 2002 B. Boser 1 A/D DSP Digital Filters Advantages of digital filters Dynamic range No coefficient errors, aging – Programmable Always work on first silicon if … FIR filters Linear phase – Synthesis FIR / IIR comparison Implementation issues Coefficient rounding Intermediate result dynamic range Limit cycles EECS 247 Lecture 11: Digital Filters © 2002 B. Boser 2 A/D DSP Analog versus Digital DR It’s much less expensive to add dynamic range to digital circuits than analog circuits To double the dynamic range of a digital datapath, we need to add only a bit to an already-wide datapath: 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 16 +6dB DR

Digital Filters - inst.eecs.berkeley.edu

  • Upload
    others

  • View
    17

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Digital Filters - inst.eecs.berkeley.edu

EECS 247 Lecture 11: Digital Filters © 2002 B. Boser 1A/DDSP

Digital Filters• Advantages of digital filters

– Dynamic range– No coefficient errors, aging– Programmable– Always work on first silicon if …

• FIR filters– Linear phase– Synthesis

• FIR / IIR comparison• Implementation issues

– Coefficient rounding– Intermediate result dynamic range– Limit cycles

EECS 247 Lecture 11: Digital Filters © 2002 B. Boser 2A/DDSP

Analog versus Digital DR• It’s much less expensive to add dynamic range to

digital circuits than analog circuits• To double the dynamic range of a digital datapath,

we need to add only a bit to an already-wide datapath:

15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 016

+6dB DR

Page 2: Digital Filters - inst.eecs.berkeley.edu

EECS 247 Lecture 11: Digital Filters © 2002 B. Boser 3A/DDSP

Analog versus Digital DRFor comparison, consider summing the outputs of 4 identical analog circuits with identical inputs:

A1 A2 A3 A4

Σ

vOUT

vIN

EECS 247 Lecture 11: Digital Filters © 2002 B. Boser 4A/DDSP

Analog versus Digital DRAnalog noise is typically uncorrelated in each of the blocks A1-A4:

A1 A2 A3 A4

Σ

vOUT

vIN

Signal grows 4XNoise grows 2X+6dB Dynamic Range

Page 3: Digital Filters - inst.eecs.berkeley.edu

EECS 247 Lecture 11: Digital Filters © 2002 B. Boser 5A/DDSP

Analog versus Digital DR• Doubling analog DR is very expensive:

– 4X the power– 4X the area

• Doubling digital DR is relatively cheap,– And cost/function decreases by 29%/year (3dB/year)!

• Practical circuits tolerate very little loss of DR due to finite datapath precision in their DSP sections– Analog dynamic range is too precious to lose– Digital DR loss of 5% (~ 0.4dB) of total noise power is typical

• Why use analog filters at all?

EECS 247 Lecture 11: Digital Filters © 2002 B. Boser 6A/DDSP

ADC Dynamic Range

• The figure shows the DR of the best standalone ADCs in 2000

• Dynamic range decreases as converter bandwidth increases

• From 1975-1995, ADC performance at any sampling frequency improved by 2dB/year

ADC Sampling Frequency (Hz)104 106 108

40

80

60

120

140

100

20

Dyn

amic

Ran

ge (d

B |

Bits

)

6

13

10

20

23

16

3

Page 4: Digital Filters - inst.eecs.berkeley.edu

EECS 247 Lecture 11: Digital Filters © 2002 B. Boser 7A/DDSP

ADC Dynamic Range• ADCs embedded in IC “Systems

on a Chip” (SoCs) have less DR than the best standalone ADCs

• The embedded ADC performance level is shown in red

• Analog-digital crosstalk and design risk issues limit embedded ADC DR to about 100dB

• 1 GHz, 30dB DR levels are much more forgiving and the performance gap narrows ADC Sampling Frequency (Hz)

104 106 108

40

80

60

120

140

100

20D

ynam

ic R

ange

(dB

)

embedded ADCs

EECS 247 Lecture 11: Digital Filters © 2002 B. Boser 8A/DDSP

ADC Dynamic Range

• Minimization of analog signal processing is a key goal of mixed-signal IC architecture

• However, analog signal processing is almost unavoidable “above the red line”

ADC Sampling Frequency (Hz)104 106 108

40

80

60

120

140

100

20

Dyn

amic

Ran

ge (d

B)

embedded ADCs

Page 5: Digital Filters - inst.eecs.berkeley.edu

EECS 247 Lecture 11: Digital Filters © 2002 B. Boser 9A/DDSP

Practical Constraints

• Only few ADC design teams in the world can produce “green line” dynamic range

• If your SoC architecture requires one of those teams to succeed, think again!

• Mixed-signal SoC architectures fail when their architects choose to ignore long-established, empirically-proven performance scaling laws

EECS 247 Lecture 11: Digital Filters © 2002 B. Boser 10A/DDSP

FIR Filters• Only finite zeros

• Linear phase if coefficients are symmetric

• Implement with delays, multipliers, adders

• Lack of good analog delays prevents widespread use of analog FIR filters

• Good synthesis tools (e.g. Remez-Exchange algorithm)

Page 6: Digital Filters - inst.eecs.berkeley.edu

EECS 247 Lecture 11: Digital Filters © 2002 B. Boser 11A/DDSP

FIR Filter Phase Response

• Consider the Nth-order FIR filter with transfer function:

H(z) = a0 + a1z-1 + a2z-2 +…+ aN-2z2-N + aN-1z1-N + aNz-N

• Suppose the filter coefficients are symmetric about the middle term, i.e.:

H(z) = a0 + a1z-1 + a2z-2 +…+ a2z2-N + a1z1-N + a0z-N

EECS 247 Lecture 11: Digital Filters © 2002 B. Boser 12A/DDSP

FIR Filter Phase Response

H(z) = a0 + a1z-1 + a2z-2 +…+ a2z2-N + a1z1-N + a0z-N

= a0 (1+z-N) + a1 (z-1+z1-N) + a2 (z-2 + z2-N) +…

= a0z-N/2(zN/2+z-N/2) + a1z-N/2 (z-1+N/2+z1-N/2) +

+ a2z-N/2 (z-2+N/2 + z2-N/2) +…

= z-N/2[ a0(zN/2+z-N/2) + a1(z-1+N/2+z1-N/2) +

a2(z-2+N/2 + z2-N/2) +…]

Page 7: Digital Filters - inst.eecs.berkeley.edu

EECS 247 Lecture 11: Digital Filters © 2002 B. Boser 13A/DDSP

FIR Filter Phase Response• The term in brackets [] is a sum of cosine

terms with no phase shift:

H(ejωT) = e-jωNT/2 [ 2a0cos(ωNT/2) + more real cos terms]

θ(ω) = - ωNT/2 τGR = NT/2

• The constant group delay of the symmetric coefficient FIR filter is obvious:

half the filter impulse response duration

EECS 247 Lecture 11: Digital Filters © 2002 B. Boser 14A/DDSP

Coefficient Symmetry

• Three classes of zero groupings produce symmetric coefficients and linear phase

• The first is real axis zeroes at r and 1/r:

H(z) = z-2-(r+1/r)z-1+1

Page 8: Digital Filters - inst.eecs.berkeley.edu

EECS 247 Lecture 11: Digital Filters © 2002 B. Boser 15A/DDSP

Coefficient Symmetry

• Conjugate pairs of unit circle zeroes provide linear phase:

H(z) = z-2- 2z-1cos θ +1

θ

EECS 247 Lecture 11: Digital Filters © 2002 B. Boser 16A/DDSP

Coefficient Symmetry

• Finally, groups of four zeroes at re±jθ and (1/r)e±jθ provide linear phase

• The filter coefficients for these 4 zeroes are:

θ

1-2(r+1/r)cosθ

4+r2+1/r2

-2(r+1/r)cosθ1

Page 9: Digital Filters - inst.eecs.berkeley.edu

EECS 247 Lecture 11: Digital Filters © 2002 B. Boser 17A/DDSP

FIR Filter Phase Response

• Another interesting case involves antisymmetric filter coefficients:

• It’s easy to show that

H(z) = a0 + a1z-1 + a2z-2 +…- a2z2-N - a1z1-N - a0z-N

H(ejωT) = e-jωNT/2ejπ/2 [ 2a0sin(ωNT/2) + more sin terms]

EECS 247 Lecture 11: Digital Filters © 2002 B. Boser 18A/DDSP

FIR Filter Phase Response

• For the antisymmetric coefficient case

θ(ω) = - ωNT/2 τGR = NT/2π2

• It’s still linear phase, but with the frequency independent 90° phase shift characteristic of differentiators

Page 10: Digital Filters - inst.eecs.berkeley.edu

EECS 247 Lecture 11: Digital Filters © 2002 B. Boser 19A/DDSP

Linear Phase FIR Examplefs = 1e6;Fp = 0.10*fs; Fs = 0.13*fs;Rp = 0.1; Rs = 60;x = (10^(Rp/20)1)/(10^(Rp/20)+1); y = 10^(-Rs/20); [N,fo,ao,W]=remezord( …

[Fp Fs],[1 0],[x y],fs);b = remez(N, fo, ao, W);Hr = tf(b, 1, 1/fs);Hr = Hr / 10^(rpass/40);

0 1 2 3 4 5

x 105

-70

-60

-50

-40

-30

-20

-10

0

Frequency 0...fs/2 [Hz]

Mag

nitu

de [

dB]

0 2 4 6 8 10

x 104

-0.12

-0.1

-0.08

-0.06

-0.04

-0.02

0

Frequency 0...fs/2 [Hz]

Mag

nitu

de [

dB]

EECS 247 Lecture 11: Digital Filters © 2002 B. Boser 20A/DDSP

z-Plane

-2 -1 0 1 2 3 4 5-1

-0.8

-0.6

-0.4

-0.2

0

0.2

0.4

0.6

0.8

1Pole-Zero Map

Real Axis

Imag

inar

y A

xis

Page 11: Digital Filters - inst.eecs.berkeley.edu

EECS 247 Lecture 11: Digital Filters © 2002 B. Boser 21A/DDSP

Phase Response

0 1 2 3 4 5

x 105

0

500

1000

1500

2000

2500

Frequency [Hz]

Pha

se [

degr

ees]

Linear?

EECS 247 Lecture 11: Digital Filters © 2002 B. Boser 22A/DDSP

FIR / IIR Comparison

91st order linear phase FIR

or

7th order elliptic IIR

0 1 2 3 4 5

x 105

-70

-60

-50

-40

-30

-20

-10

0

Frequency 0...fs /2 [Hz]

Mag

nitu

de [

dB]

FIRIIR

1 2 3 4 5 6 7 8 9 10

x 104

-0.16

-0.14

-0.12

-0.1

-0.08

-0.06

-0.04

-0.02

0

0.02

0.04

Frequency 0...fs/2 [Hz]

Mag

nitu

de [

dB]

FIRIIR

Page 12: Digital Filters - inst.eecs.berkeley.edu

EECS 247 Lecture 11: Digital Filters © 2002 B. Boser 23A/DDSP

FIR Coefficient Rounding

0 1 2 3 4 5

x 105

-120

-100

-80

-60

-40

-20

0

Frequency 0...fs /2 [Hz]

Mag

nitu

de

[dB

]

8 Bits16 Bits24 BitsFloating Point

EECS 247 Lecture 11: Digital Filters © 2002 B. Boser 24A/DDSP

FIR Coefficient Precision

• Finite precision FIR filters add transfer functions of two filters – The infinite precision FIR filter– A rounding error FIR filter

• The infinite precision FIR dominates the passband response

• The rounding error FIR filter sets stopband attenuation when the infinite precision FIR response is much smaller

Page 13: Digital Filters - inst.eecs.berkeley.edu

EECS 247 Lecture 11: Digital Filters © 2002 B. Boser 25A/DDSP

FIR Coefficient Precision• Random rounding errors transform to white

“stopband noise”– Stopband attenuation increases by about 6dB for each bit of

coefficient precision

• If you don’t like the highest bump in the stopband response, generate a new pattern of rounding error– Use slightly different dc gain– Or slightly different Parks-McClellan (remez) bands

• Trial and error can improve filter stopbands by several dB at a given coefficient precision

EECS 247 Lecture 11: Digital Filters © 2002 B. Boser 26A/DDSP

Filter Dynamic Range

• Digital filters need more numeric dynamic range than the signals they process– They must not overload– They must not surprise you with quantization noise

• Digital multiplier/accumulators are multiplexed– Difference equations are added up term-by-term, giving us

“intermediate transfer functions” to worry about– Intermediate overload is as bad as overload

• Let’s look at an IIR bandstop filter example…

Page 14: Digital Filters - inst.eecs.berkeley.edu

EECS 247 Lecture 11: Digital Filters © 2002 B. Boser 27A/DDSP

2nd-Order Bandstop Filter

• Bandstop filters have transfer functions:

• Their gains are close to unity at both dc and fs/2

θ

s

P

s

P

Qff

r

ff

rzzrzz

zH

π

π

−≈

≈Θ

+Θ−+Θ−

= −−

−−

1

21)cos2(

1)cos2()( 122

12

EECS 247 Lecture 11: Digital Filters © 2002 B. Boser 28A/DDSP

2nd-Order Bandstop Filter

• Bandstop design specifications:– fS=1MHz– fP=20kHz– QP=100

θ

Page 15: Digital Filters - inst.eecs.berkeley.edu

EECS 247 Lecture 11: Digital Filters © 2002 B. Boser 29A/DDSP

Direct Form Realization

[ ] [ ]

kkkkkk xxxyryzry

zzzXrzzrzY

+Θ−=+Θ−

+Θ−=+Θ−

−−−−

−−−−

)cos2()cos2(

1)cos2()(1)cos2()(

12122

2

12122

1)cos2(1)cos2(

)()(

122

12

+Θ−+Θ−

= −−

−−

rzzrzz

zXzY

Note: Direct form realizations are not ideal for higher order IIR filters. Lattice filters (and variants), which simulate LC ladders, are less susceptible to finite coefficient precision and dynamic range.

EECS 247 Lecture 11: Digital Filters © 2002 B. Boser 30A/DDSP

2nd-Order Bandstop Filter

• We can build a direct form bandstop this way (method #1):

• Or this way (method #2):

• The order of addition matters if we overload in the middle!

222

3result teintermedia

1

2result teintermedia

2

1result teintermedia

1 )cos2()cos2( −−−−− −Θ++Θ−= zryryxxxy kkkkkk

4444444 34444444 214444 34444 21

44 344 21

2122

21 )cos2()cos2( −−−

−− +Θ−+−Θ= kkkkkk xxxzryryy

Page 16: Digital Filters - inst.eecs.berkeley.edu

EECS 247 Lecture 11: Digital Filters © 2002 B. Boser 31A/DDSP

2nd-Order Bandstop Filter

• Proceeding from left to right, the difference equation generates 3 intermediate transfer functions plus the complete bandstop transfer function

• All 4 of these transfer function magnitude responses for method 1 are shown on the next slide

EECS 247 Lecture 11: Digital Filters © 2002 B. Boser 32A/DDSP

Method #1 Bandstop Responses

Frequency (kHz)

Gai

n (d

B)

20

0

- 20

- 40

- 600 100 200 300 400 500

intermediate responses

complete bandstop

Page 17: Digital Filters - inst.eecs.berkeley.edu

EECS 247 Lecture 11: Digital Filters © 2002 B. Boser 33A/DDSP

Method #1 Bandstop Responses

12dB max. gain

Frequency (kHz)

Gai

n (d

B)

20

0

- 20

- 40

- 600 100 200 300 400 500

intermediate responses

EECS 247 Lecture 11: Digital Filters © 2002 B. Boser 34A/DDSP

Method #1 Bandstop Responses

• The complete bandstop filter never exceeds unity gain for sinusoidal inputs

• Intermediate gains exceed 12dB– That’s 2-bits above the input MSB

• Let’s examine the area of the notch in more detail …

Page 18: Digital Filters - inst.eecs.berkeley.edu

EECS 247 Lecture 11: Digital Filters © 2002 B. Boser 35A/DDSP

Method #1 Bandstop Responses

Frequency (kHz)

Gai

n (d

B)

19.5 20.5

20

0

- 20

- 40

- 60

no “high Q surprises”

EECS 247 Lecture 11: Digital Filters © 2002 B. Boser 36A/DDSP

Method #2 Bandstop Responses

• Next, we’ll examine all the intermediate transfer functions for the method #2 difference equation

• The following figures show significantly different intermediate frequency responses and somewhat lower maximum intermediate gains

Page 19: Digital Filters - inst.eecs.berkeley.edu

EECS 247 Lecture 11: Digital Filters © 2002 B. Boser 37A/DDSP

Method #2 Bandstop Responses

Frequency (kHz)

Gai

n (d

B)

0

- 50

- 100

- 150

- 2000 100 200 300 400 500

9.5dB max. gain

EECS 247 Lecture 11: Digital Filters © 2002 B. Boser 38A/DDSP

Frequency (kHz)

Gai

n (d

B)

19.5 20.5

20

0

- 20

- 40

- 60

Method #2 Bandstop Responses

Page 20: Digital Filters - inst.eecs.berkeley.edu

EECS 247 Lecture 11: Digital Filters © 2002 B. Boser 39A/DDSP

Avoiding Overload

• Sinusoidal steady-state responses for intermediate results are easy to compute and provide useful insight, but sinusoidal inputs are “never” worst cases for overload

• Absolute values of filter impulse response coefficients can give worst-case conditions for overload and intermediate overload

EECS 247 Lecture 11: Digital Filters © 2002 B. Boser 40A/DDSP

Digital Filter Models

• The order of arithmetic operations in digital signal processing matters

• Digital filter models must be “cycle true”

• Unanticipated filter overloads are inexcusable design errors– Real-world chip developments must never be late-

to-market because of such easy-to-avoid errors!

Page 21: Digital Filters - inst.eecs.berkeley.edu

EECS 247 Lecture 11: Digital Filters © 2002 B. Boser 41A/DDSP

Biquad Quantization Noise• Suppose we build our bandstop difference equation with B-bit

registers and a BxB = 2B hardware multiplier:

• Build up the difference equation leaving partial results in a 2B-bit accumulator– Accumulate y(k)’s with a minimum number (i.e. 1) of rounding

operations– If each of the 5 products above is rounded to B-bits, you’ll have 5X

more quantization noise power

• Output noise from rounding operations can be large for high Q digital biquads

222121 )cos2()cos2( −

−−−− −Θ++Θ−= zryryGxGxGxy kkkkkk

EECS 247 Lecture 11: Digital Filters © 2002 B. Boser 42A/DDSP

Digital Filter Models

• Datapath rounding operations can degrade digital filter dynamic ranges by surprisingly large amounts

• Digital filter models must be “bit true”

• Bit true and cycle true models require that filter models (and modelers) provide exact test vectors for integrated digital filters

Page 22: Digital Filters - inst.eecs.berkeley.edu

EECS 247 Lecture 11: Digital Filters © 2002 B. Boser 43A/DDSP

Limit Cycles

• A disadvantage of digital IIR filters relative to digital FIR filters is that their responses get strange as they settle in response to transients

• As settling error approaches rounding error, offsets and oscillations can occur– Non-zero offsets lead to “dead zones”– Oscillations are called “limit cycles”

• A combination of rounding (or truncation) and feedback is required for limit cycles

EECS 247 Lecture 11: Digital Filters © 2002 B. Boser 44A/DDSP

Limit Cycles

• We’ll look for limit cycles in the bandpass filter:

• Note that this filter passes frequencies near fS/4

0.125 (z-2-1)

z-2 + 0.75H(z) =

Page 23: Digital Filters - inst.eecs.berkeley.edu

EECS 247 Lecture 11: Digital Filters © 2002 B. Boser 45A/DDSP

Frequency (kHz)

Gai

n (d

B)

20

0

- 20

- 40

- 600 100 200 300 400 500

Bandpass Magnitude Response

EECS 247 Lecture 11: Digital Filters © 2002 B. Boser 46A/DDSP

Bandpass Transient Response

• Let’s examine the bandpass filter’s response to the initial condition y(1)=y(2)=10

• The bandpass filter output should decay to 0– The floating point filter output does– The fixed point filter output doesn’t– Let’s take a look…

Page 24: Digital Filters - inst.eecs.berkeley.edu

EECS 247 Lecture 11: Digital Filters © 2002 B. Boser 47A/DDSP

Sample Number (time)

Filte

r O

utpu

t

10

5

0

- 5

- 100 10 20 30 40 50

Bandpass Transient Response

floating point filter

rounded filter

EECS 247 Lecture 11: Digital Filters © 2002 B. Boser 48A/DDSP

Limit Cycles

• This bandpass filter limit cycle oscillation occurs right at fs/4– Right in the middle of the filter passband– Could this be a low-level input to the filter at fs/4?

• IIR filter designers must evaluate and be wary of limit cycle oscillations

Page 25: Digital Filters - inst.eecs.berkeley.edu

EECS 247 Lecture 11: Digital Filters © 2002 B. Boser 49A/DDSP

Digital Filter Models

• Bit true and cycle true digital filter models allow simulation and evaluation of:– Overload and intermediate overload– Quantization noise– Limit cycles and dead zones– Finite precision coefficient effects

• Spending time and money on silicon without such models is crazy!