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