Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include "arm_math.h"
00025
00026
00050 void arm_fir_sparse_q31(
00051 arm_fir_sparse_instance_q31 * S,
00052 q31_t * pSrc,
00053 q31_t * pDst,
00054 q31_t * pScratchIn,
00055 uint32_t blockSize)
00056 {
00057
00058 q31_t *pState = S->pState;
00059 q31_t *pCoeffs = S->pCoeffs;
00060 q31_t *px;
00061 q31_t *py = pState;
00062 q31_t *pb = pScratchIn;
00063 q31_t *pOut;
00064 q63_t out;
00065 int32_t *pTapDelay = S->pTapDelay;
00066 uint32_t delaySize = S->maxDelay + blockSize;
00067 uint16_t numTaps = S->numTaps;
00068 int32_t readIndex;
00069 uint32_t tapCnt, blkCnt;
00070 q31_t coeff = *pCoeffs++;
00071 q31_t in;
00072 q31_t x0, x1, y0, y1;
00073
00074
00075
00076 arm_circularWrite_f32((int32_t *) py, delaySize, &S->stateIndex, 1,
00077 (int32_t *) pSrc, 1, blockSize);
00078
00079
00080 readIndex = (int32_t) (S->stateIndex - blockSize) - *pTapDelay++;
00081
00082
00083 if(readIndex < 0)
00084 {
00085 readIndex += (int32_t) delaySize;
00086 }
00087
00088
00089 py = pState;
00090
00091
00092 arm_circularRead_f32((int32_t *) py, delaySize, &readIndex, 1,
00093 (int32_t *) pb, (int32_t *) pb, blockSize, 1,
00094 blockSize);
00095
00096
00097 px = pb;
00098
00099
00100 pOut = pDst;
00101
00102
00103
00104 blkCnt = blockSize >> 2;
00105
00106 while(blkCnt > 0u)
00107 {
00108
00109
00110
00111 x0 = *px;
00112 x1 = *(px + 1u);
00113
00114
00115 y0 = (q31_t) (((q63_t) x0 * coeff) >> 32);
00116 y1 = (q31_t) (((q63_t) x1 * coeff) >> 32);
00117
00118
00119 *pOut++ = y0;
00120 *pOut++ = y1;
00121
00122
00123 x0 = *(px + 2u);
00124 x1 = *(px + 3u);
00125
00126
00127 y0 = (q31_t) (((q63_t) x0 * coeff) >> 32);
00128 y1 = (q31_t) (((q63_t) x1 * coeff) >> 32);
00129
00130
00131 *pOut++ = y0;
00132 px += 4u;
00133
00134 *pOut++ = y1;
00135
00136
00137
00138 blkCnt--;
00139 }
00140
00141
00142
00143 blkCnt = blockSize % 0x4u;
00144
00145 while(blkCnt > 0u)
00146 {
00147
00148 *pOut++ = (q31_t) (((q63_t) * px++ * coeff) >> 32);
00149
00150
00151 blkCnt--;
00152 }
00153
00154
00155
00156 coeff = *pCoeffs++;
00157
00158
00159 readIndex = (int32_t) (S->stateIndex - blockSize) - *pTapDelay++;
00160
00161
00162 if(readIndex < 0)
00163 {
00164 readIndex += (int32_t) delaySize;
00165 }
00166
00167
00168 tapCnt = (uint32_t) numTaps - 1u;
00169
00170 while(tapCnt > 0u)
00171 {
00172
00173 py = pState;
00174
00175
00176 arm_circularRead_f32((int32_t *) py, delaySize, &readIndex, 1,
00177 (int32_t *) pb, (int32_t *) pb, blockSize, 1,
00178 blockSize);
00179
00180
00181 px = pb;
00182
00183
00184 pOut = pDst;
00185
00186
00187
00188 blkCnt = blockSize >> 2;
00189
00190 while(blkCnt > 0u)
00191 {
00192
00193 x0 = *px;
00194 x1 = *(px + 1u);
00195
00196
00197 y0 = *pOut;
00198 y1 = *(pOut + 1u);
00199
00200
00201 y0 = (q31_t) ((((q63_t) y0 << 32) + ((q63_t) x0 * (coeff))) >> 32);
00202 y1 = (q31_t) ((((q63_t) y1 << 32) + ((q63_t) x1 * (coeff))) >> 32);
00203
00204
00205 *pOut = y0;
00206 *(pOut + 1u) = y1;
00207
00208
00209 x0 = *(px + 2u);
00210 x1 = *(px + 3u);
00211
00212 y0 = *(pOut + 2u);
00213 y1 = *(pOut + 3u);
00214
00215
00216 y0 = (q31_t) ((((q63_t) y0 << 32) + ((q63_t) x0 * (coeff))) >> 32);
00217 y1 = (q31_t) ((((q63_t) y1 << 32) + ((q63_t) x1 * (coeff))) >> 32);
00218
00219
00220 *(pOut + 2u) = y0;
00221 *(pOut + 3u) = y1;
00222
00223
00224 px += 4u;
00225 pOut += 4u;
00226
00227
00228
00229 blkCnt--;
00230 }
00231
00232
00233
00234 blkCnt = blockSize % 0x4u;
00235
00236 while(blkCnt > 0u)
00237 {
00238
00239 out = *pOut;
00240 out += ((q63_t) * px++ * coeff) >> 32;
00241 *pOut++ = (q31_t) (out);
00242
00243
00244 blkCnt--;
00245 }
00246
00247
00248
00249 coeff = *pCoeffs++;
00250
00251
00252 readIndex = (int32_t) (S->stateIndex - blockSize) - *pTapDelay++;
00253
00254
00255 if(readIndex < 0)
00256 {
00257 readIndex += (int32_t) delaySize;
00258 }
00259
00260
00261 tapCnt--;
00262 }
00263
00264
00265 pOut = pDst;
00266
00267
00268
00269
00270 blkCnt = blockSize >> 2;
00271
00272 while(blkCnt > 0u)
00273 {
00274
00275
00276 y0 = *pOut;
00277 y1 = *(pOut + 1u);
00278
00279
00280 y0 = y0 << 1u;
00281 y1 = y1 << 1u;
00282
00283
00284 *pOut = y0;
00285 *(pOut + 1u) = y1;
00286
00287
00288 y0 = *(pOut + 2u);
00289 y1 = *(pOut + 3u);
00290
00291
00292 y0 = y0 << 1u;
00293 y1 = y1 << 1u;
00294
00295
00296 *(pOut + 2u) = y0;
00297 *(pOut + 3u) = y1;
00298
00299
00300 pOut += 4u;
00301
00302
00303
00304 blkCnt--;
00305 }
00306
00307
00308
00309 blkCnt = blockSize % 0x4u;
00310
00311 while(blkCnt > 0u)
00312 {
00313 in = *pOut << 1;
00314 *pOut++ = in;
00315
00316
00317 blkCnt--;
00318 }
00319 }
00320