V4.0.1 of the ARM CMSIS DSP libraries. Note that arm_bitreversal2.s, arm_cfft_f32.c and arm_rfft_fast_f32.c had to be removed. arm_bitreversal2.s will not assemble with the online tools. So, the fast f32 FFT functions are not yet available. All the other FFT functions are available.
Dependents: MPU9150_Example fir_f32 fir_f32 MPU9150_nucleo_noni2cdev ... more
FilteringFunctions/arm_fir_lattice_q15.c@0:3d9c67d97d6f, 2014-07-28 (annotated)
- Committer:
- emh203
- Date:
- Mon Jul 28 15:03:15 2014 +0000
- Revision:
- 0:3d9c67d97d6f
1st working commit. Had to remove arm_bitreversal2.s arm_cfft_f32.c and arm_rfft_fast_f32.c. The .s will not assemble. For now I removed these functions so we could at least have a library for the other functions.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
emh203 | 0:3d9c67d97d6f | 1 | /* ---------------------------------------------------------------------- |
emh203 | 0:3d9c67d97d6f | 2 | * Copyright (C) 2010-2014 ARM Limited. All rights reserved. |
emh203 | 0:3d9c67d97d6f | 3 | * |
emh203 | 0:3d9c67d97d6f | 4 | * $Date: 12. March 2014 |
emh203 | 0:3d9c67d97d6f | 5 | * $Revision: V1.4.3 |
emh203 | 0:3d9c67d97d6f | 6 | * |
emh203 | 0:3d9c67d97d6f | 7 | * Project: CMSIS DSP Library |
emh203 | 0:3d9c67d97d6f | 8 | * Title: arm_fir_lattice_q15.c |
emh203 | 0:3d9c67d97d6f | 9 | * |
emh203 | 0:3d9c67d97d6f | 10 | * Description: Q15 FIR lattice filter processing function. |
emh203 | 0:3d9c67d97d6f | 11 | * |
emh203 | 0:3d9c67d97d6f | 12 | * Target Processor: Cortex-M4/Cortex-M3/Cortex-M0 |
emh203 | 0:3d9c67d97d6f | 13 | * |
emh203 | 0:3d9c67d97d6f | 14 | * Redistribution and use in source and binary forms, with or without |
emh203 | 0:3d9c67d97d6f | 15 | * modification, are permitted provided that the following conditions |
emh203 | 0:3d9c67d97d6f | 16 | * are met: |
emh203 | 0:3d9c67d97d6f | 17 | * - Redistributions of source code must retain the above copyright |
emh203 | 0:3d9c67d97d6f | 18 | * notice, this list of conditions and the following disclaimer. |
emh203 | 0:3d9c67d97d6f | 19 | * - Redistributions in binary form must reproduce the above copyright |
emh203 | 0:3d9c67d97d6f | 20 | * notice, this list of conditions and the following disclaimer in |
emh203 | 0:3d9c67d97d6f | 21 | * the documentation and/or other materials provided with the |
emh203 | 0:3d9c67d97d6f | 22 | * distribution. |
emh203 | 0:3d9c67d97d6f | 23 | * - Neither the name of ARM LIMITED nor the names of its contributors |
emh203 | 0:3d9c67d97d6f | 24 | * may be used to endorse or promote products derived from this |
emh203 | 0:3d9c67d97d6f | 25 | * software without specific prior written permission. |
emh203 | 0:3d9c67d97d6f | 26 | * |
emh203 | 0:3d9c67d97d6f | 27 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
emh203 | 0:3d9c67d97d6f | 28 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
emh203 | 0:3d9c67d97d6f | 29 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
emh203 | 0:3d9c67d97d6f | 30 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
emh203 | 0:3d9c67d97d6f | 31 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
emh203 | 0:3d9c67d97d6f | 32 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
emh203 | 0:3d9c67d97d6f | 33 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
emh203 | 0:3d9c67d97d6f | 34 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
emh203 | 0:3d9c67d97d6f | 35 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
emh203 | 0:3d9c67d97d6f | 36 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
emh203 | 0:3d9c67d97d6f | 37 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
emh203 | 0:3d9c67d97d6f | 38 | * POSSIBILITY OF SUCH DAMAGE. |
emh203 | 0:3d9c67d97d6f | 39 | * -------------------------------------------------------------------- */ |
emh203 | 0:3d9c67d97d6f | 40 | |
emh203 | 0:3d9c67d97d6f | 41 | #include "arm_math.h" |
emh203 | 0:3d9c67d97d6f | 42 | |
emh203 | 0:3d9c67d97d6f | 43 | /** |
emh203 | 0:3d9c67d97d6f | 44 | * @ingroup groupFilters |
emh203 | 0:3d9c67d97d6f | 45 | */ |
emh203 | 0:3d9c67d97d6f | 46 | |
emh203 | 0:3d9c67d97d6f | 47 | /** |
emh203 | 0:3d9c67d97d6f | 48 | * @addtogroup FIR_Lattice |
emh203 | 0:3d9c67d97d6f | 49 | * @{ |
emh203 | 0:3d9c67d97d6f | 50 | */ |
emh203 | 0:3d9c67d97d6f | 51 | |
emh203 | 0:3d9c67d97d6f | 52 | |
emh203 | 0:3d9c67d97d6f | 53 | /** |
emh203 | 0:3d9c67d97d6f | 54 | * @brief Processing function for the Q15 FIR lattice filter. |
emh203 | 0:3d9c67d97d6f | 55 | * @param[in] *S points to an instance of the Q15 FIR lattice structure. |
emh203 | 0:3d9c67d97d6f | 56 | * @param[in] *pSrc points to the block of input data. |
emh203 | 0:3d9c67d97d6f | 57 | * @param[out] *pDst points to the block of output data |
emh203 | 0:3d9c67d97d6f | 58 | * @param[in] blockSize number of samples to process. |
emh203 | 0:3d9c67d97d6f | 59 | * @return none. |
emh203 | 0:3d9c67d97d6f | 60 | */ |
emh203 | 0:3d9c67d97d6f | 61 | |
emh203 | 0:3d9c67d97d6f | 62 | void arm_fir_lattice_q15( |
emh203 | 0:3d9c67d97d6f | 63 | const arm_fir_lattice_instance_q15 * S, |
emh203 | 0:3d9c67d97d6f | 64 | q15_t * pSrc, |
emh203 | 0:3d9c67d97d6f | 65 | q15_t * pDst, |
emh203 | 0:3d9c67d97d6f | 66 | uint32_t blockSize) |
emh203 | 0:3d9c67d97d6f | 67 | { |
emh203 | 0:3d9c67d97d6f | 68 | q15_t *pState; /* State pointer */ |
emh203 | 0:3d9c67d97d6f | 69 | q15_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ |
emh203 | 0:3d9c67d97d6f | 70 | q15_t *px; /* temporary state pointer */ |
emh203 | 0:3d9c67d97d6f | 71 | q15_t *pk; /* temporary coefficient pointer */ |
emh203 | 0:3d9c67d97d6f | 72 | |
emh203 | 0:3d9c67d97d6f | 73 | |
emh203 | 0:3d9c67d97d6f | 74 | #ifndef ARM_MATH_CM0_FAMILY |
emh203 | 0:3d9c67d97d6f | 75 | |
emh203 | 0:3d9c67d97d6f | 76 | /* Run the below code for Cortex-M4 and Cortex-M3 */ |
emh203 | 0:3d9c67d97d6f | 77 | |
emh203 | 0:3d9c67d97d6f | 78 | q31_t fcurnt1, fnext1, gcurnt1 = 0, gnext1; /* temporary variables for first sample in loop unrolling */ |
emh203 | 0:3d9c67d97d6f | 79 | q31_t fcurnt2, fnext2, gnext2; /* temporary variables for second sample in loop unrolling */ |
emh203 | 0:3d9c67d97d6f | 80 | q31_t fcurnt3, fnext3, gnext3; /* temporary variables for third sample in loop unrolling */ |
emh203 | 0:3d9c67d97d6f | 81 | q31_t fcurnt4, fnext4, gnext4; /* temporary variables for fourth sample in loop unrolling */ |
emh203 | 0:3d9c67d97d6f | 82 | uint32_t numStages = S->numStages; /* Number of stages in the filter */ |
emh203 | 0:3d9c67d97d6f | 83 | uint32_t blkCnt, stageCnt; /* temporary variables for counts */ |
emh203 | 0:3d9c67d97d6f | 84 | |
emh203 | 0:3d9c67d97d6f | 85 | pState = &S->pState[0]; |
emh203 | 0:3d9c67d97d6f | 86 | |
emh203 | 0:3d9c67d97d6f | 87 | blkCnt = blockSize >> 2u; |
emh203 | 0:3d9c67d97d6f | 88 | |
emh203 | 0:3d9c67d97d6f | 89 | /* First part of the processing with loop unrolling. Compute 4 outputs at a time. |
emh203 | 0:3d9c67d97d6f | 90 | ** a second loop below computes the remaining 1 to 3 samples. */ |
emh203 | 0:3d9c67d97d6f | 91 | while(blkCnt > 0u) |
emh203 | 0:3d9c67d97d6f | 92 | { |
emh203 | 0:3d9c67d97d6f | 93 | |
emh203 | 0:3d9c67d97d6f | 94 | /* Read two samples from input buffer */ |
emh203 | 0:3d9c67d97d6f | 95 | /* f0(n) = x(n) */ |
emh203 | 0:3d9c67d97d6f | 96 | fcurnt1 = *pSrc++; |
emh203 | 0:3d9c67d97d6f | 97 | fcurnt2 = *pSrc++; |
emh203 | 0:3d9c67d97d6f | 98 | |
emh203 | 0:3d9c67d97d6f | 99 | /* Initialize coeff pointer */ |
emh203 | 0:3d9c67d97d6f | 100 | pk = (pCoeffs); |
emh203 | 0:3d9c67d97d6f | 101 | |
emh203 | 0:3d9c67d97d6f | 102 | /* Initialize state pointer */ |
emh203 | 0:3d9c67d97d6f | 103 | px = pState; |
emh203 | 0:3d9c67d97d6f | 104 | |
emh203 | 0:3d9c67d97d6f | 105 | /* Read g0(n-1) from state */ |
emh203 | 0:3d9c67d97d6f | 106 | gcurnt1 = *px; |
emh203 | 0:3d9c67d97d6f | 107 | |
emh203 | 0:3d9c67d97d6f | 108 | /* Process first sample for first tap */ |
emh203 | 0:3d9c67d97d6f | 109 | /* f1(n) = f0(n) + K1 * g0(n-1) */ |
emh203 | 0:3d9c67d97d6f | 110 | fnext1 = (q31_t) ((gcurnt1 * (*pk)) >> 15u) + fcurnt1; |
emh203 | 0:3d9c67d97d6f | 111 | fnext1 = __SSAT(fnext1, 16); |
emh203 | 0:3d9c67d97d6f | 112 | |
emh203 | 0:3d9c67d97d6f | 113 | /* g1(n) = f0(n) * K1 + g0(n-1) */ |
emh203 | 0:3d9c67d97d6f | 114 | gnext1 = (q31_t) ((fcurnt1 * (*pk)) >> 15u) + gcurnt1; |
emh203 | 0:3d9c67d97d6f | 115 | gnext1 = __SSAT(gnext1, 16); |
emh203 | 0:3d9c67d97d6f | 116 | |
emh203 | 0:3d9c67d97d6f | 117 | /* Process second sample for first tap */ |
emh203 | 0:3d9c67d97d6f | 118 | /* for sample 2 processing */ |
emh203 | 0:3d9c67d97d6f | 119 | fnext2 = (q31_t) ((fcurnt1 * (*pk)) >> 15u) + fcurnt2; |
emh203 | 0:3d9c67d97d6f | 120 | fnext2 = __SSAT(fnext2, 16); |
emh203 | 0:3d9c67d97d6f | 121 | |
emh203 | 0:3d9c67d97d6f | 122 | gnext2 = (q31_t) ((fcurnt2 * (*pk)) >> 15u) + fcurnt1; |
emh203 | 0:3d9c67d97d6f | 123 | gnext2 = __SSAT(gnext2, 16); |
emh203 | 0:3d9c67d97d6f | 124 | |
emh203 | 0:3d9c67d97d6f | 125 | |
emh203 | 0:3d9c67d97d6f | 126 | /* Read next two samples from input buffer */ |
emh203 | 0:3d9c67d97d6f | 127 | /* f0(n+2) = x(n+2) */ |
emh203 | 0:3d9c67d97d6f | 128 | fcurnt3 = *pSrc++; |
emh203 | 0:3d9c67d97d6f | 129 | fcurnt4 = *pSrc++; |
emh203 | 0:3d9c67d97d6f | 130 | |
emh203 | 0:3d9c67d97d6f | 131 | /* Copy only last input samples into the state buffer |
emh203 | 0:3d9c67d97d6f | 132 | which is used for next four samples processing */ |
emh203 | 0:3d9c67d97d6f | 133 | *px++ = (q15_t) fcurnt4; |
emh203 | 0:3d9c67d97d6f | 134 | |
emh203 | 0:3d9c67d97d6f | 135 | /* Process third sample for first tap */ |
emh203 | 0:3d9c67d97d6f | 136 | fnext3 = (q31_t) ((fcurnt2 * (*pk)) >> 15u) + fcurnt3; |
emh203 | 0:3d9c67d97d6f | 137 | fnext3 = __SSAT(fnext3, 16); |
emh203 | 0:3d9c67d97d6f | 138 | gnext3 = (q31_t) ((fcurnt3 * (*pk)) >> 15u) + fcurnt2; |
emh203 | 0:3d9c67d97d6f | 139 | gnext3 = __SSAT(gnext3, 16); |
emh203 | 0:3d9c67d97d6f | 140 | |
emh203 | 0:3d9c67d97d6f | 141 | /* Process fourth sample for first tap */ |
emh203 | 0:3d9c67d97d6f | 142 | fnext4 = (q31_t) ((fcurnt3 * (*pk)) >> 15u) + fcurnt4; |
emh203 | 0:3d9c67d97d6f | 143 | fnext4 = __SSAT(fnext4, 16); |
emh203 | 0:3d9c67d97d6f | 144 | gnext4 = (q31_t) ((fcurnt4 * (*pk++)) >> 15u) + fcurnt3; |
emh203 | 0:3d9c67d97d6f | 145 | gnext4 = __SSAT(gnext4, 16); |
emh203 | 0:3d9c67d97d6f | 146 | |
emh203 | 0:3d9c67d97d6f | 147 | /* Update of f values for next coefficient set processing */ |
emh203 | 0:3d9c67d97d6f | 148 | fcurnt1 = fnext1; |
emh203 | 0:3d9c67d97d6f | 149 | fcurnt2 = fnext2; |
emh203 | 0:3d9c67d97d6f | 150 | fcurnt3 = fnext3; |
emh203 | 0:3d9c67d97d6f | 151 | fcurnt4 = fnext4; |
emh203 | 0:3d9c67d97d6f | 152 | |
emh203 | 0:3d9c67d97d6f | 153 | |
emh203 | 0:3d9c67d97d6f | 154 | /* Loop unrolling. Process 4 taps at a time . */ |
emh203 | 0:3d9c67d97d6f | 155 | stageCnt = (numStages - 1u) >> 2; |
emh203 | 0:3d9c67d97d6f | 156 | |
emh203 | 0:3d9c67d97d6f | 157 | |
emh203 | 0:3d9c67d97d6f | 158 | /* Loop over the number of taps. Unroll by a factor of 4. |
emh203 | 0:3d9c67d97d6f | 159 | ** Repeat until we've computed numStages-3 coefficients. */ |
emh203 | 0:3d9c67d97d6f | 160 | |
emh203 | 0:3d9c67d97d6f | 161 | /* Process 2nd, 3rd, 4th and 5th taps ... here */ |
emh203 | 0:3d9c67d97d6f | 162 | while(stageCnt > 0u) |
emh203 | 0:3d9c67d97d6f | 163 | { |
emh203 | 0:3d9c67d97d6f | 164 | /* Read g1(n-1), g3(n-1) .... from state */ |
emh203 | 0:3d9c67d97d6f | 165 | gcurnt1 = *px; |
emh203 | 0:3d9c67d97d6f | 166 | |
emh203 | 0:3d9c67d97d6f | 167 | /* save g1(n) in state buffer */ |
emh203 | 0:3d9c67d97d6f | 168 | *px++ = (q15_t) gnext4; |
emh203 | 0:3d9c67d97d6f | 169 | |
emh203 | 0:3d9c67d97d6f | 170 | /* Process first sample for 2nd, 6th .. tap */ |
emh203 | 0:3d9c67d97d6f | 171 | /* Sample processing for K2, K6.... */ |
emh203 | 0:3d9c67d97d6f | 172 | /* f1(n) = f0(n) + K1 * g0(n-1) */ |
emh203 | 0:3d9c67d97d6f | 173 | fnext1 = (q31_t) ((gcurnt1 * (*pk)) >> 15u) + fcurnt1; |
emh203 | 0:3d9c67d97d6f | 174 | fnext1 = __SSAT(fnext1, 16); |
emh203 | 0:3d9c67d97d6f | 175 | |
emh203 | 0:3d9c67d97d6f | 176 | |
emh203 | 0:3d9c67d97d6f | 177 | /* Process second sample for 2nd, 6th .. tap */ |
emh203 | 0:3d9c67d97d6f | 178 | /* for sample 2 processing */ |
emh203 | 0:3d9c67d97d6f | 179 | fnext2 = (q31_t) ((gnext1 * (*pk)) >> 15u) + fcurnt2; |
emh203 | 0:3d9c67d97d6f | 180 | fnext2 = __SSAT(fnext2, 16); |
emh203 | 0:3d9c67d97d6f | 181 | /* Process third sample for 2nd, 6th .. tap */ |
emh203 | 0:3d9c67d97d6f | 182 | fnext3 = (q31_t) ((gnext2 * (*pk)) >> 15u) + fcurnt3; |
emh203 | 0:3d9c67d97d6f | 183 | fnext3 = __SSAT(fnext3, 16); |
emh203 | 0:3d9c67d97d6f | 184 | /* Process fourth sample for 2nd, 6th .. tap */ |
emh203 | 0:3d9c67d97d6f | 185 | /* fnext4 = fcurnt4 + (*pk) * gnext3; */ |
emh203 | 0:3d9c67d97d6f | 186 | fnext4 = (q31_t) ((gnext3 * (*pk)) >> 15u) + fcurnt4; |
emh203 | 0:3d9c67d97d6f | 187 | fnext4 = __SSAT(fnext4, 16); |
emh203 | 0:3d9c67d97d6f | 188 | |
emh203 | 0:3d9c67d97d6f | 189 | /* g1(n) = f0(n) * K1 + g0(n-1) */ |
emh203 | 0:3d9c67d97d6f | 190 | /* Calculation of state values for next stage */ |
emh203 | 0:3d9c67d97d6f | 191 | gnext4 = (q31_t) ((fcurnt4 * (*pk)) >> 15u) + gnext3; |
emh203 | 0:3d9c67d97d6f | 192 | gnext4 = __SSAT(gnext4, 16); |
emh203 | 0:3d9c67d97d6f | 193 | gnext3 = (q31_t) ((fcurnt3 * (*pk)) >> 15u) + gnext2; |
emh203 | 0:3d9c67d97d6f | 194 | gnext3 = __SSAT(gnext3, 16); |
emh203 | 0:3d9c67d97d6f | 195 | |
emh203 | 0:3d9c67d97d6f | 196 | gnext2 = (q31_t) ((fcurnt2 * (*pk)) >> 15u) + gnext1; |
emh203 | 0:3d9c67d97d6f | 197 | gnext2 = __SSAT(gnext2, 16); |
emh203 | 0:3d9c67d97d6f | 198 | |
emh203 | 0:3d9c67d97d6f | 199 | gnext1 = (q31_t) ((fcurnt1 * (*pk++)) >> 15u) + gcurnt1; |
emh203 | 0:3d9c67d97d6f | 200 | gnext1 = __SSAT(gnext1, 16); |
emh203 | 0:3d9c67d97d6f | 201 | |
emh203 | 0:3d9c67d97d6f | 202 | |
emh203 | 0:3d9c67d97d6f | 203 | /* Read g2(n-1), g4(n-1) .... from state */ |
emh203 | 0:3d9c67d97d6f | 204 | gcurnt1 = *px; |
emh203 | 0:3d9c67d97d6f | 205 | |
emh203 | 0:3d9c67d97d6f | 206 | /* save g1(n) in state buffer */ |
emh203 | 0:3d9c67d97d6f | 207 | *px++ = (q15_t) gnext4; |
emh203 | 0:3d9c67d97d6f | 208 | |
emh203 | 0:3d9c67d97d6f | 209 | /* Sample processing for K3, K7.... */ |
emh203 | 0:3d9c67d97d6f | 210 | /* Process first sample for 3rd, 7th .. tap */ |
emh203 | 0:3d9c67d97d6f | 211 | /* f3(n) = f2(n) + K3 * g2(n-1) */ |
emh203 | 0:3d9c67d97d6f | 212 | fcurnt1 = (q31_t) ((gcurnt1 * (*pk)) >> 15u) + fnext1; |
emh203 | 0:3d9c67d97d6f | 213 | fcurnt1 = __SSAT(fcurnt1, 16); |
emh203 | 0:3d9c67d97d6f | 214 | |
emh203 | 0:3d9c67d97d6f | 215 | /* Process second sample for 3rd, 7th .. tap */ |
emh203 | 0:3d9c67d97d6f | 216 | fcurnt2 = (q31_t) ((gnext1 * (*pk)) >> 15u) + fnext2; |
emh203 | 0:3d9c67d97d6f | 217 | fcurnt2 = __SSAT(fcurnt2, 16); |
emh203 | 0:3d9c67d97d6f | 218 | |
emh203 | 0:3d9c67d97d6f | 219 | /* Process third sample for 3rd, 7th .. tap */ |
emh203 | 0:3d9c67d97d6f | 220 | fcurnt3 = (q31_t) ((gnext2 * (*pk)) >> 15u) + fnext3; |
emh203 | 0:3d9c67d97d6f | 221 | fcurnt3 = __SSAT(fcurnt3, 16); |
emh203 | 0:3d9c67d97d6f | 222 | |
emh203 | 0:3d9c67d97d6f | 223 | /* Process fourth sample for 3rd, 7th .. tap */ |
emh203 | 0:3d9c67d97d6f | 224 | fcurnt4 = (q31_t) ((gnext3 * (*pk)) >> 15u) + fnext4; |
emh203 | 0:3d9c67d97d6f | 225 | fcurnt4 = __SSAT(fcurnt4, 16); |
emh203 | 0:3d9c67d97d6f | 226 | |
emh203 | 0:3d9c67d97d6f | 227 | /* Calculation of state values for next stage */ |
emh203 | 0:3d9c67d97d6f | 228 | /* g3(n) = f2(n) * K3 + g2(n-1) */ |
emh203 | 0:3d9c67d97d6f | 229 | gnext4 = (q31_t) ((fnext4 * (*pk)) >> 15u) + gnext3; |
emh203 | 0:3d9c67d97d6f | 230 | gnext4 = __SSAT(gnext4, 16); |
emh203 | 0:3d9c67d97d6f | 231 | |
emh203 | 0:3d9c67d97d6f | 232 | gnext3 = (q31_t) ((fnext3 * (*pk)) >> 15u) + gnext2; |
emh203 | 0:3d9c67d97d6f | 233 | gnext3 = __SSAT(gnext3, 16); |
emh203 | 0:3d9c67d97d6f | 234 | |
emh203 | 0:3d9c67d97d6f | 235 | gnext2 = (q31_t) ((fnext2 * (*pk)) >> 15u) + gnext1; |
emh203 | 0:3d9c67d97d6f | 236 | gnext2 = __SSAT(gnext2, 16); |
emh203 | 0:3d9c67d97d6f | 237 | |
emh203 | 0:3d9c67d97d6f | 238 | gnext1 = (q31_t) ((fnext1 * (*pk++)) >> 15u) + gcurnt1; |
emh203 | 0:3d9c67d97d6f | 239 | gnext1 = __SSAT(gnext1, 16); |
emh203 | 0:3d9c67d97d6f | 240 | |
emh203 | 0:3d9c67d97d6f | 241 | /* Read g1(n-1), g3(n-1) .... from state */ |
emh203 | 0:3d9c67d97d6f | 242 | gcurnt1 = *px; |
emh203 | 0:3d9c67d97d6f | 243 | |
emh203 | 0:3d9c67d97d6f | 244 | /* save g1(n) in state buffer */ |
emh203 | 0:3d9c67d97d6f | 245 | *px++ = (q15_t) gnext4; |
emh203 | 0:3d9c67d97d6f | 246 | |
emh203 | 0:3d9c67d97d6f | 247 | /* Sample processing for K4, K8.... */ |
emh203 | 0:3d9c67d97d6f | 248 | /* Process first sample for 4th, 8th .. tap */ |
emh203 | 0:3d9c67d97d6f | 249 | /* f4(n) = f3(n) + K4 * g3(n-1) */ |
emh203 | 0:3d9c67d97d6f | 250 | fnext1 = (q31_t) ((gcurnt1 * (*pk)) >> 15u) + fcurnt1; |
emh203 | 0:3d9c67d97d6f | 251 | fnext1 = __SSAT(fnext1, 16); |
emh203 | 0:3d9c67d97d6f | 252 | |
emh203 | 0:3d9c67d97d6f | 253 | /* Process second sample for 4th, 8th .. tap */ |
emh203 | 0:3d9c67d97d6f | 254 | /* for sample 2 processing */ |
emh203 | 0:3d9c67d97d6f | 255 | fnext2 = (q31_t) ((gnext1 * (*pk)) >> 15u) + fcurnt2; |
emh203 | 0:3d9c67d97d6f | 256 | fnext2 = __SSAT(fnext2, 16); |
emh203 | 0:3d9c67d97d6f | 257 | |
emh203 | 0:3d9c67d97d6f | 258 | /* Process third sample for 4th, 8th .. tap */ |
emh203 | 0:3d9c67d97d6f | 259 | fnext3 = (q31_t) ((gnext2 * (*pk)) >> 15u) + fcurnt3; |
emh203 | 0:3d9c67d97d6f | 260 | fnext3 = __SSAT(fnext3, 16); |
emh203 | 0:3d9c67d97d6f | 261 | |
emh203 | 0:3d9c67d97d6f | 262 | /* Process fourth sample for 4th, 8th .. tap */ |
emh203 | 0:3d9c67d97d6f | 263 | fnext4 = (q31_t) ((gnext3 * (*pk)) >> 15u) + fcurnt4; |
emh203 | 0:3d9c67d97d6f | 264 | fnext4 = __SSAT(fnext4, 16); |
emh203 | 0:3d9c67d97d6f | 265 | |
emh203 | 0:3d9c67d97d6f | 266 | /* g4(n) = f3(n) * K4 + g3(n-1) */ |
emh203 | 0:3d9c67d97d6f | 267 | /* Calculation of state values for next stage */ |
emh203 | 0:3d9c67d97d6f | 268 | gnext4 = (q31_t) ((fcurnt4 * (*pk)) >> 15u) + gnext3; |
emh203 | 0:3d9c67d97d6f | 269 | gnext4 = __SSAT(gnext4, 16); |
emh203 | 0:3d9c67d97d6f | 270 | |
emh203 | 0:3d9c67d97d6f | 271 | gnext3 = (q31_t) ((fcurnt3 * (*pk)) >> 15u) + gnext2; |
emh203 | 0:3d9c67d97d6f | 272 | gnext3 = __SSAT(gnext3, 16); |
emh203 | 0:3d9c67d97d6f | 273 | |
emh203 | 0:3d9c67d97d6f | 274 | gnext2 = (q31_t) ((fcurnt2 * (*pk)) >> 15u) + gnext1; |
emh203 | 0:3d9c67d97d6f | 275 | gnext2 = __SSAT(gnext2, 16); |
emh203 | 0:3d9c67d97d6f | 276 | gnext1 = (q31_t) ((fcurnt1 * (*pk++)) >> 15u) + gcurnt1; |
emh203 | 0:3d9c67d97d6f | 277 | gnext1 = __SSAT(gnext1, 16); |
emh203 | 0:3d9c67d97d6f | 278 | |
emh203 | 0:3d9c67d97d6f | 279 | |
emh203 | 0:3d9c67d97d6f | 280 | /* Read g2(n-1), g4(n-1) .... from state */ |
emh203 | 0:3d9c67d97d6f | 281 | gcurnt1 = *px; |
emh203 | 0:3d9c67d97d6f | 282 | |
emh203 | 0:3d9c67d97d6f | 283 | /* save g4(n) in state buffer */ |
emh203 | 0:3d9c67d97d6f | 284 | *px++ = (q15_t) gnext4; |
emh203 | 0:3d9c67d97d6f | 285 | |
emh203 | 0:3d9c67d97d6f | 286 | /* Sample processing for K5, K9.... */ |
emh203 | 0:3d9c67d97d6f | 287 | /* Process first sample for 5th, 9th .. tap */ |
emh203 | 0:3d9c67d97d6f | 288 | /* f5(n) = f4(n) + K5 * g4(n-1) */ |
emh203 | 0:3d9c67d97d6f | 289 | fcurnt1 = (q31_t) ((gcurnt1 * (*pk)) >> 15u) + fnext1; |
emh203 | 0:3d9c67d97d6f | 290 | fcurnt1 = __SSAT(fcurnt1, 16); |
emh203 | 0:3d9c67d97d6f | 291 | |
emh203 | 0:3d9c67d97d6f | 292 | /* Process second sample for 5th, 9th .. tap */ |
emh203 | 0:3d9c67d97d6f | 293 | fcurnt2 = (q31_t) ((gnext1 * (*pk)) >> 15u) + fnext2; |
emh203 | 0:3d9c67d97d6f | 294 | fcurnt2 = __SSAT(fcurnt2, 16); |
emh203 | 0:3d9c67d97d6f | 295 | |
emh203 | 0:3d9c67d97d6f | 296 | /* Process third sample for 5th, 9th .. tap */ |
emh203 | 0:3d9c67d97d6f | 297 | fcurnt3 = (q31_t) ((gnext2 * (*pk)) >> 15u) + fnext3; |
emh203 | 0:3d9c67d97d6f | 298 | fcurnt3 = __SSAT(fcurnt3, 16); |
emh203 | 0:3d9c67d97d6f | 299 | |
emh203 | 0:3d9c67d97d6f | 300 | /* Process fourth sample for 5th, 9th .. tap */ |
emh203 | 0:3d9c67d97d6f | 301 | fcurnt4 = (q31_t) ((gnext3 * (*pk)) >> 15u) + fnext4; |
emh203 | 0:3d9c67d97d6f | 302 | fcurnt4 = __SSAT(fcurnt4, 16); |
emh203 | 0:3d9c67d97d6f | 303 | |
emh203 | 0:3d9c67d97d6f | 304 | /* Calculation of state values for next stage */ |
emh203 | 0:3d9c67d97d6f | 305 | /* g5(n) = f4(n) * K5 + g4(n-1) */ |
emh203 | 0:3d9c67d97d6f | 306 | gnext4 = (q31_t) ((fnext4 * (*pk)) >> 15u) + gnext3; |
emh203 | 0:3d9c67d97d6f | 307 | gnext4 = __SSAT(gnext4, 16); |
emh203 | 0:3d9c67d97d6f | 308 | gnext3 = (q31_t) ((fnext3 * (*pk)) >> 15u) + gnext2; |
emh203 | 0:3d9c67d97d6f | 309 | gnext3 = __SSAT(gnext3, 16); |
emh203 | 0:3d9c67d97d6f | 310 | gnext2 = (q31_t) ((fnext2 * (*pk)) >> 15u) + gnext1; |
emh203 | 0:3d9c67d97d6f | 311 | gnext2 = __SSAT(gnext2, 16); |
emh203 | 0:3d9c67d97d6f | 312 | gnext1 = (q31_t) ((fnext1 * (*pk++)) >> 15u) + gcurnt1; |
emh203 | 0:3d9c67d97d6f | 313 | gnext1 = __SSAT(gnext1, 16); |
emh203 | 0:3d9c67d97d6f | 314 | |
emh203 | 0:3d9c67d97d6f | 315 | stageCnt--; |
emh203 | 0:3d9c67d97d6f | 316 | } |
emh203 | 0:3d9c67d97d6f | 317 | |
emh203 | 0:3d9c67d97d6f | 318 | /* If the (filter length -1) is not a multiple of 4, compute the remaining filter taps */ |
emh203 | 0:3d9c67d97d6f | 319 | stageCnt = (numStages - 1u) % 0x4u; |
emh203 | 0:3d9c67d97d6f | 320 | |
emh203 | 0:3d9c67d97d6f | 321 | while(stageCnt > 0u) |
emh203 | 0:3d9c67d97d6f | 322 | { |
emh203 | 0:3d9c67d97d6f | 323 | gcurnt1 = *px; |
emh203 | 0:3d9c67d97d6f | 324 | |
emh203 | 0:3d9c67d97d6f | 325 | /* save g value in state buffer */ |
emh203 | 0:3d9c67d97d6f | 326 | *px++ = (q15_t) gnext4; |
emh203 | 0:3d9c67d97d6f | 327 | |
emh203 | 0:3d9c67d97d6f | 328 | /* Process four samples for last three taps here */ |
emh203 | 0:3d9c67d97d6f | 329 | fnext1 = (q31_t) ((gcurnt1 * (*pk)) >> 15u) + fcurnt1; |
emh203 | 0:3d9c67d97d6f | 330 | fnext1 = __SSAT(fnext1, 16); |
emh203 | 0:3d9c67d97d6f | 331 | fnext2 = (q31_t) ((gnext1 * (*pk)) >> 15u) + fcurnt2; |
emh203 | 0:3d9c67d97d6f | 332 | fnext2 = __SSAT(fnext2, 16); |
emh203 | 0:3d9c67d97d6f | 333 | |
emh203 | 0:3d9c67d97d6f | 334 | fnext3 = (q31_t) ((gnext2 * (*pk)) >> 15u) + fcurnt3; |
emh203 | 0:3d9c67d97d6f | 335 | fnext3 = __SSAT(fnext3, 16); |
emh203 | 0:3d9c67d97d6f | 336 | |
emh203 | 0:3d9c67d97d6f | 337 | fnext4 = (q31_t) ((gnext3 * (*pk)) >> 15u) + fcurnt4; |
emh203 | 0:3d9c67d97d6f | 338 | fnext4 = __SSAT(fnext4, 16); |
emh203 | 0:3d9c67d97d6f | 339 | |
emh203 | 0:3d9c67d97d6f | 340 | /* g1(n) = f0(n) * K1 + g0(n-1) */ |
emh203 | 0:3d9c67d97d6f | 341 | gnext4 = (q31_t) ((fcurnt4 * (*pk)) >> 15u) + gnext3; |
emh203 | 0:3d9c67d97d6f | 342 | gnext4 = __SSAT(gnext4, 16); |
emh203 | 0:3d9c67d97d6f | 343 | gnext3 = (q31_t) ((fcurnt3 * (*pk)) >> 15u) + gnext2; |
emh203 | 0:3d9c67d97d6f | 344 | gnext3 = __SSAT(gnext3, 16); |
emh203 | 0:3d9c67d97d6f | 345 | gnext2 = (q31_t) ((fcurnt2 * (*pk)) >> 15u) + gnext1; |
emh203 | 0:3d9c67d97d6f | 346 | gnext2 = __SSAT(gnext2, 16); |
emh203 | 0:3d9c67d97d6f | 347 | gnext1 = (q31_t) ((fcurnt1 * (*pk++)) >> 15u) + gcurnt1; |
emh203 | 0:3d9c67d97d6f | 348 | gnext1 = __SSAT(gnext1, 16); |
emh203 | 0:3d9c67d97d6f | 349 | |
emh203 | 0:3d9c67d97d6f | 350 | /* Update of f values for next coefficient set processing */ |
emh203 | 0:3d9c67d97d6f | 351 | fcurnt1 = fnext1; |
emh203 | 0:3d9c67d97d6f | 352 | fcurnt2 = fnext2; |
emh203 | 0:3d9c67d97d6f | 353 | fcurnt3 = fnext3; |
emh203 | 0:3d9c67d97d6f | 354 | fcurnt4 = fnext4; |
emh203 | 0:3d9c67d97d6f | 355 | |
emh203 | 0:3d9c67d97d6f | 356 | stageCnt--; |
emh203 | 0:3d9c67d97d6f | 357 | |
emh203 | 0:3d9c67d97d6f | 358 | } |
emh203 | 0:3d9c67d97d6f | 359 | |
emh203 | 0:3d9c67d97d6f | 360 | /* The results in the 4 accumulators, store in the destination buffer. */ |
emh203 | 0:3d9c67d97d6f | 361 | /* y(n) = fN(n) */ |
emh203 | 0:3d9c67d97d6f | 362 | |
emh203 | 0:3d9c67d97d6f | 363 | #ifndef ARM_MATH_BIG_ENDIAN |
emh203 | 0:3d9c67d97d6f | 364 | |
emh203 | 0:3d9c67d97d6f | 365 | *__SIMD32(pDst)++ = __PKHBT(fcurnt1, fcurnt2, 16); |
emh203 | 0:3d9c67d97d6f | 366 | *__SIMD32(pDst)++ = __PKHBT(fcurnt3, fcurnt4, 16); |
emh203 | 0:3d9c67d97d6f | 367 | |
emh203 | 0:3d9c67d97d6f | 368 | #else |
emh203 | 0:3d9c67d97d6f | 369 | |
emh203 | 0:3d9c67d97d6f | 370 | *__SIMD32(pDst)++ = __PKHBT(fcurnt2, fcurnt1, 16); |
emh203 | 0:3d9c67d97d6f | 371 | *__SIMD32(pDst)++ = __PKHBT(fcurnt4, fcurnt3, 16); |
emh203 | 0:3d9c67d97d6f | 372 | |
emh203 | 0:3d9c67d97d6f | 373 | #endif /* #ifndef ARM_MATH_BIG_ENDIAN */ |
emh203 | 0:3d9c67d97d6f | 374 | |
emh203 | 0:3d9c67d97d6f | 375 | blkCnt--; |
emh203 | 0:3d9c67d97d6f | 376 | } |
emh203 | 0:3d9c67d97d6f | 377 | |
emh203 | 0:3d9c67d97d6f | 378 | /* If the blockSize is not a multiple of 4, compute any remaining output samples here. |
emh203 | 0:3d9c67d97d6f | 379 | ** No loop unrolling is used. */ |
emh203 | 0:3d9c67d97d6f | 380 | blkCnt = blockSize % 0x4u; |
emh203 | 0:3d9c67d97d6f | 381 | |
emh203 | 0:3d9c67d97d6f | 382 | while(blkCnt > 0u) |
emh203 | 0:3d9c67d97d6f | 383 | { |
emh203 | 0:3d9c67d97d6f | 384 | /* f0(n) = x(n) */ |
emh203 | 0:3d9c67d97d6f | 385 | fcurnt1 = *pSrc++; |
emh203 | 0:3d9c67d97d6f | 386 | |
emh203 | 0:3d9c67d97d6f | 387 | /* Initialize coeff pointer */ |
emh203 | 0:3d9c67d97d6f | 388 | pk = (pCoeffs); |
emh203 | 0:3d9c67d97d6f | 389 | |
emh203 | 0:3d9c67d97d6f | 390 | /* Initialize state pointer */ |
emh203 | 0:3d9c67d97d6f | 391 | px = pState; |
emh203 | 0:3d9c67d97d6f | 392 | |
emh203 | 0:3d9c67d97d6f | 393 | /* read g2(n) from state buffer */ |
emh203 | 0:3d9c67d97d6f | 394 | gcurnt1 = *px; |
emh203 | 0:3d9c67d97d6f | 395 | |
emh203 | 0:3d9c67d97d6f | 396 | /* for sample 1 processing */ |
emh203 | 0:3d9c67d97d6f | 397 | /* f1(n) = f0(n) + K1 * g0(n-1) */ |
emh203 | 0:3d9c67d97d6f | 398 | fnext1 = (((q31_t) gcurnt1 * (*pk)) >> 15u) + fcurnt1; |
emh203 | 0:3d9c67d97d6f | 399 | fnext1 = __SSAT(fnext1, 16); |
emh203 | 0:3d9c67d97d6f | 400 | |
emh203 | 0:3d9c67d97d6f | 401 | |
emh203 | 0:3d9c67d97d6f | 402 | /* g1(n) = f0(n) * K1 + g0(n-1) */ |
emh203 | 0:3d9c67d97d6f | 403 | gnext1 = (((q31_t) fcurnt1 * (*pk++)) >> 15u) + gcurnt1; |
emh203 | 0:3d9c67d97d6f | 404 | gnext1 = __SSAT(gnext1, 16); |
emh203 | 0:3d9c67d97d6f | 405 | |
emh203 | 0:3d9c67d97d6f | 406 | /* save g1(n) in state buffer */ |
emh203 | 0:3d9c67d97d6f | 407 | *px++ = (q15_t) fcurnt1; |
emh203 | 0:3d9c67d97d6f | 408 | |
emh203 | 0:3d9c67d97d6f | 409 | /* f1(n) is saved in fcurnt1 |
emh203 | 0:3d9c67d97d6f | 410 | for next stage processing */ |
emh203 | 0:3d9c67d97d6f | 411 | fcurnt1 = fnext1; |
emh203 | 0:3d9c67d97d6f | 412 | |
emh203 | 0:3d9c67d97d6f | 413 | stageCnt = (numStages - 1u); |
emh203 | 0:3d9c67d97d6f | 414 | |
emh203 | 0:3d9c67d97d6f | 415 | /* stage loop */ |
emh203 | 0:3d9c67d97d6f | 416 | while(stageCnt > 0u) |
emh203 | 0:3d9c67d97d6f | 417 | { |
emh203 | 0:3d9c67d97d6f | 418 | /* read g2(n) from state buffer */ |
emh203 | 0:3d9c67d97d6f | 419 | gcurnt1 = *px; |
emh203 | 0:3d9c67d97d6f | 420 | |
emh203 | 0:3d9c67d97d6f | 421 | /* save g1(n) in state buffer */ |
emh203 | 0:3d9c67d97d6f | 422 | *px++ = (q15_t) gnext1; |
emh203 | 0:3d9c67d97d6f | 423 | |
emh203 | 0:3d9c67d97d6f | 424 | /* Sample processing for K2, K3.... */ |
emh203 | 0:3d9c67d97d6f | 425 | /* f2(n) = f1(n) + K2 * g1(n-1) */ |
emh203 | 0:3d9c67d97d6f | 426 | fnext1 = (((q31_t) gcurnt1 * (*pk)) >> 15u) + fcurnt1; |
emh203 | 0:3d9c67d97d6f | 427 | fnext1 = __SSAT(fnext1, 16); |
emh203 | 0:3d9c67d97d6f | 428 | |
emh203 | 0:3d9c67d97d6f | 429 | /* g2(n) = f1(n) * K2 + g1(n-1) */ |
emh203 | 0:3d9c67d97d6f | 430 | gnext1 = (((q31_t) fcurnt1 * (*pk++)) >> 15u) + gcurnt1; |
emh203 | 0:3d9c67d97d6f | 431 | gnext1 = __SSAT(gnext1, 16); |
emh203 | 0:3d9c67d97d6f | 432 | |
emh203 | 0:3d9c67d97d6f | 433 | |
emh203 | 0:3d9c67d97d6f | 434 | /* f1(n) is saved in fcurnt1 |
emh203 | 0:3d9c67d97d6f | 435 | for next stage processing */ |
emh203 | 0:3d9c67d97d6f | 436 | fcurnt1 = fnext1; |
emh203 | 0:3d9c67d97d6f | 437 | |
emh203 | 0:3d9c67d97d6f | 438 | stageCnt--; |
emh203 | 0:3d9c67d97d6f | 439 | |
emh203 | 0:3d9c67d97d6f | 440 | } |
emh203 | 0:3d9c67d97d6f | 441 | |
emh203 | 0:3d9c67d97d6f | 442 | /* y(n) = fN(n) */ |
emh203 | 0:3d9c67d97d6f | 443 | *pDst++ = __SSAT(fcurnt1, 16); |
emh203 | 0:3d9c67d97d6f | 444 | |
emh203 | 0:3d9c67d97d6f | 445 | |
emh203 | 0:3d9c67d97d6f | 446 | blkCnt--; |
emh203 | 0:3d9c67d97d6f | 447 | |
emh203 | 0:3d9c67d97d6f | 448 | } |
emh203 | 0:3d9c67d97d6f | 449 | |
emh203 | 0:3d9c67d97d6f | 450 | #else |
emh203 | 0:3d9c67d97d6f | 451 | |
emh203 | 0:3d9c67d97d6f | 452 | /* Run the below code for Cortex-M0 */ |
emh203 | 0:3d9c67d97d6f | 453 | |
emh203 | 0:3d9c67d97d6f | 454 | q31_t fcurnt, fnext, gcurnt, gnext; /* temporary variables */ |
emh203 | 0:3d9c67d97d6f | 455 | uint32_t numStages = S->numStages; /* Length of the filter */ |
emh203 | 0:3d9c67d97d6f | 456 | uint32_t blkCnt, stageCnt; /* temporary variables for counts */ |
emh203 | 0:3d9c67d97d6f | 457 | |
emh203 | 0:3d9c67d97d6f | 458 | pState = &S->pState[0]; |
emh203 | 0:3d9c67d97d6f | 459 | |
emh203 | 0:3d9c67d97d6f | 460 | blkCnt = blockSize; |
emh203 | 0:3d9c67d97d6f | 461 | |
emh203 | 0:3d9c67d97d6f | 462 | while(blkCnt > 0u) |
emh203 | 0:3d9c67d97d6f | 463 | { |
emh203 | 0:3d9c67d97d6f | 464 | /* f0(n) = x(n) */ |
emh203 | 0:3d9c67d97d6f | 465 | fcurnt = *pSrc++; |
emh203 | 0:3d9c67d97d6f | 466 | |
emh203 | 0:3d9c67d97d6f | 467 | /* Initialize coeff pointer */ |
emh203 | 0:3d9c67d97d6f | 468 | pk = (pCoeffs); |
emh203 | 0:3d9c67d97d6f | 469 | |
emh203 | 0:3d9c67d97d6f | 470 | /* Initialize state pointer */ |
emh203 | 0:3d9c67d97d6f | 471 | px = pState; |
emh203 | 0:3d9c67d97d6f | 472 | |
emh203 | 0:3d9c67d97d6f | 473 | /* read g0(n-1) from state buffer */ |
emh203 | 0:3d9c67d97d6f | 474 | gcurnt = *px; |
emh203 | 0:3d9c67d97d6f | 475 | |
emh203 | 0:3d9c67d97d6f | 476 | /* for sample 1 processing */ |
emh203 | 0:3d9c67d97d6f | 477 | /* f1(n) = f0(n) + K1 * g0(n-1) */ |
emh203 | 0:3d9c67d97d6f | 478 | fnext = ((gcurnt * (*pk)) >> 15u) + fcurnt; |
emh203 | 0:3d9c67d97d6f | 479 | fnext = __SSAT(fnext, 16); |
emh203 | 0:3d9c67d97d6f | 480 | |
emh203 | 0:3d9c67d97d6f | 481 | |
emh203 | 0:3d9c67d97d6f | 482 | /* g1(n) = f0(n) * K1 + g0(n-1) */ |
emh203 | 0:3d9c67d97d6f | 483 | gnext = ((fcurnt * (*pk++)) >> 15u) + gcurnt; |
emh203 | 0:3d9c67d97d6f | 484 | gnext = __SSAT(gnext, 16); |
emh203 | 0:3d9c67d97d6f | 485 | |
emh203 | 0:3d9c67d97d6f | 486 | /* save f0(n) in state buffer */ |
emh203 | 0:3d9c67d97d6f | 487 | *px++ = (q15_t) fcurnt; |
emh203 | 0:3d9c67d97d6f | 488 | |
emh203 | 0:3d9c67d97d6f | 489 | /* f1(n) is saved in fcurnt |
emh203 | 0:3d9c67d97d6f | 490 | for next stage processing */ |
emh203 | 0:3d9c67d97d6f | 491 | fcurnt = fnext; |
emh203 | 0:3d9c67d97d6f | 492 | |
emh203 | 0:3d9c67d97d6f | 493 | stageCnt = (numStages - 1u); |
emh203 | 0:3d9c67d97d6f | 494 | |
emh203 | 0:3d9c67d97d6f | 495 | /* stage loop */ |
emh203 | 0:3d9c67d97d6f | 496 | while(stageCnt > 0u) |
emh203 | 0:3d9c67d97d6f | 497 | { |
emh203 | 0:3d9c67d97d6f | 498 | /* read g1(n-1) from state buffer */ |
emh203 | 0:3d9c67d97d6f | 499 | gcurnt = *px; |
emh203 | 0:3d9c67d97d6f | 500 | |
emh203 | 0:3d9c67d97d6f | 501 | /* save g0(n-1) in state buffer */ |
emh203 | 0:3d9c67d97d6f | 502 | *px++ = (q15_t) gnext; |
emh203 | 0:3d9c67d97d6f | 503 | |
emh203 | 0:3d9c67d97d6f | 504 | /* Sample processing for K2, K3.... */ |
emh203 | 0:3d9c67d97d6f | 505 | /* f2(n) = f1(n) + K2 * g1(n-1) */ |
emh203 | 0:3d9c67d97d6f | 506 | fnext = ((gcurnt * (*pk)) >> 15u) + fcurnt; |
emh203 | 0:3d9c67d97d6f | 507 | fnext = __SSAT(fnext, 16); |
emh203 | 0:3d9c67d97d6f | 508 | |
emh203 | 0:3d9c67d97d6f | 509 | /* g2(n) = f1(n) * K2 + g1(n-1) */ |
emh203 | 0:3d9c67d97d6f | 510 | gnext = ((fcurnt * (*pk++)) >> 15u) + gcurnt; |
emh203 | 0:3d9c67d97d6f | 511 | gnext = __SSAT(gnext, 16); |
emh203 | 0:3d9c67d97d6f | 512 | |
emh203 | 0:3d9c67d97d6f | 513 | |
emh203 | 0:3d9c67d97d6f | 514 | /* f1(n) is saved in fcurnt |
emh203 | 0:3d9c67d97d6f | 515 | for next stage processing */ |
emh203 | 0:3d9c67d97d6f | 516 | fcurnt = fnext; |
emh203 | 0:3d9c67d97d6f | 517 | |
emh203 | 0:3d9c67d97d6f | 518 | stageCnt--; |
emh203 | 0:3d9c67d97d6f | 519 | |
emh203 | 0:3d9c67d97d6f | 520 | } |
emh203 | 0:3d9c67d97d6f | 521 | |
emh203 | 0:3d9c67d97d6f | 522 | /* y(n) = fN(n) */ |
emh203 | 0:3d9c67d97d6f | 523 | *pDst++ = __SSAT(fcurnt, 16); |
emh203 | 0:3d9c67d97d6f | 524 | |
emh203 | 0:3d9c67d97d6f | 525 | |
emh203 | 0:3d9c67d97d6f | 526 | blkCnt--; |
emh203 | 0:3d9c67d97d6f | 527 | |
emh203 | 0:3d9c67d97d6f | 528 | } |
emh203 | 0:3d9c67d97d6f | 529 | |
emh203 | 0:3d9c67d97d6f | 530 | #endif /* #ifndef ARM_MATH_CM0_FAMILY */ |
emh203 | 0:3d9c67d97d6f | 531 | |
emh203 | 0:3d9c67d97d6f | 532 | } |
emh203 | 0:3d9c67d97d6f | 533 | |
emh203 | 0:3d9c67d97d6f | 534 | /** |
emh203 | 0:3d9c67d97d6f | 535 | * @} end of FIR_Lattice group |
emh203 | 0:3d9c67d97d6f | 536 | */ |