31.6.1 mips_fir16

Description

Computes a finite impulse response (FIR) filter with coefficients specified in coeffs2x over the input data samples in indata. The function updates the delayline, which is used to initialize the filter the next time mips_fir16() is called. The number of samples to be processed is given by the parameter N and the number of filter coefficients is given by K. The scale parameter specifies the amount of right shift applied to the final result.

Mathematically,

o u t p u t n = 1 2 s c a l e k = 0 K 1   i n d a t a n k × c o e f f s k

Include

dsplib_dsp.h

Prototype

void
mips_fir16
(
       int16 *outdata,
       int16 *indata,
       int16 *coeffs2x,
       int16 *delayline,
       int N,
       int K,
       int scale
);

Argument

outdata: Output array with 16-bit fixed-point elements in Q15 format.

indata: Input array with 16-bit fixed-point elements in Q15 format.

coeffs2x: Array of 2K 16-bit fixed-point coefficients prepared by mips_fir16_setup().

delayline: Delay line array holding the last K input samples.

N: Number of samples.

K: Number of coefficients (filter taps).

scale: Scaling factor: divide the result by 2scale.

Return Value

None.

Remarks

  • The pointers outdata, indata, coeffs2x, and delayline must be aligned on a 4-byte boundary.
  • K must be larger than or equal to 4 and a multiple of 4.

    Notes

    The coeffs2x array is twice the size of the original coefficient array, coeffs. The function mips_fir16_setup() takes the original coefficient array coeffs and rearranges the coefficients into the coeffs2x array to enable more efficient processing. All elements of the delayline array must be initialized to zero before the first call to mips_fir16(). Both delayline and coeffs2x have formats that are implementation-dependent and their contents should not be changed directly.

    Example

    int i;
    int K = 8;
    int N = 32;
    int16 coeffs[K];
    int16 coeffs2x[2*K];
    int16 delayline[K];
    int16 indata[N];
    int16 outdata[N];
    for (i = 0; i < K; i++)
       delayline[i] = 0;
    // load coefficients into coeffs here
       ...
    mips_fir16_setup(coeffs2x, coeffs, K);
    while (true)
    {
       // load input data into indata
          ...
       mips_fir16(outdata, indata, coeffs2x, delayline, N, K, 3);
       // do something with outdata
          ...
    }