impulse
7
Finite                                       response
(FIR) filter design
                                                                                                     343
7.1    Introduction
                                                                                                     349
7.2    FIR   filter design
                                                                                                     350
7.3    FIR filter specifications
7.4    FIR coefficient calculation methods                                                           351
7.5    Window method                                                                                 352
7.6    The   optimal   method                                                                        367
                                                                                                     380
7.7    Frequency sampling method
7.8    Comparison of the window, optimum and frequency sampling methods                              398
                                                                                                     402
7.9    Special FIR filter design topics
7.10   Realization structures for FIR filters                                                        407
7.11   Finite wordlength effects in FIR digital filters                                              411
7.12   FIR   implementation techniques                                                               420
7.13                                                                                                 422
       Design example
7.14   Summary                                                                                       425
7.15   Application examples of FIR filters                                                           425
       Problems                                                                                      426
       References                                                                                    435
       Bibliography                                                                                  436
       Appendices                                                                                    437
                         This chapter is concerned with the design of FIR filters from specifications, through
                         coefficient calculation, to analysis of finite wordlength effects and implementations.
                         Several fully worked examples are given throughout the chapter to illustrate the
                         various design stages and to consolidate the important concepts. A complete filter
                                                                                             7.1 Introduction     343
        design is included to show how all the stages fit together and to assist
                                                                                 the readers
        who wish to design their own filters. PC-based MATLAB programs
                                                                        are available on the
        web (see Preface for details). In addition, the MATLAB and C-language prog
                                                                                    rams are
        available on the CD in the companion handbook and may be used to replicate the
        results presented here or for designing user-specified filters.
  7.1   Introduction
        First,   we   will summarize important characteristics of FIR filters before devoting
        attention to their   design.
7.1.1   Summary of key characteristic features of FIR filters
        (1)   The basic FIR filter is characterized               by the following two equations:
                                  N-1
                      y(n)=       Σ h(k)x(n-k)                                                                  (7.1a)
                                  k0
                                  N-1
                       H(z) =           h(k)z                                                                   (7.1b)
                                  20
              where    h(k), k    =   0,   1,... N-1,       are   the   impulse   response   coefficients of the
              filter, H(2) is the transfer function of the filter and N is the filter length, that is
              the number of filter coefficients. Equation 7.1a is the FIR difference equation.
              It is a time domain equation and describes the FIR filter in its nonrecursive
              form: the current output sample,             y(n),   is   a   function only of past and present
              values of the input, x(n). When FIR filters are   implemented in this form, that is
              by direct evaluation of Equation 7.1a, they are always stable. Equation 7.1b is
              the transfer function of the filter. It provides a means of analyzing the filter, for
              example evaluating the frequency response.
        (2)   FIR filters   can    have     an   exactly linear phase response. The implications of this
              will be discussed in the next section.
        (3)   FIR filters   are   very     simple   to   implement.     All DSP processors available have
              architectures that    suited to FIR filtering. Nonrecursive FIR filters suffer less
                                        are
              from the effects of finite wordlength than IIR filters. Recursive FIR filters also
              exist and may offer significant computational advantages (see Section 7.7 for
              details).
          FIR filters should be used whenever we wish to exploit any of the advantages
        above, in particular the advantage of linear phase. Issues to consider when choosing
        between FIR and IIR filters are given in Section 6.3.
344   Chapter 7   Finite impulse response (FIR) filter design
           7.1.2      Linear phase response and its                         implications
                      The   ability           exactly linear phase response is one of the most important
                                      to have an
                     properties of FIR filters. For this reason we shall look more closely at this property.
                     When a signal passes through a filter, it is modified in amplitude and/or phase. The
                      nature   and extent of the modification of the signal is dependent on the amplitude and
                     phase characteristics of the filter. The phase delay or group delay of the filter provides
                     a useful measure of how the filter modifies the phase characteristics of the signal. If
                     we consider a signal that consists of several frequency components (such as a speech
                     waveform or a modulated signal) the phase delay of the filter is the amount of time
                     delay each frequency component of the signal suffers in going through the filter. The
                     group delay on the other hand is the average time delay the composite signal suffers at
                     each frequency. Mathematically, the phase delay is the negative of the phase angle
                     divided by frequency whereas the group delay is the negative of the derivative of the
                     phase with respect         to   frequency:
                             T=-0()/                                                                       (7.2a)
                             T-do/da                                                                       (7.2b)
                     A filter with    a   nonlinear phase characteristic will   phase distortion in the signal
                                                                                     cause a
                     that passes through it. This is because the frequency components in the signal will
                     each be delayed by an amount not proportional to frequency thereby altering their
                     harmonic relationships. Such a distortion is undesirable in many applications, for
                     example music, data transmission, video, and biomedicine, and can be avoided by
                     using filters with linear phase characteristics over the frequency bands of interest.
                       A filter is said to have    linear phase response if its phase response satisfies
                                                        a                                                  one   of
                     the   following relationships:
                            00)-co                                                                         (7.3a)
                            θ(ω) = β-        αω
                                                                                                           (7.3b)
                    where    a   and B    are   constant. If   a   filter satisfies the condition
                                                                                   given in Equation 7.3a it
                    will have both constant group and constant phase delay responses. It
                                                                                           can be shown that
                    for condition 7.3a to be satisfied the impulse response of the filter must
                                                                                               have positive
                    symmetry. The phase response in this case is simply a function of the filter length:
                            h(n)=h(N-n-1),                  Jn  0, 1,.., (N-1)/2
                                                                 =                          (N odd)
                                                            n =0, 1,... (N/2) -1            (N even)
                               a=(N-1)/2
                    When the condition given in Equation 7.3b only
                                                                         is satisfied the filter will have a
                    constant group delay only. In this case, the impulse respon
                                                                                se of the filter has negative
                    symmetry:
                            h(n)=-h(N-n-1)
                            a=(N-1)/2
                            B=n/2