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 #include "arm_math.h"
00030
00057 void arm_fir_sparse_q15(
00058 arm_fir_sparse_instance_q15 * S,
00059 q15_t * pSrc,
00060 q15_t * pDst,
00061 q15_t * pScratchIn,
00062 q31_t * pScratchOut,
00063 uint32_t blockSize)
00064 {
00065
00066 q15_t *pState = S->pState;
00067 q15_t *pIn = (q15_t *) pSrc;
00068 q15_t *pOut = pDst;
00069 q15_t *pCoeffs = S->pCoeffs;
00070 q15_t *px;
00071 q15_t *pb = pScratchIn;
00072 q15_t *py = pState;
00073 int32_t *pTapDelay = S->pTapDelay;
00074 uint32_t delaySize = S->maxDelay + blockSize;
00075 uint16_t numTaps = S->numTaps;
00076 int32_t readIndex;
00077 uint32_t tapCnt, blkCnt;
00078 q15_t coeff = *pCoeffs++;
00079 q31_t *pScr2 = pScratchOut;
00080 q31_t in1, in2;
00081
00082
00083
00084
00085
00086 arm_circularWrite_q15(py, delaySize, &S->stateIndex, 1, pIn, 1, blockSize);
00087
00088
00089 tapCnt = numTaps;
00090
00091
00092 readIndex = (S->stateIndex - blockSize) - *pTapDelay++;
00093
00094
00095 if(readIndex < 0)
00096 {
00097 readIndex += (int32_t) delaySize;
00098 }
00099
00100
00101 py = pState;
00102
00103
00104 arm_circularRead_q15(py, delaySize, &readIndex, 1,
00105 pb, pb, blockSize, 1, blockSize);
00106
00107
00108 px = pb;
00109
00110
00111 pScratchOut = pScr2;
00112
00113
00114
00115 blkCnt = blockSize >> 2;
00116
00117 while(blkCnt > 0u)
00118 {
00119
00120 *pScratchOut++ = ((q31_t) * px++ * coeff);
00121 *pScratchOut++ = ((q31_t) * px++ * coeff);
00122 *pScratchOut++ = ((q31_t) * px++ * coeff);
00123 *pScratchOut++ = ((q31_t) * px++ * coeff);
00124
00125
00126 blkCnt--;
00127 }
00128
00129
00130
00131 blkCnt = blockSize % 0x4u;
00132
00133 while(blkCnt > 0u)
00134 {
00135
00136 *pScratchOut++ = ((q31_t) * px++ * coeff);
00137
00138
00139 blkCnt--;
00140 }
00141
00142
00143
00144 coeff = *pCoeffs++;
00145
00146
00147 readIndex = (S->stateIndex - blockSize) - *pTapDelay++;
00148
00149
00150 if(readIndex < 0)
00151 {
00152 readIndex += (int32_t) delaySize;
00153 }
00154
00155
00156 tapCnt = (uint32_t) numTaps - 1u;
00157
00158 while(tapCnt > 0u)
00159 {
00160
00161 py = pState;
00162
00163
00164 arm_circularRead_q15(py, delaySize, &readIndex, 1,
00165 pb, pb, blockSize, 1, blockSize);
00166
00167
00168 px = pb;
00169
00170
00171 pScratchOut = pScr2;
00172
00173
00174
00175 blkCnt = blockSize >> 2;
00176
00177 while(blkCnt > 0u)
00178 {
00179
00180 *pScratchOut++ += (q31_t) * px++ * coeff;
00181 *pScratchOut++ += (q31_t) * px++ * coeff;
00182 *pScratchOut++ += (q31_t) * px++ * coeff;
00183 *pScratchOut++ += (q31_t) * px++ * coeff;
00184
00185
00186 blkCnt--;
00187 }
00188
00189
00190
00191 blkCnt = blockSize % 0x4u;
00192
00193 while(blkCnt > 0u)
00194 {
00195
00196 *pScratchOut++ += (q31_t) * px++ * coeff;
00197
00198
00199 blkCnt--;
00200 }
00201
00202
00203
00204 coeff = *pCoeffs++;
00205
00206
00207 readIndex = (S->stateIndex - blockSize) - *pTapDelay++;
00208
00209
00210 if(readIndex < 0)
00211 {
00212 readIndex += (int32_t) delaySize;
00213 }
00214
00215
00216 tapCnt--;
00217 }
00218
00219
00220
00221
00222 blkCnt = blockSize >> 2;
00223
00224 while(blkCnt > 0u)
00225 {
00226 in1 = *pScr2++;
00227 in2 = *pScr2++;
00228 *__SIMD32(pOut)++ =
00229 __PKHBT((q15_t) __SSAT(in1 >> 15, 16), (q15_t) __SSAT(in2 >> 15, 16),
00230 16);
00231
00232 in1 = *pScr2++;
00233 in2 = *pScr2++;
00234 *__SIMD32(pOut)++ =
00235 __PKHBT((q15_t) __SSAT(in1 >> 15, 16), (q15_t) __SSAT(in2 >> 15, 16),
00236 16);
00237
00238 blkCnt--;
00239
00240 }
00241
00242
00243
00244 blkCnt = blockSize % 0x4u;
00245
00246 while(blkCnt > 0u)
00247 {
00248 *pOut++ = (q15_t) __SSAT(*pScr2++ >> 15, 16);
00249 blkCnt--;
00250 }
00251 }
00252