ISCAS2001
A STUDY OF SPT-TERM DISTRIBUTION OF CSD NUMBERS AND ITS APPLICATION FOR DESIGNING FIXED-POINT LINEAR PHASE FIR FILTERS Chia-Yu Yao Department of Electronic Engineering Huafan University, Taiwan, ROC
[email protected] ABSTRACT
The distribution of the signed-powers-of-two (SPT) terms of canonical signed digit (CSD) numbers is nonuniform. In this paper, the author shows an explicit representation of this distribution. Based on this distribution, an algorithm is proposed for designing xed-point linear phase FIR lters with CSD coecients. Design examples demonstrate that the algorithm can produce lters using fewer SPT terms than other methods.
1. INTRODUCTION Fixed-point FIR lter design employs canonical-signed-digit (CSD) coecients to a great extent. Therefore, it is important to explore more properties of CSD codes. The distribution of CSD numbers is nonuniform when the number of signed-powers-of-two (SPT) digits is constrained [1], [2]. This results in a nonuniform quantization error. For xedpoint FIR lter's coecients, the worst-case quantization error usually occurs for the larger valued coecient. When the number of SPT digits is xed, the number of M -digit CSD codes is given by Lim, et al. [2]. Besides, Hartley [3] shows the number of total M -digit CSD codes and the number of SPT terms of all M -digit CSD numbers. CSD numbers do not allow adjacent SPT terms. Let L denote the number of SPT terms of an M -digit CSD code. Apparently, L b(M + 1)=2c. Denote the maximum of L as Lmax. When Lmax < b(M + 1)=2c, the author calls that L is constrained; otherwise, L is unconstrained. The number of M -digit CSD numbers for a given L is shown in [2]: 8 L=0 > < 1; L;1 L Y (1) JM;L = > 2 (M ; m + 1 ; L) L > 0 : L! m=0 When L is unconstrained (Lmax = b(M +1)=2c), it has been shown that there are in total KU = (2M +2 ; (;1)M )=3 (2) M -digit CSD numbers and [(12M + 8)2M ; (6M + 8)(;1)M ]=27 SPT terms of all M -digit CSD numbers [3].
References [2] and [3] derived representations of the number of CSD codes and the number of SPT terms. In this paper, the distribution of SPT terms of CSD numbers is studied. Based on the distribution, an algorithm for designing xed-point linear phase FIR lters with CSD coecients is proposed. This paper is organized as follows. In Section 2, the distributions of SPT terms for both constrained and unconstrained L are derived. In Section 3, an algorithm based on the distributions is proposed for designing xedpoint linear phase FIR lters with CSD coecients. In Section 4, designed examples and comparisons with other methods are shown. Finally, conclusions are summarized in Section 5.
2. DERIVATION OF SPT-TERM DISTRIBUTION Without loss of generality, the CSD numbers are assumed to be less than one in magnitude and are assumed to have M -digit resolution. First, the author considers the case of unconstrained L. The number of SPT terms allocated to the ith digit of all CSD numbers is derived as follows. Let Q be a CSD number whose ith digit is not zero. Let q be the CSD number whose rst i digits are the same as those of Q and the last M ; i digits are zeros.
Lemma 1 There are (2M ;i+1 +(;1)M ;i)=3 CSD numbers
(including Q) whose rst i digits are the same as those of Q.
pf) Let Q = 0:a1 a2 ai;2 0ai 0ai+2 aM where aj 2 f;1; 0; 1g, j 6= i ; 1; i; i + 1, and ai 2 f;1; 1g. Then q = 0:a1 a2 ai;2 0ai . The maximum and minimumMCSD numPb 2;i c ;2j;i bers with the same a1 , a2 , : : :, ai as Q are q+ j=1 2 Pb M2;i c ;2j;i and q ; Pb M ;i cj=1 2 , respectively. Therefore, there are 2 j=12 2;2j;i =2;M + 1 CSD numbers whose rst i digits are a1 , a2 , : : :, ai . This can be simpli ed as (2M ;i+1 + (;1)M ;i)=3.
Lemma 2 There are in total (2i+1 ; 2(;1)i )=3 q's in which the ith digit is not zero.
II-301 0-7803-6685-9/01/$10.00©2001 IEEE
pf) The distance between two adjacent q's is M2;;(1i;1) . The Pb
j Pb M2;1 c 2;2j;1 ; 2;i k j=0
2;(i;1)
9 CSD numbers whose ith digit is allocated an SPT term; i.e., there are gU (i) SPT terms allocated to the ith digit of all CSD number. It is noticed that gU (i) is symmetrical (i.e., gU (i) = gU (M ; i + 1)). The probability of allocating an SPT term to the ith digit for unconstrained L is
pU (i) = gU (i)=KU 0:5)i ][(1 ; (;0:5)M ;i+1 ] = [1 ; (;3[1 ; (;0:5)M +2 ] Next, the author considers the case of constrained L. When Lmax is speci ed, the number of CSD numbers is LX max
L! m=0(M ; m + 1 ; L)
pC(m)
0.2
0.1
0.1 1
2
3
4
5
6
7
8
9
The number of CSD codes whose ith digit is 1 or ;1 for a given L is derived as follows. When the ith digit is 1 or ;1, the (i ; 1)th and the (i +1)th digits must be 0's. Thus, there are i ; 2 digits (i > 1) available for placing SPT terms to the left of the ith digit. Similarly, there are M ; i ; 1 digits (i < M ) available for placing SPT terms to the right of the ith digit. Assuming k SPT terms are allocated to the left of the ith digit, then L ; k ; 1 SPT terms are allocated to the right of the ith digit. Obviously, k 2 f0; 1; 2; : : : ; b(i;1)=2cg and L ; k ; 1 2 f0; 1; 2; : : : ; b(M ; i)=2cg. The intersection of these two sets about k yields n o k 2 max 0; L ; 1 ;b M 2; i c ; : : : ; min b i ;2 1 c; L ; 1
1
2
a
4
5
6
7
8
9
10
9
10
b
0.6
0.6
0.5
0.5
pC(m)
0.7
0.4
0.4 0.3 0.2
0.1 0
3
m (digit number)
0.7
0.1 1
2
3
4
5
6
7
8
9
10
m (digit number)
c
0
1
2
3
4
5
6
7
8
m (digit number)
d
Figure 1: The probability of allocating an SPT term to
the ith digit of a 10-digit CSD number for dierent Lmax, (a) L is not constrained; i.e., Lmax = 5 in this case, (b) Lmax = 4, (c) Lmax = 3, (d) Lmax = 2. Denote max(0; L ; 1 ; b(M ; i)=2c) as kmin and min(b(i ; 1)=2c; L ; 1) as kmax . From equation 1, the number of (i ; 2)-digit CSD numbers with k SPT terms is J(i;2);k and the number of (M ; i ; 1)-digit CSD numbers with L ; k ; 1 SPT terms is J(M ;i;1);(L;k;1) . It is noticed that the conditions i > 1 and i < M can be ignored here without in uencing the nal result. Now, the number of M -digit CSD codes with their ith digit possessing an SPT term for a given L is kX max
k=kmin
2J(i;2);k J(M ;i;1);(L;k;1)
for L > 0. Hence, the number of CSD codes whose ith digit is 1 or ;1 for constrained L is
gC (i) = (3)
0
10
m (digit number)
0.2
M ;i+1 + (;1)M ;i 2i+1 ; 2(;1)i gU (i) = 2 3 3 M +2 [1 ; (;0:5)i ][1 ; (;0:5)M ;i+1 ] 2 =
L=1
0.3
0.3
9 pf) From Lemma 1, 2 and the fact that the CSD representation of any number is unique, there are
= 1+
0.4
0.2
0
ith digit of all CSD numbers is M +2 i M ;i+1 ] gU (i) = 2 [1 ; (;0:5) ][1 ; (;0:5) :
2
0.5
0.3
+1
Theorem 1 The number of SPT terms allocated to the
JM;L L=0 LX ;1 max L LY
0.6
0.5 0.4
which can be simpli ed as (2i ; (;1)i )=3. Similarly, the number of negative q's is also (2i ; (;1)i )=3. Hence, the number of total q's is (2i+1 ; 2(;1)i )=3.
KC =
0.7
0.6
pC(m)
maximum CSD number less than one is The minimum positive q is 2;i . Therefor, the number of q's for positive CSD numbers is
0.7
pU(m)
2 c ;2j;1 . j=0 2
LX max kX max
L=1 k=kmin
2J(i;2);k J(M ;i;1);(L;k;1) :
(4)
Dividing equation 4 by equation 3 yields the probability of allocating an SPT term to the ith digit of an M -digit CSD number for constrained L: PLmax Pkmax k=kmin 2J(i;2);k J(M ;i;1);(L;k;1) : pC (i) = L=1PLmax Q 1 + L=1 2LL! Lm;=01 (M ; m + 1 ; L) Figure 1 shows examples of pU (i) ans pC (i) for 10-digit CSD numbers. When Lmax is getting smaller, pC (i) is getting more uniform.
3. ALGORITHM FOR DESIGNING FIXED-POINT LINEAR PHASE FIR FILTERS Figure 1(a) shows that there are a lot of SPT terms allocated to the least signi cant digits (LSDs) for unconstrained
II-302
L. Furthermore, most FIR lter coecients are small in magnitude. This makes the distribution of gU (i) of the FIR
lter coecients tending to possess larger values for larger i. On the other hand, the LSDs of the FIR lter coecients have least signi cant eect to the lter's frequency response. Therefore, the author conjectures that reducing the SPT terms of LSDs of lter coecients while keeping the lter's frequency speci cations satis ed will lower the total SPT terms required to implement the FIR lter. The algorithm is shown as follows: 1. Determine the in nite-precision optimal lter coecients h(n); n = 0; 1; : : : ; N ; 1. h(n) = h(N ; 1 ; n) or h(n) = ;h(N ; 1 ; n) for a symmetrical or anti symmetrical impulse response, respectively. 2. Quantize h(n) as CSD numbers hCSD (n) for a given Lmax and M .
hCSD(n) =
M X i=1
ai;n 2;i
min
M X
n=0 i=M ;D+1
jai;n j
subject to
b 2 [blow ; bup ] ;1 b NX 2 c
n=0 ;1 b NX 2 c
n=0 ;1 b NX 2 c
n=0 ;1 b NX 2 c
n=0
cn cn cn cn
M X
i=M ;D+1 M X i=M ;D+1 M X i=M ;D+1 M X i=M ;D+1
ai;n 2;i T (n; !) ; b(1 ; P ) > ;Ho (!); ! in passband ai;n 2;i T (n; !) ; b(1 + P ) < ;Ho (!); ! in passband ai;n 2;i T (n; !) + bS > ;Ho (!); ! in stopband ai;n 2;i T (n; !) ; bS
< ;Ho (!); ! in stopband jai;n j 1; and ai;n 2 f;1; 0; 1g; 8i; n M MX ;D X jai;n j Lmax ; jai;n j; 8n i=M ;D+1
i=1
where
Ho (!) =
N ;1 c bX 2
n=0
cn
MX ;D i=1
ai;n 2;i T (n; !);
passband gain, respectively. 4. If there is no solution of the above minimization problem, then increase the lter length N and goto step 1. Otherwise, it's done. The basic idea of the above algorithm is to minimize the number of total SPT terms by minimizing the number of the SPT terms of some LSDs. The frequency speci cations are formulated as the constraints of the minimization problem.
4. EXAMPLES
P where ai;n 2 f;1; 0; 1g. M i=1 jai;n j Lmax, 8n. 3. Minimize the number of SPT terms of the last D digits. That is ;1 c b NX 2
cn = 2 ; n; N2;1 , (n; N2;1 is the Kronecker delta symbol.) T (n; !) = cos N2;1 ; n ! for a symmetri cal impulse response and cn = 2, T (n; !) = sin N 2;1 ; n ! for an anti symmetrical impulse response, P is the passband ripple spec., S is the stopband attenuation spec., , b is the passband gain, and blow and bup are the lower bound and the upper bound of the
Example 1 The speci cations are: A lowpass lter with
normalized passband and stopband edge frequencies at 0.15 and 0.25, respectively. The normalized peak ripple magnitude (NPRM, [4]) NPRM = ;50 dB and the ripple weighting factor is 1. Two Lmax 's, 3 and 4, are used for constrained L. The frequency response and lter coecients determined by the proposed algorithm are given in Figure 2. Compared with the result designed by trellis search [5], a 6.9% SPT terms' savings over the lter designed by trellis search is gained for Lmax = 4 and a 6.7% saving over trellis search is obtained for Lmax = 3. The number of SPT terms and NPRM of trellis search and the proposed method are summarized in Table 1. Example 2 The author redesign the 2PFIR example given by Zhao [6]. The speci cations are: A lowpass lter. The normalized passband edge frequency is 0.15625 and the stopband edge frequency is 0.1875, respectively; P and S are both less than ;80dB. Zhao rst designed a 2PFIR prototype lter. Then using the sharpening method proposed by Kaiser and Hamming [7], Zhao tried to obtain a lter which met the speci cations. However, the prototype lter coecients given in [6] were not correct (probably because of typos). They cannot produce a frequency response as Zhao expected. The prototype 2PFIR lter coecients designed by the proposed algorithm are h(0) = h(44) = ;2;6 h(1) = h(43) = ;2;6 h(2) = h(42) = 2;6 h(3) = h(41) = 2;6 h(4) = h(40) = 2;6 h(5) = h(39) = ;2;6 h(6) = h(38) = ;2;5 + 2;7 h(7) = h(37) = ;2;6 h(8) = h(36) = 2;6 h(9) = h(35) = 2;5 h(10) = h(34) = 2;6 h(11) = h(33) = ;2;5 h(12) = h(32) = ;2;4 + 2;6 h(13) = h(31) = ;2;6 h(14) = h(30) = 2;4 ; 2;6 h(15) = h(29) = 2;4 + 2;6 h(16) = h(28) = 2;6 h(17) = h(27) = ;2;4 ; 2;6 h(18) = h(26) = ;2;3 h(19) = h(25) = ;2;6 h(20) = h(24) = 2;2 ; 2;6 h(21) = h(23) = 2;1 h(22) = 2;1 + 2;3
II-303
Table 1: Minimum Number of SPT terms Required to Attain ;50 dB NPRM in Example 1
0.02
0
0 −10
Lmax Algorithm NPRM (dB) # SPT N 4 trellis[5] ;50:07 58 28
−0.02 −20
0
0.05
0.1
0.15
Ideal coefficients CSD coefficients (L =4) max CSD coefficients (Lmax=3)
−30
−40
3
−50
Proposed trellis[5] Proposed
-50.08
54 60 56
;50:12 ;50:02
28 28 28
−70
−80
0
0.05
0.1
0.15
0.2
0.25
0.3
0.35
0.4
0.45
0.5
Normalized frequency (cycles/sample)
Filter coecients for Lmax = 4 h(0) = h(27) = ;2;8 + 2;10 h(2) = h(25) = 2;7 + 2;12 h(4) = h(23) = ;2;7 ; 2;9 h(6) = h(21) = 0 h(8) = h(19) = 2;5 + 2;10 h(10) = h(17) = ;2;3 + 2;5 ; 2;8 h(12) = h(15) = 2;2
h(1) = h(26) = 2;12 h(3) = h(24) = 2;7 ; 2;11 h(5) = h(22) = ;2;5 + 2;7 + 2;9 h(7) = h(20) = 2;5 + 2;7 h(9) = h(18) = ;2;4 + 2;6 + 2;8 ;2;12 h(11) = h(16) = 0 h(13) = h(14) = 2;1 ; 2;5 + 2;8
h(0) = h(27) = ;2;8 + 2;10 h(2) = h(25) = 2;7 h(4) = h(23) = ;2;7 ; 2;9 + 2;12 h(6) = h(21) = 0 h(8) = h(19) = 2;5 + 2;10 + 2;12 h(10) = h(17) = ;2;3 + 2;5 ; 2;8 h(12) = h(15) = 2;2 ; 2;12
h(1) = h(26) = 2;12 h(3) = h(24) = 2;7 ; 2;11 h(5) = h(22) = ;2;5 + 2;7 + 2;9 h(7) = h(20) = 2;5 + 2;7 h(9) = h(18) = ;2;4 + 2;6 + 2;8 h(11) = h(16) = 0 h(13) = h(14) = 2;1 ; 2;5 + 2;8
Filter coecients for Lmax = 3
Figure 2: Frequency response and lter coecients of the lters designed in Example 1 with ;50 dB NPRM speci cation.
Only 58 SPT terms suce. Its frequency response is shown in Figure 3(a). Because the passband gain of the prototype lter is not unity, the author adds a gain stage after the prototype 2PFIR lter to result in H1 = H (2;1 + 2;4 ). Then by using the amplitude change function (ACF) given in [7]: Hout = H14 (1 + 4H1 + 10H1 2 + 20H1 3 ) where H1 = 1 ; H1 , a lter which meets the speci cations is obtained. The magnitude response of it is shown in Figure 3(b). It is worth noting that all coecients, including the prototype lter coecients, the gain stage, and the coecients of the ACF, are composed of no more than two SPT terms.
5. SUMMARIES In this paper, general formulae of the probability of allocating an SPT term to the ith digit of an CSD number for constrained and unconstrained L are derived. Observing the distribution of SPT terms predicted by the formulae, the author proposed an algorithm for designing xed-point linear phase FIR lters with CSD coecients. Design examples show that the proposed algorithm is able to produce lters possessing a small amount of SPT terms.
10 0
0.2 0 −0.2
−10
0
−20
0.1
−30 −40
0
0.1
0.2
0.3
0.4
Normalized frequency (cycles/sample)
a
0.5
Normalized magnitude response (dB)
−60
Normalized magnitude response (dB)
Normalized magnitude response (dB)
10
0
−3
x 10 1 0 −1
−20 −40 −60
0
0.1
0.3
0.4
−80 −100 0
0.1
0.2
0.5
Normalized frequency (cycles/sample)
b
Figure 3: (a) The magnitude response of the prototype
lter of Example 2. (b) The magnitude response of the lter determined by the sharpening method.
REFERENCES [1] H. Samueli, \An improved search algorithm for the design of multiplierless FIR lters with powers-of-two coecients," IEEE Trans. Circuits Syst., vol. 36, pp. 1044{1047, July 1989. [2] Y. C. Lim, R. Yang, D. Li, and J. Song, \Signed-powerof-two term allocation scheme for the design of digital lters," IEEE Trans. Circuits Syst. II, vol. 46, pp. 577{ 584, May 1999. [3] R. I. Hartley, \Subexpression sharing in lters using canonic signed digit multipliers," IEEE Trans. Circuits Syst. II, vol. 43, pp. 677{688, Oct. 1996. [4] Y. C. Lim and S. R. Parker, \Design of discretecoecient-value linear phase FIR lters with optimum normalized peak ripple magnitude," IEEE Trans. Circuits Syst., vol. 37, pp. 1480{1486, Dec. 1990. [5] C.-L. Chen and A. N. Willson, Jr., \A trellis search algorithm for the design of FIR lters with signed-powersof-two coecients," IEEE Trans. Circuits Syst. II, vol. 46, pp. 29{39, Jan. 1999. [6] Q. Zhao and Y. Tadokoro, \A simple design of FIR lters with powers-of-two coecients," IEEE Trans. Circuits Syst., vol. 35, pp. 566{570, May 1988. [7] J.F. Kaiser and R.W. Hamming, \Sharpening the response of a symmetric nonrecursive lter by multiple use of the same lter," IEEE Trans. Acoust., Speech, Signal Processing, vol. ASSP-25, pp. 415{422, Oct. 1977.
II-304