Round-off Error Free Fixed-Point Desin of Polynomial FIR Predictors Jarno. A. Tanskanen and Vassil S. Dimitrov Institute of Intellient Power Electronics Department of Electrical and Communications Enineerin Helsinki University of Technoloy, Espoo, Finland Tel. +358-9-45 446, Fax: +358-9-46 4, E-mail: jarno.tanskanen@hut.fi Laboratory of Sinal Processin and Computer Technoloy Department of Electrical and Communications Enineerin Helsinki University of Technoloy, Espoo, Finland Tel. +358-9-45 455, Fax: +358-9-46 4, E-mail: vdimitro@wooster.hut.fi Abstract In this paper, we present a novel method for desinin polynomial FIR predictors for fixed-point environments. Our method yields filters that perform exact prediction of polynomial sinals even with short coefficient word lenths. Under ordinary coefficient truncation or roundin, prediction capability derades, or may be totally lost. With the proposed method, the filters are desined so that the predictive properties are exactly preserved in fixed-point implementations. The proposed filter desin method is based on inteer prorammin (IP) and can be directly applied to any fixed-point FIR desin specifications which can be formulated in a form of linear constraints on the filter coefficients.. Introduction By their nature, diital devices handle numbers usin a finite number of bits per diit []. In many embedded applications usin hihly optimized, small and less power consumin application specific interated circuits (ASICs) it would be desirable to et by with low precision fixed-point arithmetic but havin only a very limited number of bits available for presentin filter coefficients results in filter quality deradation and possibly even in a totally unintended kind of filterin operation. In this paper, we present a novel method for desinin polynomial FIR predictors [] whose quantized coefficients exactly fulfill the set constraints and provide for exact prediction even with coefficient precision of 6 bits (4 in some cases). Our application examples include motion control of an elevator car [3], and mobile phone power control [4]. In these and many other practical applications, measured sinals can be accurately modeled as piecewise polynomials buried in noise. Also the closed control loops employed in these applications are inherently delay limited. Hence, polynomial-predictive noise filterin is a naturally lucrative approach. Our main oal in this paper is to preserve the exact prediction step and dc-ain with quantized coefficient polynomial FIR predictors. As the method presented in this paper does yield quantizedcoefficient filters that exactly preserve the prediction step and dc-ain, and as they are FIR filters, the desined filters are naturally safe for even critical applications in short word lenth fixed point environments.. Polynomial FIR predictors in fixed-point environments. Polynomial FIR predictors Polynomial predictive filterin theory has been well established [,3,4,5] but applicability of polynomial FIR predictors has suffered from the practical constraint of finite coefficient precision. Polynomial FIR predictors, derived in [], assume a low-deree polynomial input sinal contaminated by white noise. Filter output is defined to be a p-step-ahead predicted input, hk xn k xn p () k
where h(k) are filter coefficients, x(n) are input samples, is filter lenth, and p is prediction step. After providin for exact prediction, the rest of the derees of freedom are used to minimize the white noise ain, G k h n. () A set of constraints can be derived from the definition of the filter output () []: hk (3) k kh k (4) k k hk (5) k k h k (6) k The constraints (3)-(6) yield prediction of the polynomial derees,,, and from them can closed form solutions for the FIR coefficients for low-deree polynomial input sinals be calculated by the method of Larane multipliers [6]. The closed form solutions for FIR coefficients for the first, second, and third deree polynomial input sinals are iven in []. Since prediction of a first deree polynomial sinal is, in a way, trivial from an application point of view, in this paper we consider a case with the hihest polynomial input sinal component deree of two, =, as an example. In this case we have to fulfill the constraints (3), (4) and (5), and use the remainin derees of freedom to minimize the noise ain (). The exact, i.e., infinite precision, coefficients for the one-step-ahead predictive p = second deree polynomial = FIR predictors are iven by [] h k 9 9 36k 3k 8 6, 3 3 k,,...,. In [5], a feedback extension to FIR differentiators is iven to provide considerable noise attenuation while maintainin the prediction property set forth by the underlyin FIR predictor. In order for the feedback extension to function properly, it is necessary that the underlyin FIR basis filters are implemented exactly. Until now, this has been rarely possible in short word lenth fixed-point environments. (7).. Coefficient quantization effects For fixed-point presentation of filter coefficients, two s complement presentation is used, and as the conventional quantization method for the filter coefficients (7), manitude truncation is applied. In our calculations, infinite precision means the computational precision of atlab..5 anitude (a) Group delay (samples).5.5..98...4.6.8 ormalized frequency 5 5.6 5.8.5...4.6.8 (b) ormalized frequency Fi.. Frequency response (a) and roup delay (b) of the second deree polynomial FIR predictor of lenth = 6 with coefficients truncated (dash-dot) and ideally quantized (solid) to 6 bits, alon with the same filter with infinite precision coefficients (dotted). The quantization effects can be seen in Fi.. In Fi., frequency response and roup delay of a second deree polynomial = one-step-ahead p = predictor of lenth = 6 is shown with infinite, and conventionally and ideally quantized 6-bit coefficients. From Fi. it seen that the exact one-step-ahead prediction at zero frequency is lost, and also that the dc-ain is deviated from unity. The one-step-ahead prediction property can be seen as the neative unity roup delay at zero frequency, Fi. b. Let us note that the coefficients (7) for the p =, =, polynomial FIR predictor of
lenth = 3 are still exact if quantized to six bits but the frequency response of that filter is not practical for usual applications, and loner filters are needed to provide for better noise attenuation. 3. Polynomial FIR predictor desin by linear diophantine equation based solution The optimization problem that has to be solved, i.e., solvin (3)-(6) exactly for truncated coefficients h(k) and thereafter minimizin the noise ain (), can be reformulated as an inteer prorammin problem. Suppose that all the coefficients of the filter, h(k), are multiplied by n, where n is the number of bits available, and truncated to yield inteer coefficients h ( k ) where the asterisk denotes an inteer quantity.. Without restrictin the variables to be inteers, we have a closed form solution of the problem, which is iven by (7) for the case p =, =. Althouh the values computed by this formula are not inteers, this expression ives us a very ood initial approximation. Thouh it is at best difficult to prove, it is reasonable to assume that a solution of (9)-() would lie in a vicinity of the infinite precision solution (7). 3. To make sure that the conditions (9)-() are met exactly, one has to solve the above system in inteers. This problem has been a subject of very deep investiations in number theory and the theory of Diophantine equations. By eliminatin the variables, one can reduce the problem to a sinle linear equation of the form: A x A x A l x l B (3) The optimization task can now be defined as follows: where A A, A,, l and B are inteers. Input: Function () G F( h (), h (),, h ( )) h ( k) (8) k with inteer variables h ( k). The constraint conditions (3)-(6) for the coefficients can be formulated as: n h ( k) (9) k k kh ( k) () k h k) k k k ( () h ( k) () Output: An inteer vector, h = (h (), h (),, h ()) that minimizes G (8) and satisfies exactly the constrains (9)-(), and thus also (3)-(6). The solution we offer is based on the followin considerations:. The task in hand is a quadratic inteer prorammin problem, which is well-known to be an P-complete problem [7,8,9]; therefore it is unrealistic to find the best solution in a reasonable amount of time, especially for lon filters. This state of affairs is in sharp contrast to the quadratic real prorammin problem [8], which is solvable in polynomial time. The solutions of (3) are usually obtained by multidimensional continued fraction alorithms [,], and the reader can find a lare variety of methods aimed at solvin this class Diophantine equations. Here our approach is based on Clausen-Fortenbacher alorithm []. The reasons why we chose this particular technique are: firstly, the alorithm succeeds in findin very fast the solutions of (9)-(), from which the optimal one, that is, the one that minimizes the noise ain G (8), can be quickly found; secondly, the proram provided in [] can be easily eneralized to more than 6 variables (the larest case analyzed by Clausen and Fortenbacher); thirdly, we have a ood initial approximation that sinificantly speeds us the alorithm. Since the filters shown in this paper are not very lon, the alorithm is applied as a exhaustive search for the ideally quantized coefficients that fulfill (9)-() over a search band of r from the normally quantized coefficients presented in inteer form. This search band is illustrated in Fi. in real number form for the filter lenth = 6 with coefficient precision of 6 bits alon with the conventionally and ideally quantized 6-bit coefficients for the p =, =, = 6 filter. It is worth notin that in our experiments, truncatin or roundin the infinite precision coefficients has never but once produced a solution of the system of the Diophantine equations (9)- (); the filter of the lenth = 3 is an exception. This demonstrates the necessity of special techniques aimed at solvin the inteer optimization problem. In Table, the p =, =, = 6, FIR predictor coefficients h(k) (7) are shown in real number form (infinite precision, multiplied by n and truncated to 6 decimals) alon with the best 6-bit ideal inteer solution obtained within the band shown in Fi.. In the example
in Table it can be seen that for 8 out of 6 coefficients one had to approximate the real coefficient with an inteer that is not the closest one. Also, out of the 6 ideally quantized coefficients differ from the correspondin manitude truncated real number form coefficients in Table..6 anitude.4.. 4 6 8 4 6 Coefficient number Fi.. Ideal quantization search band (between solid lines) for the filter lenth = 8 with the coefficient precisions of 6 bits. Circles o denote the truncated, and plusses + the ideally quantized coefficients. Table. The infinite precision presentation (real number form, truncated to 6 decimals) of the diital filter coefficients computed by (7) for the filter lenth = 6 and their best inteer solutions within the search band that uarantees the exact solution of (9)- () while also minimizin the noise ain (8) with the coefficient precision of 6 bits. Coeff. Real number Best int. Coeff. Real number Best int. form solut. form solut. 64 h() 36. 35 64 h(9) -8.8-8 64 h() 6.4 6 64 h() -9.5743-64 h(3) 7.94857 9 64 h() -8.5749-9 64 h(4).6857 64 h() -6.74857-7 64 h(5) 4.45743 5 64 h(3) -3.7749-4 64 h(6) -.5749 64 h(4).34857 64 h(7) -4.45743-4 64 h(5) 5.6 6 64 h(8) -7. -8 64 h(6). The best inteer solution is not the inteer closest to the real (infinite precision) coefficient value. The best inteer solution is not the nearest inteer on either side of the real (infinite precision) coefficient value. The best inteer solution is not the manitude truncated real number form coefficient. Table lists the numbers of solutions that exactly satisfy the constraints (9)-() for coefficient precisions 6, 8,,, 4, and 6 bits for the filter lenths = 8 and = 6. To find the optimum solution, it is necessary of search all the solutions and to select the one which minimizes noise ain (8). Within the search band of r, for filter of lenths of = 8 and = 6, there are 4 8 = 65536, and 4 6 = 4.9496796 9 possible coefficients vectors to be tested aainst the constraints (9)-(), respectively. For the filter lenth = 8, the search and noise ain minimization takes less than one second on a 66 Hz Pentium processor usin exhaustive search prorammed with C lanuae while for = 6 the time is around 47 minutes. This clearly demonstrates for the necessity of applyin efficient alorithms to solve the Diophantine equation (3) when desinin loner filters with = 5,,. For many applications, also the first-found solution could most probably be adequate, which should be checked by comparin the noise ain aainst the noise ain of the correspondin infinite precision filter, and the application at hand. By startin the search with coefficients initially approximated towards zero, it is possible to desin a search alorithm whose first found solution is at least not one of the hihest noise ain solutions. Table demonstrates that there truly are several exact solutions of (9)-() within a close vicinity of the infinite precision coefficients, and that there are still some derees of freedom left for minimizin the noise ain (8) after fulfillin the constraints (9)-(). Table. umbers IQS of coefficient vectors h that exactly satisfy the constraints (9)-() within the band of r for the filter lenths = 8 and = 6 as functions of coefficient precision, 6, 8,,, 4, and 6 bits. Coefficient precision (bits) 6 8 4 6 IQS, = 8 5 4 5 5 4 5 IQS, = 6 5586 5476 4964 54394 5476 4964 4. Characteristics of the truncated and ideally quantized coefficient filters In Fi. it can be seen that the predictor with conventionally quantized coefficients does not provide for exact prediction at zero frequency, and also the dc-ain of exact unity is lost, whereas the predictor with the ideally quantized coefficients possesses both quantities exactly, as it should, since it satisfies the constraints (3)-(5) exactly. It is to be noted that enerally the deviation from the exact prediction step and dc-ain values, due to conventional coefficient quantization, ets larer as the filter lenth increases, but for practical applications loner filters may be needed to provide for lower noise ains. The noise ains of the best ideally quantized coefficient filters within the search band are listed in Table 3. From Table 3 it can be seen that as the coefficient precision is increased, the noise ain of the
ideally quantized coefficient filter approaches the noise ain of the correspondin infinite precision coefficient filter, and that the noise ain loss can be rearded marinal with any of the ideally quantized coefficient precisions, 6, 8,, 6 bits. Table 3. oise ains of the ideally quantized coefficient, p =, =, polynomial FIR predictors of lenths = 8 and = 6 as functions of coefficient precision in bits. Also the noise ains of the same filters with infinite precision coefficients are mentioned. Coefficient G, = 8 G, = 6 precision (bits) 6.9535.734875 8.9476565.7346875.94647679.733638458.946487757.73359774 4.9464858.7335766 6.94648578.73357444 Inf. precision.94648574.7335748 5. Conclusions A new technique for perfect polynomial-predictive FIR diital filter coefficient quantization has been proposed. As it is demonstrated in this paper, the filter desin constraints ivin the filters their polynomial sinal prediction properties can be exactly satisfied with low fixed-point coefficient precisions, and thus, the influence of the round-off errors is eliminated. For the second deree polynomial FIR predictors, used in this paper as an example, the conditions can be exactly satisfied with even as low as 6-bit coefficient precision, with still some derees of freedom left to minimize the noise ain of the desined fixed-point coefficients filter. The proposed inteer prorammin method for fixed-point filter desin is well suited for all filter desin tasks in which the desin criteria can be formulated in a form of linear constraints on the filter coefficients. Acknowledment The work of V. S. Dimitrov has been funded by the Technoloy Development Centre of Finland, okia Corporation, Sonera Ltd., Finland, and Omnitele Ltd., Finland. The work of J.. A. Tanskanen has been partially funded by the parties mentioned above, and his work has also been supported by Jenny ja Antti Wihuri Foundation, Finland, Walter Ahlström Foundation, Finland, The Finnish Society of Electronics Enineers, and by Foundation of Technoloy, Finland. References [] J. G. Proakis and D. G. anolakis, Diital Sinal Processin: Principles, Alorithms, and Applications. ew York, Y, USA: acmillan Publishin Company, 99. [] P. Heinonen and Y. euvo, FIR-median hybrid filters with predictive FIR substructures, IEEE Trans. Acoustics, Speech, and Sinal Processin, vol. 36, pp. 89 899, June 988. [3] S. Väliviita and S. J. Ovaska, Delayless recursive differentiator with efficient noise attenuation for control instrumentation, Sinal Processin, vol. 69, pp. 67 8, Sept. 998. [4] P. T. Harju, T. I. Laakso, and S. J. Ovaska, Applyin IIR predictors on Rayleih fadin sinal, Sinal Processin, vol. 48, pp. 9 96, Jan. 996. [5] S. J. Ovaska, O. Vainio, and T. I. Laakso, Desin of predictive IIR filters via feedback extension of FIR forward predictors, Proc. 38th idwest Symposium on Circuits and Systems, Rio de Janeiro, Brazil, 995, pp. 37-375. [6] D. Bertsekas, Constrained Optimization and Larane ultipliers ethods. ew York, Y, USA: Academic Press, 98. [7] E. L. Johnson, Inteer prorammin, facets, subadditivity and duality for roup and semiroup problems. Philadelphia, PA, USA: SIA, 98. [8] A. Schrijver, Theory of Linear and Inteer Prorammin. ew York, Y, USA: John Wiley, 986. [9] C. R. Papadimitriou and K. Steilitz, Combinatorial Optimization: Alorithms and Complexity. Enlewood Cliffs, J, USA: Prentice Hall, 98. [] G. Szekeres, ultidimensional continued fraction alorithms, Ann. Univ. Sci. Budapest Eotvos, Sect. ath., vol. 3, pp. 3 4, 97. [] H. R. P. Feruson and R. W. Forcade, Generalization of the Euclidean alorithm for real numbers to all dimensions hiher than two, Bull. AS, pp. 9 94, ov. 979. []. Clausen and A. Fortenbacher, Efficient solution of linear Diophantine equations, Journal of Symbolic Computation, vol. 8, pp. 6, July/Au. 989.