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_biquad_cascade_df1_fast_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_biquad_cascade_df1_fast_q15.c |
emh203 | 0:3d9c67d97d6f | 9 | * |
emh203 | 0:3d9c67d97d6f | 10 | * Description: Fast processing function for the |
emh203 | 0:3d9c67d97d6f | 11 | * Q15 Biquad cascade filter. |
emh203 | 0:3d9c67d97d6f | 12 | * |
emh203 | 0:3d9c67d97d6f | 13 | * Target Processor: Cortex-M4/Cortex-M3 |
emh203 | 0:3d9c67d97d6f | 14 | * |
emh203 | 0:3d9c67d97d6f | 15 | * Redistribution and use in source and binary forms, with or without |
emh203 | 0:3d9c67d97d6f | 16 | * modification, are permitted provided that the following conditions |
emh203 | 0:3d9c67d97d6f | 17 | * are met: |
emh203 | 0:3d9c67d97d6f | 18 | * - Redistributions of source code must retain the above copyright |
emh203 | 0:3d9c67d97d6f | 19 | * notice, this list of conditions and the following disclaimer. |
emh203 | 0:3d9c67d97d6f | 20 | * - Redistributions in binary form must reproduce the above copyright |
emh203 | 0:3d9c67d97d6f | 21 | * notice, this list of conditions and the following disclaimer in |
emh203 | 0:3d9c67d97d6f | 22 | * the documentation and/or other materials provided with the |
emh203 | 0:3d9c67d97d6f | 23 | * distribution. |
emh203 | 0:3d9c67d97d6f | 24 | * - Neither the name of ARM LIMITED nor the names of its contributors |
emh203 | 0:3d9c67d97d6f | 25 | * may be used to endorse or promote products derived from this |
emh203 | 0:3d9c67d97d6f | 26 | * software without specific prior written permission. |
emh203 | 0:3d9c67d97d6f | 27 | * |
emh203 | 0:3d9c67d97d6f | 28 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
emh203 | 0:3d9c67d97d6f | 29 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
emh203 | 0:3d9c67d97d6f | 30 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
emh203 | 0:3d9c67d97d6f | 31 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
emh203 | 0:3d9c67d97d6f | 32 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
emh203 | 0:3d9c67d97d6f | 33 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
emh203 | 0:3d9c67d97d6f | 34 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
emh203 | 0:3d9c67d97d6f | 35 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
emh203 | 0:3d9c67d97d6f | 36 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
emh203 | 0:3d9c67d97d6f | 37 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
emh203 | 0:3d9c67d97d6f | 38 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
emh203 | 0:3d9c67d97d6f | 39 | * POSSIBILITY OF SUCH DAMAGE. |
emh203 | 0:3d9c67d97d6f | 40 | * -------------------------------------------------------------------- */ |
emh203 | 0:3d9c67d97d6f | 41 | |
emh203 | 0:3d9c67d97d6f | 42 | #include "arm_math.h" |
emh203 | 0:3d9c67d97d6f | 43 | |
emh203 | 0:3d9c67d97d6f | 44 | /** |
emh203 | 0:3d9c67d97d6f | 45 | * @ingroup groupFilters |
emh203 | 0:3d9c67d97d6f | 46 | */ |
emh203 | 0:3d9c67d97d6f | 47 | |
emh203 | 0:3d9c67d97d6f | 48 | /** |
emh203 | 0:3d9c67d97d6f | 49 | * @addtogroup BiquadCascadeDF1 |
emh203 | 0:3d9c67d97d6f | 50 | * @{ |
emh203 | 0:3d9c67d97d6f | 51 | */ |
emh203 | 0:3d9c67d97d6f | 52 | |
emh203 | 0:3d9c67d97d6f | 53 | /** |
emh203 | 0:3d9c67d97d6f | 54 | * @details |
emh203 | 0:3d9c67d97d6f | 55 | * @param[in] *S points to an instance of the Q15 Biquad cascade 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 per call. |
emh203 | 0:3d9c67d97d6f | 59 | * @return none. |
emh203 | 0:3d9c67d97d6f | 60 | * |
emh203 | 0:3d9c67d97d6f | 61 | * <b>Scaling and Overflow Behavior:</b> |
emh203 | 0:3d9c67d97d6f | 62 | * \par |
emh203 | 0:3d9c67d97d6f | 63 | * This fast version uses a 32-bit accumulator with 2.30 format. |
emh203 | 0:3d9c67d97d6f | 64 | * The accumulator maintains full precision of the intermediate multiplication results but provides only a single guard bit. |
emh203 | 0:3d9c67d97d6f | 65 | * Thus, if the accumulator result overflows it wraps around and distorts the result. |
emh203 | 0:3d9c67d97d6f | 66 | * In order to avoid overflows completely the input signal must be scaled down by two bits and lie in the range [-0.25 +0.25). |
emh203 | 0:3d9c67d97d6f | 67 | * The 2.30 accumulator is then shifted by <code>postShift</code> bits and the result truncated to 1.15 format by discarding the low 16 bits. |
emh203 | 0:3d9c67d97d6f | 68 | * |
emh203 | 0:3d9c67d97d6f | 69 | * \par |
emh203 | 0:3d9c67d97d6f | 70 | * Refer to the function <code>arm_biquad_cascade_df1_q15()</code> for a slower implementation of this function which uses 64-bit accumulation to avoid wrap around distortion. Both the slow and the fast versions use the same instance structure. |
emh203 | 0:3d9c67d97d6f | 71 | * Use the function <code>arm_biquad_cascade_df1_init_q15()</code> to initialize the filter structure. |
emh203 | 0:3d9c67d97d6f | 72 | * |
emh203 | 0:3d9c67d97d6f | 73 | */ |
emh203 | 0:3d9c67d97d6f | 74 | |
emh203 | 0:3d9c67d97d6f | 75 | void arm_biquad_cascade_df1_fast_q15( |
emh203 | 0:3d9c67d97d6f | 76 | const arm_biquad_casd_df1_inst_q15 * S, |
emh203 | 0:3d9c67d97d6f | 77 | q15_t * pSrc, |
emh203 | 0:3d9c67d97d6f | 78 | q15_t * pDst, |
emh203 | 0:3d9c67d97d6f | 79 | uint32_t blockSize) |
emh203 | 0:3d9c67d97d6f | 80 | { |
emh203 | 0:3d9c67d97d6f | 81 | q15_t *pIn = pSrc; /* Source pointer */ |
emh203 | 0:3d9c67d97d6f | 82 | q15_t *pOut = pDst; /* Destination pointer */ |
emh203 | 0:3d9c67d97d6f | 83 | q31_t in; /* Temporary variable to hold input value */ |
emh203 | 0:3d9c67d97d6f | 84 | q31_t out; /* Temporary variable to hold output value */ |
emh203 | 0:3d9c67d97d6f | 85 | q31_t b0; /* Temporary variable to hold bo value */ |
emh203 | 0:3d9c67d97d6f | 86 | q31_t b1, a1; /* Filter coefficients */ |
emh203 | 0:3d9c67d97d6f | 87 | q31_t state_in, state_out; /* Filter state variables */ |
emh203 | 0:3d9c67d97d6f | 88 | q31_t acc; /* Accumulator */ |
emh203 | 0:3d9c67d97d6f | 89 | int32_t shift = (int32_t) (15 - S->postShift); /* Post shift */ |
emh203 | 0:3d9c67d97d6f | 90 | q15_t *pState = S->pState; /* State pointer */ |
emh203 | 0:3d9c67d97d6f | 91 | q15_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ |
emh203 | 0:3d9c67d97d6f | 92 | uint32_t sample, stage = S->numStages; /* Stage loop counter */ |
emh203 | 0:3d9c67d97d6f | 93 | |
emh203 | 0:3d9c67d97d6f | 94 | |
emh203 | 0:3d9c67d97d6f | 95 | |
emh203 | 0:3d9c67d97d6f | 96 | do |
emh203 | 0:3d9c67d97d6f | 97 | { |
emh203 | 0:3d9c67d97d6f | 98 | |
emh203 | 0:3d9c67d97d6f | 99 | /* Read the b0 and 0 coefficients using SIMD */ |
emh203 | 0:3d9c67d97d6f | 100 | b0 = *__SIMD32(pCoeffs)++; |
emh203 | 0:3d9c67d97d6f | 101 | |
emh203 | 0:3d9c67d97d6f | 102 | /* Read the b1 and b2 coefficients using SIMD */ |
emh203 | 0:3d9c67d97d6f | 103 | b1 = *__SIMD32(pCoeffs)++; |
emh203 | 0:3d9c67d97d6f | 104 | |
emh203 | 0:3d9c67d97d6f | 105 | /* Read the a1 and a2 coefficients using SIMD */ |
emh203 | 0:3d9c67d97d6f | 106 | a1 = *__SIMD32(pCoeffs)++; |
emh203 | 0:3d9c67d97d6f | 107 | |
emh203 | 0:3d9c67d97d6f | 108 | /* Read the input state values from the state buffer: x[n-1], x[n-2] */ |
emh203 | 0:3d9c67d97d6f | 109 | state_in = *__SIMD32(pState)++; |
emh203 | 0:3d9c67d97d6f | 110 | |
emh203 | 0:3d9c67d97d6f | 111 | /* Read the output state values from the state buffer: y[n-1], y[n-2] */ |
emh203 | 0:3d9c67d97d6f | 112 | state_out = *__SIMD32(pState)--; |
emh203 | 0:3d9c67d97d6f | 113 | |
emh203 | 0:3d9c67d97d6f | 114 | /* Apply loop unrolling and compute 2 output values simultaneously. */ |
emh203 | 0:3d9c67d97d6f | 115 | /* The variable acc hold output values that are being computed: |
emh203 | 0:3d9c67d97d6f | 116 | * |
emh203 | 0:3d9c67d97d6f | 117 | * acc = b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] + a1 * y[n-1] + a2 * y[n-2] |
emh203 | 0:3d9c67d97d6f | 118 | * acc = b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] + a1 * y[n-1] + a2 * y[n-2] |
emh203 | 0:3d9c67d97d6f | 119 | */ |
emh203 | 0:3d9c67d97d6f | 120 | sample = blockSize >> 1u; |
emh203 | 0:3d9c67d97d6f | 121 | |
emh203 | 0:3d9c67d97d6f | 122 | /* First part of the processing with loop unrolling. Compute 2 outputs at a time. |
emh203 | 0:3d9c67d97d6f | 123 | ** a second loop below computes the remaining 1 sample. */ |
emh203 | 0:3d9c67d97d6f | 124 | while(sample > 0u) |
emh203 | 0:3d9c67d97d6f | 125 | { |
emh203 | 0:3d9c67d97d6f | 126 | |
emh203 | 0:3d9c67d97d6f | 127 | /* Read the input */ |
emh203 | 0:3d9c67d97d6f | 128 | in = *__SIMD32(pIn)++; |
emh203 | 0:3d9c67d97d6f | 129 | |
emh203 | 0:3d9c67d97d6f | 130 | /* out = b0 * x[n] + 0 * 0 */ |
emh203 | 0:3d9c67d97d6f | 131 | out = __SMUAD(b0, in); |
emh203 | 0:3d9c67d97d6f | 132 | /* acc = b1 * x[n-1] + acc += b2 * x[n-2] + out */ |
emh203 | 0:3d9c67d97d6f | 133 | acc = __SMLAD(b1, state_in, out); |
emh203 | 0:3d9c67d97d6f | 134 | /* acc += a1 * y[n-1] + acc += a2 * y[n-2] */ |
emh203 | 0:3d9c67d97d6f | 135 | acc = __SMLAD(a1, state_out, acc); |
emh203 | 0:3d9c67d97d6f | 136 | |
emh203 | 0:3d9c67d97d6f | 137 | /* The result is converted from 3.29 to 1.31 and then saturation is applied */ |
emh203 | 0:3d9c67d97d6f | 138 | out = __SSAT((acc >> shift), 16); |
emh203 | 0:3d9c67d97d6f | 139 | |
emh203 | 0:3d9c67d97d6f | 140 | /* Every time after the output is computed state should be updated. */ |
emh203 | 0:3d9c67d97d6f | 141 | /* The states should be updated as: */ |
emh203 | 0:3d9c67d97d6f | 142 | /* Xn2 = Xn1 */ |
emh203 | 0:3d9c67d97d6f | 143 | /* Xn1 = Xn */ |
emh203 | 0:3d9c67d97d6f | 144 | /* Yn2 = Yn1 */ |
emh203 | 0:3d9c67d97d6f | 145 | /* Yn1 = acc */ |
emh203 | 0:3d9c67d97d6f | 146 | /* x[n-N], x[n-N-1] are packed together to make state_in of type q31 */ |
emh203 | 0:3d9c67d97d6f | 147 | /* y[n-N], y[n-N-1] are packed together to make state_out of type q31 */ |
emh203 | 0:3d9c67d97d6f | 148 | |
emh203 | 0:3d9c67d97d6f | 149 | #ifndef ARM_MATH_BIG_ENDIAN |
emh203 | 0:3d9c67d97d6f | 150 | |
emh203 | 0:3d9c67d97d6f | 151 | state_in = __PKHBT(in, state_in, 16); |
emh203 | 0:3d9c67d97d6f | 152 | state_out = __PKHBT(out, state_out, 16); |
emh203 | 0:3d9c67d97d6f | 153 | |
emh203 | 0:3d9c67d97d6f | 154 | #else |
emh203 | 0:3d9c67d97d6f | 155 | |
emh203 | 0:3d9c67d97d6f | 156 | state_in = __PKHBT(state_in >> 16, (in >> 16), 16); |
emh203 | 0:3d9c67d97d6f | 157 | state_out = __PKHBT(state_out >> 16, (out), 16); |
emh203 | 0:3d9c67d97d6f | 158 | |
emh203 | 0:3d9c67d97d6f | 159 | #endif /* #ifndef ARM_MATH_BIG_ENDIAN */ |
emh203 | 0:3d9c67d97d6f | 160 | |
emh203 | 0:3d9c67d97d6f | 161 | /* out = b0 * x[n] + 0 * 0 */ |
emh203 | 0:3d9c67d97d6f | 162 | out = __SMUADX(b0, in); |
emh203 | 0:3d9c67d97d6f | 163 | /* acc0 = b1 * x[n-1] , acc0 += b2 * x[n-2] + out */ |
emh203 | 0:3d9c67d97d6f | 164 | acc = __SMLAD(b1, state_in, out); |
emh203 | 0:3d9c67d97d6f | 165 | /* acc += a1 * y[n-1] + acc += a2 * y[n-2] */ |
emh203 | 0:3d9c67d97d6f | 166 | acc = __SMLAD(a1, state_out, acc); |
emh203 | 0:3d9c67d97d6f | 167 | |
emh203 | 0:3d9c67d97d6f | 168 | /* The result is converted from 3.29 to 1.31 and then saturation is applied */ |
emh203 | 0:3d9c67d97d6f | 169 | out = __SSAT((acc >> shift), 16); |
emh203 | 0:3d9c67d97d6f | 170 | |
emh203 | 0:3d9c67d97d6f | 171 | |
emh203 | 0:3d9c67d97d6f | 172 | /* Store the output in the destination buffer. */ |
emh203 | 0:3d9c67d97d6f | 173 | |
emh203 | 0:3d9c67d97d6f | 174 | #ifndef ARM_MATH_BIG_ENDIAN |
emh203 | 0:3d9c67d97d6f | 175 | |
emh203 | 0:3d9c67d97d6f | 176 | *__SIMD32(pOut)++ = __PKHBT(state_out, out, 16); |
emh203 | 0:3d9c67d97d6f | 177 | |
emh203 | 0:3d9c67d97d6f | 178 | #else |
emh203 | 0:3d9c67d97d6f | 179 | |
emh203 | 0:3d9c67d97d6f | 180 | *__SIMD32(pOut)++ = __PKHBT(out, state_out >> 16, 16); |
emh203 | 0:3d9c67d97d6f | 181 | |
emh203 | 0:3d9c67d97d6f | 182 | #endif /* #ifndef ARM_MATH_BIG_ENDIAN */ |
emh203 | 0:3d9c67d97d6f | 183 | |
emh203 | 0:3d9c67d97d6f | 184 | /* Every time after the output is computed state should be updated. */ |
emh203 | 0:3d9c67d97d6f | 185 | /* The states should be updated as: */ |
emh203 | 0:3d9c67d97d6f | 186 | /* Xn2 = Xn1 */ |
emh203 | 0:3d9c67d97d6f | 187 | /* Xn1 = Xn */ |
emh203 | 0:3d9c67d97d6f | 188 | /* Yn2 = Yn1 */ |
emh203 | 0:3d9c67d97d6f | 189 | /* Yn1 = acc */ |
emh203 | 0:3d9c67d97d6f | 190 | /* x[n-N], x[n-N-1] are packed together to make state_in of type q31 */ |
emh203 | 0:3d9c67d97d6f | 191 | /* y[n-N], y[n-N-1] are packed together to make state_out of type q31 */ |
emh203 | 0:3d9c67d97d6f | 192 | |
emh203 | 0:3d9c67d97d6f | 193 | #ifndef ARM_MATH_BIG_ENDIAN |
emh203 | 0:3d9c67d97d6f | 194 | |
emh203 | 0:3d9c67d97d6f | 195 | state_in = __PKHBT(in >> 16, state_in, 16); |
emh203 | 0:3d9c67d97d6f | 196 | state_out = __PKHBT(out, state_out, 16); |
emh203 | 0:3d9c67d97d6f | 197 | |
emh203 | 0:3d9c67d97d6f | 198 | #else |
emh203 | 0:3d9c67d97d6f | 199 | |
emh203 | 0:3d9c67d97d6f | 200 | state_in = __PKHBT(state_in >> 16, in, 16); |
emh203 | 0:3d9c67d97d6f | 201 | state_out = __PKHBT(state_out >> 16, out, 16); |
emh203 | 0:3d9c67d97d6f | 202 | |
emh203 | 0:3d9c67d97d6f | 203 | #endif /* #ifndef ARM_MATH_BIG_ENDIAN */ |
emh203 | 0:3d9c67d97d6f | 204 | |
emh203 | 0:3d9c67d97d6f | 205 | |
emh203 | 0:3d9c67d97d6f | 206 | /* Decrement the loop counter */ |
emh203 | 0:3d9c67d97d6f | 207 | sample--; |
emh203 | 0:3d9c67d97d6f | 208 | |
emh203 | 0:3d9c67d97d6f | 209 | } |
emh203 | 0:3d9c67d97d6f | 210 | |
emh203 | 0:3d9c67d97d6f | 211 | /* If the blockSize is not a multiple of 2, compute any remaining output samples here. |
emh203 | 0:3d9c67d97d6f | 212 | ** No loop unrolling is used. */ |
emh203 | 0:3d9c67d97d6f | 213 | |
emh203 | 0:3d9c67d97d6f | 214 | if((blockSize & 0x1u) != 0u) |
emh203 | 0:3d9c67d97d6f | 215 | { |
emh203 | 0:3d9c67d97d6f | 216 | /* Read the input */ |
emh203 | 0:3d9c67d97d6f | 217 | in = *pIn++; |
emh203 | 0:3d9c67d97d6f | 218 | |
emh203 | 0:3d9c67d97d6f | 219 | /* out = b0 * x[n] + 0 * 0 */ |
emh203 | 0:3d9c67d97d6f | 220 | |
emh203 | 0:3d9c67d97d6f | 221 | #ifndef ARM_MATH_BIG_ENDIAN |
emh203 | 0:3d9c67d97d6f | 222 | |
emh203 | 0:3d9c67d97d6f | 223 | out = __SMUAD(b0, in); |
emh203 | 0:3d9c67d97d6f | 224 | |
emh203 | 0:3d9c67d97d6f | 225 | #else |
emh203 | 0:3d9c67d97d6f | 226 | |
emh203 | 0:3d9c67d97d6f | 227 | out = __SMUADX(b0, in); |
emh203 | 0:3d9c67d97d6f | 228 | |
emh203 | 0:3d9c67d97d6f | 229 | #endif /* #ifndef ARM_MATH_BIG_ENDIAN */ |
emh203 | 0:3d9c67d97d6f | 230 | |
emh203 | 0:3d9c67d97d6f | 231 | /* acc = b1 * x[n-1], acc += b2 * x[n-2] + out */ |
emh203 | 0:3d9c67d97d6f | 232 | acc = __SMLAD(b1, state_in, out); |
emh203 | 0:3d9c67d97d6f | 233 | /* acc += a1 * y[n-1] + acc += a2 * y[n-2] */ |
emh203 | 0:3d9c67d97d6f | 234 | acc = __SMLAD(a1, state_out, acc); |
emh203 | 0:3d9c67d97d6f | 235 | |
emh203 | 0:3d9c67d97d6f | 236 | /* The result is converted from 3.29 to 1.31 and then saturation is applied */ |
emh203 | 0:3d9c67d97d6f | 237 | out = __SSAT((acc >> shift), 16); |
emh203 | 0:3d9c67d97d6f | 238 | |
emh203 | 0:3d9c67d97d6f | 239 | /* Store the output in the destination buffer. */ |
emh203 | 0:3d9c67d97d6f | 240 | *pOut++ = (q15_t) out; |
emh203 | 0:3d9c67d97d6f | 241 | |
emh203 | 0:3d9c67d97d6f | 242 | /* Every time after the output is computed state should be updated. */ |
emh203 | 0:3d9c67d97d6f | 243 | /* The states should be updated as: */ |
emh203 | 0:3d9c67d97d6f | 244 | /* Xn2 = Xn1 */ |
emh203 | 0:3d9c67d97d6f | 245 | /* Xn1 = Xn */ |
emh203 | 0:3d9c67d97d6f | 246 | /* Yn2 = Yn1 */ |
emh203 | 0:3d9c67d97d6f | 247 | /* Yn1 = acc */ |
emh203 | 0:3d9c67d97d6f | 248 | /* x[n-N], x[n-N-1] are packed together to make state_in of type q31 */ |
emh203 | 0:3d9c67d97d6f | 249 | /* y[n-N], y[n-N-1] are packed together to make state_out of type q31 */ |
emh203 | 0:3d9c67d97d6f | 250 | |
emh203 | 0:3d9c67d97d6f | 251 | #ifndef ARM_MATH_BIG_ENDIAN |
emh203 | 0:3d9c67d97d6f | 252 | |
emh203 | 0:3d9c67d97d6f | 253 | state_in = __PKHBT(in, state_in, 16); |
emh203 | 0:3d9c67d97d6f | 254 | state_out = __PKHBT(out, state_out, 16); |
emh203 | 0:3d9c67d97d6f | 255 | |
emh203 | 0:3d9c67d97d6f | 256 | #else |
emh203 | 0:3d9c67d97d6f | 257 | |
emh203 | 0:3d9c67d97d6f | 258 | state_in = __PKHBT(state_in >> 16, in, 16); |
emh203 | 0:3d9c67d97d6f | 259 | state_out = __PKHBT(state_out >> 16, out, 16); |
emh203 | 0:3d9c67d97d6f | 260 | |
emh203 | 0:3d9c67d97d6f | 261 | #endif /* #ifndef ARM_MATH_BIG_ENDIAN */ |
emh203 | 0:3d9c67d97d6f | 262 | |
emh203 | 0:3d9c67d97d6f | 263 | } |
emh203 | 0:3d9c67d97d6f | 264 | |
emh203 | 0:3d9c67d97d6f | 265 | /* The first stage goes from the input buffer to the output buffer. */ |
emh203 | 0:3d9c67d97d6f | 266 | /* Subsequent (numStages - 1) occur in-place in the output buffer */ |
emh203 | 0:3d9c67d97d6f | 267 | pIn = pDst; |
emh203 | 0:3d9c67d97d6f | 268 | |
emh203 | 0:3d9c67d97d6f | 269 | /* Reset the output pointer */ |
emh203 | 0:3d9c67d97d6f | 270 | pOut = pDst; |
emh203 | 0:3d9c67d97d6f | 271 | |
emh203 | 0:3d9c67d97d6f | 272 | /* Store the updated state variables back into the state array */ |
emh203 | 0:3d9c67d97d6f | 273 | *__SIMD32(pState)++ = state_in; |
emh203 | 0:3d9c67d97d6f | 274 | *__SIMD32(pState)++ = state_out; |
emh203 | 0:3d9c67d97d6f | 275 | |
emh203 | 0:3d9c67d97d6f | 276 | |
emh203 | 0:3d9c67d97d6f | 277 | /* Decrement the loop counter */ |
emh203 | 0:3d9c67d97d6f | 278 | stage--; |
emh203 | 0:3d9c67d97d6f | 279 | |
emh203 | 0:3d9c67d97d6f | 280 | } while(stage > 0u); |
emh203 | 0:3d9c67d97d6f | 281 | } |
emh203 | 0:3d9c67d97d6f | 282 | |
emh203 | 0:3d9c67d97d6f | 283 | |
emh203 | 0:3d9c67d97d6f | 284 | /** |
emh203 | 0:3d9c67d97d6f | 285 | * @} end of BiquadCascadeDF1 group |
emh203 | 0:3d9c67d97d6f | 286 | */ |