Linear Low pass Filter

4
DESIGN OF LINEAR-PHASE FIR FILTERS WITH MINIMUM HAMMING DISTANCE Oscar Gustafsson and Lars Wanhammar Department of Electrical Engineering, Linköping University, SE-581 83 Linköping, SWEDEN E-mail: {oscarg, larsw}@isy.liu.se, Tel: +46-13-28{4059, 1344}, Fax: +46-13-139282. ABSTRACT In this paper a new approac h for the design of linear phase FIR filters with discrete coeffi cients is proposed. A mixed integer linear programming (MILP) problem is formulat- ed that minimizes the total Hamming distance between the adjacent coefficients, i.e., the number of bit switches of the coefficients. The Hamming distance between the coef- ficients is a good measure of the power consumption, when the FIR filters is implemented on a programmable architecture. The meth od is applicable both for filters with a specified passband gain and filters where the normalized peak ripple magnitude is of interest. In both cases the glo- bally minimal solution is found subject to the filter speci- fication, filter order, and number of coefficient bits. A preprocessing method that removes a significant part of the variables is also proposed and it is shown by an exam- ple that this method speeds up the optimization process significantly. Both two’s complement and signed magni- tude representation of the coefficients are considered. 1. INTRODUCTION Finding good fixed-point coefficients for FIR filters has received considerable attention during the last 20 years. The measure of good coefficients depends on the filter im- plementation, much of the work this far has been consid- ering the number of signed-power-of-two (SPT) terms for the coefficients [1]–[3]. This is motivated by that a multi- plication can be separated into a number of shift-and-add operations. Each shift-and-add operation corresponds to a SPT term which makes this an interesting variable either to minimize or to have as a constraint. If the FIR filter is implemented on a programmable ar- chitecture with one general multiplier and an accumulator, as shown in Fig . 1, the Hamming d istance between the co- efficients has been shown to be a good measure of the power consumption in the multiplier [4]. The Hamming distance between two coefficients is the number of bits that are different. Other previous work is this area has been aimed at reordering the coefficients to minimize the Hamming distance [5]. In this work we focus on minim iz- ing the Hamming distance between those coefficients that are naturally processed after each other, i.e., those coeffi- cients that are adjacent in the impulse response of the fil- ter. The motivation is that by reordering the coefficients, the data must also be reordered removing the advantage of possible correlation between the samples. Further, to ef- fectively utilize features like hardware looping on general purpose DSPs, the multiplications should be performed in order. In this paper we formulate an MILP problem that min- imizes the Hamming distance between adjacent coeffi- cients for a given filter specification subject to the filter order and coefficient wordlength. A preprocessing tech- nique to reduce the number of variable s that was previous- ly proposed by the authors is shown usef ul for this case as well. The proposed method has been modelled using OPL and solved using the general purpose optimization pack- age CPLEX [6]. An example shows the usefulness of the proposed technique. 2. LINEAR-PHASE FIR FILTERS The frequency response of a linear- phase FIR filter can be separated into a real-valued function  H  R (ωT ) and a real- valued phase function as (1) where  H  R (ωT ) is the  zero-phase frequency response. Clearly, we have , as = 1 for real-valued x. For an N th-order linear-phase FIR filter the zero-phase frequency response can be written as (2)  Figur e 1: Progr ammable multip ly-accumu late archi- tecture suitable for FIR filtering. Θ ω T ( )  H e  j ωT ( )  H  R  ω T ( ) e  j Θ ω T ( ) =  H e  j ω T ( )  H  R  ω T ( ) =  e  jx  H  R  ω T ( )  h m c m  ω T , ( ) m 1 =  N 1 + 2 ------------- =

description

Linear Low pass Filter

