DSP_fir_sym

DSP_fir_sym

Symmetric FIR Filter

Function

 

 

 

 

void DSP_fir_sym (const short * restrict x, const short * restrict h, short * re-

 

 

strict r, int nh, int nr, int s)

Arguments

 

x[nr+2*nh]

Pointer to input array of size nr + 2*nh. Must be double-word

 

 

 

aligned.

 

 

h[nh+1]

Pointer to coefficient array of size nh + 1. Coefficients are in

 

 

 

normal order and only half (nh+1 out of 2*nh+1) are required.

 

 

 

Must be double-word aligned.

 

 

r[nr]

Pointer to output array of size nr. Must be word aligned.

 

 

nh

Number of coefficients. Must be multiple of 8. The number of

 

 

 

original symmetric coefficients is 2*nh+1.

 

 

nr

Number of samples to calculate. Must be multiple of 4.

 

 

s

Number of insignificant digits to truncate; e.g., 15 for Q.15

 

 

 

input data and coefficients.

Description

 

This function applies a symmetric filter to the input samples. The filter tap array

 

 

h[] provides ‘nh+1’ total filter taps. The filter tap at h[nh] forms the center point

 

 

of the filter. The taps at h[nh − 1] through h[0] form a symmetric filter about this

 

 

central tap. The effective filter length is thus 2*nh+1 taps.

 

 

The filter is performed on 16-bit data with 16-bit coefficients, accumulating

 

 

intermediate results to 40-bit precision. The accumulator is rounded and

 

 

truncated according to the value provided in ‘s’. This allows a variety of

 

 

Q-points to be used.

Algorithm

 

This is the C equivalent of the assembly code without restrictions. Note that

 

 

the assembly code is hand optimized and restrictions may apply.

 

 

void DSP_fir_sym(short *x, short *h, short *r, int nh, int nr,

 

 

int s)

 

 

 

{

 

 

int

i, j;

long

y0;

long

round = (long) 1 << (s − 1);

for (j = 0; j < nr; j++) { y0 = round;

for (i = 0; i < nh; i++)

4-52

Page 80
Image 80
Texas Instruments TMS320C64X manual DSPfirsym, Symmetric FIR Filter