LIBML  Version 3.2.4
LIBML DSP Software Library
Functions
Finite Impulse Response (FIR) Lattice Filters
Collaboration diagram for Finite Impulse Response (FIR) Lattice Filters:

Functions

void tpt_fir_lattice_f32 (f32_t *aOutData, const tpt_fir_lattice_f32_t *aFilter, const f32_t *aInData, uint32_t aCount)
 Processing function for the floating-point FIR lattice filter. More...
 
void tpt_fir_lattice_init_f32 (tpt_fir_lattice_f32_t *aFilter, uint16_t aStages, const f32_t *aCoeffs, f32_t *aState)
 Initialization function for the floating-point FIR lattice filter. More...
 
void tpt_fir_lattice_init_q15 (tpt_fir_lattice_q15_t *aFilter, uint16_t aStages, const q15_t *aCoeffs, q15_t *aState)
 Initialization function for the Q15 FIR lattice filter. More...
 
void tpt_fir_lattice_init_q31 (tpt_fir_lattice_q31_t *aFilter, uint16_t aStages, const q31_t *aCoeffs, q31_t *aState)
 Initialization function for the Q31 FIR lattice filter. More...
 
void tpt_fir_lattice_q15 (q15_t *aOutData, const tpt_fir_lattice_q15_t *aFilter, const q15_t *aInData, uint32_t aCount)
 Processing function for Q15 FIR lattice filter. More...
 
void tpt_fir_lattice_q31 (q31_t *aOutData, const tpt_fir_lattice_q31_t *aFilter, const q31_t *aInData, uint32_t aCount)
 Processing function for the Q31 FIR lattice filter. More...
 

Detailed Description

This set of functions implements Finite Impulse Response (FIR) lattice filters for Q15, Q31 and floating-point data types. Lattice filters are used in a variety of adaptive filter applications. The filter structure is feedforward and the net impulse response is finite length. The functions operate on blocks of input and output data and each call to the function processes aCount samples through the filter. aInData and aOutData point to input and output arrays containing aCount values.

Algorithm
Finite Impulse Response Lattice
filter" The following difference equation is implemented:
    f0[n] = g0[n] = x[n]
    fm[n] = fm-1[n] + km * gm-1[n-1] for m = 1, 2, ...M
    gm[n] = km * fm-1[n] + gm-1[n-1] for m = 1, 2, ...M
    y[n] = fM[n]
  
pCoeffs points to tha array of reflection coefficients of size uStages. Reflection Coefficients are stored in the following order.
    { k1, k2, ..., kM }
  
where M is number of stages
pState points to a state array of size uStages. The state variables (g values) hold previous inputs and are stored in the following order.
    { g0[n], g1[n], g2[n] ...gM-1[n] }
  
The state variables are updated after each block of data is processed; the coefficients are untouched.
Instance Structure
The coefficients and state variables for a filter are stored together in an instance data structure. A separate instance structure must be defined for each filter. Coefficient arrays may be shared among several instances while state variable arrays cannot be shared. There are separate instance structure declarations for each of the 3 supported data types.
Initialization Functions
There is also an associated initialization function for each data type. The initialization function performs the following operations:
  • Sets the values of the internal structure fields.
  • Zeros out the values in the state buffer. To do this manually without calling the init function, assign the follow subfields of the instance structure: uStages, pCoeffs, pState. Also set all of the values in pState to zero.
Use of the initialization function is optional. However, if the initialization function is used, then the instance structure cannot be placed into a const data section. To place an instance structure into a const data section, the instance structure must be manually initialized. Set the values in the state buffer to zeros and then manually initialize the instance structure as follows:
    tpt_fir_lat_f32_t aFilter1 = { aStages, aState, aCoeffs };
    tpt_fir_lat_q31_t aFilter2 = { aStages, aState, aCoeffs };
    tpt_fir_lat_q15_t aFilter3 = { aStages, aState, aCoeffs };
  
where aStages is the number of stages in the filter; aState is the address of the state buffer; aCoeffs is the address of the coefficient buffer.
Fixed-Point Behavior
Care must be taken when using the fixed-point versions of the FIR Lattice filter functions. In particular, the overflow and saturation behavior of the accumulator used in each function must be considered. Refer to the function specific documentation below for usage guidelines.

Function Documentation

◆ tpt_fir_lattice_f32()

void tpt_fir_lattice_f32 ( f32_t aOutData,
const tpt_fir_lattice_f32_t aFilter,
const f32_t aInData,
uint32_t  aCount 
)

Processing function for the floating-point FIR lattice filter.

Parameters
[out]aOutDatapoints to the block of output data.
[in]aFilterpoints to an instance of the floating-point FIR lattice structure.
[in]aInDatapoints to the block of input data.
[in]aCountnumber of samples to process
Returns
none

◆ tpt_fir_lattice_init_f32()

void tpt_fir_lattice_init_f32 ( tpt_fir_lattice_f32_t aFilter,
uint16_t  aStages,
const f32_t aCoeffs,
f32_t aState 
)

Initialization function for the floating-point FIR lattice filter.

Parameters
[in]aFilterpoints to an instance of the floating-point FIR lattice structure.
[in]aStagesnumber of filter stages
[in]aCoeffspoints to the coefficient buffer. The array is of length aStages.
[in]aStatepoints to the state buffer.
Returns
none

◆ tpt_fir_lattice_init_q15()

void tpt_fir_lattice_init_q15 ( tpt_fir_lattice_q15_t aFilter,
uint16_t  aStages,
const q15_t aCoeffs,
q15_t aState 
)

Initialization function for the Q15 FIR lattice filter.

Parameters
[in]aFilterpoints to an instance of the Q15 FIR lattice structure.
[in]aStagesnumber of filter stages
[in]aCoeffspoints to the coefficient buffer. The array is of length aStages.
[in]aStatepoints to the state buffer. The array is of length aStages.
Returns
none

◆ tpt_fir_lattice_init_q31()

void tpt_fir_lattice_init_q31 ( tpt_fir_lattice_q31_t aFilter,
uint16_t  aStages,
const q31_t aCoeffs,
q31_t aState 
)

Initialization function for the Q31 FIR lattice filter.

Parameters
[in]aFilterpoints to an instance of the Q31 FIR lattice structure.
[in]aStagesnumber of filter stages
[in]aCoeffspoints to the coefficient buffer. The array is of length aStages.
[in]aStatepoints to the state buffer. The array is of length aStages.
Returns
none

◆ tpt_fir_lattice_q15()

void tpt_fir_lattice_q15 ( q15_t aOutData,
const tpt_fir_lattice_q15_t aFilter,
const q15_t aInData,
uint32_t  aCount 
)

Processing function for Q15 FIR lattice filter.

Parameters
[out]aOutDatapoints to the block of output data.
[in]aFilterpoints to an instance of the Q15 FIR lattice structure.
[in]aInDatapoints to the block of input data.
[in]aCountnumber of samples to process
Returns
none

◆ tpt_fir_lattice_q31()

void tpt_fir_lattice_q31 ( q31_t aOutData,
const tpt_fir_lattice_q31_t aFilter,
const q31_t aInData,
uint32_t  aCount 
)

Processing function for the Q31 FIR lattice filter.

Parameters
[out]aOutDatapoints to the block of output data.
[in]aFilterpoints to an instance of the Q31 FIR lattice structure.
[in]aInDatapoints to the block of input data.
[in]aCountnumber of samples to process
Returns
none
Scaling and Overflow Behavior
In order to avoid overflows the input signal must be scaled down by 2 * log2(uStages) bits.