quantization effects in digital...

31
Quantization Effects in Digital Filters

Upload: others

Post on 04-Jul-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Quantization Effects in Digital Filtersweb.eecs.utk.edu/~mjr/ECE506/PresentationSlides/QuantizationEffec… · Scaling Example ( ) 2 The maximum magnitude of H in this example is

Quantization Effects in Digital Filters

Page 2: Quantization Effects in Digital Filtersweb.eecs.utk.edu/~mjr/ECE506/PresentationSlides/QuantizationEffec… · Scaling Example ( ) 2 The maximum magnitude of H in this example is

In two's complement representation an exact number would have infinitely many bits (in general). When we limit the number of bitsto some finite value we have truncated all the lower-order bits.Suppose the number is 23/64. In two's complement binary thisis 0.0101110000... If we now limit the number of digits to 5 weget 0.0101 which represents exactly 20/64 or 5/16. The truncationerror is 5 /16 - 2

( )

3/ 64 3/ 64. If the exact number is 15 / 64,this is 1.110001000... in two's complement. Truncating to 5 bitsyields 1.1100 which exactly represents 1/ 4. The error is 1/ 4

15/ 64 1/ 64. This illustra

= − −

− −

− − = − tes that in two's complement truncation the error is always negative.

Distribution of Truncation Errors

Page 3: Quantization Effects in Digital Filtersweb.eecs.utk.edu/~mjr/ECE506/PresentationSlides/QuantizationEffec… · Scaling Example ( ) 2 The maximum magnitude of H in this example is

Distribution of Truncation Errors

In analysis of truncation errors we make the following assumptions.

1. The distribution of the errors is uniform over a range equivalent to the value of one LSB.

2. The error is a white noise process. That means that one error is not correlated with the next error or any other error.

3. The truncation error and the signal whose values are being truncated are not correlated.

Page 4: Quantization Effects in Digital Filtersweb.eecs.utk.edu/~mjr/ECE506/PresentationSlides/QuantizationEffec… · Scaling Example ( ) 2 The maximum magnitude of H in this example is

Quantization of Filter Coefficients

( ) 0

1

Let a digital filter's ideal transfer function be

H1

If the 's and 's are quantized, the poles and zeros move, creatinga new transfer function

Nk

kk

Nk

kk

b zz

a z

a b

=

=

=+

( ) 0

1

ˆˆ H

ˆ1

ˆˆwhere and .

Nk

kk

Nk

kk

k k k k k k

b zz

a z

a a a b b b

=

=

=+

= + ∆ = + ∆

Page 5: Quantization Effects in Digital Filtersweb.eecs.utk.edu/~mjr/ECE506/PresentationSlides/QuantizationEffec… · Scaling Example ( ) 2 The maximum magnitude of H in this example is

Quantization of Filter Coefficients

( ) ( )

( ) ( )

1 1

1

1 1

The denominator can be factored into the form

D 1 1

and, with quantization,

ˆ ˆ ˆ D 1 1

ˆwhere . T

NNk k

k kk k

NNk

k kk k

k k k

z a z p z

z a z p z

p p p

− −

= =

− −

= =

= + = −

= + = −

= + ∆

∑ ∏

∑ ∏

1 211 2

he errors in the pole locations are related to the errors in the coefficients by

N

i i i ii N k

kN k

p p p pp a a a aa a a a=

∂ ∂ ∂ ∂∆ = ∆ + ∆ + + ∆ = ∆

∂ ∂ ∂ ∂∑

Page 6: Quantization Effects in Digital Filtersweb.eecs.utk.edu/~mjr/ECE506/PresentationSlides/QuantizationEffec… · Scaling Example ( ) 2 The maximum magnitude of H in this example is

Quantization of Filter Coefficients

( ) ( )

( )( )

( )

The partial derivatives can be found from

D D

or

D /

D /

D 1

i i

i

i

i

i

k kz p z p

k z pi

k z p

k kz p

z z pa z a

z apa z z

za a

= =

=

=

=

⎡ ⎤ ⎡ ⎤∂ ∂ ∂= ×⎢ ⎥ ⎢ ⎥∂ ∂ ∂⎣ ⎦ ⎣ ⎦

