360 likes | 483 Views
Signal to Noise and Numeric Range issues for Direct Form I & II IIR Filters on Modern Analog Devices and TI Digital Signal Processors. Presented at the 2004 comp.dsp conference Mark Allie Consulting LLC. Main Topics.
E N D
Signal to Noise and Numeric Range issues for Direct Form I & II IIR Filters on Modern Analog Devices and TI Digital Signal Processors Presented at the 2004 comp.dsp conference Mark Allie Consulting LLC. Mark Allie comp.dsp 2004
Main Topics • Filter configurations Direct Form I and II and the transposes are investigated. • This presentation contains a summary of the issues of signal to noise and numeric range of Direct Form IIR filtering. • Design criteria combined with sensible dsp choices are presented. Mark Allie comp.dsp 2004
Direct Form I, II and Transposes Filter Assumptions. • Unity gain 2nd order filter sections (biquads) are used. • The transfer function of the biquad is given in equations 1 & 2. • The recursive coefficients are scaled to yield a0 = 1. • The filters are implemented with all terms being added. 1 2 Mark Allie comp.dsp 2004
Filter Forms Mark Allie comp.dsp 2004
Matlab Design Example • Because all products are summed the Matlab generated recursive coefficients a1 and a2 must be negated for use in the filter. • For example a Butterworth 2nd order low pass filter with a cutoff frequency of 0.01 * Fs has the coefficients: • b0 = 0.00094469184384 • b1 = 0.00188938368768 • b2 = 0.00094469184384 • a0 = 1.00000000000000 • a1 = -1.91119706742607 use -a1 or 1.91119706742607 • a2 = 0.91497583480143 use -a2 or -0.91497583480143 Mark Allie comp.dsp 2004
Topics of Interest • Overflow in ideal and real filters. • Noise issues. • Noise Compensation issues. Mark Allie comp.dsp 2004
Two Types of Overflow • The final result overflows. • Intermediate results overflow. • Overflow of the result. • Unity gain filters can have outputs that are greater than ±1 with a bounded input. Mark Allie comp.dsp 2004
Ideal Frequency Response Mark Allie comp.dsp 2004
Ideal Time Response Mark Allie comp.dsp 2004
Internal Overflow with Fixed Point Math • Modulo math is your friend. • Modulo math is the default when not in saturation mode. • Jackson’s Rule: Any number of additions and/or subtractions may occur. Intermediate results and operands may fall into any modulo. As long as the final result is made to fall into the first modulo by design, it will be representable in two’s complement at the chosen wordlength, and a valid result. • Once overflow detection is applied to the result the correct sign will be reflected in the saturated value. Mark Allie comp.dsp 2004
Noise Issues • Noise is generated by truncating high resolution results. • The noise generated by truncation often resembles the spectrum of the signal being filtered. • The generated noise is most harmful when it re-circulates through the recursive coefficients. • Force correlated truncation noise to be random (white) by using dither. • If the truncation process is deterministic then correction can be applied to the filter. • Fixed point truncation is deterministic. • Floating point truncation is not deterministic. Mark Allie comp.dsp 2004
Fixed Point Truncation Mark Allie comp.dsp 2004
Floating Point Truncation • The data word in a floating point processor is composed of an exponent and a mantissa. • The number of bits used to represent a mantissa is not directly reduced. • The number of bits used to represent one mantissa is usually indirectly reduced when two numbers are added. • This occurs because the exponents of floating point numbers must be equal to add them. • There is no indirect truncation when the exponents are already equal. • The number of bits lost is dependant on the ratio of the 2 numbers being added. Mark Allie comp.dsp 2004
Floating Point Truncation • For example: When adding 1 to 1/256, 7 bits are truncated because of shifting when the exponents are matched. • The truncation associated with floating point addition is not deterministic in the case of Direct Form IIR filters. • The number of bits truncated can be different for each addition. • The number of bits truncated depends on the coefficients and input signal statistics. • Truncation errors can not be corrected. • They usually must be accepted! • If the recursive products can be kept larger than the direct products then the recursive data path will not be truncated very much. Mark Allie comp.dsp 2004
Noise compensation • Fixed point compensation is accomplished through an error feedback signal. • What is the error signal? e(n) = y(n) – yt(n). • Floating point compensation can not be performed. • So how bad is this problem? Mark Allie comp.dsp 2004
How is the error term generated? Mark Allie comp.dsp 2004
Direct Form Implementation Analysis • Overload considerations. • Input scaling. • Modulo math. • Noise generation considerations. • Truncation noise. • Terms affected. Mark Allie comp.dsp 2004
Floating Point Truncation Analysis Mark Allie comp.dsp 2004
Floating Point Truncation Analysis Example Mark Allie comp.dsp 2004
Floating Point Truncation Analysis Example Mark Allie comp.dsp 2004
Tabulated Results + Good Attribute + Qualified Good Attribute - Poor Attribute Mark Allie comp.dsp 2004
Error Compensation • Fixed Point Only. • Direct Forms with 1 error term. • Attempt to correct noise by feeding back the error signal. • Evaluate DFI based on Dottorro and Wilson. Mark Allie comp.dsp 2004
Error Compensation Mark Allie comp.dsp 2004
Trivial Noise Shaping with the Error Term Mark Allie comp.dsp 2004
Optimal Noise Shaping with the Error Term Mark Allie comp.dsp 2004
2N Word Equivalent to 2nd Order Error Compensated Filter. Mark Allie comp.dsp 2004
Is This Good News? • Yes DFI and DFIIT both work. • A processor with 32 bit integer native word size capabilities doesn’t need truncation error compensation. • Some modern floating point processors can do this inexpensively and fast. • Some modern fixed point processors can do this inexpensively and more slowly. Mark Allie comp.dsp 2004
Floating Point? • All DF IIR filters can work. • Complicated analysis and addend evaluation. • Floating point processors with extended precision results may work well. • Analog devices has processors with 32 bit mantissa capabilities. • Fixed point processing at 32 bits a sure bet. Mark Allie comp.dsp 2004
References • J. Dattorro, “The Implementation of Recursive Digital Filters for High Fidelity Audio,” J. Audio Eng. Soc., vol 36, pp 851-878 (1988 Nov) • R. Wilson, “Filter Topologies,” J. Audio Eng. Soc., vol 41, pp 667-678 (1993 Sept) • S.P. Lipshitz, R.A. Wannamaker and J. Vanderkooy, “Quantization and Dither: A Theoretical Study,” J. Audio Eng. Soc., vol 40, pp355-375 (1992 May) Mark Allie comp.dsp 2004