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