Digital Filters. Analog versus Digital DR

Digital Filters • Advantages of digital filters – – – – Dynamic range No coefficient errors, aging Programmable Always work on first silicon if … • ...
Author: Irma Merritt
3 downloads 0 Views 113KB Size
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

A/D DSP

EECS 247 Lecture 11: Digital Filters

© 2002 B. Boser 1

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

4

3

2

1

0

+6dB DR 16 15 14 13 12 11 10 9

A/D DSP

EECS 247 Lecture 11: Digital Filters

8

7

6

5

© 2002 B. Boser 2

Analog versus Digital DR For comparison, consider summing the outputs of 4 identical analog circuits with identical inputs: vIN A1

A2

A3

A4

Σ vOUT A/D DSP

EECS 247 Lecture 11: Digital Filters

© 2002 B. Boser 3

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

A2

Signal grows 4X Noise grows 2X +6dB Dynamic Range A/D DSP

EECS 247 Lecture 11: Digital Filters

A3

A4

Σ vOUT © 2002 B. Boser 4

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? A/D DSP

EECS 247 Lecture 11: Digital Filters

© 2002 B. Boser 5

• 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

A/D DSP

EECS 247 Lecture 11: Digital Filters

Dynamic Range (dB | Bits)

ADC Dynamic Range 140

23

120

20

100

16

80

13

60

10

40

6

20

3

104 108 106 ADC Sampling Frequency (Hz)

© 2002 B. Boser 6

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



Dynamic Range (dB)



140

1 GHz, 30dB DR levels are much more forgiving and the performance gap narrows

A/D DSP

120 100 80 60 40

embedded ADCs

20

104 108 106 ADC Sampling Frequency (Hz)

EECS 247 Lecture 11: Digital Filters

© 2002 B. Boser 7

ADC Dynamic Range 140 • 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”

Dynamic Range (dB)



120 100 80 60 40

embedded ADCs

20

104 108 106 ADC Sampling Frequency (Hz)

A/D DSP

EECS 247 Lecture 11: Digital Filters

© 2002 B. Boser 8

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

A/D DSP

EECS 247 Lecture 11: Digital Filters

© 2002 B. Boser 9

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) A/D DSP

EECS 247 Lecture 11: Digital Filters

© 2002 B. Boser 10

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

A/D DSP

EECS 247 Lecture 11: Digital Filters

© 2002 B. Boser 11

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) +…] A/D DSP

EECS 247 Lecture 11: Digital Filters

© 2002 B. Boser 12

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]

• The constant group delay of the symmetric coefficient FIR filter is obvious: θ(ω) = - ωNT/2

τGR = NT/2 half the filter impulse response duration

A/D DSP

EECS 247 Lecture 11: Digital Filters

© 2002 B. Boser 13

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

A/D DSP

EECS 247 Lecture 11: Digital Filters

© 2002 B. Boser 14

Coefficient Symmetry • Conjugate pairs of unit circle zeroes provide linear phase:

θ

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

A/D DSP

EECS 247 Lecture 11: Digital Filters

© 2002 B. Boser 15

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 A/D DSP

EECS 247 Lecture 11: Digital Filters

© 2002 B. Boser 16

FIR Filter Phase Response • Another interesting case involves antisymmetric filter coefficients: H(z) = a0 + a1z-1 + a2z-2 +…- a2z2-N - a1z1-N - a0z-N

• It’s easy to show that H(ejωT) = e-jωNT/2ejπ/2 [ 2a0sin(ωNT/2) + more sin terms]

A/D DSP

EECS 247 Lecture 11: Digital Filters

© 2002 B. Boser 17

FIR Filter Phase Response • For the antisymmetric coefficient case θ(ω) =

π - ωNT/2 2

τGR = NT/2

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

A/D DSP

EECS 247 Lecture 11: Digital Filters

© 2002 B. Boser 18

Linear Phase FIR Example fs = 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); 0 [N,fo,ao,W]=remezord( … -10 [Fp Fs],[1 0],[x y],fs); -20 b = remez(N, fo, ao, W); -30 Hr = tf(b, 1, 1/fs); -40 Hr = Hr / 10^(rpass/40);

