Finite Impulse Response (FIR) Lattice Filters

void riscv_fir_lattice_f32(const riscv_fir_lattice_instance_f32 *S, const float32_t *pSrc, float32_t *pDst, uint32_t blockSize)

void riscv_fir_lattice_init_f32(riscv_fir_lattice_instance_f32 *S, uint16_t numStages, const float32_t *pCoeffs, float32_t *pState)

void riscv_fir_lattice_init_q15(riscv_fir_lattice_instance_q15 *S, uint16_t numStages, const q15_t *pCoeffs, q15_t *pState)

void riscv_fir_lattice_init_q31(riscv_fir_lattice_instance_q31 *S, uint16_t numStages, const q31_t *pCoeffs, q31_t *pState)

void riscv_fir_lattice_q15(const riscv_fir_lattice_instance_q15 *S, const q15_t *pSrc, q15_t *pDst, uint32_t blockSize)

void riscv_fir_lattice_q31(const riscv_fir_lattice_instance_q31 *S, const q31_t *pSrc, q31_t *pDst, uint32_t blockSize)
 group FIR_Lattice
 Deprecated:
Those functions are no more tested nor maintained and will be removed in a future version.
This set of functions implements Finite Impulse Response (FIR) lattice filters for Q15, Q31 and floatingpoint 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
blockSize
samples through the filter.pSrc
andpDst
point to input and output arrays containingblockSize
values. Algorithm
The following difference equation is implemented:
pCoeffs
points to tha array of reflection coefficients of sizenumStages
. Reflection Coefficients are stored in the following order.where M is number of stages
pState
points to a state array of sizenumStages
. The state variables (g values) hold previous inputs and are stored in the following order. 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, 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:
where
numStages
is the number of stages in the filter;pState
is the address of the state buffer;pCoeffs
is the address of the coefficient buffer. FixedPoint Behavior
Care must be taken when using the fixedpoint 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.
Functions

void riscv_fir_lattice_f32(const riscv_fir_lattice_instance_f32 *S, const float32_t *pSrc, float32_t *pDst, uint32_t blockSize)
Processing function for the floatingpoint FIR lattice filter.
 Parameters
S – [in] points to an instance of the floatingpoint FIR lattice structure
pSrc – [in] points to the block of input data
pDst – [out] points to the block of output data
blockSize – [in] number of samples to process
 Returns
none

void riscv_fir_lattice_init_f32(riscv_fir_lattice_instance_f32 *S, uint16_t numStages, const float32_t *pCoeffs, float32_t *pState)
Initialization function for the floatingpoint FIR lattice filter.
 Parameters
S – [in] points to an instance of the floatingpoint FIR lattice structure
numStages – [in] number of filter stages
pCoeffs – [in] points to the coefficient buffer. The array is of length numStages
pState – [in] points to the state buffer. The array is of length numStages
 Returns
none

void riscv_fir_lattice_init_q15(riscv_fir_lattice_instance_q15 *S, uint16_t numStages, const q15_t *pCoeffs, q15_t *pState)
Initialization function for the Q15 FIR lattice filter.
 Parameters
S – [in] points to an instance of the Q15 FIR lattice structure
numStages – [in] number of filter stages
pCoeffs – [in] points to the coefficient buffer. The array is of length numStages
pState – [in] points to the state buffer. The array is of length numStages
 Returns
none

void riscv_fir_lattice_init_q31(riscv_fir_lattice_instance_q31 *S, uint16_t numStages, const q31_t *pCoeffs, q31_t *pState)
Initialization function for the Q31 FIR lattice filter.
 Parameters
S – [in] points to an instance of the Q31 FIR lattice structure
numStages – [in] number of filter stages
pCoeffs – [in] points to the coefficient buffer. The array is of length numStages
pState – [in] points to the state buffer. The array is of length numStages
 Returns
none

void riscv_fir_lattice_q15(const riscv_fir_lattice_instance_q15 *S, const q15_t *pSrc, q15_t *pDst, uint32_t blockSize)
Processing function for Q15 FIR lattice filter.
Processing function for the Q15 FIR lattice filter.
 Parameters
S – [in] points to an instance of the Q15 FIR lattice structure
pSrc – [in] points to the block of input data
pDst – [out] points to the block of output data
blockSize – [in] number of samples to process
 Returns
none

void riscv_fir_lattice_q31(const riscv_fir_lattice_instance_q31 *S, const q31_t *pSrc, q31_t *pDst, uint32_t blockSize)
Processing function for the Q31 FIR lattice filter.
 Scaling and Overflow Behavior
In order to avoid overflows the input signal must be scaled down by 2*log2(numStages) bits.
 Parameters
S – [in] points to an instance of the Q31 FIR lattice structure
pSrc – [in] points to the block of input data
pDst – [out] points to the block of output data
blockSize – [in] number of samples to process
 Returns
none