Anda di halaman 1dari 2

ECE-486 Laboratory 2, Spring 2011 Due Feb.

14 Objectives
Develop and test xed-point C subroutines for implementing FIR and IIR lters.

Assignment
TASK 1: FIR Filter Implementation: Re-write and test your C-code implementations of discrete-time convolution from Lab 1 using a pre-dened function interface. The required function interface is dened in the header comments of the fir_filter.c and fir_filter.h les provided on the lab web site. You are not allowed to change the format of any of the function calls. (We will be calling your function using the interface as described in the comments.) Complete the fir_filter.c and fir_filter.h les, and develop a separate routine to test your implementations. TASK 2: IIR Filter Implementation: To avoid instability and avoid rounding errors, xed-point IIR lters are usually implemented as a cascade of multiple sections of second-order systems. The transfer function of each stage of the lter is a ratio of quadratic functions of z. These implementations are called biquadratic or simply biquad lter structures. H(z) = G b10 + b11 z 1 + b12 z 2 a10 + a11 z 1 + a12 z 2 b20 + b21 z 1 + b22 z 2 a20 + a21 z 1 + a22 z 2 ... bs0 + bs1 z 1 + bs2 z 2 as0 + as1 z 1 + as2 z 2 .

Develop a C implementation of this cascaded biquad lter structure. Use a function interface similar to that used for the FIR lters of TASK 1. Use the following function prototypes: BIQUAD_STRUCT *init_biquad(int s, int g, int a[][3], int b[][3]); int calc_biquad(BIQUAD_STRUCT *s, int x); void destroy_biquad(BIQUAD_STRUCT *s); In the above, the input parameter g gives the xed point representation of the scale factor G in the above transfer function. The array elements a[i-1][j] and b[i-1][j] should contain the IIR lter coefcients aij and bij using the notation given above. s denotes the number of biquad lter sections (given by s in the above equation). Complete and comment the above subroutines using le names of biquad_filter.c and biquad_filter.h. Write a separate main program to test the routines.

TASK 3: Real-Time Implementation Write programs to implement the FIR and the IIR lter in real-time using the ECE486 ARM development board. Use a sampling rate of 48 ksps. Test your FIR lter routine using a 20-coefcient lter, and test your IIR lter routine using a 4th order IIR lter (implemented as two cascaded biquad sections). In each case, measure the percentage of the available CPU processing time which is required to implement the lters. Estimate the time (in seconds) required to calculate a single lter output sample for every new lter input sample.

Additional requirements:
Each biquad stage must be implemented using the Direct-Form II lter structure. Assume that lter inputs x, lter outputs y and lter coefcients are represented as xed-point values with the 14 least-signicant bits of the data word representing the fractional part. Assume that ALL calculations performed in your calc_biquad() and calc_fir() subroutines are to be restricted to a 32-bit integer data registers. (No oating point operations are allowed.) Your IIR and FIR functions should be modular, so that (for example) its easy to implement multiple lters of the same type within the same main program without duplicating large code segments for each lter. Your functions will be graded on efciency as well as whether or not they work. Do not waste instruction cycles!

What should be handed in:


1. Hand in commented C source code listings, documentation showing how you tested your routines and results showing that they work. Program listings and documentation will be collected at the beginning of class on the due date. 2. Create a TAR archive containing only the source code les fir_filter.c, fir_filter.h, biquad_filter.c, and biquad_filter.h. The TAR le should be labeled lab2.tar and uploaded on the ECE 486 website. The TAR le must be uploaded before class (11:00 AM) on the due date. 3. Demonstrate your working routines during your scheduled group meeting time in the week of the due date.

Anda mungkin juga menyukai