0

Magnitude [dB]

-0.02 -0.04 -0.06 -0.08 -0.1 -0.12 2

4 6 Frequency 0...f /2 [Hz] s

8

10 4

x 10

Magnitude [dB]

0

-50 -60 -70

A/D DSP

0

1

2 3 Frequency 0...f /2 [Hz] s

EECS 247 Lecture 11: Digital Filters

4

5 5

x 10

© 2002 B. Boser 19

z-Plane Pole-Zero Map 1 0.8 0.6

Imaginary Axis

0.4 0.2 0 -0.2 -0.4 -0.6 -0.8 -1 -2

-1

0

1

2

3

4

5

Real Axis

A/D DSP

EECS 247 Lecture 11: Digital Filters

© 2002 B. Boser 20

Phase Response 2500

Linear?

Phase [degrees]

2000

1500

1000

500

0

A/D DSP

0

1

2 3 Frequency [Hz]

4

5 5

x 10

EECS 247 Lecture 11: Digital Filters

© 2002 B. Boser 21

FIR / IIR Comparison 0.04

91st

FIR IIR

0.02

order linear phase FIR

0

Magnitude [dB]

-0.02

0

or

-0.04 -0.06

FIR IIR

-0.08 -0.1

-10

-0.12

order elliptic IIR

Magnitude [dB]

-0.14

7th

-20

-0.16

1

2

3

4 5 6 7 Frequency 0...f /2 [Hz] s

8

9

10 4

x 10

-30 -40 -50 -60 -70

A/D DSP

EECS 247 Lecture 11: Digital Filters

0

1

2 3 Frequency 0...f /2 [Hz] s

4

5 5

x 10

© 2002 B. Boser 22

FIR Coefficient Rounding 0

8 Bits 16 Bits 24 Bits Floating Point

-20

Magnitude [dB]

-40

-60

-80

-100

-120 0

A/D DSP

1

2 3 Frequency 0...f /2 [Hz] s

EECS 247 Lecture 11: Digital Filters

4

5 5

x 10

© 2002 B. Boser 23

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

A/D DSP

EECS 247 Lecture 11: Digital Filters

© 2002 B. Boser 24

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

A/D DSP

EECS 247 Lecture 11: Digital Filters

© 2002 B. Boser 25

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… A/D DSP

EECS 247 Lecture 11: Digital Filters

© 2002 B. Boser 26

2nd-Order Bandstop Filter • Bandstop filters have transfer functions: z −2 − z −1 ( 2 cos Θ) + 1 r z − z −1 ( 2r cos Θ) + 1 2πf P Θ≈ fs πf r ≈1− P Qf s

H (z) =

2 −2

θ

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

EECS 247 Lecture 11: Digital Filters

© 2002 B. Boser 27

2nd-Order Bandstop Filter • Bandstop design specifications: – fS=1MHz – fP=20kHz – QP=100

A/D DSP

EECS 247 Lecture 11: Digital Filters

θ

© 2002 B. Boser 28

Direct Form Realization Y (z) z −2 − z −1 (2 cos Θ) + 1 = 2 −2 X ( z ) r z − z −1 (2 r cos Θ) + 1

[

]

[

]

Y ( z ) r 2 z −2 − z −1 ( 2 r cos Θ) + 1 = X ( z ) z −2 − z −1 ( 2 cos Θ) + 1 yk −2 r 2 z −2 − yk −1 ( 2 r cos Θ) + yk = xk −2 − xk −1 ( 2 cos Θ) + xk

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. A/D DSP

EECS 247 Lecture 11: Digital Filters

© 2002 B. Boser 29

