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
00053 void arm_iir_lattice_q31(
00054 const arm_iir_lattice_instance_q31 * S,
00055 q31_t * pSrc,
00056 q31_t * pDst,
00057 uint32_t blockSize)
00058 {
00059
00060 q63_t acc;
00061 q31_t k1, k2, v;
00062 q31_t fnext1, gcurr1 = 0, gnext;
00063 uint32_t blkCnt, tapCnt;
00064 q31_t *px1, *px2, *pk, *pv;
00065 uint32_t numStages = S->numStages;
00066 q31_t *pState;
00067 q31_t *pStateCurnt;
00068 q31_t gcurr2, fnext2;
00069
00070
00071
00072
00073 blkCnt = blockSize;
00074
00075
00076 pState = &S->pState[0];
00077
00078
00079 while(blkCnt > 0u)
00080 {
00081
00082
00083 fnext2 = *pSrc++;
00084
00085
00086 px1 = pState;
00087
00088 px2 = pState;
00089
00090 acc = 0;
00091
00092
00093 pv = &S->pvCoeffs[0];
00094
00095 pk = &S->pkCoeffs[0];
00096
00097
00098
00099 tapCnt = (numStages) >> 2;
00100
00101 while(tapCnt > 0u)
00102 {
00103
00104 gcurr1 = *px1;
00105
00106
00107 k1 = *pk;
00108
00109
00110 fnext1 = (q31_t)(((q63_t) gcurr1 * (k1)) >> 32);
00111
00112 #ifdef CCS
00113
00114 fnext1 = __SDSUB(fnext2, fnext1);
00115
00116 #elif __GNUC__
00117
00118 fnext1 = __QDSUB(fnext2, fnext1);
00119
00120 #else
00121
00122 fnext1 = __QSUB(fnext2, __QDBL(fnext1));
00123
00124 #endif
00125
00126 k2 = *(pk + 1u);
00127
00128
00129 gcurr2 = *(px1 + 1u);
00130
00131
00132 fnext2 = (q31_t)(((q63_t) gcurr2 * (k2)) >> 32);
00133
00134
00135 gnext = (q31_t)(((q63_t) fnext1 * (k1)) >> 32);
00136
00137 #ifdef CCS
00138
00139 fnext2 = __SDSUB(fnext1, fnext2);
00140 gnext = __SDADD(gcurr1, gnext);
00141
00142 #elif __GNUC__
00143
00144 fnext2 = __QDSUB(fnext1, fnext2);
00145 gnext = __QDADD(gcurr1, gnext);
00146
00147 #else
00148
00149 fnext2 = __QSUB(fnext1, __QDBL(fnext2));
00150 gnext = __QADD(gcurr1, __QDBL(gnext));
00151
00152 #endif
00153
00154
00155 k1 = *(pk + 2u);
00156
00157
00158 *px2++ = gnext;
00159
00160
00161 v = *pv++;
00162
00163
00164 gcurr1 = *(px1 + 2u);
00165
00166
00167 acc += ((q63_t) gnext * v);
00168
00169
00170 fnext1 = (q31_t)(((q63_t) gcurr1 * (k1)) >> 32);
00171
00172
00173
00174 gnext = (q31_t)(((q63_t) fnext2 * (k2)) >> 32);
00175
00176 #ifdef CCS
00177
00178 fnext1 = __SDSUB(fnext2, fnext1);
00179 gnext = __SDADD(gcurr2, gnext);
00180
00181 #elif __GNUC__
00182
00183 fnext1 = __QDSUB(fnext2, fnext1);
00184 gnext = __QDADD(gcurr2, gnext);
00185
00186 #else
00187
00188 fnext1 = __QSUB(fnext2, __QDBL(fnext1));
00189 gnext = __QADD(gcurr2, __QDBL(gnext));
00190
00191 #endif
00192
00193
00194 v = *pv++;
00195
00196
00197 gcurr2 = *(px1 + 3u);
00198
00199
00200 acc += ((q63_t) gnext * v);
00201
00202
00203 k2 = *(pk + 3u);
00204
00205
00206 *px2++ = gnext;
00207
00208
00209
00210 fnext2 = (q31_t)(((q63_t) gcurr2 * (k2)) >> 32);
00211
00212
00213 gnext = (q31_t)(((q63_t) fnext1 * (k1)) >> 32);
00214
00215 #ifdef CCS
00216
00217 fnext2 = __SDSUB(fnext1, fnext2);
00218 gnext = __SDADD(gcurr1, gnext);
00219
00220 #elif __GNUC__
00221
00222 fnext2 = __QDSUB(fnext1, fnext2);
00223 gnext = __QDADD(gcurr1, gnext);
00224
00225 #else
00226
00227 fnext2 = __QSUB(fnext1, __QDBL(fnext2));
00228 gnext = __QADD(gcurr1, __QDBL(gnext));
00229
00230 #endif
00231
00232
00233 v = *pv++;
00234
00235
00236 acc += ((q63_t) gnext * v);
00237
00238
00239 *px2++ = gnext;
00240
00241
00242 pk += 4u;
00243
00244
00245 gnext = (q31_t)(((q63_t) fnext2 * (k2)) >> 32);
00246
00247 #ifdef CCS
00248
00249 gnext = __SDADD(gcurr2, gnext);
00250
00251 #elif __GNUC__
00252
00253 gnext = __QDADD(gcurr2, gnext);
00254
00255 #else
00256
00257 gnext = __QADD(gcurr2, __QDBL(gnext));
00258
00259 #endif
00260
00261
00262 v = *pv++;
00263
00264
00265 acc += ((q63_t) gnext * v);
00266
00267
00268 *px2++ = gnext;
00269
00270
00271 px1 += 4u;
00272
00273
00274 tapCnt--;
00275
00276 }
00277
00278
00279
00280
00281 tapCnt = (numStages) % 0x4u;
00282
00283
00284
00285 while(tapCnt > 0u)
00286 {
00287 gcurr1 = *px1++;
00288
00289 fnext1 = __QSUB(fnext2, (q31_t) (((q63_t) gcurr1 * (*pk)) >> 31));
00290 gnext = __QADD(gcurr1, (q31_t) (((q63_t) fnext1 * (*pk++)) >> 31));
00291
00292 acc += ((q63_t) gnext * *pv++);
00293 *px2++ = gnext;
00294
00295 fnext2 = fnext1;
00296
00297 tapCnt--;
00298
00299 }
00300
00301
00302 acc += (q63_t) fnext2 * (*pv);
00303
00304 *px2++ = fnext2;
00305
00306
00307 *pDst++ = (q31_t) (acc >> 31u);
00308
00309
00310 pState = pState + 1u;
00311 blkCnt--;
00312
00313 }
00314
00315
00316
00317
00318
00319 pStateCurnt = &S->pState[0];
00320 pState = &S->pState[blockSize];
00321
00322 tapCnt = numStages >> 2u;
00323
00324
00325 while(tapCnt > 0u)
00326 {
00327 *pStateCurnt++ = *pState++;
00328 *pStateCurnt++ = *pState++;
00329 *pStateCurnt++ = *pState++;
00330 *pStateCurnt++ = *pState++;
00331
00332
00333 tapCnt--;
00334
00335 }
00336
00337
00338 tapCnt = (numStages) % 0x4u;
00339
00340
00341 while(tapCnt > 0u)
00342 {
00343 *pStateCurnt++ = *pState++;
00344
00345
00346 tapCnt--;
00347 }
00348
00349 }
00350
00351
00352
00353