You are on page 1of 10

European Journal of Scientific Research

ISSN 1450-216X Vol.31 No.1 (2009), pp. 19-28
© EuroJournals Publishing, Inc. 2009

High Speed and Low Power FPGA Implementation of FIR Filter
for DSP Applications

Shanthala S
Asst. Professor, Bangalore Institute of Technology, Bangalore, India
Research Scholar, EC Research Centre
NMAM Institute of Technology
Nitte-574110, India

S. Y. Kulkarni
Principal, NMAM Institute of Technology
Nitte-574110, Karnataka, India


Signal processing ranks among the most demanding applications of digital design
concepts and practices. It is a mature technology domain wherein the demands for
enhanced performance and reduced resource utilization have risen exponentially over the
years. Recent advancements in Field Programmable Gate Array (FPGA) design technology,
has resulted in FPGA(s) becoming the preferred platform for evaluating and implementing
signal processing algorithms. Special features of the FPGA architecture, like embedded
multipliers, fast carry chains, scalability and re-configurability make it a very attractive
platform for complex signal processing algorithms. Digital Signal Processing (DSP) deals
with the manipulation of digital signals using complex signal processing systems built from
basic building blocks like filters and signal transformations. The advent of engineering
tools like MATLAB has enabled the design of these basic building blocks faster and more
accurate. This document provides a brief discourse on the effective application of VLSI
design methodologies for efficient implementation of these basic DSP blocks, using an FIR
Filter and the Fast Fourier Transform as specific cases.

Keywords: Low Power, FIR filter, FPGA, DSP

