11 #include "mic_array/etc/fir_1x16_bit.h"
14 #if defined(MIC_COUNT) || defined(S2_DEC_FACTOR) || defined(S2_TAP_COUNT)
15 # error Application must not define the following as precompiler macros: MIC_COUNT, S2_DEC_FACTOR, S2_TAP_COUNT.
29 void shift_buffer(uint32_t* buff);
42 template <
unsigned MIC_COUNT,
unsigned S2_DEC_FACTOR,
unsigned S2_TAP_COUNT>
50 static constexpr
unsigned BLOCK_SIZE = MIC_COUNT * S2_DEC_FACTOR;
55 static constexpr
unsigned MicCount = MIC_COUNT;
86 = {[0 ... (MIC_COUNT-1)] = { [0 ... 7] = 0x55555555 } }
107 constexpr TwoStageDecimator() noexcept { }
135 const uint32_t* s1_filter_coef,
136 const int32_t* s2_filter_coef,
166 int32_t sample_out[MIC_COUNT],
176 template <
unsigned MIC_COUNT,
unsigned S2_DEC_FACTOR,
unsigned S2_TAP_COUNT>
178 const uint32_t* s1_filter_coef,
179 const int32_t* s2_filter_coef,
182 this->stage1.filter_coef = s1_filter_coef;
184 for(
int k = 0; k < MIC_COUNT; k++){
186 S2_TAP_COUNT, s2_filter_coef, s2_shr);
192 template <
unsigned MIC_COUNT,
unsigned S2_DEC_FACTOR,
unsigned S2_TAP_COUNT>
195 int32_t sample_out[MIC_COUNT],
196 uint32_t pdm_block[BLOCK_SIZE])
198 uint32_t (*pdm_data)[S2_DEC_FACTOR] = (uint32_t (*)[S2_DEC_FACTOR]) pdm_block;
200 for(
unsigned mic = 0; mic < MIC_COUNT; mic++){
201 uint32_t* hist = &this->stage1.pdm_history[mic][0];
203 for(
unsigned k = 0; k < S2_DEC_FACTOR; k++){
204 hist[0] = pdm_data[mic][k];
205 int32_t streamA_sample = fir_1x16_bit(hist, this->stage1.filter_coef);
208 if(k < (S2_DEC_FACTOR-1)){
219 void mic_array::shift_buffer(uint32_t* buff)
221 uint32_t* src = &buff[-1];
222 asm volatile(
"vldd %0[0]; vstd %1[0];" ::
"r"(src),
"r"(buff) :
"memory" );
First and Second Stage Decimator.
Definition: Decimator.hpp:44
static constexpr unsigned MicCount
Definition: Decimator.hpp:55
int32_t filter_state[MIC_COUNT][S2_TAP_COUNT]
Definition: Decimator.hpp:102
static constexpr unsigned BLOCK_SIZE
Definition: Decimator.hpp:50
void Init(const uint32_t *s1_filter_coef, const int32_t *s2_filter_coef, const right_shift_t s2_filter_shr)
Initialize the decimator.
Definition: Decimator.hpp:177
xs3_filter_fir_s32_t filters[MIC_COUNT]
Definition: Decimator.hpp:98
uint32_t pdm_history[MIC_COUNT][8]
Definition: Decimator.hpp:88
static const struct mic_array::TwoStageDecimator::@15 Stage2
const uint32_t * filter_coef
Definition: Decimator.hpp:80
void ProcessBlock(int32_t sample_out[MIC_COUNT], uint32_t pdm_block[BLOCK_SIZE])
Process one block of PDM data.
Definition: Decimator.hpp:194
unsigned DecimationFactor
Definition: Decimator.hpp:64
unsigned TapCount
Definition: Decimator.hpp:68
int right_shift_t
A rightwards arithmetic bit-shift.
Definition: xs3_math_types.h:98
int32_t xs3_filter_fir_s32(xs3_filter_fir_s32_t *filter, const int32_t new_sample)
Definition: xs3_filter_fir_s32.c:15
void xs3_filter_fir_s32_init(xs3_filter_fir_s32_t *filter, int32_t *sample_buffer, const unsigned tap_count, const int32_t *coefficients, const right_shift_t shift)
Initialize a 32-bit FIR filter.
Definition: xs3_filters.c:43
void xs3_filter_fir_s32_add_sample(xs3_filter_fir_s32_t *filter, const int32_t new_sample)
Add a new input sample to a 32-bit FIR filter without processing an output sample.
Definition: xs3_filters.c:59
32-bit Discrete-Time Finite Impulse Response (FIR) Filter
Definition: xs3_filters.h:243