Digital Signal Processing Filter Design
Total Page:16
File Type:pdf, Size:1020Kb
2065-27 Advanced Training Course on FPGA Design and VHDL for Hardware Simulation and Synthesis 26 October - 20 November, 2009 Digital Signal Processing Filter Design Massimiliano Nolich DEEI Facolta' di Ingegneria Universita' degli Studi di Trieste via Valerio, 10, 34127 Trieste Italy Filter design 1 Design considerations: a framework |H(f)| 1 C ıp 1 ıp ıs f 0 fp fs Passband Transition Stopband band The design of a digital filter involves five steps: Specification: The characteristics of the filter often have to be specified in the frequency domain. For example, for frequency selective filters (lowpass, highpass, bandpass, etc.) the specification usually involves tolerance limits as shown above. Coefficient calculation: Approximation methods have to be used to calculate the values hŒk for a FIR implementation, or ak, bk for an IIR implementation. Equivalently, this involves finding a filter which has H.z/ satisfying the requirements. Realisation: This involves converting H.z/ into a suitable filter structure. Block or flow diagrams are often used to depict filter structures, and show the computational procedure for implementing the digital filter. 1 Analysis of finite wordlength effects: In practice one should check that the quantisation used in the implementation does not degrade the performance of the filter to a point where it is unusable. Implementation: The filter is implemented in software or hardware. The criteria for selecting the implementation method involve issues such as real-time performance, complexity, processing requirements, and availability of equipment. 2 Finite impulse response (FIR) filter design A FIR filter is characterised by the equations N 1 yŒn D hŒkxŒn k kXD0 N 1 H.z/ D hŒkzk: kXD0 The following are useful properties of FIR filters: They are always stable — the system function contains no poles. This is particularly useful for adaptive filters. They can have an exactly linear phase response. The result is no frequency dispersion, which is good for pulse and data transmission. Finite length register effects are simpler to analyse and of less consequence than for IIR filters. They are very simple to implement, and all DSP processors have architectures that are suited to FIR filtering. For large N (many filter taps), the FFT can be used to improve performance. 2 Of these, the linear phase property is probably the most important. A filter is said to have a generalised linear phase response if its frequency response can be expressed in the form H.ej! / D A.ej! /ej˛!Cjˇ where ˛ and ˇ are constants, and A.ej! / is a real function of !. If this is the case, then If A is positive, then the phase is ^H.ej! / D ˇ ˛!: If A is negative, then ^H.ej! / D C ˇ ˛!: In either case, the phase is a linear function of !. It is common to restrict the filter to having a real-valued impulse response hŒn, since this greatly simplifies the computational complexity in the implementation of the filter. A FIR system has linear phase if the impulse response satisfies either the even symmetric condition hŒn D hŒN 1 n; or the odd symmetric condition hŒn DhŒN 1 n: The system has different characteristics depending on whether N is even or odd. Furthermore, it can be shown that all linear phase filters must satisfy one of these conditions. Thus there are exactly four types of linear phase filters. 3 Consider for example the case of an odd number of samples in hŒn, and even symmetry. The frequency response for N D 7 is 6 H.ej! / D hŒnej!n nD0 X D hŒ0 C hŒ1ej! C hŒ2ej2! C hŒ3ej 3! C hŒ4ej4! C hŒ5ej5! C hŒ6ej6! D ej 3!.hŒ0ej 3! C hŒ1ej2! C hŒ2ej! C hŒ3 C hŒ4ej! C hŒ5ej2! C hŒ6ej 3!/: The specified symmetry property means that hŒ0 D hŒ6, hŒ1 D hŒ5, and hŒ2 D hŒ4, so H.ej! / D ej 3!.hŒ0.ej 3! C ej 3!/ C hŒ1.ej2! C ej2!/ C hŒ2.ej! C ej!/ C hŒ3/ D ej 3!.2hŒ0 cos.3!/ C 2hŒ1 cos.2!/ C 2hŒ2 cos.!// 3 D ej 3! aŒn cos.!n/; nD0 X where aŒ0 D hŒ3, and aŒn D 2hŒ3 n for n D 1;2;3. The resulting filter clearly has a linear phase response for real hŒn. It is quite simple to show that in general for odd values of N the frequency response is .N 1/=2 H.ej! / D ej!.N 1/=2 aŒn cos.!n/; nD0 X for a set of real-valued coefficients aŒ0;:::;aŒ.N 1/=2. As different values for aŒn are selected, different linear-phase filters are obtained. 4 The cases of N odd and hŒn antisymmetric are similar to that presented, and the frequency responses are summarised in the following table: Symmetry N H.ej! / Type .N 1/=2 Even Odd ej!.N 1/=2 aŒn cos.!n/ 1 nD0 X N=2 Even Even ej!.N 1/=2 bŒn cos.!.n 1=2// 2 nD1 X .N 1/=2 Odd Odd ej Œ!.N 1/=2=2 aŒn sin.!n/ 3 nD0 X N=2 Odd Even ej Œ!.N 1/=2=2 bŒn sin.!.n1=2// 4 nD1 X Recall that even symmetry implies hŒn D hŒN 1 n and odd symmetry hŒn DhŒN 1 n. Examples of filters satisfying each of these symmetry conditions are: 5 2 [n] 1 0 h −2 −1 0 1 2 3 4 5 6 2 [n] 2 0 h −2 −1 0 1 2 3 4 5 6 2 [n] 3 0 h −2 −1 0 1 2 3 4 5 6 2 [n] 4 0 h −2 −1 0 1 2 3 4 5 6 n The center of symmetry is indicated by the dotted line. The process of linear-phase filter design involves choosing the aŒn values to obtain a filter with a desired frequency response. This is not always possible, however — the frequency response for a type II filter, for example, has the property that it is always zero for ! D , and is therefore not appropriate for a highpass filter. Similarly, filters of type 3 and 4 introduce a 90ı phase shift, and have a frequency response that is always zero at ! D 0 which makes them unsuitable for as lowpass filters. Additionally, the type 3 response is always zero at ! D , making it unsuitable as a highpass filter. The type I filter is the most versatile of the four. Linear phase filters can be thought of in a different way. Recall that a linear phase characteristic simply corresponds to a time shift or delay. Consider now a real FIR filter with an impulse response that satisfies the even symmetry condition hŒn D hŒn: 6 2 1 hŒn 0 −1 −5 0 5 n 6 / 4 j! 2 0 H.e −2 −4 0 ω Recall from the properties of the Fourier transform this filter has a real-valued frequency response A.ej! /. Delaying this impulse response by .N 1/=2 results in a causal filter with frequency response H.ej! / D A.ej! /ej!.N 1/=2: This filter therefore has linear phase. 2 1 hŒn 0 −1 −2 0 2 4 6 8 n j / 5 j! H.e j 0 0 ω / 2 j! 0 H.e ^ 2 0 ω 7 2.1 Window method for FIR filter design j! Assume that the desired filter response Hd .e / is known. Using the inverse Fourier transform we can determine hd Œn, the desired unit sample response. In the window method, a FIR filter is obtained by multiplying a window wŒn with hd Œn to obtain a finite duration hŒn of length N . This is required since hd Œn will in general be an infinite duration sequence, and the corresponding filter will therefore not be realisable. If hd Œn is even or odd symmetric and wŒn is even symmetric, then hd ŒnwŒn is a linear phase filter. Two important design criteria are the length and shape of the window wŒn. To see how these factors influence the design, consider the multiplication operation in the frequency domain: since hŒn D hd ŒnwŒn, j! j! j! H.e / D Hd .e / W.e /: The following plot demonstrates the convolution operation. In each case the j! dotted line indicates the desired response Hd .e /. / / j.! 0 W.e 0 ! 2 3 θ / j! H.e 0 0 2 3 ω From this, note that The mainlobe width of W.ej!/ affects the transition width of H.ej! /. Increasing the length N of hŒn reduces the mainlobe width and hence the 8 transition width of the overall response. The sidelobes of W.ej! / affect the passband and stopband tolerance of H.ej! /. This can be controlled by changing the shape of the window. Changing N does not affect the sidelobe behaviour. Some commonly used windows for filter design are Rectangular: 1 0 n N wŒn D 80 otherwise < Bartlett (triangular): : 2n=N 0 n N=2 wŒn D 82 2n=N N=2<n N ˆ <0 otherwise ˆ Hanning: :ˆ 0:5 0:5 cos.2n=N/ 0 n N wŒn D 80 otherwise < Hamming: : 0:54 0:46 cos.2n=N/ 0 n N wŒn D 80 otherwise < Kaiser: : 2 1=2 I0Œˇ.1 Œ.n ˛/=˛ / 0 n N wŒn D 80 otherwise < Examples of five of these: windows are shown below: 9 1 Rectangular Triangular 0.5 0 0 N/2 N n 1 Hanning Hamming 0.5 Blackman wŒn wŒn 0 0 N/2 N n All windows trade off a reduction in sidelobe level against an increase in mainlobe width.