02.10.2019 Views

UploadFile_6417

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

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

1<br />

y<br />

1<br />

y<br />

−1<br />

−2 2<br />

x<br />

−1<br />

1<br />

x<br />

−1<br />

(a) Two’s-complement Overflow<br />

FIGURE 10.9 Overflow characteristics used in Qfix<br />

−1<br />

(b) Saturation<br />

To simulate these two effects, we provide the function y = Qfix(x,B,<br />

’Qmode’,’Omode’). This function performs a fixed-point two’scomplement<br />

format quantization using (B+1)-bit representation so that<br />

the resulting number y is between −1 ≤ y < 1. The quantization mode,<br />

Qmode, iseither a rounding or a truncation operation. The overflow characteristic<br />

is provided in Omode. Using this function, we can study both<br />

types oflimit cycles.<br />

function [y] = QFix(x,B,Qmode,Omode)<br />

% Fixed-point Arithmetic using (B+1)-bit Representation<br />

% -----------------------------------------------------<br />

% [y] = QFix(x,B,Qmode,Omode)<br />

% y: Decimal equivalent of quantized x with values in [-1,1)<br />

% x: a real number array<br />

% B: Number of fractional bits<br />

% Qmode: Quantizer mode<br />

% ’round’: two’s-complement rounding characteristics<br />

% ’trunc’: Two’s complement truncation characteristics<br />

% Omode: Overflow mode<br />

% ’satur’: Saturation limiter<br />

% ’twosc’: Two’s-complement overflow<br />

% Quantization operation<br />

if strcmp(lower(Qmode), ’round’);<br />

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

elseif strcmp(lower(Qmode), ’trunc’);<br />

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

else<br />

error(’Use Qmode = "round" or "trunc"’);<br />

end;<br />

y = y*(2^(-B)); % (B+1)-bit representation<br />

% Overflow operation<br />

if strcmp(lower(Omode), ’satur’);<br />

y = min(y,1-2^(-B)); y = max(-1,y); % Saturation<br />

elseif strcmp(lower(Omode), ’twosc’);<br />

y = 2*(mod(y/2-0.5,1)-0.5); % Overflow<br />

else error(’Use Omode = "satur" or "twosc"’);<br />

end;<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!