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
00049 void arm_fir_lattice_q31(
00050 const arm_fir_lattice_instance_q31 * S,
00051 q31_t * pSrc,
00052 q31_t * pDst,
00053 uint32_t blockSize)
00054 {
00055 q31_t *pState;
00056 q31_t *pCoeffs = S->pCoeffs;
00057 q31_t *px;
00058 q31_t *pk;
00059 q31_t fcurr1, fnext1, gcurr1 = 0, gnext1;
00060 q31_t fcurr2, fnext2, gnext2;
00061 uint32_t numStages = S->numStages;
00062 uint32_t blkCnt, stageCnt;
00063 q31_t k;
00064
00065 pState = &S->pState[0];
00066
00067 blkCnt = blockSize >> 1u;
00068
00069
00070
00071 while(blkCnt > 0u)
00072 {
00073
00074 fcurr1 = *pSrc++;
00075
00076
00077 fcurr2 = *pSrc++;
00078
00079
00080 pk = (pCoeffs);
00081
00082
00083 px = pState;
00084
00085
00086 gcurr1 = *px;
00087
00088
00089 k = *pk++;
00090
00091
00092
00093 fnext1 = (q31_t)(((q63_t) gcurr1 * k) >> 32);
00094
00095
00096 gnext1 = (q31_t)(((q63_t) fcurr1 * (k)) >> 32);
00097 fnext1 = fcurr1 + (fnext1 << 1u);
00098 gnext1 = gcurr1 + (gnext1 << 1u);
00099
00100
00101
00102 fnext2 = (q31_t)(((q63_t) fcurr1 * k) >> 32);
00103
00104
00105 gnext2 = (q31_t)(((q63_t) fcurr2 * (k)) >> 32);
00106 fnext2 = fcurr2 + (fnext2 << 1u);
00107 gnext2 = fcurr1 + (gnext2 << 1u);
00108
00109
00110 *px++ = fcurr2;
00111
00112
00113
00114 fcurr1 = fnext1;
00115 fcurr2 = fnext2;
00116
00117 stageCnt = (numStages - 1u);
00118
00119
00120 while(stageCnt > 0u)
00121 {
00122
00123
00124 k = *pk++;
00125
00126
00127 gcurr1 = *px;
00128
00129
00130 *px++ = gnext2;
00131
00132
00133
00134 fnext1 = (q31_t)(((q63_t) gcurr1 * k) >> 32);
00135 fnext2 = (q31_t)(((q63_t) gnext1 * k) >> 32);
00136
00137 fnext1 = fcurr1 + (fnext1 << 1u);
00138 fnext2 = fcurr2 + (fnext2 << 1u);
00139
00140
00141 gnext2 = (q31_t)(((q63_t) fcurr2 * (k)) >> 32);
00142 gnext2 = gnext1 + (gnext2 << 1u);
00143
00144
00145 gnext1 = (q31_t)(((q63_t) fcurr1 * (k)) >> 32);
00146 gnext1 = gcurr1 + (gnext1 << 1u);
00147
00148
00149
00150 fcurr1 = fnext1;
00151 fcurr2 = fnext2;
00152
00153 stageCnt--;
00154
00155 }
00156
00157
00158 *pDst++ = fcurr1;
00159 *pDst++ = fcurr2;
00160
00161 blkCnt--;
00162
00163 }
00164
00165
00166
00167 blkCnt = blockSize % 0x2u;
00168
00169 while(blkCnt > 0u)
00170 {
00171
00172 fcurr1 = *pSrc++;
00173
00174
00175 pk = (pCoeffs);
00176
00177
00178 px = pState;
00179
00180
00181 gcurr1 = *px;
00182
00183
00184 k = *pk++;
00185
00186
00187
00188 fnext1 = (q31_t)(((q63_t) gcurr1 * k) >> 32);
00189 fnext1 = fcurr1 + (fnext1 << 1u);
00190
00191
00192 gnext1 = (q31_t)(((q63_t) fcurr1 * (k)) >> 32);
00193 gnext1 = gcurr1 + (gnext1 << 1u);
00194
00195
00196 *px++ = fcurr1;
00197
00198
00199
00200 fcurr1 = fnext1;
00201
00202 stageCnt = (numStages - 1u);
00203
00204
00205 while(stageCnt > 0u)
00206 {
00207
00208 k = *pk++;
00209
00210
00211 gcurr1 = *px;
00212
00213
00214 *px++ = gnext1;
00215
00216
00217
00218 fnext1 = (q31_t)(((q63_t) gcurr1 * k) >> 32);
00219 fnext1 = fcurr1 + (fnext1 << 1u);
00220
00221
00222 gnext1 = (q31_t)(((q63_t) fcurr1 * (k)) >> 32);
00223 gnext1 = gcurr1 + (gnext1 << 1u);
00224
00225
00226
00227 fcurr1 = fnext1;
00228
00229 stageCnt--;
00230
00231 }
00232
00233
00234
00235 *pDst++ = fcurr1;
00236
00237 blkCnt--;
00238
00239 }
00240
00241
00242 }
00243