![]() |
NMSIS-DSP
Version 1.4.0
NMSIS DSP Software Library
|
Functions | |
RISCV_DSP_ATTRIBUTE void | riscv_fir_f16 (const riscv_fir_instance_f16 *S, const float16_t *pSrc, float16_t *pDst, uint32_t blockSize) |
Processing function for floating-point FIR filter. More... | |
RISCV_DSP_ATTRIBUTE void | riscv_fir_f32 (const riscv_fir_instance_f32 *S, const float32_t *pSrc, float32_t *pDst, uint32_t blockSize) |
Processing function for floating-point FIR filter. More... | |
RISCV_DSP_ATTRIBUTE void | riscv_fir_f64 (const riscv_fir_instance_f64 *S, const float64_t *pSrc, float64_t *pDst, uint32_t blockSize) |
Processing function for floating-point FIR filter. More... | |
RISCV_DSP_ATTRIBUTE void | riscv_fir_fast_q15 (const riscv_fir_instance_q15 *S, const q15_t *pSrc, q15_t *pDst, uint32_t blockSize) |
Processing function for the Q15 FIR filter (fast version). More... | |
RISCV_DSP_ATTRIBUTE void | riscv_fir_fast_q31 (const riscv_fir_instance_q31 *S, const q31_t *pSrc, q31_t *pDst, uint32_t blockSize) |
Processing function for the Q31 FIR filter (fast version). More... | |
RISCV_DSP_ATTRIBUTE void | riscv_fir_init_f16 (riscv_fir_instance_f16 *S, uint16_t numTaps, const float16_t *pCoeffs, float16_t *pState, uint32_t blockSize) |
Initialization function for the floating-point FIR filter. More... | |
RISCV_DSP_ATTRIBUTE void | riscv_fir_init_f32 (riscv_fir_instance_f32 *S, uint16_t numTaps, const float32_t *pCoeffs, float32_t *pState, uint32_t blockSize) |
Initialization function for the floating-point FIR filter. More... | |
RISCV_DSP_ATTRIBUTE void | riscv_fir_init_f64 (riscv_fir_instance_f64 *S, uint16_t numTaps, const float64_t *pCoeffs, float64_t *pState, uint32_t blockSize) |
Initialization function for the floating-point FIR filter. More... | |
RISCV_DSP_ATTRIBUTE riscv_status | riscv_fir_init_q15 (riscv_fir_instance_q15 *S, uint16_t numTaps, const q15_t *pCoeffs, q15_t *pState, uint32_t blockSize) |
Initialization function for the Q15 FIR filter. More... | |
RISCV_DSP_ATTRIBUTE void | riscv_fir_init_q31 (riscv_fir_instance_q31 *S, uint16_t numTaps, const q31_t *pCoeffs, q31_t *pState, uint32_t blockSize) |
Initialization function for the Q31 FIR filter. More... | |
RISCV_DSP_ATTRIBUTE void | riscv_fir_init_q7 (riscv_fir_instance_q7 *S, uint16_t numTaps, const q7_t *pCoeffs, q7_t *pState, uint32_t blockSize) |
Initialization function for the Q7 FIR filter. More... | |
RISCV_DSP_ATTRIBUTE void | riscv_fir_q15 (const riscv_fir_instance_q15 *S, const q15_t *pSrc, q15_t *pDst, uint32_t blockSize) |
Processing function for the Q15 FIR filter. More... | |
RISCV_DSP_ATTRIBUTE void | riscv_fir_q31 (const riscv_fir_instance_q31 *S, const q31_t *pSrc, q31_t *pDst, uint32_t blockSize) |
Processing function for Q31 FIR filter. More... | |
RISCV_DSP_ATTRIBUTE void | riscv_fir_q7 (const riscv_fir_instance_q7 *S, const q7_t *pSrc, q7_t *pDst, uint32_t blockSize) |
Processing function for Q7 FIR filter. More... | |
This set of functions implements Finite Impulse Response (FIR) filters for Q7, Q15, Q31, and floating-point data types. Fast versions of Q15 and Q31 are also provided. 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
points to input and output arrays containing blockSize
values.
b[n]
is multiplied by a state variable which equals a previous input sample x[n]
. y[n] = b[0] * x[n] + b[1] * x[n-1] + b[2] * x[n-2] + ...+ b[numTaps-1] * x[n-numTaps+1]
pCoeffs
points to a coefficient array of size numTaps
. Coefficients are stored in time reversed order. {b[numTaps-1], b[numTaps-2], b[N-2], ..., b[1], b[0]}
pState
points to a state array of size numTaps + blockSize - 1
. Samples in the state buffer are stored in the following order. {x[n-numTaps+1], x[n-numTaps], x[n-numTaps-1], x[n-numTaps-2]....x[n](==pSrc[0]), x[n+1](==pSrc[1]), ..., x[n+blockSize-1](==pSrc[blockSize-1])}
blockSize-1
. The increased state buffer length allows circular addressing, which is traditionally used in the FIR filters, to be avoided and yields a significant speed improvement. The state variables are updated after each block of data is processed; the coefficients are untouched.riscv_fir_instance_f32 S = {numTaps, pState, pCoeffs}; riscv_fir_instance_q31 S = {numTaps, pState, pCoeffs}; riscv_fir_instance_q15 S = {numTaps, pState, pCoeffs}; riscv_fir_instance_q7 S = {numTaps, pState, pCoeffs};where
numTaps
is the number of filter coefficients in the filter; pState
is the address of the state buffer; pCoeffs
is the address of the coefficient buffer.The array length L must be a multiple of x. L = x * a :
The additional coefficients (x * a - numTaps) must be set to 0. numTaps is still set to its right value in the init function. It means that the implementation may require to read more coefficients due to the vectorization and to avoid having to manage too many different cases in the code.
numTaps + A + blockSize - 1
:RISCV_DSP_ATTRIBUTE void riscv_fir_f16 | ( | const riscv_fir_instance_f16 * | S, |
const float16_t * | pSrc, | ||
float16_t * | pDst, | ||
uint32_t | blockSize | ||
) |
Processing function for floating-point FIR filter.
Processing function for the floating-point FIR filter.
[in] | S | points to an instance of the floating-point FIR filter structure |
[in] | pSrc | points to the block of input data |
[out] | pDst | points to the block of output data |
[in] | blockSize | number of samples to process |
RISCV_DSP_ATTRIBUTE void riscv_fir_f32 | ( | const riscv_fir_instance_f32 * | S, |
const float32_t * | pSrc, | ||
float32_t * | pDst, | ||
uint32_t | blockSize | ||
) |
Processing function for floating-point FIR filter.
Processing function for the floating-point FIR filter.
[in] | S | points to an instance of the floating-point FIR filter structure |
[in] | pSrc | points to the block of input data |
[out] | pDst | points to the block of output data |
[in] | blockSize | number of samples to process |
RISCV_DSP_ATTRIBUTE void riscv_fir_f64 | ( | const riscv_fir_instance_f64 * | S, |
const float64_t * | pSrc, | ||
float64_t * | pDst, | ||
uint32_t | blockSize | ||
) |
Processing function for floating-point FIR filter.
Processing function for the floating-point FIR filter.
[in] | S | points to an instance of the floating-point FIR filter structure |
[in] | pSrc | points to the block of input data |
[out] | pDst | points to the block of output data |
[in] | blockSize | number of samples to process |
RISCV_DSP_ATTRIBUTE void riscv_fir_fast_q15 | ( | const riscv_fir_instance_q15 * | S, |
const q15_t * | pSrc, | ||
q15_t * | pDst, | ||
uint32_t | blockSize | ||
) |
Processing function for the Q15 FIR filter (fast version).
Processing function for the fast Q15 FIR filter (fast version).
[in] | S | points to an instance of the Q15 FIR filter structure |
[in] | pSrc | points to the block of input data |
[out] | pDst | points to the block of output data |
[in] | blockSize | number of samples to process |
RISCV_DSP_ATTRIBUTE void riscv_fir_fast_q31 | ( | const riscv_fir_instance_q31 * | S, |
const q31_t * | pSrc, | ||
q31_t * | pDst, | ||
uint32_t | blockSize | ||
) |
Processing function for the Q31 FIR filter (fast version).
Processing function for the fast Q31 FIR filter (fast version).
[in] | S | points to an instance of the Q31 structure |
[in] | pSrc | points to the block of input data |
[out] | pDst | points to the block of output data |
[in] | blockSize | number of samples to process |
RISCV_DSP_ATTRIBUTE void riscv_fir_init_f16 | ( | riscv_fir_instance_f16 * | S, |
uint16_t | numTaps, | ||
const float16_t * | pCoeffs, | ||
float16_t * | pState, | ||
uint32_t | blockSize | ||
) |
Initialization function for the floating-point FIR filter.
[in,out] | S | points to an instance of the floating-point FIR filter structure |
[in] | numTaps | number of filter coefficients in the filter |
[in] | pCoeffs | points to the filter coefficients buffer |
[in] | pState | points to the state buffer |
[in] | blockSize | number of samples processed per call |
pCoeffs
points to the array of filter coefficients stored in time reversed order: {b[numTaps-1], b[numTaps-2], b[N-2], ..., b[1], b[0]}
pState
points to the array of state variables. pState
is of length numTaps+blockSize-1
samples (except for Helium - see below), where blockSize
is the number of input samples processed by each call to riscv_fir_f16()
. numTaps + 8*ceil(blockSize/8) + blockSize - 1
RISCV_DSP_ATTRIBUTE void riscv_fir_init_f32 | ( | riscv_fir_instance_f32 * | S, |
uint16_t | numTaps, | ||
const float32_t * | pCoeffs, | ||
float32_t * | pState, | ||
uint32_t | blockSize | ||
) |
Initialization function for the floating-point FIR filter.
[in,out] | S | points to an instance of the floating-point FIR filter structure |
[in] | numTaps | number of filter coefficients in the filter |
[in] | pCoeffs | points to the filter coefficients buffer |
[in] | pState | points to the state buffer |
[in] | blockSize | number of samples processed per call |
pCoeffs
points to the array of filter coefficients stored in time reversed order: {b[numTaps-1], b[numTaps-2], b[N-2], ..., b[1], b[0]}
pState
points to the array of state variables and some working memory for the Helium version. pState
is of length numTaps+blockSize-1
samples (except for Helium - see below), where blockSize
is the number of input samples processed by each call to riscv_fir_f32()
. numTaps + 2 * blockSize - 1
RISCV_DSP_ATTRIBUTE void riscv_fir_init_f64 | ( | riscv_fir_instance_f64 * | S, |
uint16_t | numTaps, | ||
const float64_t * | pCoeffs, | ||
float64_t * | pState, | ||
uint32_t | blockSize | ||
) |
Initialization function for the floating-point FIR filter.
[in,out] | S | points to an instance of the floating-point FIR filter structure |
[in] | numTaps | number of filter coefficients in the filter |
[in] | pCoeffs | points to the filter coefficients buffer |
[in] | pState | points to the state buffer |
[in] | blockSize | number of samples processed per call |
pCoeffs
points to the array of filter coefficients stored in time reversed order: {b[numTaps-1], b[numTaps-2], b[N-2], ..., b[1], b[0]}
pState
points to the array of state variables. pState
is of length numTaps+blockSize-1
samples, where blockSize
is the number of input samples processed by each call to riscv_fir_f64()
.RISCV_DSP_ATTRIBUTE riscv_status riscv_fir_init_q15 | ( | riscv_fir_instance_q15 * | S, |
uint16_t | numTaps, | ||
const q15_t * | pCoeffs, | ||
q15_t * | pState, | ||
uint32_t | blockSize | ||
) |
Initialization function for the Q15 FIR filter.
[in,out] | S | points to an instance of the Q15 FIR filter structure. |
[in] | numTaps | number of filter coefficients in the filter. Must be even and greater than or equal to 4. |
[in] | pCoeffs | points to the filter coefficients buffer. |
[in] | pState | points to the state buffer. |
[in] | blockSize | number of samples processed per call. |
numTaps
is not greater than or equal to 4 and evenpCoeffs
points to the array of filter coefficients stored in time reversed order: {b[numTaps-1], b[numTaps-2], b[N-2], ..., b[1], b[0]}Note that
numTaps
must be even and greater than or equal to 4. To implement an odd length filter simply increase numTaps
by 1 and set the last coefficient to zero. For example, to implement a filter with numTaps=3
and coefficients {0.3, -0.8, 0.3}set
numTaps=4
and use the coefficients: {0.3, -0.8, 0.3, 0}.Similarly, to implement a two point filter
{0.3, -0.3}set
numTaps=4
and use the coefficients: {0.3, -0.3, 0, 0}.
pState
points to the array of state variables. pState
is of length numTaps+blockSize
, when running on RISC-V Core with DSP enabled and is of length numTaps+blockSize-1
, when running on RISC-V Core without DSP where blockSize
is the number of input samples processed by each call to riscv_fir_q15()
.RISCV_DSP_ATTRIBUTE void riscv_fir_init_q31 | ( | riscv_fir_instance_q31 * | S, |
uint16_t | numTaps, | ||
const q31_t * | pCoeffs, | ||
q31_t * | pState, | ||
uint32_t | blockSize | ||
) |
Initialization function for the Q31 FIR filter.
[in,out] | S | points to an instance of the Q31 FIR filter structure |
[in] | numTaps | number of filter coefficients in the filter |
[in] | pCoeffs | points to the filter coefficients buffer |
[in] | pState | points to the state buffer |
[in] | blockSize | number of samples processed |
pCoeffs
points to the array of filter coefficients stored in time reversed order: {b[numTaps-1], b[numTaps-2], b[N-2], ..., b[1], b[0]}
pState
points to the array of state variables. pState
is of length numTaps+blockSize-1
samples (except for Helium - see below), where blockSize
is the number of input samples processed by each call to riscv_fir_q31()
. numTaps + 8*ceil(blockSize/4) + blockSize - 1
RISCV_DSP_ATTRIBUTE void riscv_fir_init_q7 | ( | riscv_fir_instance_q7 * | S, |
uint16_t | numTaps, | ||
const q7_t * | pCoeffs, | ||
q7_t * | pState, | ||
uint32_t | blockSize | ||
) |
Initialization function for the Q7 FIR filter.
[in,out] | S | points to an instance of the Q7 FIR filter structure |
[in] | numTaps | number of filter coefficients in the filter |
[in] | pCoeffs | points to the filter coefficients buffer |
[in] | pState | points to the state buffer |
[in] | blockSize | number of samples processed |
pCoeffs
points to the array of filter coefficients stored in time reversed order: {b[numTaps-1], b[numTaps-2], b[N-2], ..., b[1], b[0]}
pState
points to the array of state variables. pState
is of length numTaps+blockSize-1
samples, where blockSize
is the number of input samples processed by each call to riscv_fir_q7()
.RISCV_DSP_ATTRIBUTE void riscv_fir_q15 | ( | const riscv_fir_instance_q15 * | S, |
const q15_t * | pSrc, | ||
q15_t * | pDst, | ||
uint32_t | blockSize | ||
) |
Processing function for the Q15 FIR filter.
[in] | S | points to an instance of the Q15 FIR filter structure |
[in] | pSrc | points to the block of input data |
[out] | pDst | points to the block of output data |
[in] | blockSize | number of samples to process |
RISCV_DSP_ATTRIBUTE void riscv_fir_q31 | ( | const riscv_fir_instance_q31 * | S, |
const q31_t * | pSrc, | ||
q31_t * | pDst, | ||
uint32_t | blockSize | ||
) |
Processing function for Q31 FIR filter.
Processing function for the Q31 FIR filter.
[in] | S | points to an instance of the Q31 FIR filter structure |
[in] | pSrc | points to the block of input data |
[out] | pDst | points to the block of output data |
[in] | blockSize | number of samples to process |
RISCV_DSP_ATTRIBUTE void riscv_fir_q7 | ( | const riscv_fir_instance_q7 * | S, |
const q7_t * | pSrc, | ||
q7_t * | pDst, | ||
uint32_t | blockSize | ||
) |
Processing function for Q7 FIR filter.
Processing function for the Q7 FIR filter.
[in] | S | points to an instance of the Q7 FIR filter structure |
[in] | pSrc | points to the block of input data |
[out] | pDst | points to the block of output data |
[in] | blockSize | number of samples to process |