1. Introduction
A filter is used to modify an input signal in order to facilitate further processing. A digital filter works
on a digital input (a sequence of numbers, resulting from sampling and quantizing an analog signal)
and produces a digital output. According to Dr. U. Meyer-Baese [Baese 2nd Ed.], “the most common
digital filter is the Linear Time-Invariant (LTI) filter”. Designing an LTI involves arriving at the filter
coefficients which, in turn, represents the impulse response of the proposed filter design. These
coefficients, in linear convolution with the input sequence will result in the desired output. The linear
convolution process can be represented as [[Baese 2nd Ed.]:

1) Here. while implementing on an FPGA. It takes the filter specifications as inputs. if the filter has an infinite impulse response. The coefficients of an FIR filter. the filter coefficients have to be quantized to a fixed point notation. 2. It can be seen that the extent of the summation is governed by k. Designing Digital FIR Filters Using FDA Tool The Filter Design and Analysis Tool (FDA Tool) is a graphical user interface (GUI) available in the Signal Processing Toolbox of MATLAB for designing and analyzing filters. Therefore. Table 1: FIR filter specifications Filter performance parameter Value Pass band frequency 11000 Hz Pass band attenuation 3 dB Stop band frequency 12000 Hz Stop band attenuation 65 dB Sampling frequency 48000 . The double length floating point notation for filter coefficients.1) can be re-written as follows. Therefore. The Filter Design and Analysis (FDA) tool packaged along with MATLAB is such a tool. Equation (1. Figure 1: FIR filter of order L. To overcome this. as follows: L −1 y [ n ] = x[ n ] * f [ n ] = ∑ k =0 f [ k ] x[ n − k ] (1. the summation extends to infinity and the filter is said to be an Infinite Impulse Response (IIR) filter. the FIR filter detailed above is an LTI filter [2]. Hardware description for the filter implementation is generated in Verilog HDL and simulations of the hardware description are performed using ModelSim. denote the impulse response of the filter.High Speed and Low Power FPGA Implementation of FIR Filter for DSP Applications 20 y[n] = x[n] * f [n] = ∑ x[k ] f [n − k ] = ∑ f [k ]x[n − k ] k k (1. which denotes the extent of the impulse response of the filter. for an order of L. A filter with a finite value for k is said to be a Finite Impulse Response (FIR) filter.2) Figure 1: shows the schematic of an FIR filter of order L. It can be inferred that the output of an FIR filter remains dependant only on the inputs and the coefficients. used by the FDA tool poses immense challenges in terms of cost and resources. y[n] signifies the output of the filter and x[n] is the digital input to the filter. The impulse response of the filter is given by f[k] and the operator ‘*’ denotes the convolution operation. It is imperative for any system implementation of such a filter to use a number format that represents the coefficients to as much precision as allowed by the resource constraints. This chapter details the process of designing filters and analyzing the effects of coefficient quantization on the overall response using the MATLAB FDA tool. resulting in the introduction of a certain amount of imprecision. as mentioned earlier. with constant coefficients x[n] Z-1 Z-1 Z-1 Z-1 X X X X X f[0] f[1] f[2] f[L-2] f[L-1] + + + + y[n] Calculating the constant coefficients of such a digital filter involves considerable amount of computation and this is generally performed using software tools. Table 1 shows the specifications of an FIR low pass equi-ripple filter.

Y. Figure 2: Filter design using MATLAB FDA tool The designed filter is of order 84. pass band. It must be noted that the FDA Tool uses double precision floating point representation for the design calculations. pass band ripple and stop band ripple are denoted in the screen shot. which is reflected in the close-to-ideal response of the reference filter. The tool performs the filter design calculations using double precision floating point numeric representation and displays the response of a reference filter. Kulkarni The sampling frequency is chosen as 4 times the stop band and the filter has a steep transition band with a width of 1000 Hz.21 Shanthala S and S. transition band. Specifications of the filter. in detail. Figure 3 shows the response of the reference filter. stop band. Figure 2 shows the filter design window of FDA tool. This allows the tool to achieve a fair degree of precision. namely. after completion of the design process. Figure 3: Response of the reference filter . These specifications are fed as inputs to the FDA tool in MATLAB R2006b.

When a filter is constructed with digital hardware. That is. . the minimum word length needed for specified performance accuracy must be determined [DeBrunner. 2002 and Lim.14 fixed point numeric representation format[Hu. the filter transfer function changes . The new transfer function [H (z)]t is given by [DeBrunner. After applying the aforesaid quantization to the filter coefficients. the reference filter is quantized to a Q16.High Speed and Low Power FPGA Implementation of FIR Filter for DSP Applications 22 The response shown is calculated from 0 Hz (DC) up to 24000 Hz.7 are considered to analyze the effects of varying the word length while quantizing the filter coefficients.14 format. the resource constraints associated with hardware implementation pose the challenge of using fixed point arithmetic in VLSI implementations. 2002]. 2. Li. DeBrunner & DeBrunner. and Song. achieving stop band attenuation at 12000 Hz.14 format Using the FDA Tool. Two such formats namely.3) 1+ ∑ak z −k k =0 As a result of the fixed point finite word length used in a digital filter.14 . Effects of finite word length The accuracy of a digital filter is limited by the finite word length used in its implementation. the next bit for representing the non-fractional magnitude and the remaining the fractional magnitude. Table 2: Numeric representation format Q16. with αk bounded in absolute value by 2-b. Similarly. Quantization to Q16. However. each coefficient is replaced by its t-bit representation.14 and Q8.2.Bit distribution MSB Bit Bit Bit Bit Bit Bit Bit Bit Bit Bit Bit Bit Bit Bit LSB (15) (14) (13) (12) (11) (10) (9) (8) (7) (6) (5) (4) (3) (2) (1) (0) s M MF MF MF MF MF MF MF MF MF MF MF MF MF MF Here. The transfer function of a direct form FIR filter is given by: M ∑b k z −k H ( z) = k =0 L (1. which is half of the sampling frequency specified (FS / 2). 1999]. Q 16. out of which the most significant bit (MSB) is used to represent the sign of the number. The pass band response ripples with 0 dB as centre and the stop band ripples are all below 65dB in magnitude. Figure 4 shows the response of the filter after quantizing the coefficients to Q16. 2002]: ∑ (b ) M k + β k z −k [ H ( z )] = k =0 (1. An ideal filter requires infinite word length to truly represent the filter coefficients.1. ‘M’ denotes the non fractional magnitude and ‘MF’ denotes the fractional magnitude. ‘S’ denotes the sign bit. The filter has a steep transition band starting at 11000 Hz. the response of the filter is compared against that of the reference filter (which uses double precision floating point representation). Table 2 illustrates this distribution in detail. the coefficient ak is replaced by (ak + αk).4) t ( ) L 1+ ∑ ak +αk z −k k =0 2. The simplest and most widely used approach to the problem is to round off the optimal infinite precision coefficients to a b-bit representation [Sung and Kum. bk is replaced by (bk + βk). Therefore. This means that the total word length is 16 bits. Yang. for the sake of cost and speed. 1995].

Table 4 shows the effect of quantization on the values of the first 4 filter coefficients. ‘M’ denotes the non fractional magnitude and ‘MF’ denotes the fractional magnitude. This is explained by the fact that the coefficients have lost some amount of precision while being quantized from a double precision floating point representation to the Q16. As established by equation 1.7 format. .7. the difference is drastic in the stop band response of the quantized filter.7 format. Here. Table 3: Numeric representation format Q16. the response of the filter is compared with the reference filter.7 format A larger effect of coefficient quantization can be observed for the representation format Q8.14 . Quantization to Q8.23 Shanthala S and S. After quantizing the filter coefficients to Q8. Table 3 illustrates this distribution in detail. ‘S’ denotes the sign bit. Kulkarni Figure 4:FIR filter response after coefficient quantization to Q16. Y.14 The quantized filter has larger ripples than the reference filter.7 format. However.3. The pass band response is relatively unaffected by the quantization. This is due to the substantial loss of precision as a result of quantization to the sub-optimal Q8.Bit distribution MSB Bit Bit Bit Bit Bit Bit Bit (8) (6) (5) (4) (3) (2) (1) (0) S M MF MF MF MF MF MF Here. any change in the precision of the filter coefficients (F[k]) will have a direct bearing on the output of the filter.2. 2.14 format. the total word length is 8 bits and the number of bits available for representing the fractional magnitude is 7. Figure 5 shows the response of the filter after quantizing coefficients to Q8.

Generating Verilog HDL Code The major challenge in implementing a higher order filter in hardware is the large number of multiplications. The FDA tool allows the user to generate test benches to analyze the response of the filter to a variety of test input patterns.02142333984375 -0.0078125 f[2] -0. HDL code and test benches (for unit impulse response) are generated for both the quantized versions (Q16. .00054931640625 0 f[1] -0.021419539568209876 -0. with multipliers implemented in pipelined tree architecture.7).034769720164499404 -0.0234375 f[3] -0.Q 16.14 format is shown in Figure 6.4. Hardware Implementation .00054329878115638654 -0. The initial portion of the simulation results for FIR filter with coefficients quantized to Q16.03125 Note: *The values of filter coefficients after quantization have been exported from FDA tool 2.00701904296875 -0.8.High Speed and Low Power FPGA Implementation of FIR Filter for DSP Applications 24 Figure 5: FIR filter response after coefficient quantization to Q8.14 and Q8. instructions can be given to optimize the HDL by using a variety of techniques like pipelining and distributed arithmetic.7* f[0] -0. The HDL code for the filter designed in the previous section is generated using FDA Tool. During HDL generation from FDA Tool.0070136005387712343 -0.7 Table 4: Effect of quantization on filter coefficients Coefficient Double precision floating point Quantized .0347900390625 -0.14* Quantized .

the output is 16 bits wide.14 FIR filter – Final portion The approach for the Q8.7 filter is just the same and results obtained are also similar.25 Shanthala S and S.7 format. Here. with 84 coefficients coming out as response. Figure 8 shows the response of the FIR filter with coefficients quantized to Q8. The last signal displayed is the iteration counter (n) that shows the order of the coefficient being output. Figure 7 shows the final portion of the output. . The response sequence starts with the first filter coefficient and goes on till time 1900ns.14 FIR filter – Initial portion An impulse input is applied to the filter at time 45ns (this is when the system comes out of reset). Y. Note that the output is 32 bit wide. The filter starts responding at time 200ns (after 155ns). showing the end of the impulse response at time 1900ns. Kulkarni Figure 6: Simulation results for Q16. Figure 7: Simulation results for Q16.

High Speed and Low Power FPGA Implementation of FIR Filter for DSP Applications 26 Figure 8: Simulation results for Q16. Methods to Reduce the Effect of Fixed Word Length Figure 9: Relation ship between δ.14 FIR filter Response Response shows shows more more inaccuracies number due to zeroes of finite word length Q8.1.7 (inaccuracies) 3. “Using the approximate design formula for optimal infinite-precision low-pass FIR filters and a statistical upper bound for error . Integer Programming The effect of fixing the word length used to represent the coefficients of a digital FIR filter of order N. 1980] 3. N and b [Kodek. can be minimized by using an optimum number of bits b to represent the N coefficients of the filter by using integer programming techniques. Kodek. According to Dusan M.

Figure 9 details the relationship: Pass band response D(f) = 1. the parallel or cascade form should be used for high-order filters whenever possible. N and b is obtained experimentally upon optimal finite word length low-pass FIR filters defined by equations (1. Next step is to obtain a minimum word-length for each group. [Sung and Kum.” [Kodek.e.5. The effects of using finite word length representation can be minimized by analytical or qualitative methods or simply by choosing to implement higher order filters in cascaded or parallel form. estimate and overcome where possible. Kulkarni caused by the rounding. number of coefficients N. While implementing a filter on hardware. Therefore. Based on the range of each signal. 0. 1980] This relationship between δ. i. 1980].5) and (1. or a switch or input-output signals of an adder etc. the biggest challenge is to achieve specified system performance at minimum hardware cost.20 (1. 2002] 4. [Kodek. Positive weight function W(f) = 1.27 Shanthala S and S. Word Length Optimization This is an iterative and qualitative method to arrive at the optimum word length based on a specified system performance.. and coefficient word length b. a multiplexer. a uniform word length is assigned to each group.3. the smallest word-length that satisfies the fixed-point performance of the system. it is possible to get an approximate relationship between deviation δ. 1995] 3. One among the hurdles is to understand. [DeBrunner .6) It can be seen that the response for optimal and rounded coefficients are very close. The word length that has the minimum hardware cost and still satisfies the specified system performance criteria. Conclusion Using powerful computer based software tools to perform redundant calculations in the filter design process enables a designer to arrive at the best design within the shortest time. The saving in the number of coefficient bits can be quite substantial. (1. Positive weight function W(f) = 1. The grouping strategy should be to group signals connected by a delay.5) Stop band response D(f) = 0.25 <f< 0. 0 <f< 0. The difference between the optimal and rounded coefficients multiplied by 2(b-1) is never greater than 4 for all N between 6 and 40 and all b between 3 and 15.6). and for the equivalent filters with rounded coefficients. . This shows that there is an optimal number of bits b for each value of Nb. Y.2. Cascade or Parallel Realization for Higher Order Filters In general. the effects of using a finite word length to represent the infinite word length coefficients. is chosen. Selecting a non- optimized word length can result in the filter transfer function being different from what is expected. the effect of coefficient inaccuracy resulting from finite word length fixed point representation is more pronounced for a high-order filter when it is realized in the direct form than when it is realized in the parallel or cascade form. The net-list of a signal flow block diagram is pre processed to group the signals that can have the same fixed-point attributes in order to minimize the number of variables for the optimization. 3.

Lim. 8. 163-166. vol. 3. C. DeBrunner. and J. Yang.109. “Simulation-Based Word-Length Optimization Method for Fixed-point Digital Signal Processing Systems”. W. [7] S. S. [2] U.12. 6. 46. Song. Chan. No. Proc. 1980. IEEE Transactions on Signal Processing. on Circuits and Systems. Hu. D. no. No. and K. Li. Digital Signal Processing with Field Programmable Gate Arrays Second Edition .577- 584. [5] X. pp. KODEK. and V. L. Liu. 4. 1999. Vol. and Signal Processing.” IEEE Transactions on Circuits and Systems II. Springer.365-368. Speech. Digital Signal Processing with Field Programmable Gate Arrays Second Edition . pp. 2001. December 1995.pp. “Signed-power-of-two term allocation scheme for the design of digital filters. June 2001.” IEEE Signal Processing Letters. Meyer-Baese. L. 2002. [6] Y. “An efficient design for FIR filters with Variable precision”. May 1999. DeBrunner. [4] Wonyong Sung and Ki-Il Kum. [3] DUSAN M. 2002 IEEE Int. Meyer-Baese. 43.High Speed and Low Power FPGA Implementation of FIR Filter for DSP Applications 28 References [1] U. Vol. vol. p. “Design of Optimal Finite Word length FIR Digital Filters Using Integer Programming Techniques” IEEE Transactions on Acoustics. C.110. “Multiplier less perfect reconstruction modulated filterbanks with sum-of-powers-of-two coefficients.May 2002. vol. Ho. p. Springer. . ASSP-28. JUNE 1980. 1995. R. Symp.