⎡ ⎤∂ ∂⎣ ⎦∂=

∂ ⎡ ⎤∂ ∂⎣ ⎦

⎡ ⎤∂ ∂=⎢ ⎥∂ ∂⎣ ⎦

( ) ( )

1

1

1

D 1

ii

i i

Nk k k

k iz pk z p

N

qqz p z p

a z z p

zp z

z z

− − −

== =

== =

⎡ ⎤ ⎡ ⎤+ = =⎢ ⎥ ⎣ ⎦⎣ ⎦

⎡ ⎤⎡ ⎤∂ ∂= −⎢ ⎥⎢ ⎥∂ ∂⎣ ⎦ ⎣ ⎦

Page 7: Quantization Effects in Digital Filtersweb.eecs.utk.edu/~mjr/ECE506/PresentationSlides/QuantizationEffec… · Scaling Example ( ) 2 The maximum magnitude of H in this example is

Quantization of Filter Coefficients

( )

( ) ( ) ( )

12

1 12 2

1 11 1

The derivative of the qth factor is

1

and the overall derivative is

D1 1

ii

qq

N NN Nk k

q q ik kq qiz p q k q kz p

pp z

z z

z p pp z p pz z p

− −

= == == ≠ ≠=

∂⎡ ⎤− =⎢ ⎥∂⎣ ⎦

⎡ ⎤⎡ ⎤∂ ⎢ ⎥= − = −⎢ ⎥ ⎢ ⎥∂⎣ ⎦ ⎢ ⎥⎣ ⎦∑ ∏ ∏

( ) ( ) ( ) ( )12 1

1 11 1

D 1

i

N NN NNk

i i q k i qNk kq qi iz p q k q k

z p p p p p p pz p p

− −+

= == == ≠ ≠

⎡ ⎤∂= − = −⎢ ⎥∂⎣ ⎦

∑ ∑∏ ∏

Page 8: Quantization Effects in Digital Filtersweb.eecs.utk.edu/~mjr/ECE506/PresentationSlides/QuantizationEffec… · Scaling Example ( ) 2 The maximum magnitude of H in this example is

Quantization of Filter Coefficients

( )

( )

1 1

1

In the summation , for any k other than i,

the iterated product has a factor 0. Therefore

the only term in the k summation that survives is the term and

NN

k i qk q

q k

N

i q i iqq k

k p p p

p p p p

k i

= =≠

=≠

− − =

=

∑ ∏

( ) ( ) ( )11 1

D 1 1

i

N N

i i q i qN Nq qi iz p q k q k

zp p p p p

z p p+= == ≠ ≠

⎡ ⎤∂= − = −⎢ ⎥∂⎣ ⎦

∏ ∏

Page 9: Quantization Effects in Digital Filtersweb.eecs.utk.edu/~mjr/ECE506/PresentationSlides/QuantizationEffec… · Scaling Example ( ) 2 The maximum magnitude of H in this example is

Quantization of Filter Coefficients

( )

( )

1

1

1

Then

1

and

ki i

Nk

i qNqiq k

N kNk i

i Nk

i qqq k

p pa p p

p

a ppp p

=≠

=

=≠

∂=

∂ −

∆∆ =

∑∏

Page 10: Quantization Effects in Digital Filtersweb.eecs.utk.edu/~mjr/ECE506/PresentationSlides/QuantizationEffec… · Scaling Example ( ) 2 The maximum magnitude of H in this example is

Quantization of Filter Coefficients

( )1

The error in a pole location caused by errors in the coefficients is strongly

affected by the denominator factor which is a product of

differences between pole locations. So if the pole

N

i qqq k

p p=≠

−∏

s are closely spaced, the distances are small and the error in the pole location is large. Therefore systems with widely-spaced poles are less sensitive to errors in the coefficients.

Page 11: Quantization Effects in Digital Filtersweb.eecs.utk.edu/~mjr/ECE506/PresentationSlides/QuantizationEffec… · Scaling Example ( ) 2 The maximum magnitude of H in this example is

Quantization of Pole Locations

( ) 1 21 2

