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