02.10.2019 Views

UploadFile_6417

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Quantization of Filter Coefficients 277<br />

To determine the exact locations of the changed poles, consider the changed<br />

denominator<br />

ˆD (z) =1−0.875z −1 +0.75z −2 = ( 1 − 0.866e j0.331π z −1)( 1 − 0.866e −j0.331π z −1)<br />

Thus, the changed pole locations are ˆp 1 =0.866e j0.331π =ˆp ∗ 2. Then |△p 1| =<br />

∣ 0.9e iπ/3 − 0.866e i0.331π∣ ∣ =0.0344, which agrees with (6.75).<br />

□<br />

Analysis using MATLAB To investigate the effect of coefficient<br />

quantization on filter behavior, MATLAB is an ideal vehicle. Using functions<br />

developed in previous sections, we can obtain quantized coefficients<br />

and then study such aspects as pole-zero movements, frequency response,<br />

or impulse response. We will have to represent all filter coefficients using<br />

the same number of integer and fraction bits. Hence instead of quantizing<br />

each coefficient separately, we will develop the function, QCoeff,<br />

for coefficient quantization. This function implements quantization using<br />

rounding operation on sign-magnitude format. Although similar functions<br />

can be written for truncation as well as for other formats, we will analyze<br />

the effects using the Qcoeff function as explained previously.<br />

function [y,L,B] = QCoeff(x,N)<br />

% [y,L,B] = QCoeff(x,N)<br />

% Coefficient Quantization using N=1+L+B bit Representation<br />

% with Rounding operation<br />

% y: quantized array (same dim as x)<br />

% L: number of integer bits<br />

% B: number of fractional bits<br />

% x: a scalar, vector, or matrix<br />

% N: total number of bits<br />

xm = abs(x);<br />

L = max(max(0,fix(log2(xm(:)+eps)+1))); % Integer bits<br />

if (L > N)<br />

errmsg = [’ *** N must be at least ’,num2str(L),’ ***’]; error(errmsg);<br />

end<br />

B = N-L;<br />

% Fractional bits<br />

y = xm./(2^L); y = round(y.*(2^N)); % Rounding to N bits<br />

y = sign(x).*y*(2^(-B));<br />

% L+B+1 bit representation<br />

The Qcoeff function represents each coefficient in the x array using<br />

N+1-bit (including the sign bit) representation. First, it determines the<br />

number of bits L needed for integer representation for the magnitude-wise<br />

largest coefficient, and then it assigns N-L bits to the fraction part. The<br />

resulting number is returned in B. Thus all coefficients have the same bit<br />

pattern L+B+1. Clearly, N ≥ L.<br />

Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).<br />

Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!