1 2 1

1 2

Consider a 2nd order system with transfer function1 H

1and quantize and with 5 bits. If we quantize in the range

1 1 and 2 2 we get a finite s

za z a z

a a aa a

− −=+ +

− ≤ < − ≤ < et of possible pole locations.

Page 12: Quantization Effects in Digital Filtersweb.eecs.utk.edu/~mjr/ECE506/PresentationSlides/QuantizationEffec… · Scaling Example ( ) 2 The maximum magnitude of H in this example is

Quantization of Pole LocationsIf we look at only pole locations for stable systems,

Obviously the pole locationsare non-uniformly distributed.

Page 13: Quantization Effects in Digital Filtersweb.eecs.utk.edu/~mjr/ECE506/PresentationSlides/QuantizationEffec… · Scaling Example ( ) 2 The maximum magnitude of H in this example is

Quantization of Pole LocationsConsider this alternative 2nd order system design.

H z( )= dz−1

1− c + jd( )z−1( )1− c − jd( )z−1( )

Pole locations are uniformlydistributed.

Page 14: Quantization Effects in Digital Filtersweb.eecs.utk.edu/~mjr/ECE506/PresentationSlides/QuantizationEffec… · Scaling Example ( ) 2 The maximum magnitude of H in this example is

Quantization of Pole Locations

Page 15: Quantization Effects in Digital Filtersweb.eecs.utk.edu/~mjr/ECE506/PresentationSlides/QuantizationEffec… · Scaling Example ( ) 2 The maximum magnitude of H in this example is

Quantization of Pole Locations

Page 16: Quantization Effects in Digital Filtersweb.eecs.utk.edu/~mjr/ECE506/PresentationSlides/QuantizationEffec… · Scaling Example ( ) 2 The maximum magnitude of H in this example is

Quantization of Pole Locations

Page 17: Quantization Effects in Digital Filtersweb.eecs.utk.edu/~mjr/ECE506/PresentationSlides/QuantizationEffec… · Scaling Example ( ) 2 The maximum magnitude of H in this example is

[ ][ ] [ ]

[ ] [ ] [ ] [ ] [ ]

[ ]

[ ]

Let y be the response at node to an input signal

x and let h be the impulse response at node .

y h x h x

Let the upper bound on x be .

y

k

k

k k k k km m

x

k

n k

n n k

n m n m m n m

n A

n A

∞ ∞

=−∞ =−∞

= − ≤ −

∑ ∑

[ ]

[ ] ( )

[ ]

x

x

h

If we want y to lie in the range -1,1 then1 h

guarantees that oveflow will not occur.

km

k

kn

m

n

An

=−∞

=−∞

<

Scaling to Prevent Overflow

Page 18: Quantization Effects in Digital Filtersweb.eecs.utk.edu/~mjr/ECE506/PresentationSlides/QuantizationEffec… · Scaling Example ( ) 2 The maximum magnitude of H in this example is

Scaling to Prevent Overflow

[ ]x

The condition1 h

may be too severe in some cases. Another type of scalingthat may be more appropriate in some cases is

1

kn

x

An

A

=−∞

<

=

( )[ ] ( )

0max H

where h H .

jk

jk k

e

n eπ

Ω

≤Ω≤

Ω←⎯→F

Page 19: Quantization Effects in Digital Filtersweb.eecs.utk.edu/~mjr/ECE506/PresentationSlides/QuantizationEffec… · Scaling Example ( ) 2 The maximum magnitude of H in this example is

Scaling to Prevent Overflow

Page 20: Quantization Effects in Digital Filtersweb.eecs.utk.edu/~mjr/ECE506/PresentationSlides/QuantizationEffec… · Scaling Example ( ) 2 The maximum magnitude of H in this example is

Scaling to Prevent Overflow

Page 21: Quantization Effects in Digital Filtersweb.eecs.utk.edu/~mjr/ECE506/PresentationSlides/QuantizationEffec… · Scaling Example ( ) 2 The maximum magnitude of H in this example is

Scaling ExampleAssume that the input signal x is white noise bounded between -1 and +1 and that all additions and multiplications are done using8-bit two’s complement arithmetic. Also let all numbers (signals and coefficients) be in the range -1 to 1.

