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
00025
00026
00027
00028
00029
00030
00031
00032
00033 #include "arm_math.h"
00034
00066 void arm_fir_fast_q31(
00067 const arm_fir_instance_q31 * S,
00068 q31_t * pSrc,
00069 q31_t * pDst,
00070 uint32_t blockSize)
00071 {
00072 q31_t *pState = S->pState;
00073 q31_t *pCoeffs = S->pCoeffs;
00074 q31_t *pStateCurnt;
00075 q31_t x0, x1, x2, x3;
00076 q31_t c0;
00077 q31_t *px;
00078 q31_t *pb;
00079 q63_t acc0, acc1, acc2, acc3;
00080 uint32_t numTaps = S->numTaps;
00081 uint32_t i, tapCnt, blkCnt;
00082
00083
00084
00085 pStateCurnt = &(S->pState[(numTaps - 1u)]);
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095 blkCnt = blockSize >> 2;
00096
00097
00098
00099 while(blkCnt > 0u)
00100 {
00101
00102 *pStateCurnt++ = *pSrc++;
00103 *pStateCurnt++ = *pSrc++;
00104 *pStateCurnt++ = *pSrc++;
00105 *pStateCurnt++ = *pSrc++;
00106
00107
00108 acc0 = 0;
00109 acc1 = 0;
00110 acc2 = 0;
00111 acc3 = 0;
00112
00113
00114 px = pState;
00115
00116
00117 pb = pCoeffs;
00118
00119
00120
00121 x0 = *(px++);
00122 x1 = *(px++);
00123 x2 = *(px++);
00124
00125
00126 tapCnt = numTaps >> 2;
00127 i = tapCnt;
00128
00129 while(i > 0u)
00130 {
00131
00132 c0 = *(pb++);
00133
00134
00135 x3 = *(px++);
00136
00137
00138 acc0 = (q31_t) ((((q63_t) x0 * c0) + (acc0 << 32)) >> 32);
00139
00140
00141 acc1 = (q31_t) ((((q63_t) x1 * c0) + (acc1 << 32)) >> 32);
00142
00143
00144 acc2 = (q31_t) ((((q63_t) x2 * c0) + (acc2 << 32)) >> 32);
00145
00146
00147 acc3 = (q31_t) ((((q63_t) x3 * c0) + (acc3 << 32)) >> 32);
00148
00149
00150 c0 = *(pb++);
00151
00152
00153 x0 = *(px++);
00154
00155
00156 acc0 = (q31_t) ((((q63_t) x1 * c0) + (acc0 << 32)) >> 32);
00157 acc1 = (q31_t) ((((q63_t) x2 * c0) + (acc1 << 32)) >> 32);
00158 acc2 = (q31_t) ((((q63_t) x3 * c0) + (acc2 << 32)) >> 32);
00159 acc3 = (q31_t) ((((q63_t) x0 * c0) + (acc3 << 32)) >> 32);
00160
00161
00162 c0 = *(pb++);
00163
00164
00165 x1 = *(px++);
00166
00167
00168 acc0 = (q31_t) ((((q63_t) x2 * c0) + (acc0 << 32)) >> 32);
00169 acc1 = (q31_t) ((((q63_t) x3 * c0) + (acc1 << 32)) >> 32);
00170 acc2 = (q31_t) ((((q63_t) x0 * c0) + (acc2 << 32)) >> 32);
00171 acc3 = (q31_t) ((((q63_t) x1 * c0) + (acc3 << 32)) >> 32);
00172
00173
00174 c0 = *(pb++);
00175
00176
00177 x2 = *(px++);
00178
00179
00180 acc0 = (q31_t) ((((q63_t) x3 * c0) + (acc0 << 32)) >> 32);
00181 acc1 = (q31_t) ((((q63_t) x0 * c0) + (acc1 << 32)) >> 32);
00182 acc2 = (q31_t) ((((q63_t) x1 * c0) + (acc2 << 32)) >> 32);
00183 acc3 = (q31_t) ((((q63_t) x2 * c0) + (acc3 << 32)) >> 32);
00184 i--;
00185 }
00186
00187
00188
00189 i = numTaps - (tapCnt * 4u);
00190 while(i > 0u)
00191 {
00192
00193 c0 = *(pb++);
00194
00195
00196 x3 = *(px++);
00197
00198
00199 acc0 = (q31_t) ((((q63_t) x0 * c0) + (acc0 << 32)) >> 32);
00200 acc1 = (q31_t) ((((q63_t) x1 * c0) + (acc1 << 32)) >> 32);
00201 acc2 = (q31_t) ((((q63_t) x2 * c0) + (acc2 << 32)) >> 32);
00202 acc3 = (q31_t) ((((q63_t) x3 * c0) + (acc3 << 32)) >> 32);
00203
00204
00205 x0 = x1;
00206 x1 = x2;
00207 x2 = x3;
00208
00209
00210 i--;
00211 }
00212
00213
00214 pState = pState + 4;
00215
00216
00217
00218 *pDst++ = (q31_t) (acc0 << 1);
00219 *pDst++ = (q31_t) (acc1 << 1);
00220 *pDst++ = (q31_t) (acc2 << 1);
00221 *pDst++ = (q31_t) (acc3 << 1);
00222
00223
00224 blkCnt--;
00225 }
00226
00227
00228
00229
00230 blkCnt = blockSize % 4u;
00231
00232 while(blkCnt > 0u)
00233 {
00234
00235 *pStateCurnt++ = *pSrc++;
00236
00237
00238 acc0 = 0;
00239
00240
00241 px = pState;
00242
00243
00244 pb = (pCoeffs);
00245
00246 i = numTaps;
00247
00248
00249 do
00250 {
00251 acc0 = (q31_t) ((((q63_t) * (px++) * (*(pb++))) + (acc0 << 32)) >> 32);
00252 i--;
00253 } while(i > 0u);
00254
00255
00256
00257 *pDst++ = (q31_t) (acc0 << 1);
00258
00259
00260 pState = pState + 1;
00261
00262
00263 blkCnt--;
00264 }
00265
00266
00267
00268
00269
00270
00271 pStateCurnt = S->pState;
00272
00273 tapCnt = (numTaps - 1u) >> 2u;
00274
00275
00276 while(tapCnt > 0u)
00277 {
00278 *pStateCurnt++ = *pState++;
00279 *pStateCurnt++ = *pState++;
00280 *pStateCurnt++ = *pState++;
00281 *pStateCurnt++ = *pState++;
00282
00283
00284 tapCnt--;
00285 }
00286
00287
00288 tapCnt = (numTaps - 1u) % 0x4u;
00289
00290
00291 while(tapCnt > 0u)
00292 {
00293 *pStateCurnt++ = *pState++;
00294
00295
00296 tapCnt--;
00297 }
00298
00299 }
00300