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
00059 void arm_fir_decimate_fast_q31(
00060 arm_fir_decimate_instance_q31 * S,
00061 q31_t * pSrc,
00062 q31_t * pDst,
00063 uint32_t blockSize)
00064 {
00065 q31_t *pState = S->pState;
00066 q31_t *pCoeffs = S->pCoeffs;
00067 q31_t *pStateCurnt;
00068 q31_t x0, c0;
00069 q31_t *px;
00070 q31_t *pb;
00071 q31_t sum0;
00072 uint32_t numTaps = S->numTaps;
00073 uint32_t i, tapCnt, blkCnt, outBlockSize = blockSize / S->M;
00074 uint32_t blkCntN2;
00075 q31_t x1;
00076 q31_t acc0, acc1;
00077 q31_t *px0, *px1;
00078
00079
00080
00081 pStateCurnt = S->pState + (numTaps - 1u);
00082
00083
00084
00085 blkCnt = outBlockSize / 2;
00086 blkCntN2 = outBlockSize - (2*blkCnt);
00087
00088 while(blkCnt > 0u)
00089 {
00090
00091 i = 2 * S->M;
00092
00093 do
00094 {
00095 *pStateCurnt++ = *pSrc++;
00096
00097 } while(--i);
00098
00099
00100 acc0 = 0;
00101 acc1 = 0;
00102
00103
00104 px0 = pState;
00105 px1 = pState + S->M;
00106
00107
00108 pb = pCoeffs;
00109
00110
00111 tapCnt = numTaps >> 2;
00112
00113
00114
00115 while(tapCnt > 0u)
00116 {
00117
00118 c0 = *(pb);
00119
00120
00121 x0 = *(px0);
00122 x1 = *(px1);
00123
00124
00125 acc0 = (q31_t) ((((q63_t) acc0 << 32) + ((q63_t) x0 * c0)) >> 32);
00126 acc1 = (q31_t) ((((q63_t) acc1 << 32) + ((q63_t) x1 * c0)) >> 32);
00127
00128
00129 c0 = *(pb + 1u);
00130
00131
00132 x0 = *(px0 + 1u);
00133 x1 = *(px1 + 1u);
00134
00135
00136 acc0 = (q31_t) ((((q63_t) acc0 << 32) + ((q63_t) x0 * c0)) >> 32);
00137 acc1 = (q31_t) ((((q63_t) acc1 << 32) + ((q63_t) x1 * c0)) >> 32);
00138
00139
00140 c0 = *(pb + 2u);
00141
00142
00143 x0 = *(px0 + 2u);
00144 x1 = *(px1 + 2u);
00145 pb += 4u;
00146
00147
00148 acc0 = (q31_t) ((((q63_t) acc0 << 32) + ((q63_t) x0 * c0)) >> 32);
00149 acc1 = (q31_t) ((((q63_t) acc1 << 32) + ((q63_t) x1 * c0)) >> 32);
00150
00151
00152 c0 = *(pb - 1u);
00153
00154
00155 x0 = *(px0 + 3u);
00156 x1 = *(px1 + 3u);
00157
00158
00159
00160 acc0 = (q31_t) ((((q63_t) acc0 << 32) + ((q63_t) x0 * c0)) >> 32);
00161 acc1 = (q31_t) ((((q63_t) acc1 << 32) + ((q63_t) x1 * c0)) >> 32);
00162
00163
00164 px0 += 4u;
00165 px1 += 4u;
00166
00167
00168 tapCnt--;
00169 }
00170
00171
00172 tapCnt = numTaps % 0x4u;
00173
00174 while(tapCnt > 0u)
00175 {
00176
00177 c0 = *(pb++);
00178
00179
00180 x0 = *(px0++);
00181 x1 = *(px1++);
00182
00183
00184 acc0 = (q31_t) ((((q63_t) acc0 << 32) + ((q63_t) x0 * c0)) >> 32);
00185 acc1 = (q31_t) ((((q63_t) acc1 << 32) + ((q63_t) x1 * c0)) >> 32);
00186
00187
00188 tapCnt--;
00189 }
00190
00191
00192
00193 pState = pState + S->M * 2;
00194
00195
00196 *pDst++ = (q31_t) (acc0 << 1);
00197 *pDst++ = (q31_t) (acc1 << 1);
00198
00199
00200 blkCnt--;
00201 }
00202
00203 while(blkCntN2 > 0u)
00204 {
00205
00206 i = S->M;
00207
00208 do
00209 {
00210 *pStateCurnt++ = *pSrc++;
00211
00212 } while(--i);
00213
00214
00215 sum0 = 0;
00216
00217
00218 px = pState;
00219
00220
00221 pb = pCoeffs;
00222
00223
00224 tapCnt = numTaps >> 2;
00225
00226
00227
00228 while(tapCnt > 0u)
00229 {
00230
00231 c0 = *(pb++);
00232
00233
00234 x0 = *(px++);
00235
00236
00237 sum0 = (q31_t) ((((q63_t) sum0 << 32) + ((q63_t) x0 * c0)) >> 32);
00238
00239
00240 c0 = *(pb++);
00241
00242
00243 x0 = *(px++);
00244
00245
00246 sum0 = (q31_t) ((((q63_t) sum0 << 32) + ((q63_t) x0 * c0)) >> 32);
00247
00248
00249 c0 = *(pb++);
00250
00251
00252 x0 = *(px++);
00253
00254
00255 sum0 = (q31_t) ((((q63_t) sum0 << 32) + ((q63_t) x0 * c0)) >> 32);
00256
00257
00258 c0 = *(pb++);
00259
00260
00261 x0 = *(px++);
00262
00263
00264 sum0 = (q31_t) ((((q63_t) sum0 << 32) + ((q63_t) x0 * c0)) >> 32);
00265
00266
00267 tapCnt--;
00268 }
00269
00270
00271 tapCnt = numTaps % 0x4u;
00272
00273 while(tapCnt > 0u)
00274 {
00275
00276 c0 = *(pb++);
00277
00278
00279 x0 = *(px++);
00280
00281
00282 sum0 = (q31_t) ((((q63_t) sum0 << 32) + ((q63_t) x0 * c0)) >> 32);
00283
00284
00285 tapCnt--;
00286 }
00287
00288
00289
00290 pState = pState + S->M;
00291
00292
00293 *pDst++ = (q31_t) (sum0 << 1);
00294
00295
00296 blkCntN2--;
00297 }
00298
00299
00300
00301
00302
00303
00304 pStateCurnt = S->pState;
00305
00306 i = (numTaps - 1u) >> 2u;
00307
00308
00309 while(i > 0u)
00310 {
00311 *pStateCurnt++ = *pState++;
00312 *pStateCurnt++ = *pState++;
00313 *pStateCurnt++ = *pState++;
00314 *pStateCurnt++ = *pState++;
00315
00316
00317 i--;
00318 }
00319
00320 i = (numTaps - 1u) % 0x04u;
00321
00322
00323 while(i > 0u)
00324 {
00325 *pStateCurnt++ = *pState++;
00326
00327
00328 i--;
00329 }
00330 }
00331