2nd-Order Bandstop Filter • We can build a direct form bandstop this way (method #1):

yk = xk − xk −1 ( 2 cos Θ) + xk −2 + yk −1 ( 2 r cos Θ) − yk −2 r 2 z −2 1442443 intermedia te result 1 444 14 44 4 24 3 intermedia te result 2 14444444244444443 intermedia te result 3

• Or this way (method #2):

yk = yk −1 ( 2 r cos Θ) − yk −2 r 2 z −2 + xk − xk −1 ( 2 cos Θ) + xk −2 • The order of addition matters if we overload in the middle! A/D DSP

EECS 247 Lecture 11: Digital Filters

© 2002 B. Boser 30

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 A/D DSP

EECS 247 Lecture 11: Digital Filters

© 2002 B. Boser 31

Method #1 Bandstop Responses 20 intermediate responses

Gain (dB)

0 complete bandstop - 20

- 40

- 60 0

100

200

300

400

500

Frequency (kHz) A/D DSP

EECS 247 Lecture 11: Digital Filters

© 2002 B. Boser 32

Method #1 Bandstop Responses 20 intermediate responses

Gain (dB)

0

- 20

12dB max. gain - 40

- 60 0

100

200

300

400

500

Frequency (kHz) A/D DSP

EECS 247 Lecture 11: Digital Filters

© 2002 B. Boser 33

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 … A/D DSP

EECS 247 Lecture 11: Digital Filters

© 2002 B. Boser 34

Method #1 Bandstop Responses 20

Gain (dB)

0

- 20

no “high Q surprises” - 40

- 60 19.5

20.5 Frequency (kHz)

A/D DSP

EECS 247 Lecture 11: Digital Filters

© 2002 B. Boser 35

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 A/D DSP

EECS 247 Lecture 11: Digital Filters

© 2002 B. Boser 36

Method #2 Bandstop Responses 0

Gain (dB)

- 50

9.5dB max. gain

- 100

- 150

- 200 0

100

200

300

400

500

Frequency (kHz) A/D DSP

EECS 247 Lecture 11: Digital Filters

© 2002 B. Boser 37

Method #2 Bandstop Responses 20

Gain (dB)

0

- 20

- 40

- 60 19.5

20.5 Frequency (kHz)

A/D DSP

EECS 247 Lecture 11: Digital Filters

© 2002 B. Boser 38

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 A/D DSP

EECS 247 Lecture 11: Digital Filters

© 2002 B. Boser 39

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 lateto-market because of such easy-to-avoid errors! A/D DSP

EECS 247 Lecture 11: Digital Filters

© 2002 B. Boser 40

Biquad Quantization Noise • Suppose we build our bandstop difference equation with B-bit registers and a BxB = 2B hardware multiplier:

y k = Gx k − Gx k −1 ( 2 cos Θ) + Gx k −2 + y k −1 ( 2 r cos Θ) − yk −2 r 2 z −2 • 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 A/D DSP

EECS 247 Lecture 11: Digital Filters

© 2002 B. Boser 41

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 A/D DSP

EECS 247 Lecture 11: Digital Filters

© 2002 B. Boser 42

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 A/D DSP

EECS 247 Lecture 11: Digital Filters

© 2002 B. Boser 43

Limit Cycles • We’ll look for limit cycles in the bandpass filter: H(z) =

0.125 (z-2-1) z-2 + 0.75

• Note that this filter passes frequencies near fS/4 A/D DSP

EECS 247 Lecture 11: Digital Filters

© 2002 B. Boser 44

Bandpass Magnitude Response 20

Gain (dB)

0

- 20

- 40

- 60 0

A/D DSP

100

200 300 Frequency (kHz)

EECS 247 Lecture 11: Digital Filters

400

500

© 2002 B. Boser 45

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…

A/D DSP

EECS 247 Lecture 11: Digital Filters

© 2002 B. Boser 46

Bandpass Transient Response 10

floating point filter

Filter Output

5

0

-5

rounded filter - 10 0

10

20

30

40

50

Sample Number (time) A/D DSP

EECS 247 Lecture 11: Digital Filters

© 2002 B. Boser 47

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

A/D DSP

EECS 247 Lecture 11: Digital Filters

© 2002 B. Boser 48

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! A/D DSP

EECS 247 Lecture 11: Digital Filters

© 2002 B. Boser 49