CMSIS DSP Library from CMSIS 2.0. See http://www.onarm.com/cmsis/ for full details

Dependents:   K22F_DSP_Matrix_least_square BNO055-ELEC3810 1BNO055 ECE4180Project--Slave2 ... more

Committer:
simon
Date:
Thu Mar 10 15:07:50 2011 +0000
Revision:
0:1014af42efd9

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
simon 0:1014af42efd9 1 /* ----------------------------------------------------------------------
simon 0:1014af42efd9 2 * Copyright (C) 2010 ARM Limited. All rights reserved.
simon 0:1014af42efd9 3 *
simon 0:1014af42efd9 4 * $Date: 29. November 2010
simon 0:1014af42efd9 5 * $Revision: V1.0.3
simon 0:1014af42efd9 6 *
simon 0:1014af42efd9 7 * Project: CMSIS DSP Library
simon 0:1014af42efd9 8 * Title: arm_fir_lattice_q31.c
simon 0:1014af42efd9 9 *
simon 0:1014af42efd9 10 * Description: Q31 FIR lattice filter processing function.
simon 0:1014af42efd9 11 *
simon 0:1014af42efd9 12 * Target Processor: Cortex-M4/Cortex-M3
simon 0:1014af42efd9 13 *
simon 0:1014af42efd9 14 * Version 1.0.3 2010/11/29
simon 0:1014af42efd9 15 * Re-organized the CMSIS folders and updated documentation.
simon 0:1014af42efd9 16 *
simon 0:1014af42efd9 17 * Version 1.0.2 2010/11/11
simon 0:1014af42efd9 18 * Documentation updated.
simon 0:1014af42efd9 19 *
simon 0:1014af42efd9 20 * Version 1.0.1 2010/10/05
simon 0:1014af42efd9 21 * Production release and review comments incorporated.
simon 0:1014af42efd9 22 *
simon 0:1014af42efd9 23 * Version 1.0.0 2010/09/20
simon 0:1014af42efd9 24 * Production release and review comments incorporated
simon 0:1014af42efd9 25 *
simon 0:1014af42efd9 26 * Version 0.0.7 2010/06/10
simon 0:1014af42efd9 27 * Misra-C changes done
simon 0:1014af42efd9 28 * -------------------------------------------------------------------- */
simon 0:1014af42efd9 29
simon 0:1014af42efd9 30 #include "arm_math.h"
simon 0:1014af42efd9 31
simon 0:1014af42efd9 32 /**
simon 0:1014af42efd9 33 * @ingroup groupFilters
simon 0:1014af42efd9 34 */
simon 0:1014af42efd9 35
simon 0:1014af42efd9 36 /**
simon 0:1014af42efd9 37 * @addtogroup FIR_Lattice
simon 0:1014af42efd9 38 * @{
simon 0:1014af42efd9 39 */
simon 0:1014af42efd9 40
simon 0:1014af42efd9 41
simon 0:1014af42efd9 42 /**
simon 0:1014af42efd9 43 * @brief Processing function for the Q31 FIR lattice filter.
simon 0:1014af42efd9 44 * @param[in] *S points to an instance of the Q31 FIR lattice structure.
simon 0:1014af42efd9 45 * @param[in] *pSrc points to the block of input data.
simon 0:1014af42efd9 46 * @param[out] *pDst points to the block of output data
simon 0:1014af42efd9 47 * @param[in] blockSize number of samples to process.
simon 0:1014af42efd9 48 * @return none.
simon 0:1014af42efd9 49 *
simon 0:1014af42efd9 50 * @details
simon 0:1014af42efd9 51 * <b>Scaling and Overflow Behavior:</b>
simon 0:1014af42efd9 52 * In order to avoid overflows the input signal must be scaled down by 2*log2(numStages) bits.
simon 0:1014af42efd9 53 */
simon 0:1014af42efd9 54
simon 0:1014af42efd9 55 void arm_fir_lattice_q31(
simon 0:1014af42efd9 56 const arm_fir_lattice_instance_q31 * S,
simon 0:1014af42efd9 57 q31_t * pSrc,
simon 0:1014af42efd9 58 q31_t * pDst,
simon 0:1014af42efd9 59 uint32_t blockSize)
simon 0:1014af42efd9 60 {
simon 0:1014af42efd9 61 q31_t *pState; /* State pointer */
simon 0:1014af42efd9 62 q31_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */
simon 0:1014af42efd9 63 q31_t *px; /* temporary state pointer */
simon 0:1014af42efd9 64 q31_t *pk; /* temporary coefficient pointer */
simon 0:1014af42efd9 65 q31_t fcurr1, fnext1, gcurr1 = 0, gnext1; /* temporary variables for first sample in loop unrolling */
simon 0:1014af42efd9 66 q63_t fcurr2, fnext2, gnext2; /* temporary variables for second sample in loop unrolling */
simon 0:1014af42efd9 67 q63_t fcurr3, fnext3, gnext3; /* temporary variables for third sample in loop unrolling */
simon 0:1014af42efd9 68 q63_t fcurr4, fnext4, gnext4; /* temporary variables for fourth sample in loop unrolling */
simon 0:1014af42efd9 69 uint32_t numStages = S->numStages; /* Length of the filter */
simon 0:1014af42efd9 70 uint32_t blkCnt, stageCnt; /* temporary variables for counts */
simon 0:1014af42efd9 71
simon 0:1014af42efd9 72 pState = &S->pState[0];
simon 0:1014af42efd9 73
simon 0:1014af42efd9 74 blkCnt = blockSize >> 2u;
simon 0:1014af42efd9 75
simon 0:1014af42efd9 76 /* First part of the processing with loop unrolling. Compute 4 outputs at a time.
simon 0:1014af42efd9 77 ** a second loop below computes the remaining 1 to 3 samples. */
simon 0:1014af42efd9 78 while(blkCnt > 0u)
simon 0:1014af42efd9 79 {
simon 0:1014af42efd9 80
simon 0:1014af42efd9 81 /* Read two samples from input buffer */
simon 0:1014af42efd9 82 /* f0(n) = x(n) */
simon 0:1014af42efd9 83 fcurr1 = *pSrc++;
simon 0:1014af42efd9 84 /* f0(n) = x(n) */
simon 0:1014af42efd9 85 fcurr2 = *pSrc++;
simon 0:1014af42efd9 86
simon 0:1014af42efd9 87 /* Initialize coeff pointer */
simon 0:1014af42efd9 88 pk = (pCoeffs);
simon 0:1014af42efd9 89
simon 0:1014af42efd9 90 /* Initialize state pointer */
simon 0:1014af42efd9 91 px = pState;
simon 0:1014af42efd9 92
simon 0:1014af42efd9 93 /* Read g0(n-1) from state */
simon 0:1014af42efd9 94 gcurr1 = *px;
simon 0:1014af42efd9 95
simon 0:1014af42efd9 96 /* Process first sample for first tap */
simon 0:1014af42efd9 97 /* f1(n) = f0(n) + K1 * g0(n-1) */
simon 0:1014af42efd9 98 fnext1 = (q31_t) (((q63_t) gcurr1 * (*pk)) >> 31) + fcurr1;
simon 0:1014af42efd9 99 /* g1(n) = f0(n) * K1 + g0(n-1) */
simon 0:1014af42efd9 100 gnext1 = (q31_t) (((q63_t) fcurr1 * (*pk)) >> 31) + gcurr1;
simon 0:1014af42efd9 101
simon 0:1014af42efd9 102 /* Process second sample for first tap */
simon 0:1014af42efd9 103 /* for sample 2 processing */
simon 0:1014af42efd9 104 fnext2 = (q31_t) (((q63_t) fcurr1 * (*pk)) >> 31) + fcurr2;
simon 0:1014af42efd9 105 gnext2 = (q31_t) (((q63_t) fcurr2 * (*pk)) >> 31) + fcurr1;
simon 0:1014af42efd9 106
simon 0:1014af42efd9 107
simon 0:1014af42efd9 108 /* Read next two samples from input buffer */
simon 0:1014af42efd9 109 /* f0(n+2) = x(n+2) */
simon 0:1014af42efd9 110 fcurr3 = *pSrc++;
simon 0:1014af42efd9 111 fcurr4 = *pSrc++;
simon 0:1014af42efd9 112
simon 0:1014af42efd9 113 /* Copy only last input samples into the state buffer
simon 0:1014af42efd9 114 which will be used for next four samples processing */
simon 0:1014af42efd9 115 *px++ = (q31_t) fcurr4;
simon 0:1014af42efd9 116
simon 0:1014af42efd9 117 /* Process third sample for first tap */
simon 0:1014af42efd9 118 fnext3 = (q31_t) (((q63_t) fcurr2 * (*pk)) >> 31) + fcurr3;
simon 0:1014af42efd9 119 gnext3 = (q31_t) (((q63_t) fcurr3 * (*pk)) >> 31) + fcurr2;
simon 0:1014af42efd9 120
simon 0:1014af42efd9 121 /* Process fourth sample for first tap */
simon 0:1014af42efd9 122 fnext4 = (q31_t) (((q63_t) fcurr3 * (*pk)) >> 31) + fcurr4;
simon 0:1014af42efd9 123 gnext4 = (q31_t) (((q63_t) fcurr4 * (*pk++)) >> 31) + fcurr3;
simon 0:1014af42efd9 124
simon 0:1014af42efd9 125 /* save g1(n) in state buffer for next sample processing */
simon 0:1014af42efd9 126 /* *px++ = gnext4; */
simon 0:1014af42efd9 127
simon 0:1014af42efd9 128 /* Update of f values for next coefficient set processing */
simon 0:1014af42efd9 129 fcurr1 = fnext1;
simon 0:1014af42efd9 130 fcurr2 = fnext2;
simon 0:1014af42efd9 131 fcurr3 = fnext3;
simon 0:1014af42efd9 132 fcurr4 = fnext4;
simon 0:1014af42efd9 133
simon 0:1014af42efd9 134
simon 0:1014af42efd9 135 /* Loop unrolling. Process 4 taps at a time . */
simon 0:1014af42efd9 136 stageCnt = (numStages - 1u) >> 2u;
simon 0:1014af42efd9 137
simon 0:1014af42efd9 138
simon 0:1014af42efd9 139 /* Loop over the number of taps. Unroll by a factor of 4.
simon 0:1014af42efd9 140 ** Repeat until we've computed numStages-3 coefficients. */
simon 0:1014af42efd9 141
simon 0:1014af42efd9 142 /* Process 2nd, 3rd, 4th and 5th taps ... here */
simon 0:1014af42efd9 143 while(stageCnt > 0u)
simon 0:1014af42efd9 144 {
simon 0:1014af42efd9 145 /* Read g1(n-1), g3(n-1) .... from state */
simon 0:1014af42efd9 146 gcurr1 = *px;
simon 0:1014af42efd9 147
simon 0:1014af42efd9 148 /* save g1(n) in state buffer */
simon 0:1014af42efd9 149 *px++ = (q31_t) gnext4;
simon 0:1014af42efd9 150
simon 0:1014af42efd9 151 /* Process first sample for 2nd, 6th .. tap */
simon 0:1014af42efd9 152 /* Sample processing for K2, K6.... */
simon 0:1014af42efd9 153 /* f2(n) = f1(n) + K2 * g1(n-1) */
simon 0:1014af42efd9 154 fnext1 = (q31_t) (((q63_t) gcurr1 * (*pk)) >> 31) + fcurr1;
simon 0:1014af42efd9 155 /* Process second sample for 2nd, 6th .. tap */
simon 0:1014af42efd9 156 /* for sample 2 processing */
simon 0:1014af42efd9 157 fnext2 = (q31_t) (((q63_t) gnext1 * (*pk)) >> 31) + fcurr2;
simon 0:1014af42efd9 158 /* Process third sample for 2nd, 6th .. tap */
simon 0:1014af42efd9 159 fnext3 = (q31_t) (((q63_t) gnext2 * (*pk)) >> 31) + fcurr3;
simon 0:1014af42efd9 160 /* Process fourth sample for 2nd, 6th .. tap */
simon 0:1014af42efd9 161 fnext4 = (q31_t) (((q63_t) gnext3 * (*pk)) >> 31) + fcurr4;
simon 0:1014af42efd9 162
simon 0:1014af42efd9 163 /* g2(n) = f1(n) * K2 + g1(n-1) */
simon 0:1014af42efd9 164 /* Calculation of state values for next stage */
simon 0:1014af42efd9 165 gnext4 = (q31_t) (((q63_t) fcurr4 * (*pk)) >> 31) + gnext3;
simon 0:1014af42efd9 166 gnext3 = (q31_t) (((q63_t) fcurr3 * (*pk)) >> 31) + gnext2;
simon 0:1014af42efd9 167 gnext2 = (q31_t) (((q63_t) fcurr2 * (*pk)) >> 31) + gnext1;
simon 0:1014af42efd9 168 gnext1 = (q31_t) (((q63_t) fcurr1 * (*pk++)) >> 31) + gcurr1;
simon 0:1014af42efd9 169
simon 0:1014af42efd9 170
simon 0:1014af42efd9 171 /* Read g2(n-1), g4(n-1) .... from state */
simon 0:1014af42efd9 172 gcurr1 = *px;
simon 0:1014af42efd9 173
simon 0:1014af42efd9 174 /* save g2(n) in state buffer */
simon 0:1014af42efd9 175 *px++ = (q31_t) gnext4;
simon 0:1014af42efd9 176
simon 0:1014af42efd9 177 /* Sample processing for K3, K7.... */
simon 0:1014af42efd9 178 /* Process first sample for 3rd, 7th .. tap */
simon 0:1014af42efd9 179 /* f3(n) = f2(n) + K3 * g2(n-1) */
simon 0:1014af42efd9 180 fcurr1 = (q31_t) (((q63_t) gcurr1 * (*pk)) >> 31) + fnext1;
simon 0:1014af42efd9 181 /* Process second sample for 3rd, 7th .. tap */
simon 0:1014af42efd9 182 fcurr2 = (q31_t) (((q63_t) gnext1 * (*pk)) >> 31) + fnext2;
simon 0:1014af42efd9 183 /* Process third sample for 3rd, 7th .. tap */
simon 0:1014af42efd9 184 fcurr3 = (q31_t) (((q63_t) gnext2 * (*pk)) >> 31) + fnext3;
simon 0:1014af42efd9 185 /* Process fourth sample for 3rd, 7th .. tap */
simon 0:1014af42efd9 186 fcurr4 = (q31_t) (((q63_t) gnext3 * (*pk)) >> 31) + fnext4;
simon 0:1014af42efd9 187
simon 0:1014af42efd9 188 /* Calculation of state values for next stage */
simon 0:1014af42efd9 189 /* gnext4 = fnext4 * (*pk) + gnext3; */
simon 0:1014af42efd9 190 gnext4 = (q31_t) (((q63_t) fnext4 * (*pk)) >> 31) + gnext3;
simon 0:1014af42efd9 191 gnext3 = (q31_t) (((q63_t) fnext3 * (*pk)) >> 31) + gnext2;
simon 0:1014af42efd9 192 /* gnext2 = fnext2 * (*pk) + gnext1; */
simon 0:1014af42efd9 193 gnext2 = (q31_t) (((q63_t) fnext2 * (*pk)) >> 31) + gnext1;
simon 0:1014af42efd9 194
simon 0:1014af42efd9 195 /* g1(n) = f0(n) * K1 + g0(n-1) */
simon 0:1014af42efd9 196 /* gnext1 = fnext1 * (*pk++) + gcurr1; */
simon 0:1014af42efd9 197 gnext1 = (q31_t) (((q63_t) fnext1 * (*pk++)) >> 31) + gcurr1;
simon 0:1014af42efd9 198
simon 0:1014af42efd9 199 /* Read g1(n-1), g3(n-1) .... from state */
simon 0:1014af42efd9 200 gcurr1 = *px;
simon 0:1014af42efd9 201
simon 0:1014af42efd9 202 /* save g1(n) in state buffer */
simon 0:1014af42efd9 203 *px++ = (q31_t) gnext4;
simon 0:1014af42efd9 204
simon 0:1014af42efd9 205 /* Sample processing for K4, K8.... */
simon 0:1014af42efd9 206 /* Process first sample for 4th, 8th .. tap */
simon 0:1014af42efd9 207 /* f4(n) = f3(n) + K4 * g3(n-1) */
simon 0:1014af42efd9 208 fnext1 = (q31_t) (((q63_t) gcurr1 * (*pk)) >> 31) + fcurr1;
simon 0:1014af42efd9 209 /* Process second sample for 4th, 8th .. tap */
simon 0:1014af42efd9 210 /* for sample 2 processing */
simon 0:1014af42efd9 211 fnext2 = (q31_t) (((q63_t) gnext1 * (*pk)) >> 31) + fcurr2;
simon 0:1014af42efd9 212 /* Process third sample for 4th, 8th .. tap */
simon 0:1014af42efd9 213 fnext3 = (q31_t) (((q63_t) gnext2 * (*pk)) >> 31) + fcurr3;
simon 0:1014af42efd9 214 /* Process fourth sample for 4th, 8th .. tap */
simon 0:1014af42efd9 215 fnext4 = (q31_t) (((q63_t) gnext3 * (*pk)) >> 31) + fcurr4;
simon 0:1014af42efd9 216
simon 0:1014af42efd9 217 /* g4(n) = f3(n) * K4 + g3(n-1) */
simon 0:1014af42efd9 218 /* Calculation of state values for next stage */
simon 0:1014af42efd9 219 gnext4 = (q31_t) (((q63_t) fcurr4 * (*pk)) >> 31) + gnext3;
simon 0:1014af42efd9 220 gnext3 = (q31_t) (((q63_t) fcurr3 * (*pk)) >> 31) + gnext2;
simon 0:1014af42efd9 221 gnext2 = (q31_t) (((q63_t) fcurr2 * (*pk)) >> 31) + gnext1;
simon 0:1014af42efd9 222 gnext1 = (q31_t) (((q63_t) fcurr1 * (*pk++)) >> 31) + gcurr1;
simon 0:1014af42efd9 223
simon 0:1014af42efd9 224 /* Read g2(n-1), g4(n-1) .... from state */
simon 0:1014af42efd9 225 gcurr1 = *px;
simon 0:1014af42efd9 226
simon 0:1014af42efd9 227 /* save g4(n) in state buffer */
simon 0:1014af42efd9 228 *px++ = (q31_t) gnext4;
simon 0:1014af42efd9 229
simon 0:1014af42efd9 230 /* Sample processing for K5, K9.... */
simon 0:1014af42efd9 231 /* Process first sample for 5th, 9th .. tap */
simon 0:1014af42efd9 232 /* f5(n) = f4(n) + K5 * g4(n-1) */
simon 0:1014af42efd9 233 fcurr1 = (q31_t) (((q63_t) gcurr1 * (*pk)) >> 31) + fnext1;
simon 0:1014af42efd9 234 /* Process second sample for 5th, 9th .. tap */
simon 0:1014af42efd9 235 fcurr2 = (q31_t) (((q63_t) gnext1 * (*pk)) >> 31) + fnext2;
simon 0:1014af42efd9 236 /* Process third sample for 5th, 9th .. tap */
simon 0:1014af42efd9 237 fcurr3 = (q31_t) (((q63_t) gnext2 * (*pk)) >> 31) + fnext3;
simon 0:1014af42efd9 238 /* Process fourth sample for 5th, 9th .. tap */
simon 0:1014af42efd9 239 fcurr4 = (q31_t) (((q63_t) gnext3 * (*pk)) >> 31) + fnext4;
simon 0:1014af42efd9 240
simon 0:1014af42efd9 241 /* Calculation of state values for next stage */
simon 0:1014af42efd9 242 /* g5(n) = f4(n) * K5 + g4(n-1) */
simon 0:1014af42efd9 243 gnext4 = (q31_t) (((q63_t) fnext4 * (*pk)) >> 31) + gnext3;
simon 0:1014af42efd9 244 gnext3 = (q31_t) (((q63_t) fnext3 * (*pk)) >> 31) + gnext2;
simon 0:1014af42efd9 245 gnext2 = (q31_t) (((q63_t) fnext2 * (*pk)) >> 31) + gnext1;
simon 0:1014af42efd9 246 gnext1 = (q31_t) (((q63_t) fnext1 * (*pk++)) >> 31) + gcurr1;
simon 0:1014af42efd9 247
simon 0:1014af42efd9 248 stageCnt--;
simon 0:1014af42efd9 249 }
simon 0:1014af42efd9 250
simon 0:1014af42efd9 251 /* If the (filter length -1) is not a multiple of 4, compute the remaining filter taps */
simon 0:1014af42efd9 252 stageCnt = (numStages - 1u) % 0x4u;
simon 0:1014af42efd9 253
simon 0:1014af42efd9 254 while(stageCnt > 0u)
simon 0:1014af42efd9 255 {
simon 0:1014af42efd9 256 gcurr1 = *px;
simon 0:1014af42efd9 257
simon 0:1014af42efd9 258 /* save g value in state buffer */
simon 0:1014af42efd9 259 *px++ = (q31_t) gnext4;
simon 0:1014af42efd9 260
simon 0:1014af42efd9 261 /* Process four samples for last three taps here */
simon 0:1014af42efd9 262 fnext1 = (q31_t) (((q63_t) gcurr1 * (*pk)) >> 31) + fcurr1;
simon 0:1014af42efd9 263 fnext2 = (q31_t) (((q63_t) gnext1 * (*pk)) >> 31) + fcurr2;
simon 0:1014af42efd9 264 fnext3 = (q31_t) (((q63_t) gnext2 * (*pk)) >> 31) + fcurr3;
simon 0:1014af42efd9 265 fnext4 = (q31_t) (((q63_t) gnext3 * (*pk)) >> 31) + fcurr4;
simon 0:1014af42efd9 266
simon 0:1014af42efd9 267 /* g1(n) = f0(n) * K1 + g0(n-1) */
simon 0:1014af42efd9 268 gnext4 = (q31_t) (((q63_t) fcurr4 * (*pk)) >> 31) + gnext3;
simon 0:1014af42efd9 269 gnext3 = (q31_t) (((q63_t) fcurr3 * (*pk)) >> 31) + gnext2;
simon 0:1014af42efd9 270 gnext2 = (q31_t) (((q63_t) fcurr2 * (*pk)) >> 31) + gnext1;
simon 0:1014af42efd9 271 gnext1 = (q31_t) (((q63_t) fcurr1 * (*pk++)) >> 31) + gcurr1;
simon 0:1014af42efd9 272
simon 0:1014af42efd9 273 /* Update of f values for next coefficient set processing */
simon 0:1014af42efd9 274 fcurr1 = fnext1;
simon 0:1014af42efd9 275 fcurr2 = fnext2;
simon 0:1014af42efd9 276 fcurr3 = fnext3;
simon 0:1014af42efd9 277 fcurr4 = fnext4;
simon 0:1014af42efd9 278
simon 0:1014af42efd9 279 stageCnt--;
simon 0:1014af42efd9 280
simon 0:1014af42efd9 281 }
simon 0:1014af42efd9 282
simon 0:1014af42efd9 283 /* The results in the 4 accumulators, store in the destination buffer. */
simon 0:1014af42efd9 284 /* y(n) = fN(n) */
simon 0:1014af42efd9 285 *pDst++ = fcurr1;
simon 0:1014af42efd9 286 *pDst++ = (q31_t) fcurr2;
simon 0:1014af42efd9 287 *pDst++ = (q31_t) fcurr3;
simon 0:1014af42efd9 288 *pDst++ = (q31_t) fcurr4;
simon 0:1014af42efd9 289
simon 0:1014af42efd9 290 blkCnt--;
simon 0:1014af42efd9 291 }
simon 0:1014af42efd9 292
simon 0:1014af42efd9 293 /* If the blockSize is not a multiple of 4, compute any remaining output samples here.
simon 0:1014af42efd9 294 ** No loop unrolling is used. */
simon 0:1014af42efd9 295 blkCnt = blockSize % 0x4u;
simon 0:1014af42efd9 296
simon 0:1014af42efd9 297 while(blkCnt > 0u)
simon 0:1014af42efd9 298 {
simon 0:1014af42efd9 299 /* f0(n) = x(n) */
simon 0:1014af42efd9 300 fcurr1 = *pSrc++;
simon 0:1014af42efd9 301
simon 0:1014af42efd9 302 /* Initialize coeff pointer */
simon 0:1014af42efd9 303 pk = (pCoeffs);
simon 0:1014af42efd9 304
simon 0:1014af42efd9 305 /* Initialize state pointer */
simon 0:1014af42efd9 306 px = pState;
simon 0:1014af42efd9 307
simon 0:1014af42efd9 308 /* read g2(n) from state buffer */
simon 0:1014af42efd9 309 gcurr1 = *px;
simon 0:1014af42efd9 310
simon 0:1014af42efd9 311 /* for sample 1 processing */
simon 0:1014af42efd9 312 /* f1(n) = f0(n) + K1 * g0(n-1) */
simon 0:1014af42efd9 313 fnext1 = (q31_t) (((q63_t) gcurr1 * (*pk)) >> 31) + fcurr1;
simon 0:1014af42efd9 314 /* g1(n) = f0(n) * K1 + g0(n-1) */
simon 0:1014af42efd9 315 gnext1 = (q31_t) (((q63_t) fcurr1 * (*pk++)) >> 31) + gcurr1;
simon 0:1014af42efd9 316 /* save g1(n) in state buffer */
simon 0:1014af42efd9 317 *px++ = fcurr1;
simon 0:1014af42efd9 318
simon 0:1014af42efd9 319 /* f1(n) is saved in fcurr1
simon 0:1014af42efd9 320 for next stage processing */
simon 0:1014af42efd9 321 fcurr1 = fnext1;
simon 0:1014af42efd9 322
simon 0:1014af42efd9 323 stageCnt = (numStages - 1u);
simon 0:1014af42efd9 324
simon 0:1014af42efd9 325 /* stage loop */
simon 0:1014af42efd9 326 while(stageCnt > 0u)
simon 0:1014af42efd9 327 {
simon 0:1014af42efd9 328 /* read g2(n) from state buffer */
simon 0:1014af42efd9 329 gcurr1 = *px;
simon 0:1014af42efd9 330
simon 0:1014af42efd9 331 /* save g1(n) in state buffer */
simon 0:1014af42efd9 332 *px++ = gnext1;
simon 0:1014af42efd9 333
simon 0:1014af42efd9 334 /* Sample processing for K2, K3.... */
simon 0:1014af42efd9 335 /* f2(n) = f1(n) + K2 * g1(n-1) */
simon 0:1014af42efd9 336 fnext1 = (q31_t) (((q63_t) gcurr1 * (*pk)) >> 31) + fcurr1;
simon 0:1014af42efd9 337 /* g2(n) = f1(n) * K2 + g1(n-1) */
simon 0:1014af42efd9 338 gnext1 = (q31_t) (((q63_t) fcurr1 * (*pk++)) >> 31) + gcurr1;
simon 0:1014af42efd9 339
simon 0:1014af42efd9 340 /* f1(n) is saved in fcurr1
simon 0:1014af42efd9 341 for next stage processing */
simon 0:1014af42efd9 342 fcurr1 = fnext1;
simon 0:1014af42efd9 343
simon 0:1014af42efd9 344 stageCnt--;
simon 0:1014af42efd9 345
simon 0:1014af42efd9 346 }
simon 0:1014af42efd9 347
simon 0:1014af42efd9 348 /* y(n) = fN(n) */
simon 0:1014af42efd9 349 *pDst++ = fcurr1;
simon 0:1014af42efd9 350
simon 0:1014af42efd9 351 blkCnt--;
simon 0:1014af42efd9 352
simon 0:1014af42efd9 353 }
simon 0:1014af42efd9 354 }
simon 0:1014af42efd9 355
simon 0:1014af42efd9 356 /**
simon 0:1014af42efd9 357 * @} end of FIR_Lattice group
simon 0:1014af42efd9 358 */