Summary: This module is an overview of the design and implementation of FIR filtering.
In this lab, you will learn the design and implementation of FIR filtering. The discrete convolution equation that describes the behavior of a causal length-
You can skip reading this section if you are already familiar with digital filtering.
|
In this lab, we will not be concerned with the details of filter design techniques. Rather, you only learn how to use several MATLAB commands that design the filters for you once you specify desired frequency response of the filter. The real-time implementation will be simply implementing the discrete-time convolution equation with the impulse response (filter coefficients) obtained from MATLAB. If you want to learn more details, please refer to any introductory digital signal processing textbook.
Design FIR filters and compare them using MATLAB by the following steps (assume 48kHz sampling rate in all your designs):
fir1, fir2, remez, filter, and freqz.fir1 command.remez commandfreqz command. How are the filters different?fir2 command.remez command.freqz command. How are the filters different?remez command. Specify the transition bands as 3kHz-4kHz and 8kHz-9kHz.In this lab, you implement the FIR filtering in assemb1y language by modifying the dot product code you wrote in (Reference).
Rather than defining the filter coefficients in your main assembly program file, it is usually more convenient to store them in a separate file. By defining the coefficients in a separate assembly (for example, coeff.asm) file, you can load the coefficients at a desired memory location at the run time, although it is not essential for the current simple FIR filtering lab.
The assembly file containing the filter coefficients can be written as follows:
1 .def _coef
2 .sect “coeffs”
3
4 _coef:
5 .short 0ff9bh
6 .short 0ff06h
7 .short 0feffh
8 .short 0ff93h
9 .short 070h
10 .short 0117h
11 .short 0120h
12 .short 07bh
Each coefficient must be converted to the Q-15 format and defined by each .short assembly directive. For your convenience, I wrote a short MATLAB script save_coef.m that converts the filter coefficients stored as a MATLAB vector to Q-15 format and then writes to a file exactly in the above format. The section coeffs should be defined in the link command file so that the coefficients are to be loaded at the correct memory location.
You can simply include the coeff.asm using the .include directive at the beginning of your main assembly program.
Make coefficient files for each of the filters you designed in Exercise 1.
Now you are ready to implement FIR filter algorithm.
.asm file, use the provided save_coef.m function. First implement the length-40 lowpass filter with 10kHz passband designed using the remez.You can count the number of CPU cycles necessary to execute the FIR filtering function to see the maximum possible sampling frequency the filter can handle.
As you might already have noticed, a lot of cycles are wasted in FIR filtering while maintaining the buffer to see if you reached the end of buffer and update the address pointers properly. To avoid this unnecessary buffer maintenance, the TI DSP processors have a special addressing mode, called circular addressing. Using circular addressing, you can define a block of memory as a circular buffer. As you increase (or decrease) the pointer register pointing to the buffer index beyond the buffer limit, it automatically points to the other end of the buffer, implementing a circle of data array. Instead of moving the data samples themselves, you can move the pointer which specifies the beginning of the buffer, as each new sample is processed. You don’t need to check if you reached the end of buffer because the address pointer returns to the beginning of the buffer immediately after reaching the end.
Of the 32 registers on the C6x, 8 of them can perform circular addressing. These registers are A4 through A7 and B4 through B7. Since circular addressing is not default, each of these registers must be specified as circular using the AMR (Address Mode Register) register. The lower 16 bits of the AMR are used to select the mode for each of the 8 registers. The upper 10 bits (6 are reserved) are used to set the length of the circular buffer. Buffer size is determined by .align assembler directive. See the explanation on the .align directive in (Reference).