( )1 2 2

1 2 2

1 0.5 0.5H1 0.2 0.15 0.2 0.15

z z z zzz z z z

− −

− −

− + − += =

+ − + −

Page 22: Quantization Effects in Digital Filtersweb.eecs.utk.edu/~mjr/ECE506/PresentationSlides/QuantizationEffec… · Scaling Example ( ) 2 The maximum magnitude of H in this example is

Scaling Example[ ][ ]

[ ]

1

2

0

1

Quantize the 's to 8 bits. 0.2353 0.2344 (0.0011110)

0.15 0.1562 (1.1101100)Scale and quantize the 's.

1.338 1.338/1.338 1 0.9922 (0.1111111)

1.1 1.1/1

KK Q

K Qv

v Q

v

= → →

= − → → −

= → = → →

= − → − [ ][ ]2

.338 0.8221 0.8281 (1.0010110)

0.5 0.5 /1.338 0.3737 0.3672 (0.0101111)

Q

v Q

= − → → −

= → = → →

Page 23: Quantization Effects in Digital Filtersweb.eecs.utk.edu/~mjr/ECE506/PresentationSlides/QuantizationEffec… · Scaling Example ( ) 2 The maximum magnitude of H in this example is

Scaling Example

Scaling the v’s scales the output signal but the input signal maystill need scaling to prevent overflow.

( ) ( ) ( )

( ) ( )( ) ( )

( ) ( )

02

1 22 2

1 22 0

1 1 21 2

1The exact transfer function is H where

1 0.2 0.15 . The actual , after quantizing the

's is 1 0.1978 0.1562 . 1,

0.2344 and 0.1562 0.1978

N

m mm

z v zz

z z z z

K z z z z

z z z z z

=

− −

− −

− − −

= ΒΑ

Α = + − Α

Α = + − Β =

Β = + Β = − + +

( )1 2

1 2

. Therefore the actual transfer function is

0.7407 0.7555 0.3672 H . 1 0.1978 0.1562

z zzz z

− −

− −

− +=

+ −

Page 24: Quantization Effects in Digital Filtersweb.eecs.utk.edu/~mjr/ECE506/PresentationSlides/QuantizationEffec… · Scaling Example ( ) 2 The maximum magnitude of H in this example is

Scaling Example

( )( )2

The maximum magnitude of H in this example is 2.882 and

the maximum magnitude of H is 1.5455. So the scaling factor

should be 1/ 2.882 0.347. The simplest scaling is by shifting right. In thi

j

j

e

e

Ω

Ω

=s case that would require a shift of two bits to the right to scale by

0.25. This is significanly less that 0.347 so a more complicated scaling might be preferred. We could instead scale by 0.25 0.0+ 625 0.03125

0.34375 by shifting two bits, then four bits and then 5 bits and adding the results.

+=

Page 25: Quantization Effects in Digital Filtersweb.eecs.utk.edu/~mjr/ECE506/PresentationSlides/QuantizationEffec… · Scaling Example ( ) 2 The maximum magnitude of H in this example is

Statistical Analysis of Quantization Effects

The exact estimation of quantization effects requires numericalsimulation and is not amenable to exact analytical methods. Butan approach that has proven useful is to treat the quantization noise effects as a random process problem. In doing this we getan approximate analytical estimate instead of an exact numericalsimulation. We do this by treating quantization noise as an addednoise signal in the system everywhere quantization occurs.

Page 26: Quantization Effects in Digital Filtersweb.eecs.utk.edu/~mjr/ECE506/PresentationSlides/QuantizationEffec… · Scaling Example ( ) 2 The maximum magnitude of H in this example is

Statistical Analysis of Quantization Effects

Page 27: Quantization Effects in Digital Filtersweb.eecs.utk.edu/~mjr/ECE506/PresentationSlides/QuantizationEffec… · Scaling Example ( ) 2 The maximum magnitude of H in this example is

Statistical Analysis of Quantization Effects

( )

The probability density function for quantization noise using two's complement representation is

