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.

582 Chapter 10 ROUND-OFF EFFECTS IN DIGITAL FILTERS<br />

Solution<br />

We will need the quantities ∑ |h(n)| 2 and ( ∑ |h(n)|) 2 . These quantities should<br />

be computed using 12-bit quantization of the filter coefficients. These values<br />

using the quantized numbers are ∑ |h(n)| 2 =0.2599 and ( ∑ |h(n)|) 2 =1.Using<br />

(10.88), the output SNR is 65.42 dB for 5 multipliers and is 72.41 dB for 1<br />

multiplier. The following MATLAB script evaluates these and other quantities.<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 Distribution<br />

h = [0.1,0.2,0.4,0.2,0.1]; % Filter parameters<br />

M = length(h);<br />

% Local variables<br />

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

BB = 2^B;<br />

% useful factor in quantization<br />

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

bins = [-K+0.5:1:K-0.5]; % Bin values from -K to K<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 />

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

Xm = 1/sum(abs(h));<br />

% Scaling factor<br />

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

% Filter output without multiplication quantization<br />

yn = filter(h,1,xn); % output using filter routine<br />

% Filter output with multi quant (5 multipliers)<br />

x1 = [zeros(1,1),xn(1:N-1)]; x2 = [zeros(1,2),xn(1:N-2)];<br />

x3 = [zeros(1,3),xn(1:N-3)]; x4 = [zeros(1,4),xn(1:N-4)];<br />

h0x0 = QFix(h(1)*xn,B,’round’,’twosc’);<br />

h1x1 = QFix(h(2)*x1,B,’round’,’twosc’);<br />

h2x2 = QFix(h(3)*x2,B,’round’,’twosc’);<br />

h3x3 = QFix(h(4)*x3,B,’round’,’twosc’);<br />

h4x4 = QFix(h(5)*x4,B,’round’,’twosc’);<br />

yq = h0x0+h1x1+h2x2+h3x3+h4x4;<br />

yq = QFix(yq,B,’round’,’satur’);<br />

% Output Error Analysis<br />

qn = yn-yq;<br />

varyn = var(yn); varqn = var(qn);<br />

qqmax = max(qn); qqmin = min(qn);<br />

qnmax = max(abs([qqmax,qqmin]));<br />

qnavg = mean(qn); qnstd = std(qn);<br />

% Outout error sequence<br />

% Signal and noise power<br />

% Maximun and minimum of the error<br />

% Absolute maximum range of the error<br />

% Mean and std dev of the error<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!