CMSIS-DSP  
CMSIS DSP Software Library
Infinite Impulse Response (IIR) Lattice Filters

Functions

void arm_iir_lattice_f32 (const arm_iir_lattice_instance_f32 *S, const float32_t *pSrc, float32_t *pDst, uint32_t blockSize)
 Processing function for the floating-point IIR lattice filter. More...
 
void arm_iir_lattice_init_f32 (arm_iir_lattice_instance_f32 *S, uint16_t numStages, float32_t *pkCoeffs, float32_t *pvCoeffs, float32_t *pState, uint32_t blockSize)
 Initialization function for the floating-point IIR lattice filter. More...
 
void arm_iir_lattice_init_q15 (arm_iir_lattice_instance_q15 *S, uint16_t numStages, q15_t *pkCoeffs, q15_t *pvCoeffs, q15_t *pState, uint32_t blockSize)
 Initialization function for the Q15 IIR lattice filter. More...
 
void arm_iir_lattice_init_q31 (arm_iir_lattice_instance_q31 *S, uint16_t numStages, q31_t *pkCoeffs, q31_t *pvCoeffs, q31_t *pState, uint32_t blockSize)
 Initialization function for the Q31 IIR lattice filter. More...
 
void arm_iir_lattice_q15 (const arm_iir_lattice_instance_q15 *S, const q15_t *pSrc, q15_t *pDst, uint32_t blockSize)
 Processing function for the Q15 IIR lattice filter. More...
 
void arm_iir_lattice_q31 (const arm_iir_lattice_instance_q31 *S, const q31_t *pSrc, q31_t *pDst, uint32_t blockSize)
 Processing function for the Q31 IIR lattice filter. More...
 

Description

This set of functions implements lattice filters for Q15, Q31 and floating-point data types. Lattice filters are used in a variety of adaptive filter applications. The filter structure has feedforward and feedback components and the net impulse response is infinite length. The functions operate on blocks of input and output data and each call to the function processes blockSize samples through the filter. pSrc and pDst point to input and output arrays containing blockSize values.

Algorithm
Infinite Impulse Response Lattice filter
    fN(n)   = x(n)
    fm-1(n) = fm(n) - km * gm-1(n-1)   for m = N, N-1, ..., 1
    gm(n)   = km * fm-1(n) + gm-1(n-1) for m = N, N-1, ..., 1
    y(n)    = vN * gN(n) + vN-1 * gN-1(n) + ...+ v0 * g0(n)
pkCoeffs points to array of reflection coefficients of size numStages. Reflection Coefficients are stored in time-reversed order.
   {kN, kN-1, ..., k1}
pvCoeffs points to the array of ladder coefficients of size (numStages+1). Ladder coefficients are stored in time-reversed order.
    {vN, vN-1, ..., v0}
pState points to a state array of size numStages + blockSize. The state variables shown in the figure above (the g values) are stored in the pState array. 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: numStages, pkCoeffs, pvCoeffs, 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:
    arm_iir_lattice_instance_f32 S = {numStages, pState, pkCoeffs, pvCoeffs};
    arm_iir_lattice_instance_q31 S = {numStages, pState, pkCoeffs, pvCoeffs};
    arm_iir_lattice_instance_q15 S = {numStages, pState, pkCoeffs, pvCoeffs};
where numStages is the number of stages in the filter; pState points to the state buffer array; pkCoeffs points to array of the reflection coefficients; pvCoeffs points to the array of ladder coefficients.
Fixed-Point Behavior
Care must be taken when using the fixed-point versions of the IIR 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

◆ arm_iir_lattice_f32()

void arm_iir_lattice_f32 ( const arm_iir_lattice_instance_f32 S,
const float32_t pSrc,
float32_t pDst,
uint32_t  blockSize 
)
Parameters
[in]Spoints to an instance of the floating-point IIR lattice structure
[in]pSrcpoints to the block of input data
[out]pDstpoints to the block of output data
[in]blockSizenumber of samples to process
Returns
none