Transcript of Linear Low pass Filter

  • DESIGN OF LINEAR-PHASE FIR FILTERS WITH MINIMUM HAMMING DISTANCE

    Oscar Gustafsson and Lars Wanhammar

    Department of Electrical Engineering, Linkping University,SE-581 83 Linkping, SWEDEN

    E-mail: {oscarg, larsw}@isy.liu.se,Tel: +46-13-28{4059, 1344}, Fax: +46-13-139282.

    ABSTRACTIn this paper a new approach for the design of linear phaseFIR filters with discrete coefficients is proposed. A mixedinteger linear programming (MILP) problem is formulat-ed that minimizes the total Hamming distance between theadjacent coefficients, i.e., the number of bit switches ofthe coefficients. The Hamming distance between the coef-ficients is a good measure of the power consumption,when the FIR filters is implemented on a programmablearchitecture. The method is applicable both for filters witha specified passband gain and filters where the normalizedpeak ripple magnitude is of interest. In both cases the glo-bally minimal solution is found subject to the filter speci-fication, filter order, and number of coefficient bits. Apreprocessing method that removes a significant part ofthe variables is also proposed and it is shown by an exam-ple that this method speeds up the optimization processsignificantly. Both twos complement and signed magni-tude representation of the coefficients are considered.

    1. INTRODUCTION

    Finding good fixed-point coefficients for FIR filters hasreceived considerable attention during the last 20 years.The measure of good coefficients depends on the filter im-plementation, much of the work this far has been consid-ering the number of signed-power-of-two (SPT) terms forthe coefficients [1][3]. This is motivated by that a multi-plication can be separated into a number of shift-and-addoperations. Each shift-and-add operation corresponds to aSPT term which makes this an interesting variable eitherto minimize or to have as a constraint.

    If the FIR filter is implemented on a programmable ar-chitecture with one general multiplier and an accumulator,as shown in Fig. 1, the Hamming distance between the co-efficients has been shown to be a good measure of thepower consumption in the multiplier [4]. The Hammingdistance between two coefficients is the number of bitsthat are different. Other previous work is this area hasbeen aimed at reordering the coefficients to minimize theHamming distance [5]. In this work we focus on minimiz-ing the Hamming distance between those coefficients thatare naturally processed after each other, i.e., those coeffi-cients that are adjacent in the impulse response of the fil-ter. The motivation is that by reordering the coefficients,the data must also be reordered removing the advantage of

    possible correlation between the samples. Further, to ef-fectively utilize features like hardware looping on generalpurpose DSPs, the multiplications should be performed inorder.

    In this paper we formulate an MILP problem that min-imizes the Hamming distance between adjacent coeffi-cients for a given filter specification subject to the filterorder and coefficient wordlength. A preprocessing tech-nique to reduce the number of variables that was previous-ly proposed by the authors is shown useful for this case aswell. The proposed method has been modelled using OPLand solved using the general purpose optimization pack-age CPLEX [6]. An example shows the usefulness of theproposed technique.

    2. LINEAR-PHASE FIR FILTERS

    The frequency response of a linear-phase FIR filter can beseparated into a real-valued function HR(T) and a real-valued phase function as

    (1)

    where HR(T) is the zero-phase frequency response.Clearly, we have , as = 1 forreal-valued x.

    For an Nth-order linear-phase FIR filter the zero-phasefrequency response can be written as

    (2)

    Datamemory

    Coefficientmemory

    Register

    Figure 1: Programmable multiply-accumulate archi-tecture suitable for FIR filtering.

    T( )

    H ejT( ) HR T( )ej T( )=

    H ejT( ) HR T( )= ejx

    HR T( ) hmc m T,( )m 1=

    N 1+2-------------

    =

  • where is a proper trigonometric function de-pending on if the filter order is odd or even and if the im-pulse response is symmetric or anti-symmetric.

    Let the specifications of the filter be

    (3)

    where is the desired magnitude and is themaximum allowed ripple for a given angle T. Typically,

    is one in the passband and zero in the stopband ofthe filter.

    Note that (3), for each angle T, describes an inequal-ity that is linear in the filter coefficients.

    When fixed-point coefficient is considered it is oftenuseful to allow a non-unity passband gain [7]. This can bedone by introducing a scaling factor, s, as

    (4)

    The scaling factor is always larger than 0, so (4) can berewritten as

    (5)

    to obtain a linear inequality.

    3. PROPOSED DESIGN METHOD

    The objective is to form an MILP formulation of linear-phase FIR filter design that minimizes the Hamming dis-tance between adjacent coefficients. This will be done byfirst introducing a linear expression for the coefficientbits, where the bits corresponds to binary variables, x.Then, a second set of binary variables, y, will be intro-duced that corresponds to if a bit position is switched be-tween two coefficients. As we want to minimize thenumber of switches, the optimization problem can be stat-ed as minimizing the sum of all y variables.

    3.1. Twos Complement CoefficientsTwos complement representation is commonly used inDSP applications. A coefficient, hm, of wordlength B ex-pressed using twos complement can be written as

    (6)

    where . Thus, the coefficients of the FIR fil-ter can be described using a linear expression with binaryvariables.

    The Hamming distance between two coefficients isequal to the number of bits that are different. Introduce abinary variable, , as

    (7)

    i.e., if bit i changes value between hm and hm + 1, ym,i is oneotherwise it is zero. This can be expressed using linear ex-pressions as

    (8)

    Only one half of the impulse response needs to be con-sidered due to the symmetry of the magnitude of the coef-ficients.

    3.2. Signed Magnitude RepresentationAn alternative to twos complement is signed magnituderepresentation. A B bit signed magnitude coefficient canbe written as

    (9)

    Hence, the first bit corresponds to the sign, while the re-maining bits corresponds to the magnitude. Signed mag-nitude representation has a low switching probabilitywhen the numbers are small and with varying sign. Multi-plication is straight-forward using signed magnitude rep-resentation. The magnitudes can be multiplied usingunsigned multiplication, while the sign of the result is de-termined with a simple xor-operation of the sign bits ofthe multiplier and multiplicand. However, addition andsubtraction is more complex. It is possible to use twoscomplement representation of the data and signed magni-tude representation of the coefficients. The multiplicationis then performed in twos complement, with the coeffi-cient always being positive. The sign bit of the coefficientcontrols if the result of the multiplication should be addedor subtracted to the accumulator.

    Equation (9) can not be used directly in a linear formu-lation, instead for each coefficient a binary sign variablesm is introduced along with B 1 binary variables, ,for positive coefficients and B 1 binary variables, ,for negative coefficients. The coefficient can now be writ-ten as

    (10)

    with the constraints

    (11)

    and

    c m T,( )

    T( ) HR T( ) D T( ) T( )

    D T( ) T( )

    D T( )

    T( ) HR T( ) s D T( ) T( )

    s D T( ) T( )[ ] HR T( ) s D T( ) T( )+[ ]

    hm xm 0, xm i, 2 i

    i 1=

    B 1

    +=

    xm i, 0 1,{ }

    ym i, 0 1,{ }

    ym i,1 xm i, xm 1 i,+,

    0 xm i,, xm 1 i,+=

    = m, 1 M 1, ,=

    ym i, xm i, xm 1 i,+

    ym i, xm 1+ i, xm i,m 1 M 1, ,=i 0 B 1, ,=

    ,

    hm 1( )xm 0, xm i, 2 ii 1=

    B 1

    =

    xm i,+

    xm i,

    hm xm i,+ xm i,( )2 ii 1=

    B 1

    =

    xm i,+

    i 1=

    B 1

    B 1( ) 1 sm( ) 1 m M ,

  • (12)

    These constraints make sure that if the coefficient hm ispositive, sm = 0 and for all i, and similarly, ifthe coefficient hm is negative, sm = 1 and for alli. The new variables are related to the formulation in (9) as

    (13)

    The number of switched bits can now be expressed as in(8).3.3. Problem FormulationThe resulting optimization problem can for twos comple-ment representation be formulated as

    (14)

    For signed magnitude representation the last row of (14)can be exchanged for (10)(13).

    As the constraints are continuous in T it is necessaryformulate the constraint for discrete values of T. This iseasily done by selecting a number of values in the pass-band and the stopband to obtain a grid of values whicheach leads to one constraint. As the specifications arechecked only in these points it is necessary to check the re-sulting transfer function with a much finer grid to verifythat a valid coefficient set is obtained. If not, additionalpoints must be added to the constraints.

    If a prescribed passband gain is required the value of scan be fixed before the optimization starts. Note also thats must be larger than 0 as this otherwise would yield anoptimal solution with all variables equal to 0. In general itis possible to constrain s to be larger than 0.1, say, without

    losing optimality in the solution. This is due to the factthat scaling s with 2 is equal to shifting each coefficientone step.

    4. REDUCING THE NUMBER OF VARIABLES

    In the optimization problem in (14) the number of 0/1-var-iables is (2M 1)B and 3MB M B for twos comple-ment and signed magnitude representation, respectively.This number will be high for filters with stringent specifi-cations and the execution time will therefore be long.Hence, it is of interest to find ways to decrease the numberof variables before the actual optimization starts. We willapply a method similar to that proposed in [3].

    To obtain the ranges for the coefficients it is possibleto use linear programming. The problem can be stated asfirst a separate maximization of each variable hm, subjectto (3). These values are assigned to the variables .Then a minimization of each variable hm is performed andthe result is assigned the variables . However, thesevalues are for s = 1, so the possible range of s must befound to obtain the true bounds for hm.

    For a both a twos complement and a signed-magni-tude number with wordlength B, the maximal value forany positive coefficient is bounded approximately by one.A negative coefficient is bounded by minus one. To usethe complete range of the coefficients the absolute valuefor the coefficient with the largest magnitude should be atleast 1/2.

    The minimal value for the scaling factor is obtainedwhen the maximal absolute value for the upper or lowerbound times the scaling factor is 1/2. Hence

    (15)

    The maximal value for the scaling factor is when themaximal value of the coefficients minimum absolutebounds are 1. This is for coefficients that do not changesign. The upper bound is then

    (16)

    where the coefficients concerned are those that do notchange sign. This reasoning is only valid when at least onecoefficient have the same sign on its maximum and mini-mum value. However, this is the case for most filters un-less the design margin is very large.

    New bounds on the coefficients can now be derived as

    (17)

    and

    xm i,

    i 1=

    B 1

    B 1( )sm 1 m M ,

    xm i, 0=

    xm i,+ 0=

    xm 0, sm=

    xm i, xm i,+ xm i,

    i,+ 1 B 1, ,= =

    minimize ym i,i 0=

    B 1

    m 1=

    M 1

    subject to s D T( ) T( )[ ] hmc m T,( )m 1=

    M

    hmc m T,( )m 1=

    M

    s D T( ) T( )+[ ]ym i, xm i, xm 1 i,+

    ym i, xm 1+ i, xm i,

    hm xm 0, xm i, 2 i

    i 1=

    B 1

    +=

    hmub( )

    hmlb( )

    s lb( ) 12max max hmub( ) hmlb( ),{ }{ }------------------------------------------------------------------------=

    s ub( ) 1max min hmub( ) hmlb( ),{ }{ }--------------------------------------------------------------------=

    h mub( )min 1 hmub( )s lb( ),( ) hmub( ) 0,max 1 hmub( )s ub( ),( ) hmub( ) 0

  • (18)

    If the passband gain is specified we have s(ub) = s(lb) = ss,where ss is the specified passband gain. Finally, the fol-lowing inequality is obtained

    (19)

    This inequality can either be added to the constraints ofthe optimization or used to preevaluate possible values ofthe variables. Here, (19) is utilized to determine which bitsthat do have a fixed value and remove these from the op-timization problem. This can be done by searching all pos-sible values for the filter coefficient and keep track ofwhich values the bits assume. All variables that only as-sign one value can be fixed and thereby removed from theoptimization problem.

    As will be shown in the example below, the number ofvariables that can be removed depends on the availabledesign margin and the representation used. The number ofvariables that can be removed are in general not dependenton the coefficient wordlength, as typically it is the mostsignificant bits of a coefficient that are fixed. However,the relative savings will be smaller when the wordlengthis increased.

    5. EXAMPLE

    To show the usefulness of the proposed idea we will con-sider one filter design example. The filter under consider-ation is a lowpass filter with passband edge at 0.3pi andstopband edge at 0.5pi. The allowed ripple is 0.001 in boththe passband and the stopband. A filter order of 33 is used.Hence, there are 17 coefficients to be designed. Using theRemez exchange algorithm and rounding, 15 coefficientbits are required to satisfy the specification. For twoscomplement representation the sum of the Hamming dis-tances between subsequent coefficients are 118. Using theproposed design method a solution with 13 bits can befound with a total Hamming distance of 79. The originaloptimization problem has 448 variables, while after theproposed preprocessing it has 292 variables. Thus, a sig-nificant speed-up was obtained for the solution. The prob-lem was solved on an AMD Athlon 1800+ with 1.5 GB ofRAM. The pre-processing took approximately 30 s, whilethe MILP stage took 55 minutes. For signed magnituderepresentation, the rounded solution has a total Hammingdistance of 78. The original optimization problem has 652variables, while after preprocessing 255 variables remain.The optimized solution has a total Hamming distance of60. For this problem the MILP stage took approximately150 minutes. The magnitude responses for the three de-signed filters are shown in Fig. 2.

    6. CONCLUSIONS

    In this paper a mixed integer linear programming problemfor design of linear-phase FIR filters with minimum Ham-ming distance between adjacent coefficients was formu-lated. It has been shown in earlier work that the Hammingdistance is a good measure of the power consumption fora programmable FIR filter. A preprocessing technique toremove 0/1-variables, and, thus, decrease the solutiontime, was discussed. Both twos complement and signedmagnitude representation were considered. A design ex-ample showed the usefulness of the proposed method.

    7. REFERENCES[1] T. Saramki and J. Yli-Kaakinen, Design of digital filters

    and filter banks by optimization: applications, in Proc. XEuropean Signal Processing Conf., Tampere, Finland,Sept. 48, 2000.

    [2] H. Samuli, An improved search algorithm for the designof multiplierless FIR filters with powers-of-two coeffi-cients, IEEE Trans. Circuits Syst., vol. 36, pp. 10441047, July 1989.

    [3] O. Gustafsson, H. Johansson, and L. Wanhammar, AnMILP approach for the design of linear-phase FIR filterswith minimum number of signed-power-of-two terms, inProc. European Conf. Circuit Theory Design, Espoo, Fin-land, Aug. 2831, 2001.

    [4] M. Mehendale, S. D. Sherlekar, and G. Venkatesh, Coef-ficient optimization for low power realization of FIR fil-ters, in Proc. IEEE Workshop VLSI Signal Processing,1995, pp. 352361.

    [5] P. K. Merakos et al, A novel transformation for reductionof switching activity in FIR filters implementation, inProc. Int. Conf. Digital Signal Processing, 1997, vol. 2,pp. 653656.

    [6] ILOG, http://www.ilog.com/, June 2002.[7] Y. C. Lim, Design of discrete-coefficient-value linear

    phase FIR filters with optimum normalized peak ripplemagnitude, IEEE Trans. Circuits Syst., vol. 37, pp.14801486, Dec. 1990.

    h mlb( )min 1 hmlb( )s ub( ),( ) hmlb( ) 0,max 1 hmlb( )s lb( ),( ) hmlb( ) 0