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

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?

UserRevisionLine numberNew 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_fast_q15.c
emh203 0:3d9c67d97d6f 9 *
emh203 0:3d9c67d97d6f 10 * Description: Q15 Fast FIR filter processing function.
emh203 0:3d9c67d97d6f 11 *
emh203 0:3d9c67d97d6f 12 * Target Processor: Cortex-M4/Cortex-M3
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
emh203 0:3d9c67d97d6f 49 * @{
emh203 0:3d9c67d97d6f 50 */
emh203 0:3d9c67d97d6f 51
emh203 0:3d9c67d97d6f 52 /**
emh203 0:3d9c67d97d6f 53 * @param[in] *S points to an instance of the Q15 FIR filter structure.
emh203 0:3d9c67d97d6f 54 * @param[in] *pSrc points to the block of input data.
emh203 0:3d9c67d97d6f 55 * @param[out] *pDst points to the block of output data.
emh203 0:3d9c67d97d6f 56 * @param[in] blockSize number of samples to process per call.
emh203 0:3d9c67d97d6f 57 * @return none.
emh203 0:3d9c67d97d6f 58 *
emh203 0:3d9c67d97d6f 59 * <b>Scaling and Overflow Behavior:</b>
emh203 0:3d9c67d97d6f 60 * \par
emh203 0:3d9c67d97d6f 61 * This fast version uses a 32-bit accumulator with 2.30 format.
emh203 0:3d9c67d97d6f 62 * The accumulator maintains full precision of the intermediate multiplication results but provides only a single guard bit.
emh203 0:3d9c67d97d6f 63 * Thus, if the accumulator result overflows it wraps around and distorts the result.
emh203 0:3d9c67d97d6f 64 * In order to avoid overflows completely the input signal must be scaled down by log2(numTaps) bits.
emh203 0:3d9c67d97d6f 65 * The 2.30 accumulator is then truncated to 2.15 format and saturated to yield the 1.15 result.
emh203 0:3d9c67d97d6f 66 *
emh203 0:3d9c67d97d6f 67 * \par
emh203 0:3d9c67d97d6f 68 * Refer to the function <code>arm_fir_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 69 * Use the function <code>arm_fir_init_q15()</code> to initialize the filter structure.
emh203 0:3d9c67d97d6f 70 */
emh203 0:3d9c67d97d6f 71
emh203 0:3d9c67d97d6f 72 void arm_fir_fast_q15(
emh203 0:3d9c67d97d6f 73 const arm_fir_instance_q15 * S,
emh203 0:3d9c67d97d6f 74 q15_t * pSrc,
emh203 0:3d9c67d97d6f 75 q15_t * pDst,
emh203 0:3d9c67d97d6f 76 uint32_t blockSize)
emh203 0:3d9c67d97d6f 77 {
emh203 0:3d9c67d97d6f 78 q15_t *pState = S->pState; /* State pointer */
emh203 0:3d9c67d97d6f 79 q15_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */
emh203 0:3d9c67d97d6f 80 q15_t *pStateCurnt; /* Points to the current sample of the state */
emh203 0:3d9c67d97d6f 81 q31_t acc0, acc1, acc2, acc3; /* Accumulators */
emh203 0:3d9c67d97d6f 82 q15_t *pb; /* Temporary pointer for coefficient buffer */
emh203 0:3d9c67d97d6f 83 q15_t *px; /* Temporary q31 pointer for SIMD state buffer accesses */
emh203 0:3d9c67d97d6f 84 q31_t x0, x1, x2, c0; /* Temporary variables to hold SIMD state and coefficient values */
emh203 0:3d9c67d97d6f 85 uint32_t numTaps = S->numTaps; /* Number of taps in the filter */
emh203 0:3d9c67d97d6f 86 uint32_t tapCnt, blkCnt; /* Loop counters */
emh203 0:3d9c67d97d6f 87
emh203 0:3d9c67d97d6f 88
emh203 0:3d9c67d97d6f 89 /* S->pState points to state array which contains previous frame (numTaps - 1) samples */
emh203 0:3d9c67d97d6f 90 /* pStateCurnt points to the location where the new input data should be written */
emh203 0:3d9c67d97d6f 91 pStateCurnt = &(S->pState[(numTaps - 1u)]);
emh203 0:3d9c67d97d6f 92
emh203 0:3d9c67d97d6f 93 /* Apply loop unrolling and compute 4 output values simultaneously.
emh203 0:3d9c67d97d6f 94 * The variables acc0 ... acc3 hold output values that are being computed:
emh203 0:3d9c67d97d6f 95 *
emh203 0:3d9c67d97d6f 96 * acc0 = b[numTaps-1] * x[n-numTaps-1] + b[numTaps-2] * x[n-numTaps-2] + b[numTaps-3] * x[n-numTaps-3] +...+ b[0] * x[0]
emh203 0:3d9c67d97d6f 97 * acc1 = b[numTaps-1] * x[n-numTaps] + b[numTaps-2] * x[n-numTaps-1] + b[numTaps-3] * x[n-numTaps-2] +...+ b[0] * x[1]
emh203 0:3d9c67d97d6f 98 * acc2 = b[numTaps-1] * x[n-numTaps+1] + b[numTaps-2] * x[n-numTaps] + b[numTaps-3] * x[n-numTaps-1] +...+ b[0] * x[2]
emh203 0:3d9c67d97d6f 99 * acc3 = b[numTaps-1] * x[n-numTaps+2] + b[numTaps-2] * x[n-numTaps+1] + b[numTaps-3] * x[n-numTaps] +...+ b[0] * x[3]
emh203 0:3d9c67d97d6f 100 */
emh203 0:3d9c67d97d6f 101
emh203 0:3d9c67d97d6f 102 blkCnt = blockSize >> 2;
emh203 0:3d9c67d97d6f 103
emh203 0:3d9c67d97d6f 104 /* First part of the processing with loop unrolling. Compute 4 outputs at a time.
emh203 0:3d9c67d97d6f 105 ** a second loop below computes the remaining 1 to 3 samples. */
emh203 0:3d9c67d97d6f 106 while(blkCnt > 0u)
emh203 0:3d9c67d97d6f 107 {
emh203 0:3d9c67d97d6f 108 /* Copy four new input samples into the state buffer.
emh203 0:3d9c67d97d6f 109 ** Use 32-bit SIMD to move the 16-bit data. Only requires two copies. */
emh203 0:3d9c67d97d6f 110 *pStateCurnt++ = *pSrc++;
emh203 0:3d9c67d97d6f 111 *pStateCurnt++ = *pSrc++;
emh203 0:3d9c67d97d6f 112 *pStateCurnt++ = *pSrc++;
emh203 0:3d9c67d97d6f 113 *pStateCurnt++ = *pSrc++;
emh203 0:3d9c67d97d6f 114
emh203 0:3d9c67d97d6f 115
emh203 0:3d9c67d97d6f 116 /* Set all accumulators to zero */
emh203 0:3d9c67d97d6f 117 acc0 = 0;
emh203 0:3d9c67d97d6f 118 acc1 = 0;
emh203 0:3d9c67d97d6f 119 acc2 = 0;
emh203 0:3d9c67d97d6f 120 acc3 = 0;
emh203 0:3d9c67d97d6f 121
emh203 0:3d9c67d97d6f 122 /* Typecast q15_t pointer to q31_t pointer for state reading in q31_t */
emh203 0:3d9c67d97d6f 123 px = pState;
emh203 0:3d9c67d97d6f 124
emh203 0:3d9c67d97d6f 125 /* Typecast q15_t pointer to q31_t pointer for coefficient reading in q31_t */
emh203 0:3d9c67d97d6f 126 pb = pCoeffs;
emh203 0:3d9c67d97d6f 127
emh203 0:3d9c67d97d6f 128 /* Read the first two samples from the state buffer: x[n-N], x[n-N-1] */
emh203 0:3d9c67d97d6f 129 x0 = *__SIMD32(px)++;
emh203 0:3d9c67d97d6f 130
emh203 0:3d9c67d97d6f 131 /* Read the third and forth samples from the state buffer: x[n-N-2], x[n-N-3] */
emh203 0:3d9c67d97d6f 132 x2 = *__SIMD32(px)++;
emh203 0:3d9c67d97d6f 133
emh203 0:3d9c67d97d6f 134 /* Loop over the number of taps. Unroll by a factor of 4.
emh203 0:3d9c67d97d6f 135 ** Repeat until we've computed numTaps-(numTaps%4) coefficients. */
emh203 0:3d9c67d97d6f 136 tapCnt = numTaps >> 2;
emh203 0:3d9c67d97d6f 137
emh203 0:3d9c67d97d6f 138 while(tapCnt > 0)
emh203 0:3d9c67d97d6f 139 {
emh203 0:3d9c67d97d6f 140 /* Read the first two coefficients using SIMD: b[N] and b[N-1] coefficients */
emh203 0:3d9c67d97d6f 141 c0 = *__SIMD32(pb)++;
emh203 0:3d9c67d97d6f 142
emh203 0:3d9c67d97d6f 143 /* acc0 += b[N] * x[n-N] + b[N-1] * x[n-N-1] */
emh203 0:3d9c67d97d6f 144 acc0 = __SMLAD(x0, c0, acc0);
emh203 0:3d9c67d97d6f 145
emh203 0:3d9c67d97d6f 146 /* acc2 += b[N] * x[n-N-2] + b[N-1] * x[n-N-3] */
emh203 0:3d9c67d97d6f 147 acc2 = __SMLAD(x2, c0, acc2);
emh203 0:3d9c67d97d6f 148
emh203 0:3d9c67d97d6f 149 /* pack x[n-N-1] and x[n-N-2] */
emh203 0:3d9c67d97d6f 150 #ifndef ARM_MATH_BIG_ENDIAN
emh203 0:3d9c67d97d6f 151 x1 = __PKHBT(x2, x0, 0);
emh203 0:3d9c67d97d6f 152 #else
emh203 0:3d9c67d97d6f 153 x1 = __PKHBT(x0, x2, 0);
emh203 0:3d9c67d97d6f 154 #endif
emh203 0:3d9c67d97d6f 155
emh203 0:3d9c67d97d6f 156 /* Read state x[n-N-4], x[n-N-5] */
emh203 0:3d9c67d97d6f 157 x0 = _SIMD32_OFFSET(px);
emh203 0:3d9c67d97d6f 158
emh203 0:3d9c67d97d6f 159 /* acc1 += b[N] * x[n-N-1] + b[N-1] * x[n-N-2] */
emh203 0:3d9c67d97d6f 160 acc1 = __SMLADX(x1, c0, acc1);
emh203 0:3d9c67d97d6f 161
emh203 0:3d9c67d97d6f 162 /* pack x[n-N-3] and x[n-N-4] */
emh203 0:3d9c67d97d6f 163 #ifndef ARM_MATH_BIG_ENDIAN
emh203 0:3d9c67d97d6f 164 x1 = __PKHBT(x0, x2, 0);
emh203 0:3d9c67d97d6f 165 #else
emh203 0:3d9c67d97d6f 166 x1 = __PKHBT(x2, x0, 0);
emh203 0:3d9c67d97d6f 167 #endif
emh203 0:3d9c67d97d6f 168
emh203 0:3d9c67d97d6f 169 /* acc3 += b[N] * x[n-N-3] + b[N-1] * x[n-N-4] */
emh203 0:3d9c67d97d6f 170 acc3 = __SMLADX(x1, c0, acc3);
emh203 0:3d9c67d97d6f 171
emh203 0:3d9c67d97d6f 172 /* Read coefficients b[N-2], b[N-3] */
emh203 0:3d9c67d97d6f 173 c0 = *__SIMD32(pb)++;
emh203 0:3d9c67d97d6f 174
emh203 0:3d9c67d97d6f 175 /* acc0 += b[N-2] * x[n-N-2] + b[N-3] * x[n-N-3] */
emh203 0:3d9c67d97d6f 176 acc0 = __SMLAD(x2, c0, acc0);
emh203 0:3d9c67d97d6f 177
emh203 0:3d9c67d97d6f 178 /* Read state x[n-N-6], x[n-N-7] with offset */
emh203 0:3d9c67d97d6f 179 x2 = _SIMD32_OFFSET(px + 2u);
emh203 0:3d9c67d97d6f 180
emh203 0:3d9c67d97d6f 181 /* acc2 += b[N-2] * x[n-N-4] + b[N-3] * x[n-N-5] */
emh203 0:3d9c67d97d6f 182 acc2 = __SMLAD(x0, c0, acc2);
emh203 0:3d9c67d97d6f 183
emh203 0:3d9c67d97d6f 184 /* acc1 += b[N-2] * x[n-N-3] + b[N-3] * x[n-N-4] */
emh203 0:3d9c67d97d6f 185 acc1 = __SMLADX(x1, c0, acc1);
emh203 0:3d9c67d97d6f 186
emh203 0:3d9c67d97d6f 187 /* pack x[n-N-5] and x[n-N-6] */
emh203 0:3d9c67d97d6f 188 #ifndef ARM_MATH_BIG_ENDIAN
emh203 0:3d9c67d97d6f 189 x1 = __PKHBT(x2, x0, 0);
emh203 0:3d9c67d97d6f 190 #else
emh203 0:3d9c67d97d6f 191 x1 = __PKHBT(x0, x2, 0);
emh203 0:3d9c67d97d6f 192 #endif
emh203 0:3d9c67d97d6f 193
emh203 0:3d9c67d97d6f 194 /* acc3 += b[N-2] * x[n-N-5] + b[N-3] * x[n-N-6] */
emh203 0:3d9c67d97d6f 195 acc3 = __SMLADX(x1, c0, acc3);
emh203 0:3d9c67d97d6f 196
emh203 0:3d9c67d97d6f 197 /* Update state pointer for next state reading */
emh203 0:3d9c67d97d6f 198 px += 4u;
emh203 0:3d9c67d97d6f 199
emh203 0:3d9c67d97d6f 200 /* Decrement tap count */
emh203 0:3d9c67d97d6f 201 tapCnt--;
emh203 0:3d9c67d97d6f 202
emh203 0:3d9c67d97d6f 203 }
emh203 0:3d9c67d97d6f 204
emh203 0:3d9c67d97d6f 205 /* If the filter length is not a multiple of 4, compute the remaining filter taps.
emh203 0:3d9c67d97d6f 206 ** This is always be 2 taps since the filter length is even. */
emh203 0:3d9c67d97d6f 207 if((numTaps & 0x3u) != 0u)
emh203 0:3d9c67d97d6f 208 {
emh203 0:3d9c67d97d6f 209
emh203 0:3d9c67d97d6f 210 /* Read last two coefficients */
emh203 0:3d9c67d97d6f 211 c0 = *__SIMD32(pb)++;
emh203 0:3d9c67d97d6f 212
emh203 0:3d9c67d97d6f 213 /* Perform the multiply-accumulates */
emh203 0:3d9c67d97d6f 214 acc0 = __SMLAD(x0, c0, acc0);
emh203 0:3d9c67d97d6f 215 acc2 = __SMLAD(x2, c0, acc2);
emh203 0:3d9c67d97d6f 216
emh203 0:3d9c67d97d6f 217 /* pack state variables */
emh203 0:3d9c67d97d6f 218 #ifndef ARM_MATH_BIG_ENDIAN
emh203 0:3d9c67d97d6f 219 x1 = __PKHBT(x2, x0, 0);
emh203 0:3d9c67d97d6f 220 #else
emh203 0:3d9c67d97d6f 221 x1 = __PKHBT(x0, x2, 0);
emh203 0:3d9c67d97d6f 222 #endif
emh203 0:3d9c67d97d6f 223
emh203 0:3d9c67d97d6f 224 /* Read last state variables */
emh203 0:3d9c67d97d6f 225 x0 = *__SIMD32(px);
emh203 0:3d9c67d97d6f 226
emh203 0:3d9c67d97d6f 227 /* Perform the multiply-accumulates */
emh203 0:3d9c67d97d6f 228 acc1 = __SMLADX(x1, c0, acc1);
emh203 0:3d9c67d97d6f 229
emh203 0:3d9c67d97d6f 230 /* pack state variables */
emh203 0:3d9c67d97d6f 231 #ifndef ARM_MATH_BIG_ENDIAN
emh203 0:3d9c67d97d6f 232 x1 = __PKHBT(x0, x2, 0);
emh203 0:3d9c67d97d6f 233 #else
emh203 0:3d9c67d97d6f 234 x1 = __PKHBT(x2, x0, 0);
emh203 0:3d9c67d97d6f 235 #endif
emh203 0:3d9c67d97d6f 236
emh203 0:3d9c67d97d6f 237 /* Perform the multiply-accumulates */
emh203 0:3d9c67d97d6f 238 acc3 = __SMLADX(x1, c0, acc3);
emh203 0:3d9c67d97d6f 239 }
emh203 0:3d9c67d97d6f 240
emh203 0:3d9c67d97d6f 241 /* The results in the 4 accumulators are in 2.30 format. Convert to 1.15 with saturation.
emh203 0:3d9c67d97d6f 242 ** Then store the 4 outputs in the destination buffer. */
emh203 0:3d9c67d97d6f 243
emh203 0:3d9c67d97d6f 244 #ifndef ARM_MATH_BIG_ENDIAN
emh203 0:3d9c67d97d6f 245
emh203 0:3d9c67d97d6f 246 *__SIMD32(pDst)++ =
emh203 0:3d9c67d97d6f 247 __PKHBT(__SSAT((acc0 >> 15), 16), __SSAT((acc1 >> 15), 16), 16);
emh203 0:3d9c67d97d6f 248
emh203 0:3d9c67d97d6f 249 *__SIMD32(pDst)++ =
emh203 0:3d9c67d97d6f 250 __PKHBT(__SSAT((acc2 >> 15), 16), __SSAT((acc3 >> 15), 16), 16);
emh203 0:3d9c67d97d6f 251
emh203 0:3d9c67d97d6f 252 #else
emh203 0:3d9c67d97d6f 253
emh203 0:3d9c67d97d6f 254 *__SIMD32(pDst)++ =
emh203 0:3d9c67d97d6f 255 __PKHBT(__SSAT((acc1 >> 15), 16), __SSAT((acc0 >> 15), 16), 16);
emh203 0:3d9c67d97d6f 256
emh203 0:3d9c67d97d6f 257 *__SIMD32(pDst)++ =
emh203 0:3d9c67d97d6f 258 __PKHBT(__SSAT((acc3 >> 15), 16), __SSAT((acc2 >> 15), 16), 16);
emh203 0:3d9c67d97d6f 259
emh203 0:3d9c67d97d6f 260
emh203 0:3d9c67d97d6f 261 #endif /* #ifndef ARM_MATH_BIG_ENDIAN */
emh203 0:3d9c67d97d6f 262
emh203 0:3d9c67d97d6f 263 /* Advance the state pointer by 4 to process the next group of 4 samples */
emh203 0:3d9c67d97d6f 264 pState = pState + 4u;
emh203 0:3d9c67d97d6f 265
emh203 0:3d9c67d97d6f 266 /* Decrement the loop counter */
emh203 0:3d9c67d97d6f 267 blkCnt--;
emh203 0:3d9c67d97d6f 268 }
emh203 0:3d9c67d97d6f 269
emh203 0:3d9c67d97d6f 270 /* If the blockSize is not a multiple of 4, compute any remaining output samples here.
emh203 0:3d9c67d97d6f 271 ** No loop unrolling is used. */
emh203 0:3d9c67d97d6f 272 blkCnt = blockSize % 0x4u;
emh203 0:3d9c67d97d6f 273 while(blkCnt > 0u)
emh203 0:3d9c67d97d6f 274 {
emh203 0:3d9c67d97d6f 275 /* Copy two samples into state buffer */
emh203 0:3d9c67d97d6f 276 *pStateCurnt++ = *pSrc++;
emh203 0:3d9c67d97d6f 277
emh203 0:3d9c67d97d6f 278 /* Set the accumulator to zero */
emh203 0:3d9c67d97d6f 279 acc0 = 0;
emh203 0:3d9c67d97d6f 280
emh203 0:3d9c67d97d6f 281 /* Use SIMD to hold states and coefficients */
emh203 0:3d9c67d97d6f 282 px = pState;
emh203 0:3d9c67d97d6f 283 pb = pCoeffs;
emh203 0:3d9c67d97d6f 284
emh203 0:3d9c67d97d6f 285 tapCnt = numTaps >> 1u;
emh203 0:3d9c67d97d6f 286
emh203 0:3d9c67d97d6f 287 do
emh203 0:3d9c67d97d6f 288 {
emh203 0:3d9c67d97d6f 289
emh203 0:3d9c67d97d6f 290 acc0 += (q31_t) * px++ * *pb++;
emh203 0:3d9c67d97d6f 291 acc0 += (q31_t) * px++ * *pb++;
emh203 0:3d9c67d97d6f 292
emh203 0:3d9c67d97d6f 293 tapCnt--;
emh203 0:3d9c67d97d6f 294 }
emh203 0:3d9c67d97d6f 295 while(tapCnt > 0u);
emh203 0:3d9c67d97d6f 296
emh203 0:3d9c67d97d6f 297 /* The result is in 2.30 format. Convert to 1.15 with saturation.
emh203 0:3d9c67d97d6f 298 ** Then store the output in the destination buffer. */
emh203 0:3d9c67d97d6f 299 *pDst++ = (q15_t) (__SSAT((acc0 >> 15), 16));
emh203 0:3d9c67d97d6f 300
emh203 0:3d9c67d97d6f 301 /* Advance state pointer by 1 for the next sample */
emh203 0:3d9c67d97d6f 302 pState = pState + 1u;
emh203 0:3d9c67d97d6f 303
emh203 0:3d9c67d97d6f 304 /* Decrement the loop counter */
emh203 0:3d9c67d97d6f 305 blkCnt--;
emh203 0:3d9c67d97d6f 306 }
emh203 0:3d9c67d97d6f 307
emh203 0:3d9c67d97d6f 308 /* Processing is complete.
emh203 0:3d9c67d97d6f 309 ** Now copy the last numTaps - 1 samples to the satrt of the state buffer.
emh203 0:3d9c67d97d6f 310 ** This prepares the state buffer for the next function call. */
emh203 0:3d9c67d97d6f 311
emh203 0:3d9c67d97d6f 312 /* Points to the start of the state buffer */
emh203 0:3d9c67d97d6f 313 pStateCurnt = S->pState;
emh203 0:3d9c67d97d6f 314
emh203 0:3d9c67d97d6f 315 /* Calculation of count for copying integer writes */
emh203 0:3d9c67d97d6f 316 tapCnt = (numTaps - 1u) >> 2;
emh203 0:3d9c67d97d6f 317
emh203 0:3d9c67d97d6f 318 while(tapCnt > 0u)
emh203 0:3d9c67d97d6f 319 {
emh203 0:3d9c67d97d6f 320 *pStateCurnt++ = *pState++;
emh203 0:3d9c67d97d6f 321 *pStateCurnt++ = *pState++;
emh203 0:3d9c67d97d6f 322 *pStateCurnt++ = *pState++;
emh203 0:3d9c67d97d6f 323 *pStateCurnt++ = *pState++;
emh203 0:3d9c67d97d6f 324
emh203 0:3d9c67d97d6f 325 tapCnt--;
emh203 0:3d9c67d97d6f 326
emh203 0:3d9c67d97d6f 327 }
emh203 0:3d9c67d97d6f 328
emh203 0:3d9c67d97d6f 329 /* Calculation of count for remaining q15_t data */
emh203 0:3d9c67d97d6f 330 tapCnt = (numTaps - 1u) % 0x4u;
emh203 0:3d9c67d97d6f 331
emh203 0:3d9c67d97d6f 332 /* copy remaining data */
emh203 0:3d9c67d97d6f 333 while(tapCnt > 0u)
emh203 0:3d9c67d97d6f 334 {
emh203 0:3d9c67d97d6f 335 *pStateCurnt++ = *pState++;
emh203 0:3d9c67d97d6f 336
emh203 0:3d9c67d97d6f 337 /* Decrement the loop counter */
emh203 0:3d9c67d97d6f 338 tapCnt--;
emh203 0:3d9c67d97d6f 339 }
emh203 0:3d9c67d97d6f 340
emh203 0:3d9c67d97d6f 341 }
emh203 0:3d9c67d97d6f 342
emh203 0:3d9c67d97d6f 343 /**
emh203 0:3d9c67d97d6f 344 * @} end of FIR group
emh203 0:3d9c67d97d6f 345 */