1 , LSB 01 f .0 , otherwise LSB

The expected value of the quantization nois

Q

qq

− < <⎧= ⎨

⎩( )

( ) ( ) ( )

2 2

22 2 2 2 2

e is E LSB/ 2.

The variance of the quantization noise is LSB /12. Therefore

the mean-squared quantization noise is

E E LSB /12 LSB/ 2 LSB / 3

Q

Q

Q

Q Q

σ

σ

= −

=

= + = + − =

Page 28: Quantization Effects in Digital Filtersweb.eecs.utk.edu/~mjr/ECE506/PresentationSlides/QuantizationEffec… · Scaling Example ( ) 2 The maximum magnitude of H in this example is

Statistical Analysis of Quantization Effects

( )2

The power spectral density function for quantization noise using two's complement representation is G . It has an impulse of

strength LSB / 4 at 0 and is otherwise flat with a value inthe range 1/

Q F

F K=−

( ) ( ) ( ) ( )

( ) ( ) ( )

1/ 2 1/ 22 2

1/ 2 1/ 22 2

2

2 2

2 1/ 2. It repeats periodically outside this range.

E G LSB / 4

LSB / 4 LSB / 3Solving, LSB /12 and

G LSB /12 LSB / 4

Qk

Qk

F

Q F dF F k K dF

KK

F F k

δ

δ

=−∞− −

=−∞

< <

⎡ ⎤= = − +⎢ ⎥⎣ ⎦= + =

=

= + −

∑∫ ∫

Page 29: Quantization Effects in Digital Filtersweb.eecs.utk.edu/~mjr/ECE506/PresentationSlides/QuantizationEffec… · Scaling Example ( ) 2 The maximum magnitude of H in this example is

Statistical Analysis of Quantization Effects

( ) ( ) ( )2 2G LSB /12 LSB / 4 is the power spectral

density of both quantization noise sources. The power spectral densityof the quantization noise effect on the output signal is

Qk

F F kδ∞

=−∞

= + −∑

( ) ( ) ( )

( ) ( ) ( )

( ) ( ) ( )

( ) ( )( ) ( ) ( )

( )

y y,x y,

2 2

y,x x x y x y

2 2

y, y y y

2 2

x y y2 2x

G G G

where G G H G H

and G G H G H

Y Yand H and H

f

Q

f f Q f

j F j F

fj F j Ff

F F F

F F F

F F F

F Fe eF FQ F e a Q F e a

π π

π π

= +

= =

= =

= = = =− −

Page 30: Quantization Effects in Digital Filtersweb.eecs.utk.edu/~mjr/ECE506/PresentationSlides/QuantizationEffec… · Scaling Example ( ) 2 The maximum magnitude of H in this example is

Statistical Analysis of Quantization Effects

The two quantization noise sources have the same power spectraldensity and they are independent so the output quantization noiseis just twice what would be produced by one of them acting alone.

( )21/ 2 2

,y 21/ 2

22 1/ 22 2 2

21/ 2

22 2

,y 2

2 G

LSB 1 LSB 2 1 6

LSB 1 LSB 1Evaluating the integral, .2 1 6 1

j F

Q Q j F

j F

j F

Q

eP F dFe a

e dFa e a

Pa a

π

π

π

π

=−

⎛ ⎞= +⎜ ⎟− −⎝ ⎠

⎛ ⎞= +⎜ ⎟− −⎝ ⎠

Page 31: Quantization Effects in Digital Filtersweb.eecs.utk.edu/~mjr/ECE506/PresentationSlides/QuantizationEffec… · Scaling Example ( ) 2 The maximum magnitude of H in this example is

Statistical Analysis of Quantization Effects

22 2

,y 2

22

2

2

LSB 1 LSB 1In 2 1 6 1

LSB 1 is the effect of the expected value of the input 2 1

quantization noise andLSB 1 is the effect of the variance of the input quantization noise.

6 1Both

QPa a

a

a

⎛ ⎞= +⎜ ⎟− −⎝ ⎠

⎛ ⎞⎜ ⎟−⎝ ⎠

− are dependent on . The closer is to one, the larger the output

quantization noise.a a