◆ arm_iir_lattice_init_f32()

void arm_iir_lattice_init_f32 ( arm_iir_lattice_instance_f32 S,
uint16_t  numStages,
float32_t pkCoeffs,
float32_t pvCoeffs,
float32_t pState,
uint32_t  blockSize 
)
Parameters
[in]Spoints to an instance of the floating-point IIR lattice structure
[in]numStagesnumber of stages in the filter
[in]pkCoeffspoints to reflection coefficient buffer. The array is of length numStages
[in]pvCoeffspoints to ladder coefficient buffer. The array is of length numStages+1
[in]pStatepoints to state buffer. The array is of length numStages+blockSize
[in]blockSizenumber of samples to process
Returns
none

◆ arm_iir_lattice_init_q15()

void arm_iir_lattice_init_q15 ( arm_iir_lattice_instance_q15 S,
uint16_t  numStages,
q15_t pkCoeffs,
q15_t pvCoeffs,
q15_t pState,
uint32_t  blockSize 
)
Parameters
[in]Spoints to an instance of the Q15 IIR lattice structure
[in]numStagesnumber of stages in the filter
[in]pkCoeffspoints to reflection coefficient buffer. The array is of length numStages
[in]pvCoeffspoints to ladder coefficient buffer. The array is of length numStages+1
[in]pStatepoints to state buffer. The array is of length numStages+blockSize
[in]blockSizenumber of samples to process
Returns
none

◆ arm_iir_lattice_init_q31()

void arm_iir_lattice_init_q31 ( arm_iir_lattice_instance_q31 S,
uint16_t  numStages,
q31_t pkCoeffs,
q31_t pvCoeffs,
q31_t pState,
uint32_t  blockSize 
)
Parameters
[in]Spoints to an instance of the Q31 IIR lattice structure
[in]numStagesnumber of stages in the filter
[in]pkCoeffspoints to reflection coefficient buffer. The array is of length numStages
[in]pvCoeffspoints to ladder coefficient buffer. The array is of length numStages+1
[in]pStatepoints to state buffer. The array is of length numStages+blockSize
[in]blockSizenumber of samples to process
Returns
none

◆ arm_iir_lattice_q15()

void arm_iir_lattice_q15 ( const arm_iir_lattice_instance_q15 S,
const q15_t pSrc,
q15_t pDst,
uint32_t  blockSize 
)
Parameters
[in]Spoints to an instance of the Q15 IIR lattice structure
[in]pSrcpoints to the block of input data
[out]pDstpoints to the block of output data
[in]blockSizenumber of samples to process
Returns
none
Scaling and Overflow Behavior
The function is implemented using an internal 64-bit accumulator. Both coefficients and state variables are represented in 1.15 format and multiplications yield a 2.30 result. The 2.30 intermediate results are accumulated in a 64-bit accumulator in 34.30 format. There is no risk of internal overflow with this approach and the full precision of intermediate multiplications is preserved. After all additions have been performed, the accumulator is truncated to 34.15 format by discarding low 15 bits. Lastly, the accumulator is saturated to yield a result in 1.15 format.

◆ arm_iir_lattice_q31()

void arm_iir_lattice_q31 ( const arm_iir_lattice_instance_q31 S,
const q31_t pSrc,
q31_t pDst,
uint32_t  blockSize 
)
Parameters
[in]Spoints to an instance of the Q31 IIR lattice structure
[in]pSrcpoints to the block of input data
[out]pDstpoints to the block of output data
[in]blockSizenumber of samples to process
Returns
none
Scaling and Overflow Behavior
The function is implemented using an internal 64-bit accumulator. The accumulator has a 2.62 format and maintains full precision of the intermediate multiplication results but provides only a single guard bit. Thus, if the accumulator result overflows it wraps around rather than clip. In order to avoid overflows completely the input signal must be scaled down by 2*log2(numStages) bits. After all multiply-accumulates are performed, the 2.62 accumulator is saturated to 1.32 format and then truncated to 1.31 format.