47 #include "../common/c71/DSPLIB_inlines.h"
56 template <
typename dataType>
65 __SE_TEMPLATE_v1 se0Params;
66 __SE_TEMPLATE_v1 se1Params;
67 __SA_TEMPLATE_v1 sa0Params;
68 __SA_TEMPLATE_v1 sa1Params;
71 uint8_t *pBlock = pKerPrivArgs->
bufPblock;
79 __SE_ELETYPE SE_ELETYPE;
80 __SE_VECLEN SE_VECLEN;
81 __SA_VECLEN SA_VECLEN;
83 typedef typename c7x::make_full_vector<dataType>::type vec;
84 SE_VECLEN = c7x::se_veclen<vec>::value;
85 SA_VECLEN = c7x::sa_veclen<vec>::value;
86 SE_ELETYPE = c7x::se_eletype<vec>::value;
88 uint32_t eleCount = c7x::element_count_of<vec>::value;
91 printf(
"DSPLIB_DEBUGPRINT SE_VECLEN: %d, SA_VECLEN: %d, SE_ELETYPE: %d "
92 "numChannels %d numStages %d\n",
93 SE_VECLEN, SA_VECLEN, SE_ELETYPE, numChannels, numStages);
94 printf(
"DSPLIB_DEBUGPRINT SE_VECLEN: %d, SA_VECLEN: %d, SE_ELETYPE: %d "
96 SE_VECLEN, SA_VECLEN, SE_ELETYPE, eleCount);
99 uint32_t icnt1Param = (numChannels > eleCount) ? eleCount : numChannels;
100 icnt1Param = (icnt1Param == 0) ? 1 : icnt1Param;
101 uint32_t icnt2Param =
102 (numChannels % eleCount == 0) ? (numChannels / eleCount) : (numChannels + eleCount) / eleCount;
107 se1Params = __gen_SE_TEMPLATE_v1();
109 se1Params.ICNT0 = icnt1Param;
110 se1Params.ICNT1 = dataSize;
111 se1Params.DIM1 = (int32_t) dataBufferInPitch;
112 se1Params.ICNT2 = icnt2Param;
113 se1Params.DIM2 = eleCount;
114 se1Params.ELETYPE = SE_ELETYPE;
115 se1Params.VECLEN = SE_VECLEN;
116 se1Params.DECDIM1_WIDTH = numChannels;
117 se1Params.DECDIM1 = __SE_DECDIM_DIM2;
118 se1Params.DIMFMT = __SE_DIMFMT_3D;
122 se0Params = __gen_SE_TEMPLATE_v1();
123 se0Params.ICNT0 = icnt1Param;
124 se0Params.ICNT1 = numStages * 2;
125 se0Params.DIM1 = (int32_t) filterVarPitch;
126 se0Params.ICNT2 = icnt2Param;
127 se0Params.DIM2 = eleCount;
128 se0Params.ELETYPE = SE_ELETYPE;
129 se0Params.VECLEN = SE_VECLEN;
130 se0Params.DECDIM1_WIDTH = numChannels;
131 se0Params.DECDIM1 = __SE_DECDIM_DIM2;
132 se0Params.DIMFMT = __SE_DIMFMT_3D;
137 sa0Params = __gen_SA_TEMPLATE_v1();
139 sa0Params.ICNT0 = icnt1Param;
140 sa0Params.ICNT1 = dataSize;
141 sa0Params.DIM1 = (int32_t) dataBufferOutPitch;
142 sa0Params.ICNT2 = icnt2Param;
143 sa0Params.DIM2 = eleCount;
144 sa0Params.DECDIM1_WIDTH = numChannels;
145 sa0Params.DECDIM1 = __SA_DECDIM_DIM2;
146 sa0Params.DECDIM2_WIDTH = dataBufferOutPitch * dataSize;
147 sa0Params.DECDIM2 = __SA_DECDIM_DIM2;
148 sa0Params.VECLEN = SA_VECLEN;
149 sa0Params.DIMFMT = __SA_DIMFMT_3D;
154 sa1Params = __gen_SA_TEMPLATE_v1();
156 sa1Params.ICNT0 = icnt1Param;
157 sa1Params.ICNT1 = numStages * 2;
158 sa1Params.DIM1 = (int32_t) filterVarPitch;
159 sa1Params.ICNT2 = icnt2Param;
160 sa1Params.DIM2 = eleCount;
161 sa1Params.DECDIM1_WIDTH = numChannels;
162 sa1Params.DECDIM1 = __SA_DECDIM_DIM2;
163 sa1Params.VECLEN = SA_VECLEN;
164 sa1Params.DIMFMT = __SA_DIMFMT_3D;
173 template <
typename dataType>
static inline dataType
fast_recip(dataType x)
175 typedef typename c7x::make_full_vector<dataType>::type vec;
182 vec out = f * (2 - a * f);
198 template <
typename dataType>
201 void *restrict pFilterCoeff,
202 void *restrict pFilterVar,
205 __SE_TEMPLATE_v1 se0Params;
206 __SE_TEMPLATE_v1 se1Params;
207 __SA_TEMPLATE_v1 sa0Params;
208 __SA_TEMPLATE_v1 sa1Params;
211 uint8_t *pBlock = pKerPrivArgs->
bufPblock;
216 dataType *pInLocal = (dataType *) pIn;
217 dataType *pFilterCoeffLocal = (dataType *) pFilterCoeff;
218 dataType *pFilterVarLocal = (dataType *) pFilterVar;
219 dataType *pOutLocal = (dataType *) pOut;
221 #if DSPLIB_DEBUGPRINT
222 printf(
"Enter DSPLIB_cascadeBiquad_exec_ci\n");
225 typedef typename c7x::make_full_vector<dataType>::type vec;
226 int eleCount = c7x::element_count_of<vec>::value;
231 #if DSPLIB_DEBUGPRINT
232 printf(
"Enter pFilter %p\n", pFilterCoeff);
237 __SE0_OPEN(pFilterVarLocal, se0Params);
241 __SE1_OPEN(pInLocal, se1Params);
245 __SA0_OPEN(sa0Params);
249 __SA1_OPEN(sa1Params);
251 #if DSPLIB_DEBUGPRINT
252 printf(
"DSPLIB_DEBUGPRINT dataSize %d numChannels %d numStages %d pOutLocal "
254 dataSize, numChannels, numStages, pOutLocal);
257 vec output1, output2, output3;
258 vec temp1_mul_1, temp0_mul_1, d0_temp_1, d1_mul_1;
259 vec temp1_mul_2, temp0_mul_2, d0_temp_2, d1_mul_2;
260 vec temp1_mul_3, temp0_mul_3, d0_temp_3, d1_mul_3;
261 vec temp1_add_1, temp1_add_2, temp1_add_3;
263 dataType coeff0 = pFilterCoeffLocal[0];
265 vec b10 = (vec) (coeff0);
266 vec r = (vec) (fast_recip<dataType>(coeff0));
267 vec b11 = pFilterCoeffLocal[1] * r;
268 vec b12 = pFilterCoeffLocal[2] * r;
269 vec a11 = (vec) (-1 * pFilterCoeffLocal[3]);
270 vec a12 = (vec) (-1 * pFilterCoeffLocal[4]);
272 vec b20, b21, b22, a21, a22;
273 if (numStages >= 2) {
274 coeff0 = pFilterCoeffLocal[5];
275 b20 = (vec) (coeff0);
276 r = (vec) fast_recip<dataType>(coeff0);
277 b21 = pFilterCoeffLocal[6] * r;
278 b22 = pFilterCoeffLocal[7] * r;
279 a21 = -pFilterCoeffLocal[8];
280 a22 = -pFilterCoeffLocal[9];
291 vec b30, b31, b32, a31, a32;
292 if (numStages >= 3) {
293 coeff0 = pFilterCoeffLocal[10];
294 b30 = (vec) (coeff0);
295 r = (vec) fast_recip<dataType>(coeff0);
296 b31 = pFilterCoeffLocal[11] * r;
297 b32 = pFilterCoeffLocal[12] * r;
298 a31 = -pFilterCoeffLocal[13];
299 a32 = -pFilterCoeffLocal[14];
311 vec outGain = b10 * b20 * b30;
313 vec b11_a11 = b11 + a11;
314 vec b12_a12 = b12 + a12;
315 vec b21_a21 = b21 + a21;
316 vec b22_a22 = b22 + a22;
317 vec b31_a31 = b31 + a31;
318 vec b32_a32 = b32 + a32;
320 #if DSPLIB_DEBUGPRINT
321 DSPLIB_debugPrintVector(outGain);
333 for (uint32_t chCount = 0; chCount < numChannels; chCount += eleCount) {
335 vec filtVars_d0_1 = c7x::strm_eng<0, vec>::get_adv();
336 vec filtVars_d1_1 = c7x::strm_eng<0, vec>::get_adv();
337 vec filtVars_d0_2 = c7x::strm_eng<0, vec>::get_adv();
338 vec filtVars_d1_2 = c7x::strm_eng<0, vec>::get_adv();
339 vec filtVars_d0_3 = c7x::strm_eng<0, vec>::get_adv();
340 vec filtVars_d1_3 = c7x::strm_eng<0, vec>::get_adv();
342 #if DSPLIB_DEBUGPRINT
350 for (uint32_t samp = 0; samp < dataSize; samp++) {
352 input = c7x::strm_eng<1, vec>::get();
353 #if DSPLIB_DEBUGPRINT
356 output1 = input + filtVars_d0_1;
357 temp1_mul_1 = input * b11_a11;
358 temp1_add_1 = temp1_mul_1 + filtVars_d1_1;
359 temp0_mul_1 = a12 * filtVars_d0_1;
360 d0_temp_1 = a11 * filtVars_d0_1;
361 filtVars_d0_1 = d0_temp_1 + temp1_add_1;
362 input = c7x::strm_eng<1, vec>::get_adv();
363 d1_mul_1 = b12_a12 * input;
364 filtVars_d1_1 = d1_mul_1 + temp0_mul_1;
367 output2 = output1 + filtVars_d0_2;
368 temp1_mul_2 = b21_a21 * output1;
369 temp1_add_2 = temp1_mul_2 + filtVars_d1_2;
370 temp0_mul_2 = a22 * filtVars_d0_2;
371 d0_temp_2 = a21 * filtVars_d0_2;
372 filtVars_d0_2 = d0_temp_2 + temp1_add_2;
373 d1_mul_2 = b22_a22 * output1;
374 filtVars_d1_2 = d1_mul_2 + temp0_mul_2;
377 output3 = output2 + filtVars_d0_3;
378 temp1_mul_3 = b31_a31 * output2;
379 temp1_add_3 = temp1_mul_3 + filtVars_d1_3;
380 temp0_mul_3 = a32 * filtVars_d0_3;
381 d0_temp_3 = a31 * filtVars_d0_3;
382 filtVars_d0_3 = d0_temp_3 + temp1_add_3;
383 d1_mul_3 = b32_a32 * output2;
384 filtVars_d1_3 = d1_mul_3 + temp0_mul_3;
386 __vpred tmp = c7x::strm_agen<0, vec>::get_vpred();
387 vec *VB1 = c7x::strm_agen<0, vec>::get_adv(pOutLocal);
388 #if DSPLIB_DEBUGPRINT
396 vec output = output3 * outGain;
397 #if DSPLIB_DEBUGPRINT
399 DSPLIB_debugPrintVector(output);
402 __vstore_pred(tmp, VB1, output);
405 __vpred tmp1 = c7x::strm_agen<1, vec>::get_vpred();
406 vec *VB2 = c7x::strm_agen<1, vec>::get_adv(pFilterVarLocal);
407 __vstore_pred(tmp1, VB2, filtVars_d0_1);
409 tmp1 = c7x::strm_agen<1, vec>::get_vpred();
410 VB2 = c7x::strm_agen<1, vec>::get_adv(pFilterVarLocal);
411 __vstore_pred(tmp1, VB2, filtVars_d1_1);
413 tmp1 = c7x::strm_agen<1, vec>::get_vpred();
414 VB2 = c7x::strm_agen<1, vec>::get_adv(pFilterVarLocal);
415 __vstore_pred(tmp1, VB2, filtVars_d0_2);
417 tmp1 = c7x::strm_agen<1, vec>::get_vpred();
418 VB2 = c7x::strm_agen<1, vec>::get_adv(pFilterVarLocal);
419 __vstore_pred(tmp1, VB2, filtVars_d1_2);
421 tmp1 = c7x::strm_agen<1, vec>::get_vpred();
422 VB2 = c7x::strm_agen<1, vec>::get_adv(pFilterVarLocal);
423 __vstore_pred(tmp1, VB2, filtVars_d0_3);
425 tmp1 = c7x::strm_agen<1, vec>::get_vpred();
426 VB2 = c7x::strm_agen<1, vec>::get_adv(pFilterVarLocal);
427 __vstore_pred(tmp1, VB2, filtVars_d1_3);
439 void *restrict pFilterCoeff,
440 void *restrict pFilterVar,
441 void *restrict pOut);
#define SE_SE0_PARAM_OFFSET
#define SE_SA0_PARAM_OFFSET
#define SE_SE1_PARAM_OFFSET
static dataType fast_recip(dataType x)
DSPLIB_STATUS DSPLIB_cascadeBiquad_init_ci(DSPLIB_kernelHandle handle, const DSPLIB_bufParams2D_t *bufParamsIn, const DSPLIB_bufParams1D_t *bufParamsFilterCoeff, const DSPLIB_bufParams2D_t *bufParamsFilterVar, const DSPLIB_bufParams2D_t *bufParamsOut, const DSPLIB_cascadeBiquad_InitArgs *pKerInitArgs)
This function is the initialization function for the C7x implementation of the kernel....
template DSPLIB_STATUS DSPLIB_cascadeBiquad_init_ci< float >(DSPLIB_kernelHandle handle, const DSPLIB_bufParams2D_t *bufParamsIn, const DSPLIB_bufParams1D_t *bufParamsFilterCoeff, const DSPLIB_bufParams2D_t *bufParamsFilterVar, const DSPLIB_bufParams2D_t *bufParamsOut, const DSPLIB_cascadeBiquad_InitArgs *pKerInitArgs)
DSPLIB_STATUS DSPLIB_cascadeBiquad_exec_ci(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pFilterCoeff, void *restrict pFilterVar, void *restrict pOut)
This function is the main execution function for the C7x implementation of the kernel....
template DSPLIB_STATUS DSPLIB_cascadeBiquad_exec_ci< float >(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pFilterCoeff, void *restrict pFilterVar, void *restrict pOut)
Header file for kernel's internal use. For the kernel's interface, please see DSPLIB_cascadeBiquad.
#define SE_SA1_PARAM_OFFSET
DSPLIB_STATUS_NAME
The enumeration of all status codes.
void * DSPLIB_kernelHandle
Handle type for DSPLIB operations.
A structure for a 1 dimensional buffer descriptor.
A structure for a 2 dimensional buffer descriptor.
Structure containing the parameters to initialize the kernel.
uint32_t dataSize
Size of input data
uint32_t numChannels
number of channels
uint32_t numStages
Size of batch in terms of number of channels of input data
Structure that is reserved for internal use by the kernel.
uint8_t bufPblock[DSPLIB_CASCADEBIQUAD_PBLOCK_SIZE]
uint32_t filterVarPitch
Pitch of filter Variable buffer for different channels DSPLIB_cascadeBiquad_init that will be retriev...
uint32_t dataBufferOutPitch
Pitch of output buffer for different batches DSPLIB_cascadeBiquad_init that will be retrieved and use...
DSPLIB_cascadeBiquad_InitArgs initArgs
Structure holding initialization parameters
uint32_t dataBufferInPitch
Pitch of input buffer for different batches DSPLIB_cascadeBiquad_init that will be retrieved and used...