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.

Round-off Effects in IIR Digital Filters 573<br />

10.2.7 ANALYSIS USING MATLAB<br />

We will again simulate round-off errors using the MATLAB function QFix<br />

with quantization mode ’round’ and overflow mode ’satur’. Since a<br />

MAC architecture is assumed, we do not have to quantize the intermediate<br />

results and worry about overflow. Only the final sum needs to be quantized<br />

with saturation. These operations are also simulated in sequential fashion,<br />

which has an impact on execution speed. The simulation steps for the<br />

2nd-order filter are detailed in the following example.<br />

□ EXAMPLE 10.12 Consider the model given in Figure 10.22d. We will simulate this model in<br />

MATLAB and investigate its output error characteristics. Let r = 0.9 and<br />

θ = π/3, from which filter parameters are computed and quantized to B bits.<br />

The input signal is uniformly distributed over the [−1, +1] interval and is also<br />

quantized to B bits prior to filtering. The scaling factor X max is determined<br />

using (10.58), which can be obtained in MATLAB by computing the impulse<br />

response for a sufficiently large number of samples. Using 100, 000 signal samples<br />

and B =6bits, the following MATLAB script computes the true output SNR,<br />

the computed SNR, and the lower and upper bounds of the SNR.<br />

close all; clc;<br />

% Example Parameters<br />

B = 12;<br />

% # of fractional bits<br />

N = 100000;<br />

% # of samples<br />

xn = (2*rand(1,N)-1); % Input sequence - Uniform<br />

r = 0.9; theta = pi/3;% Pole locations<br />

% Computed Parameters<br />

p1 = r*exp(j*theta); % Poles<br />

p2 = conj(p1); %<br />

a = poly([p1,p2]); % Filter parameters<br />

hn = filter(1,a,[1,zeros(1,1000)]); % Imp res<br />

Xm = 1/sum(abs(hn)); % Scaling factor<br />

Xm_L = (1-r)*sin(theta); % Lower bound<br />

Xm_U = (1-r)*sqrt(1+r*r-2*r*cos(2*theta)); % Upper bound<br />

% Local variables<br />

bM = 7; DbM = 2^bM; % bin parameter<br />

BB = 2^B;<br />

% useful factor in quantization<br />

M = round(DbM/2); % Half number of bins<br />

bins = [-M+0.5:1:M-0.5]; % Bin values from -M to M<br />

Q = bins/DbM; % Normalized bins<br />

YTN = 2^(-bM);<br />

% Ytick marks interval<br />

YLM = 4*YTN;<br />

% Yaxis limit<br />

% Quantize the input and the filter coefficients<br />

xn = QFix(Xm*xn,B,’round’,’satur’); % Scaled Input quant B bits<br />

a = QFix(a,B,’round’,’satur’); % a quantized to B bits<br />

a1 = a(2); a2 = a(3);<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!