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_cfft_radix4_q15.c
emh203 0:3d9c67d97d6f 9 *
emh203 0:3d9c67d97d6f 10 * Description: This file has function definition of Radix-4 FFT & IFFT function and
emh203 0:3d9c67d97d6f 11 * In-place bit reversal using bit reversal table
emh203 0:3d9c67d97d6f 12 *
emh203 0:3d9c67d97d6f 13 * Target Processor: Cortex-M4/Cortex-M3/Cortex-M0
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 void arm_radix4_butterfly_q15(
emh203 0:3d9c67d97d6f 46 q15_t * pSrc16,
emh203 0:3d9c67d97d6f 47 uint32_t fftLen,
emh203 0:3d9c67d97d6f 48 q15_t * pCoef16,
emh203 0:3d9c67d97d6f 49 uint32_t twidCoefModifier);
emh203 0:3d9c67d97d6f 50
emh203 0:3d9c67d97d6f 51 void arm_radix4_butterfly_inverse_q15(
emh203 0:3d9c67d97d6f 52 q15_t * pSrc16,
emh203 0:3d9c67d97d6f 53 uint32_t fftLen,
emh203 0:3d9c67d97d6f 54 q15_t * pCoef16,
emh203 0:3d9c67d97d6f 55 uint32_t twidCoefModifier);
emh203 0:3d9c67d97d6f 56
emh203 0:3d9c67d97d6f 57 void arm_bitreversal_q15(
emh203 0:3d9c67d97d6f 58 q15_t * pSrc,
emh203 0:3d9c67d97d6f 59 uint32_t fftLen,
emh203 0:3d9c67d97d6f 60 uint16_t bitRevFactor,
emh203 0:3d9c67d97d6f 61 uint16_t * pBitRevTab);
emh203 0:3d9c67d97d6f 62
emh203 0:3d9c67d97d6f 63 /**
emh203 0:3d9c67d97d6f 64 * @ingroup groupTransforms
emh203 0:3d9c67d97d6f 65 */
emh203 0:3d9c67d97d6f 66
emh203 0:3d9c67d97d6f 67 /**
emh203 0:3d9c67d97d6f 68 * @addtogroup ComplexFFT
emh203 0:3d9c67d97d6f 69 * @{
emh203 0:3d9c67d97d6f 70 */
emh203 0:3d9c67d97d6f 71
emh203 0:3d9c67d97d6f 72
emh203 0:3d9c67d97d6f 73 /**
emh203 0:3d9c67d97d6f 74 * @details
emh203 0:3d9c67d97d6f 75 * @brief Processing function for the Q15 CFFT/CIFFT.
emh203 0:3d9c67d97d6f 76 * @param[in] *S points to an instance of the Q15 CFFT/CIFFT structure.
emh203 0:3d9c67d97d6f 77 * @param[in, out] *pSrc points to the complex data buffer. Processing occurs in-place.
emh203 0:3d9c67d97d6f 78 * @return none.
emh203 0:3d9c67d97d6f 79 *
emh203 0:3d9c67d97d6f 80 * \par Input and output formats:
emh203 0:3d9c67d97d6f 81 * \par
emh203 0:3d9c67d97d6f 82 * Internally input is downscaled by 2 for every stage to avoid saturations inside CFFT/CIFFT process.
emh203 0:3d9c67d97d6f 83 * Hence the output format is different for different FFT sizes.
emh203 0:3d9c67d97d6f 84 * The input and output formats for different FFT sizes and number of bits to upscale are mentioned in the tables below for CFFT and CIFFT:
emh203 0:3d9c67d97d6f 85 * \par
emh203 0:3d9c67d97d6f 86 * \image html CFFTQ15.gif "Input and Output Formats for Q15 CFFT"
emh203 0:3d9c67d97d6f 87 * \image html CIFFTQ15.gif "Input and Output Formats for Q15 CIFFT"
emh203 0:3d9c67d97d6f 88 */
emh203 0:3d9c67d97d6f 89
emh203 0:3d9c67d97d6f 90 void arm_cfft_radix4_q15(
emh203 0:3d9c67d97d6f 91 const arm_cfft_radix4_instance_q15 * S,
emh203 0:3d9c67d97d6f 92 q15_t * pSrc)
emh203 0:3d9c67d97d6f 93 {
emh203 0:3d9c67d97d6f 94 if(S->ifftFlag == 1u)
emh203 0:3d9c67d97d6f 95 {
emh203 0:3d9c67d97d6f 96 /* Complex IFFT radix-4 */
emh203 0:3d9c67d97d6f 97 arm_radix4_butterfly_inverse_q15(pSrc, S->fftLen, S->pTwiddle,
emh203 0:3d9c67d97d6f 98 S->twidCoefModifier);
emh203 0:3d9c67d97d6f 99 }
emh203 0:3d9c67d97d6f 100 else
emh203 0:3d9c67d97d6f 101 {
emh203 0:3d9c67d97d6f 102 /* Complex FFT radix-4 */
emh203 0:3d9c67d97d6f 103 arm_radix4_butterfly_q15(pSrc, S->fftLen, S->pTwiddle,
emh203 0:3d9c67d97d6f 104 S->twidCoefModifier);
emh203 0:3d9c67d97d6f 105 }
emh203 0:3d9c67d97d6f 106
emh203 0:3d9c67d97d6f 107 if(S->bitReverseFlag == 1u)
emh203 0:3d9c67d97d6f 108 {
emh203 0:3d9c67d97d6f 109 /* Bit Reversal */
emh203 0:3d9c67d97d6f 110 arm_bitreversal_q15(pSrc, S->fftLen, S->bitRevFactor, S->pBitRevTable);
emh203 0:3d9c67d97d6f 111 }
emh203 0:3d9c67d97d6f 112
emh203 0:3d9c67d97d6f 113 }
emh203 0:3d9c67d97d6f 114
emh203 0:3d9c67d97d6f 115 /**
emh203 0:3d9c67d97d6f 116 * @} end of ComplexFFT group
emh203 0:3d9c67d97d6f 117 */
emh203 0:3d9c67d97d6f 118
emh203 0:3d9c67d97d6f 119 /*
emh203 0:3d9c67d97d6f 120 * Radix-4 FFT algorithm used is :
emh203 0:3d9c67d97d6f 121 *
emh203 0:3d9c67d97d6f 122 * Input real and imaginary data:
emh203 0:3d9c67d97d6f 123 * x(n) = xa + j * ya
emh203 0:3d9c67d97d6f 124 * x(n+N/4 ) = xb + j * yb
emh203 0:3d9c67d97d6f 125 * x(n+N/2 ) = xc + j * yc
emh203 0:3d9c67d97d6f 126 * x(n+3N 4) = xd + j * yd
emh203 0:3d9c67d97d6f 127 *
emh203 0:3d9c67d97d6f 128 *
emh203 0:3d9c67d97d6f 129 * Output real and imaginary data:
emh203 0:3d9c67d97d6f 130 * x(4r) = xa'+ j * ya'
emh203 0:3d9c67d97d6f 131 * x(4r+1) = xb'+ j * yb'
emh203 0:3d9c67d97d6f 132 * x(4r+2) = xc'+ j * yc'
emh203 0:3d9c67d97d6f 133 * x(4r+3) = xd'+ j * yd'
emh203 0:3d9c67d97d6f 134 *
emh203 0:3d9c67d97d6f 135 *
emh203 0:3d9c67d97d6f 136 * Twiddle factors for radix-4 FFT:
emh203 0:3d9c67d97d6f 137 * Wn = co1 + j * (- si1)
emh203 0:3d9c67d97d6f 138 * W2n = co2 + j * (- si2)
emh203 0:3d9c67d97d6f 139 * W3n = co3 + j * (- si3)
emh203 0:3d9c67d97d6f 140
emh203 0:3d9c67d97d6f 141 * The real and imaginary output values for the radix-4 butterfly are
emh203 0:3d9c67d97d6f 142 * xa' = xa + xb + xc + xd
emh203 0:3d9c67d97d6f 143 * ya' = ya + yb + yc + yd
emh203 0:3d9c67d97d6f 144 * xb' = (xa+yb-xc-yd)* co1 + (ya-xb-yc+xd)* (si1)
emh203 0:3d9c67d97d6f 145 * yb' = (ya-xb-yc+xd)* co1 - (xa+yb-xc-yd)* (si1)
emh203 0:3d9c67d97d6f 146 * xc' = (xa-xb+xc-xd)* co2 + (ya-yb+yc-yd)* (si2)
emh203 0:3d9c67d97d6f 147 * yc' = (ya-yb+yc-yd)* co2 - (xa-xb+xc-xd)* (si2)
emh203 0:3d9c67d97d6f 148 * xd' = (xa-yb-xc+yd)* co3 + (ya+xb-yc-xd)* (si3)
emh203 0:3d9c67d97d6f 149 * yd' = (ya+xb-yc-xd)* co3 - (xa-yb-xc+yd)* (si3)
emh203 0:3d9c67d97d6f 150 *
emh203 0:3d9c67d97d6f 151 */
emh203 0:3d9c67d97d6f 152
emh203 0:3d9c67d97d6f 153 /**
emh203 0:3d9c67d97d6f 154 * @brief Core function for the Q15 CFFT butterfly process.
emh203 0:3d9c67d97d6f 155 * @param[in, out] *pSrc16 points to the in-place buffer of Q15 data type.
emh203 0:3d9c67d97d6f 156 * @param[in] fftLen length of the FFT.
emh203 0:3d9c67d97d6f 157 * @param[in] *pCoef16 points to twiddle coefficient buffer.
emh203 0:3d9c67d97d6f 158 * @param[in] twidCoefModifier twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table.
emh203 0:3d9c67d97d6f 159 * @return none.
emh203 0:3d9c67d97d6f 160 */
emh203 0:3d9c67d97d6f 161
emh203 0:3d9c67d97d6f 162 void arm_radix4_butterfly_q15(
emh203 0:3d9c67d97d6f 163 q15_t * pSrc16,
emh203 0:3d9c67d97d6f 164 uint32_t fftLen,
emh203 0:3d9c67d97d6f 165 q15_t * pCoef16,
emh203 0:3d9c67d97d6f 166 uint32_t twidCoefModifier)
emh203 0:3d9c67d97d6f 167 {
emh203 0:3d9c67d97d6f 168
emh203 0:3d9c67d97d6f 169 #ifndef ARM_MATH_CM0_FAMILY
emh203 0:3d9c67d97d6f 170
emh203 0:3d9c67d97d6f 171 /* Run the below code for Cortex-M4 and Cortex-M3 */
emh203 0:3d9c67d97d6f 172
emh203 0:3d9c67d97d6f 173 q31_t R, S, T, U;
emh203 0:3d9c67d97d6f 174 q31_t C1, C2, C3, out1, out2;
emh203 0:3d9c67d97d6f 175 uint32_t n1, n2, ic, i0, i1, i2, i3, j, k;
emh203 0:3d9c67d97d6f 176 q15_t in;
emh203 0:3d9c67d97d6f 177
emh203 0:3d9c67d97d6f 178 q15_t *ptr1;
emh203 0:3d9c67d97d6f 179
emh203 0:3d9c67d97d6f 180
emh203 0:3d9c67d97d6f 181
emh203 0:3d9c67d97d6f 182 q31_t xaya, xbyb, xcyc, xdyd;
emh203 0:3d9c67d97d6f 183
emh203 0:3d9c67d97d6f 184 /* Total process is divided into three stages */
emh203 0:3d9c67d97d6f 185
emh203 0:3d9c67d97d6f 186 /* process first stage, middle stages, & last stage */
emh203 0:3d9c67d97d6f 187
emh203 0:3d9c67d97d6f 188 /* Initializations for the first stage */
emh203 0:3d9c67d97d6f 189 n2 = fftLen;
emh203 0:3d9c67d97d6f 190 n1 = n2;
emh203 0:3d9c67d97d6f 191
emh203 0:3d9c67d97d6f 192 /* n2 = fftLen/4 */
emh203 0:3d9c67d97d6f 193 n2 >>= 2u;
emh203 0:3d9c67d97d6f 194
emh203 0:3d9c67d97d6f 195 /* Index for twiddle coefficient */
emh203 0:3d9c67d97d6f 196 ic = 0u;
emh203 0:3d9c67d97d6f 197
emh203 0:3d9c67d97d6f 198 /* Index for input read and output write */
emh203 0:3d9c67d97d6f 199 i0 = 0u;
emh203 0:3d9c67d97d6f 200 j = n2;
emh203 0:3d9c67d97d6f 201
emh203 0:3d9c67d97d6f 202 /* Input is in 1.15(q15) format */
emh203 0:3d9c67d97d6f 203
emh203 0:3d9c67d97d6f 204 /* start of first stage process */
emh203 0:3d9c67d97d6f 205 do
emh203 0:3d9c67d97d6f 206 {
emh203 0:3d9c67d97d6f 207 /* Butterfly implementation */
emh203 0:3d9c67d97d6f 208
emh203 0:3d9c67d97d6f 209 /* index calculation for the input as, */
emh203 0:3d9c67d97d6f 210 /* pSrc16[i0 + 0], pSrc16[i0 + fftLen/4], pSrc16[i0 + fftLen/2], pSrc16[i0 + 3fftLen/4] */
emh203 0:3d9c67d97d6f 211 i1 = i0 + n2;
emh203 0:3d9c67d97d6f 212 i2 = i1 + n2;
emh203 0:3d9c67d97d6f 213 i3 = i2 + n2;
emh203 0:3d9c67d97d6f 214
emh203 0:3d9c67d97d6f 215 /* Reading i0, i0+fftLen/2 inputs */
emh203 0:3d9c67d97d6f 216 /* Read ya (real), xa(imag) input */
emh203 0:3d9c67d97d6f 217 T = _SIMD32_OFFSET(pSrc16 + (2u * i0));
emh203 0:3d9c67d97d6f 218 in = ((int16_t) (T & 0xFFFF)) >> 2;
emh203 0:3d9c67d97d6f 219 T = ((T >> 2) & 0xFFFF0000) | (in & 0xFFFF);
emh203 0:3d9c67d97d6f 220
emh203 0:3d9c67d97d6f 221 /* Read yc (real), xc(imag) input */
emh203 0:3d9c67d97d6f 222 S = _SIMD32_OFFSET(pSrc16 + (2u * i2));
emh203 0:3d9c67d97d6f 223 in = ((int16_t) (S & 0xFFFF)) >> 2;
emh203 0:3d9c67d97d6f 224 S = ((S >> 2) & 0xFFFF0000) | (in & 0xFFFF);
emh203 0:3d9c67d97d6f 225
emh203 0:3d9c67d97d6f 226 /* R = packed((ya + yc), (xa + xc) ) */
emh203 0:3d9c67d97d6f 227 R = __QADD16(T, S);
emh203 0:3d9c67d97d6f 228
emh203 0:3d9c67d97d6f 229 /* S = packed((ya - yc), (xa - xc) ) */
emh203 0:3d9c67d97d6f 230 S = __QSUB16(T, S);
emh203 0:3d9c67d97d6f 231
emh203 0:3d9c67d97d6f 232 /* Reading i0+fftLen/4 , i0+3fftLen/4 inputs */
emh203 0:3d9c67d97d6f 233 /* Read yb (real), xb(imag) input */
emh203 0:3d9c67d97d6f 234 T = _SIMD32_OFFSET(pSrc16 + (2u * i1));
emh203 0:3d9c67d97d6f 235 in = ((int16_t) (T & 0xFFFF)) >> 2;
emh203 0:3d9c67d97d6f 236 T = ((T >> 2) & 0xFFFF0000) | (in & 0xFFFF);
emh203 0:3d9c67d97d6f 237
emh203 0:3d9c67d97d6f 238 /* Read yd (real), xd(imag) input */
emh203 0:3d9c67d97d6f 239 U = _SIMD32_OFFSET(pSrc16 + (2u * i3));
emh203 0:3d9c67d97d6f 240 in = ((int16_t) (U & 0xFFFF)) >> 2;
emh203 0:3d9c67d97d6f 241 U = ((U >> 2) & 0xFFFF0000) | (in & 0xFFFF);
emh203 0:3d9c67d97d6f 242
emh203 0:3d9c67d97d6f 243 /* T = packed((yb + yd), (xb + xd) ) */
emh203 0:3d9c67d97d6f 244 T = __QADD16(T, U);
emh203 0:3d9c67d97d6f 245
emh203 0:3d9c67d97d6f 246 /* writing the butterfly processed i0 sample */
emh203 0:3d9c67d97d6f 247 /* xa' = xa + xb + xc + xd */
emh203 0:3d9c67d97d6f 248 /* ya' = ya + yb + yc + yd */
emh203 0:3d9c67d97d6f 249 _SIMD32_OFFSET(pSrc16 + (2u * i0)) = __SHADD16(R, T);
emh203 0:3d9c67d97d6f 250
emh203 0:3d9c67d97d6f 251 /* R = packed((ya + yc) - (yb + yd), (xa + xc)- (xb + xd)) */
emh203 0:3d9c67d97d6f 252 R = __QSUB16(R, T);
emh203 0:3d9c67d97d6f 253
emh203 0:3d9c67d97d6f 254 /* co2 & si2 are read from SIMD Coefficient pointer */
emh203 0:3d9c67d97d6f 255 C2 = _SIMD32_OFFSET(pCoef16 + (4u * ic));
emh203 0:3d9c67d97d6f 256
emh203 0:3d9c67d97d6f 257 #ifndef ARM_MATH_BIG_ENDIAN
emh203 0:3d9c67d97d6f 258
emh203 0:3d9c67d97d6f 259 /* xc' = (xa-xb+xc-xd)* co2 + (ya-yb+yc-yd)* (si2) */
emh203 0:3d9c67d97d6f 260 out1 = __SMUAD(C2, R) >> 16u;
emh203 0:3d9c67d97d6f 261 /* yc' = (ya-yb+yc-yd)* co2 - (xa-xb+xc-xd)* (si2) */
emh203 0:3d9c67d97d6f 262 out2 = __SMUSDX(C2, R);
emh203 0:3d9c67d97d6f 263
emh203 0:3d9c67d97d6f 264 #else
emh203 0:3d9c67d97d6f 265
emh203 0:3d9c67d97d6f 266 /* xc' = (ya-yb+yc-yd)* co2 - (xa-xb+xc-xd)* (si2) */
emh203 0:3d9c67d97d6f 267 out1 = __SMUSDX(R, C2) >> 16u;
emh203 0:3d9c67d97d6f 268 /* yc' = (xa-xb+xc-xd)* co2 + (ya-yb+yc-yd)* (si2) */
emh203 0:3d9c67d97d6f 269 out2 = __SMUAD(C2, R);
emh203 0:3d9c67d97d6f 270
emh203 0:3d9c67d97d6f 271 #endif /* #ifndef ARM_MATH_BIG_ENDIAN */
emh203 0:3d9c67d97d6f 272
emh203 0:3d9c67d97d6f 273 /* Reading i0+fftLen/4 */
emh203 0:3d9c67d97d6f 274 /* T = packed(yb, xb) */
emh203 0:3d9c67d97d6f 275 T = _SIMD32_OFFSET(pSrc16 + (2u * i1));
emh203 0:3d9c67d97d6f 276 in = ((int16_t) (T & 0xFFFF)) >> 2;
emh203 0:3d9c67d97d6f 277 T = ((T >> 2) & 0xFFFF0000) | (in & 0xFFFF);
emh203 0:3d9c67d97d6f 278
emh203 0:3d9c67d97d6f 279 /* writing the butterfly processed i0 + fftLen/4 sample */
emh203 0:3d9c67d97d6f 280 /* writing output(xc', yc') in little endian format */
emh203 0:3d9c67d97d6f 281 _SIMD32_OFFSET(pSrc16 + (2u * i1)) =
emh203 0:3d9c67d97d6f 282 (q31_t) ((out2) & 0xFFFF0000) | (out1 & 0x0000FFFF);
emh203 0:3d9c67d97d6f 283
emh203 0:3d9c67d97d6f 284 /* Butterfly calculations */
emh203 0:3d9c67d97d6f 285 /* U = packed(yd, xd) */
emh203 0:3d9c67d97d6f 286 U = _SIMD32_OFFSET(pSrc16 + (2u * i3));
emh203 0:3d9c67d97d6f 287 in = ((int16_t) (U & 0xFFFF)) >> 2;
emh203 0:3d9c67d97d6f 288 U = ((U >> 2) & 0xFFFF0000) | (in & 0xFFFF);
emh203 0:3d9c67d97d6f 289
emh203 0:3d9c67d97d6f 290 /* T = packed(yb-yd, xb-xd) */
emh203 0:3d9c67d97d6f 291 T = __QSUB16(T, U);
emh203 0:3d9c67d97d6f 292
emh203 0:3d9c67d97d6f 293 #ifndef ARM_MATH_BIG_ENDIAN
emh203 0:3d9c67d97d6f 294
emh203 0:3d9c67d97d6f 295 /* R = packed((ya-yc) + (xb- xd) , (xa-xc) - (yb-yd)) */
emh203 0:3d9c67d97d6f 296 R = __QASX(S, T);
emh203 0:3d9c67d97d6f 297 /* S = packed((ya-yc) - (xb- xd), (xa-xc) + (yb-yd)) */
emh203 0:3d9c67d97d6f 298 S = __QSAX(S, T);
emh203 0:3d9c67d97d6f 299
emh203 0:3d9c67d97d6f 300 #else
emh203 0:3d9c67d97d6f 301
emh203 0:3d9c67d97d6f 302 /* R = packed((ya-yc) + (xb- xd) , (xa-xc) - (yb-yd)) */
emh203 0:3d9c67d97d6f 303 R = __QSAX(S, T);
emh203 0:3d9c67d97d6f 304 /* S = packed((ya-yc) - (xb- xd), (xa-xc) + (yb-yd)) */
emh203 0:3d9c67d97d6f 305 S = __QASX(S, T);
emh203 0:3d9c67d97d6f 306
emh203 0:3d9c67d97d6f 307 #endif /* #ifndef ARM_MATH_BIG_ENDIAN */
emh203 0:3d9c67d97d6f 308
emh203 0:3d9c67d97d6f 309 /* co1 & si1 are read from SIMD Coefficient pointer */
emh203 0:3d9c67d97d6f 310 C1 = _SIMD32_OFFSET(pCoef16 + (2u * ic));
emh203 0:3d9c67d97d6f 311 /* Butterfly process for the i0+fftLen/2 sample */
emh203 0:3d9c67d97d6f 312
emh203 0:3d9c67d97d6f 313 #ifndef ARM_MATH_BIG_ENDIAN
emh203 0:3d9c67d97d6f 314
emh203 0:3d9c67d97d6f 315 /* xb' = (xa+yb-xc-yd)* co1 + (ya-xb-yc+xd)* (si1) */
emh203 0:3d9c67d97d6f 316 out1 = __SMUAD(C1, S) >> 16u;
emh203 0:3d9c67d97d6f 317 /* yb' = (ya-xb-yc+xd)* co1 - (xa+yb-xc-yd)* (si1) */
emh203 0:3d9c67d97d6f 318 out2 = __SMUSDX(C1, S);
emh203 0:3d9c67d97d6f 319
emh203 0:3d9c67d97d6f 320 #else
emh203 0:3d9c67d97d6f 321
emh203 0:3d9c67d97d6f 322 /* xb' = (ya-xb-yc+xd)* co1 - (xa+yb-xc-yd)* (si1) */
emh203 0:3d9c67d97d6f 323 out1 = __SMUSDX(S, C1) >> 16u;
emh203 0:3d9c67d97d6f 324 /* yb' = (xa+yb-xc-yd)* co1 + (ya-xb-yc+xd)* (si1) */
emh203 0:3d9c67d97d6f 325 out2 = __SMUAD(C1, S);
emh203 0:3d9c67d97d6f 326
emh203 0:3d9c67d97d6f 327 #endif /* #ifndef ARM_MATH_BIG_ENDIAN */
emh203 0:3d9c67d97d6f 328
emh203 0:3d9c67d97d6f 329 /* writing output(xb', yb') in little endian format */
emh203 0:3d9c67d97d6f 330 _SIMD32_OFFSET(pSrc16 + (2u * i2)) =
emh203 0:3d9c67d97d6f 331 ((out2) & 0xFFFF0000) | ((out1) & 0x0000FFFF);
emh203 0:3d9c67d97d6f 332
emh203 0:3d9c67d97d6f 333
emh203 0:3d9c67d97d6f 334 /* co3 & si3 are read from SIMD Coefficient pointer */
emh203 0:3d9c67d97d6f 335 C3 = _SIMD32_OFFSET(pCoef16 + (6u * ic));
emh203 0:3d9c67d97d6f 336 /* Butterfly process for the i0+3fftLen/4 sample */
emh203 0:3d9c67d97d6f 337
emh203 0:3d9c67d97d6f 338 #ifndef ARM_MATH_BIG_ENDIAN
emh203 0:3d9c67d97d6f 339
emh203 0:3d9c67d97d6f 340 /* xd' = (xa-yb-xc+yd)* co3 + (ya+xb-yc-xd)* (si3) */
emh203 0:3d9c67d97d6f 341 out1 = __SMUAD(C3, R) >> 16u;
emh203 0:3d9c67d97d6f 342 /* yd' = (ya+xb-yc-xd)* co3 - (xa-yb-xc+yd)* (si3) */
emh203 0:3d9c67d97d6f 343 out2 = __SMUSDX(C3, R);
emh203 0:3d9c67d97d6f 344
emh203 0:3d9c67d97d6f 345 #else
emh203 0:3d9c67d97d6f 346
emh203 0:3d9c67d97d6f 347 /* xd' = (ya+xb-yc-xd)* co3 - (xa-yb-xc+yd)* (si3) */
emh203 0:3d9c67d97d6f 348 out1 = __SMUSDX(R, C3) >> 16u;
emh203 0:3d9c67d97d6f 349 /* yd' = (xa-yb-xc+yd)* co3 + (ya+xb-yc-xd)* (si3) */
emh203 0:3d9c67d97d6f 350 out2 = __SMUAD(C3, R);
emh203 0:3d9c67d97d6f 351
emh203 0:3d9c67d97d6f 352 #endif /* #ifndef ARM_MATH_BIG_ENDIAN */
emh203 0:3d9c67d97d6f 353
emh203 0:3d9c67d97d6f 354 /* writing output(xd', yd') in little endian format */
emh203 0:3d9c67d97d6f 355 _SIMD32_OFFSET(pSrc16 + (2u * i3)) =
emh203 0:3d9c67d97d6f 356 ((out2) & 0xFFFF0000) | (out1 & 0x0000FFFF);
emh203 0:3d9c67d97d6f 357
emh203 0:3d9c67d97d6f 358 /* Twiddle coefficients index modifier */
emh203 0:3d9c67d97d6f 359 ic = ic + twidCoefModifier;
emh203 0:3d9c67d97d6f 360
emh203 0:3d9c67d97d6f 361 /* Updating input index */
emh203 0:3d9c67d97d6f 362 i0 = i0 + 1u;
emh203 0:3d9c67d97d6f 363
emh203 0:3d9c67d97d6f 364 } while(--j);
emh203 0:3d9c67d97d6f 365 /* data is in 4.11(q11) format */
emh203 0:3d9c67d97d6f 366
emh203 0:3d9c67d97d6f 367 /* end of first stage process */
emh203 0:3d9c67d97d6f 368
emh203 0:3d9c67d97d6f 369
emh203 0:3d9c67d97d6f 370 /* start of middle stage process */
emh203 0:3d9c67d97d6f 371
emh203 0:3d9c67d97d6f 372 /* Twiddle coefficients index modifier */
emh203 0:3d9c67d97d6f 373 twidCoefModifier <<= 2u;
emh203 0:3d9c67d97d6f 374
emh203 0:3d9c67d97d6f 375 /* Calculation of Middle stage */
emh203 0:3d9c67d97d6f 376 for (k = fftLen / 4u; k > 4u; k >>= 2u)
emh203 0:3d9c67d97d6f 377 {
emh203 0:3d9c67d97d6f 378 /* Initializations for the middle stage */
emh203 0:3d9c67d97d6f 379 n1 = n2;
emh203 0:3d9c67d97d6f 380 n2 >>= 2u;
emh203 0:3d9c67d97d6f 381 ic = 0u;
emh203 0:3d9c67d97d6f 382
emh203 0:3d9c67d97d6f 383 for (j = 0u; j <= (n2 - 1u); j++)
emh203 0:3d9c67d97d6f 384 {
emh203 0:3d9c67d97d6f 385 /* index calculation for the coefficients */
emh203 0:3d9c67d97d6f 386 C1 = _SIMD32_OFFSET(pCoef16 + (2u * ic));
emh203 0:3d9c67d97d6f 387 C2 = _SIMD32_OFFSET(pCoef16 + (4u * ic));
emh203 0:3d9c67d97d6f 388 C3 = _SIMD32_OFFSET(pCoef16 + (6u * ic));
emh203 0:3d9c67d97d6f 389
emh203 0:3d9c67d97d6f 390 /* Twiddle coefficients index modifier */
emh203 0:3d9c67d97d6f 391 ic = ic + twidCoefModifier;
emh203 0:3d9c67d97d6f 392
emh203 0:3d9c67d97d6f 393 /* Butterfly implementation */
emh203 0:3d9c67d97d6f 394 for (i0 = j; i0 < fftLen; i0 += n1)
emh203 0:3d9c67d97d6f 395 {
emh203 0:3d9c67d97d6f 396 /* index calculation for the input as, */
emh203 0:3d9c67d97d6f 397 /* pSrc16[i0 + 0], pSrc16[i0 + fftLen/4], pSrc16[i0 + fftLen/2], pSrc16[i0 + 3fftLen/4] */
emh203 0:3d9c67d97d6f 398 i1 = i0 + n2;
emh203 0:3d9c67d97d6f 399 i2 = i1 + n2;
emh203 0:3d9c67d97d6f 400 i3 = i2 + n2;
emh203 0:3d9c67d97d6f 401
emh203 0:3d9c67d97d6f 402 /* Reading i0, i0+fftLen/2 inputs */
emh203 0:3d9c67d97d6f 403 /* Read ya (real), xa(imag) input */
emh203 0:3d9c67d97d6f 404 T = _SIMD32_OFFSET(pSrc16 + (2u * i0));
emh203 0:3d9c67d97d6f 405
emh203 0:3d9c67d97d6f 406 /* Read yc (real), xc(imag) input */
emh203 0:3d9c67d97d6f 407 S = _SIMD32_OFFSET(pSrc16 + (2u * i2));
emh203 0:3d9c67d97d6f 408
emh203 0:3d9c67d97d6f 409 /* R = packed( (ya + yc), (xa + xc)) */
emh203 0:3d9c67d97d6f 410 R = __QADD16(T, S);
emh203 0:3d9c67d97d6f 411
emh203 0:3d9c67d97d6f 412 /* S = packed((ya - yc), (xa - xc)) */
emh203 0:3d9c67d97d6f 413 S = __QSUB16(T, S);
emh203 0:3d9c67d97d6f 414
emh203 0:3d9c67d97d6f 415 /* Reading i0+fftLen/4 , i0+3fftLen/4 inputs */
emh203 0:3d9c67d97d6f 416 /* Read yb (real), xb(imag) input */
emh203 0:3d9c67d97d6f 417 T = _SIMD32_OFFSET(pSrc16 + (2u * i1));
emh203 0:3d9c67d97d6f 418
emh203 0:3d9c67d97d6f 419 /* Read yd (real), xd(imag) input */
emh203 0:3d9c67d97d6f 420 U = _SIMD32_OFFSET(pSrc16 + (2u * i3));
emh203 0:3d9c67d97d6f 421
emh203 0:3d9c67d97d6f 422 /* T = packed( (yb + yd), (xb + xd)) */
emh203 0:3d9c67d97d6f 423 T = __QADD16(T, U);
emh203 0:3d9c67d97d6f 424
emh203 0:3d9c67d97d6f 425 /* writing the butterfly processed i0 sample */
emh203 0:3d9c67d97d6f 426
emh203 0:3d9c67d97d6f 427 /* xa' = xa + xb + xc + xd */
emh203 0:3d9c67d97d6f 428 /* ya' = ya + yb + yc + yd */
emh203 0:3d9c67d97d6f 429 out1 = __SHADD16(R, T);
emh203 0:3d9c67d97d6f 430 in = ((int16_t) (out1 & 0xFFFF)) >> 1;
emh203 0:3d9c67d97d6f 431 out1 = ((out1 >> 1) & 0xFFFF0000) | (in & 0xFFFF);
emh203 0:3d9c67d97d6f 432 _SIMD32_OFFSET(pSrc16 + (2u * i0)) = out1;
emh203 0:3d9c67d97d6f 433
emh203 0:3d9c67d97d6f 434 /* R = packed( (ya + yc) - (yb + yd), (xa + xc) - (xb + xd)) */
emh203 0:3d9c67d97d6f 435 R = __SHSUB16(R, T);
emh203 0:3d9c67d97d6f 436
emh203 0:3d9c67d97d6f 437 #ifndef ARM_MATH_BIG_ENDIAN
emh203 0:3d9c67d97d6f 438
emh203 0:3d9c67d97d6f 439 /* (ya-yb+yc-yd)* (si2) + (xa-xb+xc-xd)* co2 */
emh203 0:3d9c67d97d6f 440 out1 = __SMUAD(C2, R) >> 16u;
emh203 0:3d9c67d97d6f 441
emh203 0:3d9c67d97d6f 442 /* (ya-yb+yc-yd)* co2 - (xa-xb+xc-xd)* (si2) */
emh203 0:3d9c67d97d6f 443 out2 = __SMUSDX(C2, R);
emh203 0:3d9c67d97d6f 444
emh203 0:3d9c67d97d6f 445 #else
emh203 0:3d9c67d97d6f 446
emh203 0:3d9c67d97d6f 447 /* (ya-yb+yc-yd)* co2 - (xa-xb+xc-xd)* (si2) */
emh203 0:3d9c67d97d6f 448 out1 = __SMUSDX(R, C2) >> 16u;
emh203 0:3d9c67d97d6f 449
emh203 0:3d9c67d97d6f 450 /* (ya-yb+yc-yd)* (si2) + (xa-xb+xc-xd)* co2 */
emh203 0:3d9c67d97d6f 451 out2 = __SMUAD(C2, R);
emh203 0:3d9c67d97d6f 452
emh203 0:3d9c67d97d6f 453 #endif /* #ifndef ARM_MATH_BIG_ENDIAN */
emh203 0:3d9c67d97d6f 454
emh203 0:3d9c67d97d6f 455 /* Reading i0+3fftLen/4 */
emh203 0:3d9c67d97d6f 456 /* Read yb (real), xb(imag) input */
emh203 0:3d9c67d97d6f 457 T = _SIMD32_OFFSET(pSrc16 + (2u * i1));
emh203 0:3d9c67d97d6f 458
emh203 0:3d9c67d97d6f 459 /* writing the butterfly processed i0 + fftLen/4 sample */
emh203 0:3d9c67d97d6f 460 /* xc' = (xa-xb+xc-xd)* co2 + (ya-yb+yc-yd)* (si2) */
emh203 0:3d9c67d97d6f 461 /* yc' = (ya-yb+yc-yd)* co2 - (xa-xb+xc-xd)* (si2) */
emh203 0:3d9c67d97d6f 462 _SIMD32_OFFSET(pSrc16 + (2u * i1)) =
emh203 0:3d9c67d97d6f 463 ((out2) & 0xFFFF0000) | (out1 & 0x0000FFFF);
emh203 0:3d9c67d97d6f 464
emh203 0:3d9c67d97d6f 465 /* Butterfly calculations */
emh203 0:3d9c67d97d6f 466
emh203 0:3d9c67d97d6f 467 /* Read yd (real), xd(imag) input */
emh203 0:3d9c67d97d6f 468 U = _SIMD32_OFFSET(pSrc16 + (2u * i3));
emh203 0:3d9c67d97d6f 469
emh203 0:3d9c67d97d6f 470 /* T = packed(yb-yd, xb-xd) */
emh203 0:3d9c67d97d6f 471 T = __QSUB16(T, U);
emh203 0:3d9c67d97d6f 472
emh203 0:3d9c67d97d6f 473 #ifndef ARM_MATH_BIG_ENDIAN
emh203 0:3d9c67d97d6f 474
emh203 0:3d9c67d97d6f 475 /* R = packed((ya-yc) + (xb- xd) , (xa-xc) - (yb-yd)) */
emh203 0:3d9c67d97d6f 476 R = __SHASX(S, T);
emh203 0:3d9c67d97d6f 477
emh203 0:3d9c67d97d6f 478 /* S = packed((ya-yc) - (xb- xd), (xa-xc) + (yb-yd)) */
emh203 0:3d9c67d97d6f 479 S = __SHSAX(S, T);
emh203 0:3d9c67d97d6f 480
emh203 0:3d9c67d97d6f 481
emh203 0:3d9c67d97d6f 482 /* Butterfly process for the i0+fftLen/2 sample */
emh203 0:3d9c67d97d6f 483 out1 = __SMUAD(C1, S) >> 16u;
emh203 0:3d9c67d97d6f 484 out2 = __SMUSDX(C1, S);
emh203 0:3d9c67d97d6f 485
emh203 0:3d9c67d97d6f 486 #else
emh203 0:3d9c67d97d6f 487
emh203 0:3d9c67d97d6f 488 /* R = packed((ya-yc) + (xb- xd) , (xa-xc) - (yb-yd)) */
emh203 0:3d9c67d97d6f 489 R = __SHSAX(S, T);
emh203 0:3d9c67d97d6f 490
emh203 0:3d9c67d97d6f 491 /* S = packed((ya-yc) - (xb- xd), (xa-xc) + (yb-yd)) */
emh203 0:3d9c67d97d6f 492 S = __SHASX(S, T);
emh203 0:3d9c67d97d6f 493
emh203 0:3d9c67d97d6f 494
emh203 0:3d9c67d97d6f 495 /* Butterfly process for the i0+fftLen/2 sample */
emh203 0:3d9c67d97d6f 496 out1 = __SMUSDX(S, C1) >> 16u;
emh203 0:3d9c67d97d6f 497 out2 = __SMUAD(C1, S);
emh203 0:3d9c67d97d6f 498
emh203 0:3d9c67d97d6f 499 #endif /* #ifndef ARM_MATH_BIG_ENDIAN */
emh203 0:3d9c67d97d6f 500
emh203 0:3d9c67d97d6f 501 /* xb' = (xa+yb-xc-yd)* co1 + (ya-xb-yc+xd)* (si1) */
emh203 0:3d9c67d97d6f 502 /* yb' = (ya-xb-yc+xd)* co1 - (xa+yb-xc-yd)* (si1) */
emh203 0:3d9c67d97d6f 503 _SIMD32_OFFSET(pSrc16 + (2u * i2)) =
emh203 0:3d9c67d97d6f 504 ((out2) & 0xFFFF0000) | (out1 & 0x0000FFFF);
emh203 0:3d9c67d97d6f 505
emh203 0:3d9c67d97d6f 506 /* Butterfly process for the i0+3fftLen/4 sample */
emh203 0:3d9c67d97d6f 507
emh203 0:3d9c67d97d6f 508 #ifndef ARM_MATH_BIG_ENDIAN
emh203 0:3d9c67d97d6f 509
emh203 0:3d9c67d97d6f 510 out1 = __SMUAD(C3, R) >> 16u;
emh203 0:3d9c67d97d6f 511 out2 = __SMUSDX(C3, R);
emh203 0:3d9c67d97d6f 512
emh203 0:3d9c67d97d6f 513 #else
emh203 0:3d9c67d97d6f 514
emh203 0:3d9c67d97d6f 515 out1 = __SMUSDX(R, C3) >> 16u;
emh203 0:3d9c67d97d6f 516 out2 = __SMUAD(C3, R);
emh203 0:3d9c67d97d6f 517
emh203 0:3d9c67d97d6f 518 #endif /* #ifndef ARM_MATH_BIG_ENDIAN */
emh203 0:3d9c67d97d6f 519
emh203 0:3d9c67d97d6f 520 /* xd' = (xa-yb-xc+yd)* co3 + (ya+xb-yc-xd)* (si3) */
emh203 0:3d9c67d97d6f 521 /* yd' = (ya+xb-yc-xd)* co3 - (xa-yb-xc+yd)* (si3) */
emh203 0:3d9c67d97d6f 522 _SIMD32_OFFSET(pSrc16 + (2u * i3)) =
emh203 0:3d9c67d97d6f 523 ((out2) & 0xFFFF0000) | (out1 & 0x0000FFFF);
emh203 0:3d9c67d97d6f 524 }
emh203 0:3d9c67d97d6f 525 }
emh203 0:3d9c67d97d6f 526 /* Twiddle coefficients index modifier */
emh203 0:3d9c67d97d6f 527 twidCoefModifier <<= 2u;
emh203 0:3d9c67d97d6f 528 }
emh203 0:3d9c67d97d6f 529 /* end of middle stage process */
emh203 0:3d9c67d97d6f 530
emh203 0:3d9c67d97d6f 531
emh203 0:3d9c67d97d6f 532 /* data is in 10.6(q6) format for the 1024 point */
emh203 0:3d9c67d97d6f 533 /* data is in 8.8(q8) format for the 256 point */
emh203 0:3d9c67d97d6f 534 /* data is in 6.10(q10) format for the 64 point */
emh203 0:3d9c67d97d6f 535 /* data is in 4.12(q12) format for the 16 point */
emh203 0:3d9c67d97d6f 536
emh203 0:3d9c67d97d6f 537 /* Initializations for the last stage */
emh203 0:3d9c67d97d6f 538 j = fftLen >> 2;
emh203 0:3d9c67d97d6f 539
emh203 0:3d9c67d97d6f 540 ptr1 = &pSrc16[0];
emh203 0:3d9c67d97d6f 541
emh203 0:3d9c67d97d6f 542 /* start of last stage process */
emh203 0:3d9c67d97d6f 543
emh203 0:3d9c67d97d6f 544 /* Butterfly implementation */
emh203 0:3d9c67d97d6f 545 do
emh203 0:3d9c67d97d6f 546 {
emh203 0:3d9c67d97d6f 547 /* Read xa (real), ya(imag) input */
emh203 0:3d9c67d97d6f 548 xaya = *__SIMD32(ptr1)++;
emh203 0:3d9c67d97d6f 549
emh203 0:3d9c67d97d6f 550 /* Read xb (real), yb(imag) input */
emh203 0:3d9c67d97d6f 551 xbyb = *__SIMD32(ptr1)++;
emh203 0:3d9c67d97d6f 552
emh203 0:3d9c67d97d6f 553 /* Read xc (real), yc(imag) input */
emh203 0:3d9c67d97d6f 554 xcyc = *__SIMD32(ptr1)++;
emh203 0:3d9c67d97d6f 555
emh203 0:3d9c67d97d6f 556 /* Read xd (real), yd(imag) input */
emh203 0:3d9c67d97d6f 557 xdyd = *__SIMD32(ptr1)++;
emh203 0:3d9c67d97d6f 558
emh203 0:3d9c67d97d6f 559 /* R = packed((ya + yc), (xa + xc)) */
emh203 0:3d9c67d97d6f 560 R = __QADD16(xaya, xcyc);
emh203 0:3d9c67d97d6f 561
emh203 0:3d9c67d97d6f 562 /* T = packed((yb + yd), (xb + xd)) */
emh203 0:3d9c67d97d6f 563 T = __QADD16(xbyb, xdyd);
emh203 0:3d9c67d97d6f 564
emh203 0:3d9c67d97d6f 565 /* pointer updation for writing */
emh203 0:3d9c67d97d6f 566 ptr1 = ptr1 - 8u;
emh203 0:3d9c67d97d6f 567
emh203 0:3d9c67d97d6f 568
emh203 0:3d9c67d97d6f 569 /* xa' = xa + xb + xc + xd */
emh203 0:3d9c67d97d6f 570 /* ya' = ya + yb + yc + yd */
emh203 0:3d9c67d97d6f 571 *__SIMD32(ptr1)++ = __SHADD16(R, T);
emh203 0:3d9c67d97d6f 572
emh203 0:3d9c67d97d6f 573 /* T = packed((yb + yd), (xb + xd)) */
emh203 0:3d9c67d97d6f 574 T = __QADD16(xbyb, xdyd);
emh203 0:3d9c67d97d6f 575
emh203 0:3d9c67d97d6f 576 /* xc' = (xa-xb+xc-xd) */
emh203 0:3d9c67d97d6f 577 /* yc' = (ya-yb+yc-yd) */
emh203 0:3d9c67d97d6f 578 *__SIMD32(ptr1)++ = __SHSUB16(R, T);
emh203 0:3d9c67d97d6f 579
emh203 0:3d9c67d97d6f 580 /* S = packed((ya - yc), (xa - xc)) */
emh203 0:3d9c67d97d6f 581 S = __QSUB16(xaya, xcyc);
emh203 0:3d9c67d97d6f 582
emh203 0:3d9c67d97d6f 583 /* Read yd (real), xd(imag) input */
emh203 0:3d9c67d97d6f 584 /* T = packed( (yb - yd), (xb - xd)) */
emh203 0:3d9c67d97d6f 585 U = __QSUB16(xbyb, xdyd);
emh203 0:3d9c67d97d6f 586
emh203 0:3d9c67d97d6f 587 #ifndef ARM_MATH_BIG_ENDIAN
emh203 0:3d9c67d97d6f 588
emh203 0:3d9c67d97d6f 589 /* xb' = (xa+yb-xc-yd) */
emh203 0:3d9c67d97d6f 590 /* yb' = (ya-xb-yc+xd) */
emh203 0:3d9c67d97d6f 591 *__SIMD32(ptr1)++ = __SHSAX(S, U);
emh203 0:3d9c67d97d6f 592
emh203 0:3d9c67d97d6f 593
emh203 0:3d9c67d97d6f 594 /* xd' = (xa-yb-xc+yd) */
emh203 0:3d9c67d97d6f 595 /* yd' = (ya+xb-yc-xd) */
emh203 0:3d9c67d97d6f 596 *__SIMD32(ptr1)++ = __SHASX(S, U);
emh203 0:3d9c67d97d6f 597
emh203 0:3d9c67d97d6f 598 #else
emh203 0:3d9c67d97d6f 599
emh203 0:3d9c67d97d6f 600 /* xb' = (xa+yb-xc-yd) */
emh203 0:3d9c67d97d6f 601 /* yb' = (ya-xb-yc+xd) */
emh203 0:3d9c67d97d6f 602 *__SIMD32(ptr1)++ = __SHASX(S, U);
emh203 0:3d9c67d97d6f 603
emh203 0:3d9c67d97d6f 604
emh203 0:3d9c67d97d6f 605 /* xd' = (xa-yb-xc+yd) */
emh203 0:3d9c67d97d6f 606 /* yd' = (ya+xb-yc-xd) */
emh203 0:3d9c67d97d6f 607 *__SIMD32(ptr1)++ = __SHSAX(S, U);
emh203 0:3d9c67d97d6f 608
emh203 0:3d9c67d97d6f 609 #endif /* #ifndef ARM_MATH_BIG_ENDIAN */
emh203 0:3d9c67d97d6f 610
emh203 0:3d9c67d97d6f 611 } while(--j);
emh203 0:3d9c67d97d6f 612
emh203 0:3d9c67d97d6f 613 /* end of last stage process */
emh203 0:3d9c67d97d6f 614
emh203 0:3d9c67d97d6f 615 /* output is in 11.5(q5) format for the 1024 point */
emh203 0:3d9c67d97d6f 616 /* output is in 9.7(q7) format for the 256 point */
emh203 0:3d9c67d97d6f 617 /* output is in 7.9(q9) format for the 64 point */
emh203 0:3d9c67d97d6f 618 /* output is in 5.11(q11) format for the 16 point */
emh203 0:3d9c67d97d6f 619
emh203 0:3d9c67d97d6f 620
emh203 0:3d9c67d97d6f 621 #else
emh203 0:3d9c67d97d6f 622
emh203 0:3d9c67d97d6f 623 /* Run the below code for Cortex-M0 */
emh203 0:3d9c67d97d6f 624
emh203 0:3d9c67d97d6f 625 q15_t R0, R1, S0, S1, T0, T1, U0, U1;
emh203 0:3d9c67d97d6f 626 q15_t Co1, Si1, Co2, Si2, Co3, Si3, out1, out2;
emh203 0:3d9c67d97d6f 627 uint32_t n1, n2, ic, i0, i1, i2, i3, j, k;
emh203 0:3d9c67d97d6f 628
emh203 0:3d9c67d97d6f 629 /* Total process is divided into three stages */
emh203 0:3d9c67d97d6f 630
emh203 0:3d9c67d97d6f 631 /* process first stage, middle stages, & last stage */
emh203 0:3d9c67d97d6f 632
emh203 0:3d9c67d97d6f 633 /* Initializations for the first stage */
emh203 0:3d9c67d97d6f 634 n2 = fftLen;
emh203 0:3d9c67d97d6f 635 n1 = n2;
emh203 0:3d9c67d97d6f 636
emh203 0:3d9c67d97d6f 637 /* n2 = fftLen/4 */
emh203 0:3d9c67d97d6f 638 n2 >>= 2u;
emh203 0:3d9c67d97d6f 639
emh203 0:3d9c67d97d6f 640 /* Index for twiddle coefficient */
emh203 0:3d9c67d97d6f 641 ic = 0u;
emh203 0:3d9c67d97d6f 642
emh203 0:3d9c67d97d6f 643 /* Index for input read and output write */
emh203 0:3d9c67d97d6f 644 i0 = 0u;
emh203 0:3d9c67d97d6f 645 j = n2;
emh203 0:3d9c67d97d6f 646
emh203 0:3d9c67d97d6f 647 /* Input is in 1.15(q15) format */
emh203 0:3d9c67d97d6f 648
emh203 0:3d9c67d97d6f 649 /* start of first stage process */
emh203 0:3d9c67d97d6f 650 do
emh203 0:3d9c67d97d6f 651 {
emh203 0:3d9c67d97d6f 652 /* Butterfly implementation */
emh203 0:3d9c67d97d6f 653
emh203 0:3d9c67d97d6f 654 /* index calculation for the input as, */
emh203 0:3d9c67d97d6f 655 /* pSrc16[i0 + 0], pSrc16[i0 + fftLen/4], pSrc16[i0 + fftLen/2], pSrc16[i0 + 3fftLen/4] */
emh203 0:3d9c67d97d6f 656 i1 = i0 + n2;
emh203 0:3d9c67d97d6f 657 i2 = i1 + n2;
emh203 0:3d9c67d97d6f 658 i3 = i2 + n2;
emh203 0:3d9c67d97d6f 659
emh203 0:3d9c67d97d6f 660 /* Reading i0, i0+fftLen/2 inputs */
emh203 0:3d9c67d97d6f 661
emh203 0:3d9c67d97d6f 662 /* input is down scale by 4 to avoid overflow */
emh203 0:3d9c67d97d6f 663 /* Read ya (real), xa(imag) input */
emh203 0:3d9c67d97d6f 664 T0 = pSrc16[i0 * 2u] >> 2u;
emh203 0:3d9c67d97d6f 665 T1 = pSrc16[(i0 * 2u) + 1u] >> 2u;
emh203 0:3d9c67d97d6f 666
emh203 0:3d9c67d97d6f 667 /* input is down scale by 4 to avoid overflow */
emh203 0:3d9c67d97d6f 668 /* Read yc (real), xc(imag) input */
emh203 0:3d9c67d97d6f 669 S0 = pSrc16[i2 * 2u] >> 2u;
emh203 0:3d9c67d97d6f 670 S1 = pSrc16[(i2 * 2u) + 1u] >> 2u;
emh203 0:3d9c67d97d6f 671
emh203 0:3d9c67d97d6f 672 /* R0 = (ya + yc) */
emh203 0:3d9c67d97d6f 673 R0 = __SSAT(T0 + S0, 16u);
emh203 0:3d9c67d97d6f 674 /* R1 = (xa + xc) */
emh203 0:3d9c67d97d6f 675 R1 = __SSAT(T1 + S1, 16u);
emh203 0:3d9c67d97d6f 676
emh203 0:3d9c67d97d6f 677 /* S0 = (ya - yc) */
emh203 0:3d9c67d97d6f 678 S0 = __SSAT(T0 - S0, 16);
emh203 0:3d9c67d97d6f 679 /* S1 = (xa - xc) */
emh203 0:3d9c67d97d6f 680 S1 = __SSAT(T1 - S1, 16);
emh203 0:3d9c67d97d6f 681
emh203 0:3d9c67d97d6f 682 /* Reading i0+fftLen/4 , i0+3fftLen/4 inputs */
emh203 0:3d9c67d97d6f 683 /* input is down scale by 4 to avoid overflow */
emh203 0:3d9c67d97d6f 684 /* Read yb (real), xb(imag) input */
emh203 0:3d9c67d97d6f 685 T0 = pSrc16[i1 * 2u] >> 2u;
emh203 0:3d9c67d97d6f 686 T1 = pSrc16[(i1 * 2u) + 1u] >> 2u;
emh203 0:3d9c67d97d6f 687
emh203 0:3d9c67d97d6f 688 /* input is down scale by 4 to avoid overflow */
emh203 0:3d9c67d97d6f 689 /* Read yd (real), xd(imag) input */
emh203 0:3d9c67d97d6f 690 U0 = pSrc16[i3 * 2u] >> 2u;
emh203 0:3d9c67d97d6f 691 U1 = pSrc16[(i3 * 2u) + 1] >> 2u;
emh203 0:3d9c67d97d6f 692
emh203 0:3d9c67d97d6f 693 /* T0 = (yb + yd) */
emh203 0:3d9c67d97d6f 694 T0 = __SSAT(T0 + U0, 16u);
emh203 0:3d9c67d97d6f 695 /* T1 = (xb + xd) */
emh203 0:3d9c67d97d6f 696 T1 = __SSAT(T1 + U1, 16u);
emh203 0:3d9c67d97d6f 697
emh203 0:3d9c67d97d6f 698 /* writing the butterfly processed i0 sample */
emh203 0:3d9c67d97d6f 699 /* ya' = ya + yb + yc + yd */
emh203 0:3d9c67d97d6f 700 /* xa' = xa + xb + xc + xd */
emh203 0:3d9c67d97d6f 701 pSrc16[i0 * 2u] = (R0 >> 1u) + (T0 >> 1u);
emh203 0:3d9c67d97d6f 702 pSrc16[(i0 * 2u) + 1u] = (R1 >> 1u) + (T1 >> 1u);
emh203 0:3d9c67d97d6f 703
emh203 0:3d9c67d97d6f 704 /* R0 = (ya + yc) - (yb + yd) */
emh203 0:3d9c67d97d6f 705 /* R1 = (xa + xc) - (xb + xd) */
emh203 0:3d9c67d97d6f 706 R0 = __SSAT(R0 - T0, 16u);
emh203 0:3d9c67d97d6f 707 R1 = __SSAT(R1 - T1, 16u);
emh203 0:3d9c67d97d6f 708
emh203 0:3d9c67d97d6f 709 /* co2 & si2 are read from Coefficient pointer */
emh203 0:3d9c67d97d6f 710 Co2 = pCoef16[2u * ic * 2u];
emh203 0:3d9c67d97d6f 711 Si2 = pCoef16[(2u * ic * 2u) + 1];
emh203 0:3d9c67d97d6f 712
emh203 0:3d9c67d97d6f 713 /* xc' = (xa-xb+xc-xd)* co2 + (ya-yb+yc-yd)* (si2) */
emh203 0:3d9c67d97d6f 714 out1 = (q15_t) ((Co2 * R0 + Si2 * R1) >> 16u);
emh203 0:3d9c67d97d6f 715 /* yc' = (ya-yb+yc-yd)* co2 - (xa-xb+xc-xd)* (si2) */
emh203 0:3d9c67d97d6f 716 out2 = (q15_t) ((-Si2 * R0 + Co2 * R1) >> 16u);
emh203 0:3d9c67d97d6f 717
emh203 0:3d9c67d97d6f 718 /* Reading i0+fftLen/4 */
emh203 0:3d9c67d97d6f 719 /* input is down scale by 4 to avoid overflow */
emh203 0:3d9c67d97d6f 720 /* T0 = yb, T1 = xb */
emh203 0:3d9c67d97d6f 721 T0 = pSrc16[i1 * 2u] >> 2;
emh203 0:3d9c67d97d6f 722 T1 = pSrc16[(i1 * 2u) + 1] >> 2;
emh203 0:3d9c67d97d6f 723
emh203 0:3d9c67d97d6f 724 /* writing the butterfly processed i0 + fftLen/4 sample */
emh203 0:3d9c67d97d6f 725 /* writing output(xc', yc') in little endian format */
emh203 0:3d9c67d97d6f 726 pSrc16[i1 * 2u] = out1;
emh203 0:3d9c67d97d6f 727 pSrc16[(i1 * 2u) + 1] = out2;
emh203 0:3d9c67d97d6f 728
emh203 0:3d9c67d97d6f 729 /* Butterfly calculations */
emh203 0:3d9c67d97d6f 730 /* input is down scale by 4 to avoid overflow */
emh203 0:3d9c67d97d6f 731 /* U0 = yd, U1 = xd */
emh203 0:3d9c67d97d6f 732 U0 = pSrc16[i3 * 2u] >> 2;
emh203 0:3d9c67d97d6f 733 U1 = pSrc16[(i3 * 2u) + 1] >> 2;
emh203 0:3d9c67d97d6f 734 /* T0 = yb-yd */
emh203 0:3d9c67d97d6f 735 T0 = __SSAT(T0 - U0, 16);
emh203 0:3d9c67d97d6f 736 /* T1 = xb-xd */
emh203 0:3d9c67d97d6f 737 T1 = __SSAT(T1 - U1, 16);
emh203 0:3d9c67d97d6f 738
emh203 0:3d9c67d97d6f 739 /* R1 = (ya-yc) + (xb- xd), R0 = (xa-xc) - (yb-yd)) */
emh203 0:3d9c67d97d6f 740 R0 = (q15_t) __SSAT((q31_t) (S0 - T1), 16);
emh203 0:3d9c67d97d6f 741 R1 = (q15_t) __SSAT((q31_t) (S1 + T0), 16);
emh203 0:3d9c67d97d6f 742
emh203 0:3d9c67d97d6f 743 /* S1 = (ya-yc) - (xb- xd), S0 = (xa-xc) + (yb-yd)) */
emh203 0:3d9c67d97d6f 744 S0 = (q15_t) __SSAT(((q31_t) S0 + T1), 16u);
emh203 0:3d9c67d97d6f 745 S1 = (q15_t) __SSAT(((q31_t) S1 - T0), 16u);
emh203 0:3d9c67d97d6f 746
emh203 0:3d9c67d97d6f 747 /* co1 & si1 are read from Coefficient pointer */
emh203 0:3d9c67d97d6f 748 Co1 = pCoef16[ic * 2u];
emh203 0:3d9c67d97d6f 749 Si1 = pCoef16[(ic * 2u) + 1];
emh203 0:3d9c67d97d6f 750 /* Butterfly process for the i0+fftLen/2 sample */
emh203 0:3d9c67d97d6f 751 /* xb' = (xa+yb-xc-yd)* co1 + (ya-xb-yc+xd)* (si1) */
emh203 0:3d9c67d97d6f 752 out1 = (q15_t) ((Si1 * S1 + Co1 * S0) >> 16);
emh203 0:3d9c67d97d6f 753 /* yb' = (ya-xb-yc+xd)* co1 - (xa+yb-xc-yd)* (si1) */
emh203 0:3d9c67d97d6f 754 out2 = (q15_t) ((-Si1 * S0 + Co1 * S1) >> 16);
emh203 0:3d9c67d97d6f 755
emh203 0:3d9c67d97d6f 756 /* writing output(xb', yb') in little endian format */
emh203 0:3d9c67d97d6f 757 pSrc16[i2 * 2u] = out1;
emh203 0:3d9c67d97d6f 758 pSrc16[(i2 * 2u) + 1] = out2;
emh203 0:3d9c67d97d6f 759
emh203 0:3d9c67d97d6f 760 /* Co3 & si3 are read from Coefficient pointer */
emh203 0:3d9c67d97d6f 761 Co3 = pCoef16[3u * (ic * 2u)];
emh203 0:3d9c67d97d6f 762 Si3 = pCoef16[(3u * (ic * 2u)) + 1];
emh203 0:3d9c67d97d6f 763 /* Butterfly process for the i0+3fftLen/4 sample */
emh203 0:3d9c67d97d6f 764 /* xd' = (xa-yb-xc+yd)* Co3 + (ya+xb-yc-xd)* (si3) */
emh203 0:3d9c67d97d6f 765 out1 = (q15_t) ((Si3 * R1 + Co3 * R0) >> 16u);
emh203 0:3d9c67d97d6f 766 /* yd' = (ya+xb-yc-xd)* Co3 - (xa-yb-xc+yd)* (si3) */
emh203 0:3d9c67d97d6f 767 out2 = (q15_t) ((-Si3 * R0 + Co3 * R1) >> 16u);
emh203 0:3d9c67d97d6f 768 /* writing output(xd', yd') in little endian format */
emh203 0:3d9c67d97d6f 769 pSrc16[i3 * 2u] = out1;
emh203 0:3d9c67d97d6f 770 pSrc16[(i3 * 2u) + 1] = out2;
emh203 0:3d9c67d97d6f 771
emh203 0:3d9c67d97d6f 772 /* Twiddle coefficients index modifier */
emh203 0:3d9c67d97d6f 773 ic = ic + twidCoefModifier;
emh203 0:3d9c67d97d6f 774
emh203 0:3d9c67d97d6f 775 /* Updating input index */
emh203 0:3d9c67d97d6f 776 i0 = i0 + 1u;
emh203 0:3d9c67d97d6f 777
emh203 0:3d9c67d97d6f 778 } while(--j);
emh203 0:3d9c67d97d6f 779 /* data is in 4.11(q11) format */
emh203 0:3d9c67d97d6f 780
emh203 0:3d9c67d97d6f 781 /* end of first stage process */
emh203 0:3d9c67d97d6f 782
emh203 0:3d9c67d97d6f 783
emh203 0:3d9c67d97d6f 784 /* start of middle stage process */
emh203 0:3d9c67d97d6f 785
emh203 0:3d9c67d97d6f 786 /* Twiddle coefficients index modifier */
emh203 0:3d9c67d97d6f 787 twidCoefModifier <<= 2u;
emh203 0:3d9c67d97d6f 788
emh203 0:3d9c67d97d6f 789 /* Calculation of Middle stage */
emh203 0:3d9c67d97d6f 790 for (k = fftLen / 4u; k > 4u; k >>= 2u)
emh203 0:3d9c67d97d6f 791 {
emh203 0:3d9c67d97d6f 792 /* Initializations for the middle stage */
emh203 0:3d9c67d97d6f 793 n1 = n2;
emh203 0:3d9c67d97d6f 794 n2 >>= 2u;
emh203 0:3d9c67d97d6f 795 ic = 0u;
emh203 0:3d9c67d97d6f 796
emh203 0:3d9c67d97d6f 797 for (j = 0u; j <= (n2 - 1u); j++)
emh203 0:3d9c67d97d6f 798 {
emh203 0:3d9c67d97d6f 799 /* index calculation for the coefficients */
emh203 0:3d9c67d97d6f 800 Co1 = pCoef16[ic * 2u];
emh203 0:3d9c67d97d6f 801 Si1 = pCoef16[(ic * 2u) + 1u];
emh203 0:3d9c67d97d6f 802 Co2 = pCoef16[2u * (ic * 2u)];
emh203 0:3d9c67d97d6f 803 Si2 = pCoef16[(2u * (ic * 2u)) + 1u];
emh203 0:3d9c67d97d6f 804 Co3 = pCoef16[3u * (ic * 2u)];
emh203 0:3d9c67d97d6f 805 Si3 = pCoef16[(3u * (ic * 2u)) + 1u];
emh203 0:3d9c67d97d6f 806
emh203 0:3d9c67d97d6f 807 /* Twiddle coefficients index modifier */
emh203 0:3d9c67d97d6f 808 ic = ic + twidCoefModifier;
emh203 0:3d9c67d97d6f 809
emh203 0:3d9c67d97d6f 810 /* Butterfly implementation */
emh203 0:3d9c67d97d6f 811 for (i0 = j; i0 < fftLen; i0 += n1)
emh203 0:3d9c67d97d6f 812 {
emh203 0:3d9c67d97d6f 813 /* index calculation for the input as, */
emh203 0:3d9c67d97d6f 814 /* pSrc16[i0 + 0], pSrc16[i0 + fftLen/4], pSrc16[i0 + fftLen/2], pSrc16[i0 + 3fftLen/4] */
emh203 0:3d9c67d97d6f 815 i1 = i0 + n2;
emh203 0:3d9c67d97d6f 816 i2 = i1 + n2;
emh203 0:3d9c67d97d6f 817 i3 = i2 + n2;
emh203 0:3d9c67d97d6f 818
emh203 0:3d9c67d97d6f 819 /* Reading i0, i0+fftLen/2 inputs */
emh203 0:3d9c67d97d6f 820 /* Read ya (real), xa(imag) input */
emh203 0:3d9c67d97d6f 821 T0 = pSrc16[i0 * 2u];
emh203 0:3d9c67d97d6f 822 T1 = pSrc16[(i0 * 2u) + 1u];
emh203 0:3d9c67d97d6f 823
emh203 0:3d9c67d97d6f 824 /* Read yc (real), xc(imag) input */
emh203 0:3d9c67d97d6f 825 S0 = pSrc16[i2 * 2u];
emh203 0:3d9c67d97d6f 826 S1 = pSrc16[(i2 * 2u) + 1u];
emh203 0:3d9c67d97d6f 827
emh203 0:3d9c67d97d6f 828 /* R0 = (ya + yc), R1 = (xa + xc) */
emh203 0:3d9c67d97d6f 829 R0 = __SSAT(T0 + S0, 16);
emh203 0:3d9c67d97d6f 830 R1 = __SSAT(T1 + S1, 16);
emh203 0:3d9c67d97d6f 831
emh203 0:3d9c67d97d6f 832 /* S0 = (ya - yc), S1 =(xa - xc) */
emh203 0:3d9c67d97d6f 833 S0 = __SSAT(T0 - S0, 16);
emh203 0:3d9c67d97d6f 834 S1 = __SSAT(T1 - S1, 16);
emh203 0:3d9c67d97d6f 835
emh203 0:3d9c67d97d6f 836 /* Reading i0+fftLen/4 , i0+3fftLen/4 inputs */
emh203 0:3d9c67d97d6f 837 /* Read yb (real), xb(imag) input */
emh203 0:3d9c67d97d6f 838 T0 = pSrc16[i1 * 2u];
emh203 0:3d9c67d97d6f 839 T1 = pSrc16[(i1 * 2u) + 1u];
emh203 0:3d9c67d97d6f 840
emh203 0:3d9c67d97d6f 841 /* Read yd (real), xd(imag) input */
emh203 0:3d9c67d97d6f 842 U0 = pSrc16[i3 * 2u];
emh203 0:3d9c67d97d6f 843 U1 = pSrc16[(i3 * 2u) + 1u];
emh203 0:3d9c67d97d6f 844
emh203 0:3d9c67d97d6f 845
emh203 0:3d9c67d97d6f 846 /* T0 = (yb + yd), T1 = (xb + xd) */
emh203 0:3d9c67d97d6f 847 T0 = __SSAT(T0 + U0, 16);
emh203 0:3d9c67d97d6f 848 T1 = __SSAT(T1 + U1, 16);
emh203 0:3d9c67d97d6f 849
emh203 0:3d9c67d97d6f 850 /* writing the butterfly processed i0 sample */
emh203 0:3d9c67d97d6f 851
emh203 0:3d9c67d97d6f 852 /* xa' = xa + xb + xc + xd */
emh203 0:3d9c67d97d6f 853 /* ya' = ya + yb + yc + yd */
emh203 0:3d9c67d97d6f 854 out1 = ((R0 >> 1u) + (T0 >> 1u)) >> 1u;
emh203 0:3d9c67d97d6f 855 out2 = ((R1 >> 1u) + (T1 >> 1u)) >> 1u;
emh203 0:3d9c67d97d6f 856
emh203 0:3d9c67d97d6f 857 pSrc16[i0 * 2u] = out1;
emh203 0:3d9c67d97d6f 858 pSrc16[(2u * i0) + 1u] = out2;
emh203 0:3d9c67d97d6f 859
emh203 0:3d9c67d97d6f 860 /* R0 = (ya + yc) - (yb + yd), R1 = (xa + xc) - (xb + xd) */
emh203 0:3d9c67d97d6f 861 R0 = (R0 >> 1u) - (T0 >> 1u);
emh203 0:3d9c67d97d6f 862 R1 = (R1 >> 1u) - (T1 >> 1u);
emh203 0:3d9c67d97d6f 863
emh203 0:3d9c67d97d6f 864 /* (ya-yb+yc-yd)* (si2) + (xa-xb+xc-xd)* co2 */
emh203 0:3d9c67d97d6f 865 out1 = (q15_t) ((Co2 * R0 + Si2 * R1) >> 16u);
emh203 0:3d9c67d97d6f 866
emh203 0:3d9c67d97d6f 867 /* (ya-yb+yc-yd)* co2 - (xa-xb+xc-xd)* (si2) */
emh203 0:3d9c67d97d6f 868 out2 = (q15_t) ((-Si2 * R0 + Co2 * R1) >> 16u);
emh203 0:3d9c67d97d6f 869
emh203 0:3d9c67d97d6f 870 /* Reading i0+3fftLen/4 */
emh203 0:3d9c67d97d6f 871 /* Read yb (real), xb(imag) input */
emh203 0:3d9c67d97d6f 872 T0 = pSrc16[i1 * 2u];
emh203 0:3d9c67d97d6f 873 T1 = pSrc16[(i1 * 2u) + 1u];
emh203 0:3d9c67d97d6f 874
emh203 0:3d9c67d97d6f 875 /* writing the butterfly processed i0 + fftLen/4 sample */
emh203 0:3d9c67d97d6f 876 /* xc' = (xa-xb+xc-xd)* co2 + (ya-yb+yc-yd)* (si2) */
emh203 0:3d9c67d97d6f 877 /* yc' = (ya-yb+yc-yd)* co2 - (xa-xb+xc-xd)* (si2) */
emh203 0:3d9c67d97d6f 878 pSrc16[i1 * 2u] = out1;
emh203 0:3d9c67d97d6f 879 pSrc16[(i1 * 2u) + 1u] = out2;
emh203 0:3d9c67d97d6f 880
emh203 0:3d9c67d97d6f 881 /* Butterfly calculations */
emh203 0:3d9c67d97d6f 882
emh203 0:3d9c67d97d6f 883 /* Read yd (real), xd(imag) input */
emh203 0:3d9c67d97d6f 884 U0 = pSrc16[i3 * 2u];
emh203 0:3d9c67d97d6f 885 U1 = pSrc16[(i3 * 2u) + 1u];
emh203 0:3d9c67d97d6f 886
emh203 0:3d9c67d97d6f 887 /* T0 = yb-yd, T1 = xb-xd */
emh203 0:3d9c67d97d6f 888 T0 = __SSAT(T0 - U0, 16);
emh203 0:3d9c67d97d6f 889 T1 = __SSAT(T1 - U1, 16);
emh203 0:3d9c67d97d6f 890
emh203 0:3d9c67d97d6f 891 /* R0 = (ya-yc) + (xb- xd), R1 = (xa-xc) - (yb-yd)) */
emh203 0:3d9c67d97d6f 892 R0 = (S0 >> 1u) - (T1 >> 1u);
emh203 0:3d9c67d97d6f 893 R1 = (S1 >> 1u) + (T0 >> 1u);
emh203 0:3d9c67d97d6f 894
emh203 0:3d9c67d97d6f 895 /* S0 = (ya-yc) - (xb- xd), S1 = (xa-xc) + (yb-yd)) */
emh203 0:3d9c67d97d6f 896 S0 = (S0 >> 1u) + (T1 >> 1u);
emh203 0:3d9c67d97d6f 897 S1 = (S1 >> 1u) - (T0 >> 1u);
emh203 0:3d9c67d97d6f 898
emh203 0:3d9c67d97d6f 899 /* Butterfly process for the i0+fftLen/2 sample */
emh203 0:3d9c67d97d6f 900 out1 = (q15_t) ((Co1 * S0 + Si1 * S1) >> 16u);
emh203 0:3d9c67d97d6f 901
emh203 0:3d9c67d97d6f 902 out2 = (q15_t) ((-Si1 * S0 + Co1 * S1) >> 16u);
emh203 0:3d9c67d97d6f 903
emh203 0:3d9c67d97d6f 904 /* xb' = (xa+yb-xc-yd)* co1 + (ya-xb-yc+xd)* (si1) */
emh203 0:3d9c67d97d6f 905 /* yb' = (ya-xb-yc+xd)* co1 - (xa+yb-xc-yd)* (si1) */
emh203 0:3d9c67d97d6f 906 pSrc16[i2 * 2u] = out1;
emh203 0:3d9c67d97d6f 907 pSrc16[(i2 * 2u) + 1u] = out2;
emh203 0:3d9c67d97d6f 908
emh203 0:3d9c67d97d6f 909 /* Butterfly process for the i0+3fftLen/4 sample */
emh203 0:3d9c67d97d6f 910 out1 = (q15_t) ((Si3 * R1 + Co3 * R0) >> 16u);
emh203 0:3d9c67d97d6f 911
emh203 0:3d9c67d97d6f 912 out2 = (q15_t) ((-Si3 * R0 + Co3 * R1) >> 16u);
emh203 0:3d9c67d97d6f 913 /* xd' = (xa-yb-xc+yd)* Co3 + (ya+xb-yc-xd)* (si3) */
emh203 0:3d9c67d97d6f 914 /* yd' = (ya+xb-yc-xd)* Co3 - (xa-yb-xc+yd)* (si3) */
emh203 0:3d9c67d97d6f 915 pSrc16[i3 * 2u] = out1;
emh203 0:3d9c67d97d6f 916 pSrc16[(i3 * 2u) + 1u] = out2;
emh203 0:3d9c67d97d6f 917 }
emh203 0:3d9c67d97d6f 918 }
emh203 0:3d9c67d97d6f 919 /* Twiddle coefficients index modifier */
emh203 0:3d9c67d97d6f 920 twidCoefModifier <<= 2u;
emh203 0:3d9c67d97d6f 921 }
emh203 0:3d9c67d97d6f 922 /* end of middle stage process */
emh203 0:3d9c67d97d6f 923
emh203 0:3d9c67d97d6f 924
emh203 0:3d9c67d97d6f 925 /* data is in 10.6(q6) format for the 1024 point */
emh203 0:3d9c67d97d6f 926 /* data is in 8.8(q8) format for the 256 point */
emh203 0:3d9c67d97d6f 927 /* data is in 6.10(q10) format for the 64 point */
emh203 0:3d9c67d97d6f 928 /* data is in 4.12(q12) format for the 16 point */
emh203 0:3d9c67d97d6f 929
emh203 0:3d9c67d97d6f 930 /* Initializations for the last stage */
emh203 0:3d9c67d97d6f 931 n1 = n2;
emh203 0:3d9c67d97d6f 932 n2 >>= 2u;
emh203 0:3d9c67d97d6f 933
emh203 0:3d9c67d97d6f 934 /* start of last stage process */
emh203 0:3d9c67d97d6f 935
emh203 0:3d9c67d97d6f 936 /* Butterfly implementation */
emh203 0:3d9c67d97d6f 937 for (i0 = 0u; i0 <= (fftLen - n1); i0 += n1)
emh203 0:3d9c67d97d6f 938 {
emh203 0:3d9c67d97d6f 939 /* index calculation for the input as, */
emh203 0:3d9c67d97d6f 940 /* pSrc16[i0 + 0], pSrc16[i0 + fftLen/4], pSrc16[i0 + fftLen/2], pSrc16[i0 + 3fftLen/4] */
emh203 0:3d9c67d97d6f 941 i1 = i0 + n2;
emh203 0:3d9c67d97d6f 942 i2 = i1 + n2;
emh203 0:3d9c67d97d6f 943 i3 = i2 + n2;
emh203 0:3d9c67d97d6f 944
emh203 0:3d9c67d97d6f 945 /* Reading i0, i0+fftLen/2 inputs */
emh203 0:3d9c67d97d6f 946 /* Read ya (real), xa(imag) input */
emh203 0:3d9c67d97d6f 947 T0 = pSrc16[i0 * 2u];
emh203 0:3d9c67d97d6f 948 T1 = pSrc16[(i0 * 2u) + 1u];
emh203 0:3d9c67d97d6f 949
emh203 0:3d9c67d97d6f 950 /* Read yc (real), xc(imag) input */
emh203 0:3d9c67d97d6f 951 S0 = pSrc16[i2 * 2u];
emh203 0:3d9c67d97d6f 952 S1 = pSrc16[(i2 * 2u) + 1u];
emh203 0:3d9c67d97d6f 953
emh203 0:3d9c67d97d6f 954 /* R0 = (ya + yc), R1 = (xa + xc) */
emh203 0:3d9c67d97d6f 955 R0 = __SSAT(T0 + S0, 16u);
emh203 0:3d9c67d97d6f 956 R1 = __SSAT(T1 + S1, 16u);
emh203 0:3d9c67d97d6f 957
emh203 0:3d9c67d97d6f 958 /* S0 = (ya - yc), S1 = (xa - xc) */
emh203 0:3d9c67d97d6f 959 S0 = __SSAT(T0 - S0, 16u);
emh203 0:3d9c67d97d6f 960 S1 = __SSAT(T1 - S1, 16u);
emh203 0:3d9c67d97d6f 961
emh203 0:3d9c67d97d6f 962 /* Reading i0+fftLen/4 , i0+3fftLen/4 inputs */
emh203 0:3d9c67d97d6f 963 /* Read yb (real), xb(imag) input */
emh203 0:3d9c67d97d6f 964 T0 = pSrc16[i1 * 2u];
emh203 0:3d9c67d97d6f 965 T1 = pSrc16[(i1 * 2u) + 1u];
emh203 0:3d9c67d97d6f 966 /* Read yd (real), xd(imag) input */
emh203 0:3d9c67d97d6f 967 U0 = pSrc16[i3 * 2u];
emh203 0:3d9c67d97d6f 968 U1 = pSrc16[(i3 * 2u) + 1u];
emh203 0:3d9c67d97d6f 969
emh203 0:3d9c67d97d6f 970 /* T0 = (yb + yd), T1 = (xb + xd)) */
emh203 0:3d9c67d97d6f 971 T0 = __SSAT(T0 + U0, 16u);
emh203 0:3d9c67d97d6f 972 T1 = __SSAT(T1 + U1, 16u);
emh203 0:3d9c67d97d6f 973
emh203 0:3d9c67d97d6f 974 /* writing the butterfly processed i0 sample */
emh203 0:3d9c67d97d6f 975 /* xa' = xa + xb + xc + xd */
emh203 0:3d9c67d97d6f 976 /* ya' = ya + yb + yc + yd */
emh203 0:3d9c67d97d6f 977 pSrc16[i0 * 2u] = (R0 >> 1u) + (T0 >> 1u);
emh203 0:3d9c67d97d6f 978 pSrc16[(i0 * 2u) + 1u] = (R1 >> 1u) + (T1 >> 1u);
emh203 0:3d9c67d97d6f 979
emh203 0:3d9c67d97d6f 980 /* R0 = (ya + yc) - (yb + yd), R1 = (xa + xc) - (xb + xd) */
emh203 0:3d9c67d97d6f 981 R0 = (R0 >> 1u) - (T0 >> 1u);
emh203 0:3d9c67d97d6f 982 R1 = (R1 >> 1u) - (T1 >> 1u);
emh203 0:3d9c67d97d6f 983 /* Read yb (real), xb(imag) input */
emh203 0:3d9c67d97d6f 984 T0 = pSrc16[i1 * 2u];
emh203 0:3d9c67d97d6f 985 T1 = pSrc16[(i1 * 2u) + 1u];
emh203 0:3d9c67d97d6f 986
emh203 0:3d9c67d97d6f 987 /* writing the butterfly processed i0 + fftLen/4 sample */
emh203 0:3d9c67d97d6f 988 /* xc' = (xa-xb+xc-xd) */
emh203 0:3d9c67d97d6f 989 /* yc' = (ya-yb+yc-yd) */
emh203 0:3d9c67d97d6f 990 pSrc16[i1 * 2u] = R0;
emh203 0:3d9c67d97d6f 991 pSrc16[(i1 * 2u) + 1u] = R1;
emh203 0:3d9c67d97d6f 992
emh203 0:3d9c67d97d6f 993 /* Read yd (real), xd(imag) input */
emh203 0:3d9c67d97d6f 994 U0 = pSrc16[i3 * 2u];
emh203 0:3d9c67d97d6f 995 U1 = pSrc16[(i3 * 2u) + 1u];
emh203 0:3d9c67d97d6f 996 /* T0 = (yb - yd), T1 = (xb - xd) */
emh203 0:3d9c67d97d6f 997 T0 = __SSAT(T0 - U0, 16u);
emh203 0:3d9c67d97d6f 998 T1 = __SSAT(T1 - U1, 16u);
emh203 0:3d9c67d97d6f 999
emh203 0:3d9c67d97d6f 1000 /* writing the butterfly processed i0 + fftLen/2 sample */
emh203 0:3d9c67d97d6f 1001 /* xb' = (xa+yb-xc-yd) */
emh203 0:3d9c67d97d6f 1002 /* yb' = (ya-xb-yc+xd) */
emh203 0:3d9c67d97d6f 1003 pSrc16[i2 * 2u] = (S0 >> 1u) + (T1 >> 1u);
emh203 0:3d9c67d97d6f 1004 pSrc16[(i2 * 2u) + 1u] = (S1 >> 1u) - (T0 >> 1u);
emh203 0:3d9c67d97d6f 1005
emh203 0:3d9c67d97d6f 1006 /* writing the butterfly processed i0 + 3fftLen/4 sample */
emh203 0:3d9c67d97d6f 1007 /* xd' = (xa-yb-xc+yd) */
emh203 0:3d9c67d97d6f 1008 /* yd' = (ya+xb-yc-xd) */
emh203 0:3d9c67d97d6f 1009 pSrc16[i3 * 2u] = (S0 >> 1u) - (T1 >> 1u);
emh203 0:3d9c67d97d6f 1010 pSrc16[(i3 * 2u) + 1u] = (S1 >> 1u) + (T0 >> 1u);
emh203 0:3d9c67d97d6f 1011
emh203 0:3d9c67d97d6f 1012 }
emh203 0:3d9c67d97d6f 1013
emh203 0:3d9c67d97d6f 1014 /* end of last stage process */
emh203 0:3d9c67d97d6f 1015
emh203 0:3d9c67d97d6f 1016 /* output is in 11.5(q5) format for the 1024 point */
emh203 0:3d9c67d97d6f 1017 /* output is in 9.7(q7) format for the 256 point */
emh203 0:3d9c67d97d6f 1018 /* output is in 7.9(q9) format for the 64 point */
emh203 0:3d9c67d97d6f 1019 /* output is in 5.11(q11) format for the 16 point */
emh203 0:3d9c67d97d6f 1020
emh203 0:3d9c67d97d6f 1021 #endif /* #ifndef ARM_MATH_CM0_FAMILY */
emh203 0:3d9c67d97d6f 1022
emh203 0:3d9c67d97d6f 1023 }
emh203 0:3d9c67d97d6f 1024
emh203 0:3d9c67d97d6f 1025
emh203 0:3d9c67d97d6f 1026 /**
emh203 0:3d9c67d97d6f 1027 * @brief Core function for the Q15 CIFFT butterfly process.
emh203 0:3d9c67d97d6f 1028 * @param[in, out] *pSrc16 points to the in-place buffer of Q15 data type.
emh203 0:3d9c67d97d6f 1029 * @param[in] fftLen length of the FFT.
emh203 0:3d9c67d97d6f 1030 * @param[in] *pCoef16 points to twiddle coefficient buffer.
emh203 0:3d9c67d97d6f 1031 * @param[in] twidCoefModifier twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table.
emh203 0:3d9c67d97d6f 1032 * @return none.
emh203 0:3d9c67d97d6f 1033 */
emh203 0:3d9c67d97d6f 1034
emh203 0:3d9c67d97d6f 1035 /*
emh203 0:3d9c67d97d6f 1036 * Radix-4 IFFT algorithm used is :
emh203 0:3d9c67d97d6f 1037 *
emh203 0:3d9c67d97d6f 1038 * CIFFT uses same twiddle coefficients as CFFT function
emh203 0:3d9c67d97d6f 1039 * x[k] = x[n] + (j)k * x[n + fftLen/4] + (-1)k * x[n+fftLen/2] + (-j)k * x[n+3*fftLen/4]
emh203 0:3d9c67d97d6f 1040 *
emh203 0:3d9c67d97d6f 1041 *
emh203 0:3d9c67d97d6f 1042 * IFFT is implemented with following changes in equations from FFT
emh203 0:3d9c67d97d6f 1043 *
emh203 0:3d9c67d97d6f 1044 * Input real and imaginary data:
emh203 0:3d9c67d97d6f 1045 * x(n) = xa + j * ya
emh203 0:3d9c67d97d6f 1046 * x(n+N/4 ) = xb + j * yb
emh203 0:3d9c67d97d6f 1047 * x(n+N/2 ) = xc + j * yc
emh203 0:3d9c67d97d6f 1048 * x(n+3N 4) = xd + j * yd
emh203 0:3d9c67d97d6f 1049 *
emh203 0:3d9c67d97d6f 1050 *
emh203 0:3d9c67d97d6f 1051 * Output real and imaginary data:
emh203 0:3d9c67d97d6f 1052 * x(4r) = xa'+ j * ya'
emh203 0:3d9c67d97d6f 1053 * x(4r+1) = xb'+ j * yb'
emh203 0:3d9c67d97d6f 1054 * x(4r+2) = xc'+ j * yc'
emh203 0:3d9c67d97d6f 1055 * x(4r+3) = xd'+ j * yd'
emh203 0:3d9c67d97d6f 1056 *
emh203 0:3d9c67d97d6f 1057 *
emh203 0:3d9c67d97d6f 1058 * Twiddle factors for radix-4 IFFT:
emh203 0:3d9c67d97d6f 1059 * Wn = co1 + j * (si1)
emh203 0:3d9c67d97d6f 1060 * W2n = co2 + j * (si2)
emh203 0:3d9c67d97d6f 1061 * W3n = co3 + j * (si3)
emh203 0:3d9c67d97d6f 1062
emh203 0:3d9c67d97d6f 1063 * The real and imaginary output values for the radix-4 butterfly are
emh203 0:3d9c67d97d6f 1064 * xa' = xa + xb + xc + xd
emh203 0:3d9c67d97d6f 1065 * ya' = ya + yb + yc + yd
emh203 0:3d9c67d97d6f 1066 * xb' = (xa-yb-xc+yd)* co1 - (ya+xb-yc-xd)* (si1)
emh203 0:3d9c67d97d6f 1067 * yb' = (ya+xb-yc-xd)* co1 + (xa-yb-xc+yd)* (si1)
emh203 0:3d9c67d97d6f 1068 * xc' = (xa-xb+xc-xd)* co2 - (ya-yb+yc-yd)* (si2)
emh203 0:3d9c67d97d6f 1069 * yc' = (ya-yb+yc-yd)* co2 + (xa-xb+xc-xd)* (si2)
emh203 0:3d9c67d97d6f 1070 * xd' = (xa+yb-xc-yd)* co3 - (ya-xb-yc+xd)* (si3)
emh203 0:3d9c67d97d6f 1071 * yd' = (ya-xb-yc+xd)* co3 + (xa+yb-xc-yd)* (si3)
emh203 0:3d9c67d97d6f 1072 *
emh203 0:3d9c67d97d6f 1073 */
emh203 0:3d9c67d97d6f 1074
emh203 0:3d9c67d97d6f 1075 void arm_radix4_butterfly_inverse_q15(
emh203 0:3d9c67d97d6f 1076 q15_t * pSrc16,
emh203 0:3d9c67d97d6f 1077 uint32_t fftLen,
emh203 0:3d9c67d97d6f 1078 q15_t * pCoef16,
emh203 0:3d9c67d97d6f 1079 uint32_t twidCoefModifier)
emh203 0:3d9c67d97d6f 1080 {
emh203 0:3d9c67d97d6f 1081
emh203 0:3d9c67d97d6f 1082 #ifndef ARM_MATH_CM0_FAMILY
emh203 0:3d9c67d97d6f 1083
emh203 0:3d9c67d97d6f 1084 /* Run the below code for Cortex-M4 and Cortex-M3 */
emh203 0:3d9c67d97d6f 1085
emh203 0:3d9c67d97d6f 1086 q31_t R, S, T, U;
emh203 0:3d9c67d97d6f 1087 q31_t C1, C2, C3, out1, out2;
emh203 0:3d9c67d97d6f 1088 uint32_t n1, n2, ic, i0, i1, i2, i3, j, k;
emh203 0:3d9c67d97d6f 1089 q15_t in;
emh203 0:3d9c67d97d6f 1090
emh203 0:3d9c67d97d6f 1091 q15_t *ptr1;
emh203 0:3d9c67d97d6f 1092
emh203 0:3d9c67d97d6f 1093
emh203 0:3d9c67d97d6f 1094
emh203 0:3d9c67d97d6f 1095 q31_t xaya, xbyb, xcyc, xdyd;
emh203 0:3d9c67d97d6f 1096
emh203 0:3d9c67d97d6f 1097 /* Total process is divided into three stages */
emh203 0:3d9c67d97d6f 1098
emh203 0:3d9c67d97d6f 1099 /* process first stage, middle stages, & last stage */
emh203 0:3d9c67d97d6f 1100
emh203 0:3d9c67d97d6f 1101 /* Initializations for the first stage */
emh203 0:3d9c67d97d6f 1102 n2 = fftLen;
emh203 0:3d9c67d97d6f 1103 n1 = n2;
emh203 0:3d9c67d97d6f 1104
emh203 0:3d9c67d97d6f 1105 /* n2 = fftLen/4 */
emh203 0:3d9c67d97d6f 1106 n2 >>= 2u;
emh203 0:3d9c67d97d6f 1107
emh203 0:3d9c67d97d6f 1108 /* Index for twiddle coefficient */
emh203 0:3d9c67d97d6f 1109 ic = 0u;
emh203 0:3d9c67d97d6f 1110
emh203 0:3d9c67d97d6f 1111 /* Index for input read and output write */
emh203 0:3d9c67d97d6f 1112 i0 = 0u;
emh203 0:3d9c67d97d6f 1113 j = n2;
emh203 0:3d9c67d97d6f 1114
emh203 0:3d9c67d97d6f 1115 /* Input is in 1.15(q15) format */
emh203 0:3d9c67d97d6f 1116
emh203 0:3d9c67d97d6f 1117 /* start of first stage process */
emh203 0:3d9c67d97d6f 1118 do
emh203 0:3d9c67d97d6f 1119 {
emh203 0:3d9c67d97d6f 1120 /* Butterfly implementation */
emh203 0:3d9c67d97d6f 1121
emh203 0:3d9c67d97d6f 1122 /* index calculation for the input as, */
emh203 0:3d9c67d97d6f 1123 /* pSrc16[i0 + 0], pSrc16[i0 + fftLen/4], pSrc16[i0 + fftLen/2], pSrc16[i0 + 3fftLen/4] */
emh203 0:3d9c67d97d6f 1124 i1 = i0 + n2;
emh203 0:3d9c67d97d6f 1125 i2 = i1 + n2;
emh203 0:3d9c67d97d6f 1126 i3 = i2 + n2;
emh203 0:3d9c67d97d6f 1127
emh203 0:3d9c67d97d6f 1128 /* Reading i0, i0+fftLen/2 inputs */
emh203 0:3d9c67d97d6f 1129 /* Read ya (real), xa(imag) input */
emh203 0:3d9c67d97d6f 1130 T = _SIMD32_OFFSET(pSrc16 + (2u * i0));
emh203 0:3d9c67d97d6f 1131 in = ((int16_t) (T & 0xFFFF)) >> 2;
emh203 0:3d9c67d97d6f 1132 T = ((T >> 2) & 0xFFFF0000) | (in & 0xFFFF);
emh203 0:3d9c67d97d6f 1133
emh203 0:3d9c67d97d6f 1134 /* Read yc (real), xc(imag) input */
emh203 0:3d9c67d97d6f 1135 S = _SIMD32_OFFSET(pSrc16 + (2u * i2));
emh203 0:3d9c67d97d6f 1136 in = ((int16_t) (S & 0xFFFF)) >> 2;
emh203 0:3d9c67d97d6f 1137 S = ((S >> 2) & 0xFFFF0000) | (in & 0xFFFF);
emh203 0:3d9c67d97d6f 1138
emh203 0:3d9c67d97d6f 1139 /* R = packed((ya + yc), (xa + xc) ) */
emh203 0:3d9c67d97d6f 1140 R = __QADD16(T, S);
emh203 0:3d9c67d97d6f 1141
emh203 0:3d9c67d97d6f 1142 /* S = packed((ya - yc), (xa - xc) ) */
emh203 0:3d9c67d97d6f 1143 S = __QSUB16(T, S);
emh203 0:3d9c67d97d6f 1144
emh203 0:3d9c67d97d6f 1145 /* Reading i0+fftLen/4 , i0+3fftLen/4 inputs */
emh203 0:3d9c67d97d6f 1146 /* Read yb (real), xb(imag) input */
emh203 0:3d9c67d97d6f 1147 T = _SIMD32_OFFSET(pSrc16 + (2u * i1));
emh203 0:3d9c67d97d6f 1148 in = ((int16_t) (T & 0xFFFF)) >> 2;
emh203 0:3d9c67d97d6f 1149 T = ((T >> 2) & 0xFFFF0000) | (in & 0xFFFF);
emh203 0:3d9c67d97d6f 1150
emh203 0:3d9c67d97d6f 1151 /* Read yd (real), xd(imag) input */
emh203 0:3d9c67d97d6f 1152 U = _SIMD32_OFFSET(pSrc16 + (2u * i3));
emh203 0:3d9c67d97d6f 1153 in = ((int16_t) (U & 0xFFFF)) >> 2;
emh203 0:3d9c67d97d6f 1154 U = ((U >> 2) & 0xFFFF0000) | (in & 0xFFFF);
emh203 0:3d9c67d97d6f 1155
emh203 0:3d9c67d97d6f 1156 /* T = packed((yb + yd), (xb + xd) ) */
emh203 0:3d9c67d97d6f 1157 T = __QADD16(T, U);
emh203 0:3d9c67d97d6f 1158
emh203 0:3d9c67d97d6f 1159 /* writing the butterfly processed i0 sample */
emh203 0:3d9c67d97d6f 1160 /* xa' = xa + xb + xc + xd */
emh203 0:3d9c67d97d6f 1161 /* ya' = ya + yb + yc + yd */
emh203 0:3d9c67d97d6f 1162 _SIMD32_OFFSET(pSrc16 + (2u * i0)) = __SHADD16(R, T);
emh203 0:3d9c67d97d6f 1163
emh203 0:3d9c67d97d6f 1164 /* R = packed((ya + yc) - (yb + yd), (xa + xc)- (xb + xd)) */
emh203 0:3d9c67d97d6f 1165 R = __QSUB16(R, T);
emh203 0:3d9c67d97d6f 1166
emh203 0:3d9c67d97d6f 1167 /* co2 & si2 are read from SIMD Coefficient pointer */
emh203 0:3d9c67d97d6f 1168 C2 = _SIMD32_OFFSET(pCoef16 + (4u * ic));
emh203 0:3d9c67d97d6f 1169
emh203 0:3d9c67d97d6f 1170 #ifndef ARM_MATH_BIG_ENDIAN
emh203 0:3d9c67d97d6f 1171
emh203 0:3d9c67d97d6f 1172 /* xc' = (xa-xb+xc-xd)* co2 + (ya-yb+yc-yd)* (si2) */
emh203 0:3d9c67d97d6f 1173 out1 = __SMUSD(C2, R) >> 16u;
emh203 0:3d9c67d97d6f 1174 /* yc' = (ya-yb+yc-yd)* co2 - (xa-xb+xc-xd)* (si2) */
emh203 0:3d9c67d97d6f 1175 out2 = __SMUADX(C2, R);
emh203 0:3d9c67d97d6f 1176
emh203 0:3d9c67d97d6f 1177 #else
emh203 0:3d9c67d97d6f 1178
emh203 0:3d9c67d97d6f 1179 /* xc' = (ya-yb+yc-yd)* co2 - (xa-xb+xc-xd)* (si2) */
emh203 0:3d9c67d97d6f 1180 out1 = __SMUADX(C2, R) >> 16u;
emh203 0:3d9c67d97d6f 1181 /* yc' = (xa-xb+xc-xd)* co2 + (ya-yb+yc-yd)* (si2) */
emh203 0:3d9c67d97d6f 1182 out2 = __SMUSD(__QSUB16(0, C2), R);
emh203 0:3d9c67d97d6f 1183
emh203 0:3d9c67d97d6f 1184 #endif /* #ifndef ARM_MATH_BIG_ENDIAN */
emh203 0:3d9c67d97d6f 1185
emh203 0:3d9c67d97d6f 1186 /* Reading i0+fftLen/4 */
emh203 0:3d9c67d97d6f 1187 /* T = packed(yb, xb) */
emh203 0:3d9c67d97d6f 1188 T = _SIMD32_OFFSET(pSrc16 + (2u * i1));
emh203 0:3d9c67d97d6f 1189 in = ((int16_t) (T & 0xFFFF)) >> 2;
emh203 0:3d9c67d97d6f 1190 T = ((T >> 2) & 0xFFFF0000) | (in & 0xFFFF);
emh203 0:3d9c67d97d6f 1191
emh203 0:3d9c67d97d6f 1192 /* writing the butterfly processed i0 + fftLen/4 sample */
emh203 0:3d9c67d97d6f 1193 /* writing output(xc', yc') in little endian format */
emh203 0:3d9c67d97d6f 1194 _SIMD32_OFFSET(pSrc16 + (2u * i1)) =
emh203 0:3d9c67d97d6f 1195 (q31_t) ((out2) & 0xFFFF0000) | (out1 & 0x0000FFFF);
emh203 0:3d9c67d97d6f 1196
emh203 0:3d9c67d97d6f 1197 /* Butterfly calculations */
emh203 0:3d9c67d97d6f 1198 /* U = packed(yd, xd) */
emh203 0:3d9c67d97d6f 1199 U = _SIMD32_OFFSET(pSrc16 + (2u * i3));
emh203 0:3d9c67d97d6f 1200 in = ((int16_t) (U & 0xFFFF)) >> 2;
emh203 0:3d9c67d97d6f 1201 U = ((U >> 2) & 0xFFFF0000) | (in & 0xFFFF);
emh203 0:3d9c67d97d6f 1202
emh203 0:3d9c67d97d6f 1203 /* T = packed(yb-yd, xb-xd) */
emh203 0:3d9c67d97d6f 1204 T = __QSUB16(T, U);
emh203 0:3d9c67d97d6f 1205
emh203 0:3d9c67d97d6f 1206 #ifndef ARM_MATH_BIG_ENDIAN
emh203 0:3d9c67d97d6f 1207
emh203 0:3d9c67d97d6f 1208 /* R = packed((ya-yc) + (xb- xd) , (xa-xc) - (yb-yd)) */
emh203 0:3d9c67d97d6f 1209 R = __QSAX(S, T);
emh203 0:3d9c67d97d6f 1210 /* S = packed((ya-yc) + (xb- xd), (xa-xc) - (yb-yd)) */
emh203 0:3d9c67d97d6f 1211 S = __QASX(S, T);
emh203 0:3d9c67d97d6f 1212
emh203 0:3d9c67d97d6f 1213 #else
emh203 0:3d9c67d97d6f 1214
emh203 0:3d9c67d97d6f 1215 /* R = packed((ya-yc) + (xb- xd) , (xa-xc) - (yb-yd)) */
emh203 0:3d9c67d97d6f 1216 R = __QASX(S, T);
emh203 0:3d9c67d97d6f 1217 /* S = packed((ya-yc) - (xb- xd), (xa-xc) + (yb-yd)) */
emh203 0:3d9c67d97d6f 1218 S = __QSAX(S, T);
emh203 0:3d9c67d97d6f 1219
emh203 0:3d9c67d97d6f 1220 #endif /* #ifndef ARM_MATH_BIG_ENDIAN */
emh203 0:3d9c67d97d6f 1221
emh203 0:3d9c67d97d6f 1222 /* co1 & si1 are read from SIMD Coefficient pointer */
emh203 0:3d9c67d97d6f 1223 C1 = _SIMD32_OFFSET(pCoef16 + (2u * ic));
emh203 0:3d9c67d97d6f 1224 /* Butterfly process for the i0+fftLen/2 sample */
emh203 0:3d9c67d97d6f 1225
emh203 0:3d9c67d97d6f 1226 #ifndef ARM_MATH_BIG_ENDIAN
emh203 0:3d9c67d97d6f 1227
emh203 0:3d9c67d97d6f 1228 /* xb' = (xa+yb-xc-yd)* co1 + (ya-xb-yc+xd)* (si1) */
emh203 0:3d9c67d97d6f 1229 out1 = __SMUSD(C1, S) >> 16u;
emh203 0:3d9c67d97d6f 1230 /* yb' = (ya-xb-yc+xd)* co1 - (xa+yb-xc-yd)* (si1) */
emh203 0:3d9c67d97d6f 1231 out2 = __SMUADX(C1, S);
emh203 0:3d9c67d97d6f 1232
emh203 0:3d9c67d97d6f 1233 #else
emh203 0:3d9c67d97d6f 1234
emh203 0:3d9c67d97d6f 1235 /* xb' = (ya-xb-yc+xd)* co1 - (xa+yb-xc-yd)* (si1) */
emh203 0:3d9c67d97d6f 1236 out1 = __SMUADX(C1, S) >> 16u;
emh203 0:3d9c67d97d6f 1237 /* yb' = (xa+yb-xc-yd)* co1 + (ya-xb-yc+xd)* (si1) */
emh203 0:3d9c67d97d6f 1238 out2 = __SMUSD(__QSUB16(0, C1), S);
emh203 0:3d9c67d97d6f 1239
emh203 0:3d9c67d97d6f 1240 #endif /* #ifndef ARM_MATH_BIG_ENDIAN */
emh203 0:3d9c67d97d6f 1241
emh203 0:3d9c67d97d6f 1242 /* writing output(xb', yb') in little endian format */
emh203 0:3d9c67d97d6f 1243 _SIMD32_OFFSET(pSrc16 + (2u * i2)) =
emh203 0:3d9c67d97d6f 1244 ((out2) & 0xFFFF0000) | ((out1) & 0x0000FFFF);
emh203 0:3d9c67d97d6f 1245
emh203 0:3d9c67d97d6f 1246
emh203 0:3d9c67d97d6f 1247 /* co3 & si3 are read from SIMD Coefficient pointer */
emh203 0:3d9c67d97d6f 1248 C3 = _SIMD32_OFFSET(pCoef16 + (6u * ic));
emh203 0:3d9c67d97d6f 1249 /* Butterfly process for the i0+3fftLen/4 sample */
emh203 0:3d9c67d97d6f 1250
emh203 0:3d9c67d97d6f 1251 #ifndef ARM_MATH_BIG_ENDIAN
emh203 0:3d9c67d97d6f 1252
emh203 0:3d9c67d97d6f 1253 /* xd' = (xa-yb-xc+yd)* co3 + (ya+xb-yc-xd)* (si3) */
emh203 0:3d9c67d97d6f 1254 out1 = __SMUSD(C3, R) >> 16u;
emh203 0:3d9c67d97d6f 1255 /* yd' = (ya+xb-yc-xd)* co3 - (xa-yb-xc+yd)* (si3) */
emh203 0:3d9c67d97d6f 1256 out2 = __SMUADX(C3, R);
emh203 0:3d9c67d97d6f 1257
emh203 0:3d9c67d97d6f 1258 #else
emh203 0:3d9c67d97d6f 1259
emh203 0:3d9c67d97d6f 1260 /* xd' = (ya+xb-yc-xd)* co3 - (xa-yb-xc+yd)* (si3) */
emh203 0:3d9c67d97d6f 1261 out1 = __SMUADX(C3, R) >> 16u;
emh203 0:3d9c67d97d6f 1262 /* yd' = (xa-yb-xc+yd)* co3 + (ya+xb-yc-xd)* (si3) */
emh203 0:3d9c67d97d6f 1263 out2 = __SMUSD(__QSUB16(0, C3), R);
emh203 0:3d9c67d97d6f 1264
emh203 0:3d9c67d97d6f 1265 #endif /* #ifndef ARM_MATH_BIG_ENDIAN */
emh203 0:3d9c67d97d6f 1266
emh203 0:3d9c67d97d6f 1267 /* writing output(xd', yd') in little endian format */
emh203 0:3d9c67d97d6f 1268 _SIMD32_OFFSET(pSrc16 + (2u * i3)) =
emh203 0:3d9c67d97d6f 1269 ((out2) & 0xFFFF0000) | (out1 & 0x0000FFFF);
emh203 0:3d9c67d97d6f 1270
emh203 0:3d9c67d97d6f 1271 /* Twiddle coefficients index modifier */
emh203 0:3d9c67d97d6f 1272 ic = ic + twidCoefModifier;
emh203 0:3d9c67d97d6f 1273
emh203 0:3d9c67d97d6f 1274 /* Updating input index */
emh203 0:3d9c67d97d6f 1275 i0 = i0 + 1u;
emh203 0:3d9c67d97d6f 1276
emh203 0:3d9c67d97d6f 1277 } while(--j);
emh203 0:3d9c67d97d6f 1278 /* data is in 4.11(q11) format */
emh203 0:3d9c67d97d6f 1279
emh203 0:3d9c67d97d6f 1280 /* end of first stage process */
emh203 0:3d9c67d97d6f 1281
emh203 0:3d9c67d97d6f 1282
emh203 0:3d9c67d97d6f 1283 /* start of middle stage process */
emh203 0:3d9c67d97d6f 1284
emh203 0:3d9c67d97d6f 1285 /* Twiddle coefficients index modifier */
emh203 0:3d9c67d97d6f 1286 twidCoefModifier <<= 2u;
emh203 0:3d9c67d97d6f 1287
emh203 0:3d9c67d97d6f 1288 /* Calculation of Middle stage */
emh203 0:3d9c67d97d6f 1289 for (k = fftLen / 4u; k > 4u; k >>= 2u)
emh203 0:3d9c67d97d6f 1290 {
emh203 0:3d9c67d97d6f 1291 /* Initializations for the middle stage */
emh203 0:3d9c67d97d6f 1292 n1 = n2;
emh203 0:3d9c67d97d6f 1293 n2 >>= 2u;
emh203 0:3d9c67d97d6f 1294 ic = 0u;
emh203 0:3d9c67d97d6f 1295
emh203 0:3d9c67d97d6f 1296 for (j = 0u; j <= (n2 - 1u); j++)
emh203 0:3d9c67d97d6f 1297 {
emh203 0:3d9c67d97d6f 1298 /* index calculation for the coefficients */
emh203 0:3d9c67d97d6f 1299 C1 = _SIMD32_OFFSET(pCoef16 + (2u * ic));
emh203 0:3d9c67d97d6f 1300 C2 = _SIMD32_OFFSET(pCoef16 + (4u * ic));
emh203 0:3d9c67d97d6f 1301 C3 = _SIMD32_OFFSET(pCoef16 + (6u * ic));
emh203 0:3d9c67d97d6f 1302
emh203 0:3d9c67d97d6f 1303 /* Twiddle coefficients index modifier */
emh203 0:3d9c67d97d6f 1304 ic = ic + twidCoefModifier;
emh203 0:3d9c67d97d6f 1305
emh203 0:3d9c67d97d6f 1306 /* Butterfly implementation */
emh203 0:3d9c67d97d6f 1307 for (i0 = j; i0 < fftLen; i0 += n1)
emh203 0:3d9c67d97d6f 1308 {
emh203 0:3d9c67d97d6f 1309 /* index calculation for the input as, */
emh203 0:3d9c67d97d6f 1310 /* pSrc16[i0 + 0], pSrc16[i0 + fftLen/4], pSrc16[i0 + fftLen/2], pSrc16[i0 + 3fftLen/4] */
emh203 0:3d9c67d97d6f 1311 i1 = i0 + n2;
emh203 0:3d9c67d97d6f 1312 i2 = i1 + n2;
emh203 0:3d9c67d97d6f 1313 i3 = i2 + n2;
emh203 0:3d9c67d97d6f 1314
emh203 0:3d9c67d97d6f 1315 /* Reading i0, i0+fftLen/2 inputs */
emh203 0:3d9c67d97d6f 1316 /* Read ya (real), xa(imag) input */
emh203 0:3d9c67d97d6f 1317 T = _SIMD32_OFFSET(pSrc16 + (2u * i0));
emh203 0:3d9c67d97d6f 1318
emh203 0:3d9c67d97d6f 1319 /* Read yc (real), xc(imag) input */
emh203 0:3d9c67d97d6f 1320 S = _SIMD32_OFFSET(pSrc16 + (2u * i2));
emh203 0:3d9c67d97d6f 1321
emh203 0:3d9c67d97d6f 1322 /* R = packed( (ya + yc), (xa + xc)) */
emh203 0:3d9c67d97d6f 1323 R = __QADD16(T, S);
emh203 0:3d9c67d97d6f 1324
emh203 0:3d9c67d97d6f 1325 /* S = packed((ya - yc), (xa - xc)) */
emh203 0:3d9c67d97d6f 1326 S = __QSUB16(T, S);
emh203 0:3d9c67d97d6f 1327
emh203 0:3d9c67d97d6f 1328 /* Reading i0+fftLen/4 , i0+3fftLen/4 inputs */
emh203 0:3d9c67d97d6f 1329 /* Read yb (real), xb(imag) input */
emh203 0:3d9c67d97d6f 1330 T = _SIMD32_OFFSET(pSrc16 + (2u * i1));
emh203 0:3d9c67d97d6f 1331
emh203 0:3d9c67d97d6f 1332 /* Read yd (real), xd(imag) input */
emh203 0:3d9c67d97d6f 1333 U = _SIMD32_OFFSET(pSrc16 + (2u * i3));
emh203 0:3d9c67d97d6f 1334
emh203 0:3d9c67d97d6f 1335 /* T = packed( (yb + yd), (xb + xd)) */
emh203 0:3d9c67d97d6f 1336 T = __QADD16(T, U);
emh203 0:3d9c67d97d6f 1337
emh203 0:3d9c67d97d6f 1338 /* writing the butterfly processed i0 sample */
emh203 0:3d9c67d97d6f 1339
emh203 0:3d9c67d97d6f 1340 /* xa' = xa + xb + xc + xd */
emh203 0:3d9c67d97d6f 1341 /* ya' = ya + yb + yc + yd */
emh203 0:3d9c67d97d6f 1342 out1 = __SHADD16(R, T);
emh203 0:3d9c67d97d6f 1343 in = ((int16_t) (out1 & 0xFFFF)) >> 1;
emh203 0:3d9c67d97d6f 1344 out1 = ((out1 >> 1) & 0xFFFF0000) | (in & 0xFFFF);
emh203 0:3d9c67d97d6f 1345 _SIMD32_OFFSET(pSrc16 + (2u * i0)) = out1;
emh203 0:3d9c67d97d6f 1346
emh203 0:3d9c67d97d6f 1347 /* R = packed( (ya + yc) - (yb + yd), (xa + xc) - (xb + xd)) */
emh203 0:3d9c67d97d6f 1348 R = __SHSUB16(R, T);
emh203 0:3d9c67d97d6f 1349
emh203 0:3d9c67d97d6f 1350 #ifndef ARM_MATH_BIG_ENDIAN
emh203 0:3d9c67d97d6f 1351
emh203 0:3d9c67d97d6f 1352 /* (ya-yb+yc-yd)* (si2) + (xa-xb+xc-xd)* co2 */
emh203 0:3d9c67d97d6f 1353 out1 = __SMUSD(C2, R) >> 16u;
emh203 0:3d9c67d97d6f 1354
emh203 0:3d9c67d97d6f 1355 /* (ya-yb+yc-yd)* co2 - (xa-xb+xc-xd)* (si2) */
emh203 0:3d9c67d97d6f 1356 out2 = __SMUADX(C2, R);
emh203 0:3d9c67d97d6f 1357
emh203 0:3d9c67d97d6f 1358 #else
emh203 0:3d9c67d97d6f 1359
emh203 0:3d9c67d97d6f 1360 /* (ya-yb+yc-yd)* co2 - (xa-xb+xc-xd)* (si2) */
emh203 0:3d9c67d97d6f 1361 out1 = __SMUADX(R, C2) >> 16u;
emh203 0:3d9c67d97d6f 1362
emh203 0:3d9c67d97d6f 1363 /* (ya-yb+yc-yd)* (si2) + (xa-xb+xc-xd)* co2 */
emh203 0:3d9c67d97d6f 1364 out2 = __SMUSD(__QSUB16(0, C2), R);
emh203 0:3d9c67d97d6f 1365
emh203 0:3d9c67d97d6f 1366 #endif /* #ifndef ARM_MATH_BIG_ENDIAN */
emh203 0:3d9c67d97d6f 1367
emh203 0:3d9c67d97d6f 1368 /* Reading i0+3fftLen/4 */
emh203 0:3d9c67d97d6f 1369 /* Read yb (real), xb(imag) input */
emh203 0:3d9c67d97d6f 1370 T = _SIMD32_OFFSET(pSrc16 + (2u * i1));
emh203 0:3d9c67d97d6f 1371
emh203 0:3d9c67d97d6f 1372 /* writing the butterfly processed i0 + fftLen/4 sample */
emh203 0:3d9c67d97d6f 1373 /* xc' = (xa-xb+xc-xd)* co2 + (ya-yb+yc-yd)* (si2) */
emh203 0:3d9c67d97d6f 1374 /* yc' = (ya-yb+yc-yd)* co2 - (xa-xb+xc-xd)* (si2) */
emh203 0:3d9c67d97d6f 1375 _SIMD32_OFFSET(pSrc16 + (2u * i1)) =
emh203 0:3d9c67d97d6f 1376 ((out2) & 0xFFFF0000) | (out1 & 0x0000FFFF);
emh203 0:3d9c67d97d6f 1377
emh203 0:3d9c67d97d6f 1378 /* Butterfly calculations */
emh203 0:3d9c67d97d6f 1379
emh203 0:3d9c67d97d6f 1380 /* Read yd (real), xd(imag) input */
emh203 0:3d9c67d97d6f 1381 U = _SIMD32_OFFSET(pSrc16 + (2u * i3));
emh203 0:3d9c67d97d6f 1382
emh203 0:3d9c67d97d6f 1383 /* T = packed(yb-yd, xb-xd) */
emh203 0:3d9c67d97d6f 1384 T = __QSUB16(T, U);
emh203 0:3d9c67d97d6f 1385
emh203 0:3d9c67d97d6f 1386 #ifndef ARM_MATH_BIG_ENDIAN
emh203 0:3d9c67d97d6f 1387
emh203 0:3d9c67d97d6f 1388 /* R = packed((ya-yc) + (xb- xd) , (xa-xc) - (yb-yd)) */
emh203 0:3d9c67d97d6f 1389 R = __SHSAX(S, T);
emh203 0:3d9c67d97d6f 1390
emh203 0:3d9c67d97d6f 1391 /* S = packed((ya-yc) - (xb- xd), (xa-xc) + (yb-yd)) */
emh203 0:3d9c67d97d6f 1392 S = __SHASX(S, T);
emh203 0:3d9c67d97d6f 1393
emh203 0:3d9c67d97d6f 1394
emh203 0:3d9c67d97d6f 1395 /* Butterfly process for the i0+fftLen/2 sample */
emh203 0:3d9c67d97d6f 1396 out1 = __SMUSD(C1, S) >> 16u;
emh203 0:3d9c67d97d6f 1397 out2 = __SMUADX(C1, S);
emh203 0:3d9c67d97d6f 1398
emh203 0:3d9c67d97d6f 1399 #else
emh203 0:3d9c67d97d6f 1400
emh203 0:3d9c67d97d6f 1401 /* R = packed((ya-yc) + (xb- xd) , (xa-xc) - (yb-yd)) */
emh203 0:3d9c67d97d6f 1402 R = __SHASX(S, T);
emh203 0:3d9c67d97d6f 1403
emh203 0:3d9c67d97d6f 1404 /* S = packed((ya-yc) - (xb- xd), (xa-xc) + (yb-yd)) */
emh203 0:3d9c67d97d6f 1405 S = __SHSAX(S, T);
emh203 0:3d9c67d97d6f 1406
emh203 0:3d9c67d97d6f 1407
emh203 0:3d9c67d97d6f 1408 /* Butterfly process for the i0+fftLen/2 sample */
emh203 0:3d9c67d97d6f 1409 out1 = __SMUADX(S, C1) >> 16u;
emh203 0:3d9c67d97d6f 1410 out2 = __SMUSD(__QSUB16(0, C1), S);
emh203 0:3d9c67d97d6f 1411
emh203 0:3d9c67d97d6f 1412 #endif /* #ifndef ARM_MATH_BIG_ENDIAN */
emh203 0:3d9c67d97d6f 1413
emh203 0:3d9c67d97d6f 1414 /* xb' = (xa+yb-xc-yd)* co1 + (ya-xb-yc+xd)* (si1) */
emh203 0:3d9c67d97d6f 1415 /* yb' = (ya-xb-yc+xd)* co1 - (xa+yb-xc-yd)* (si1) */
emh203 0:3d9c67d97d6f 1416 _SIMD32_OFFSET(pSrc16 + (2u * i2)) =
emh203 0:3d9c67d97d6f 1417 ((out2) & 0xFFFF0000) | (out1 & 0x0000FFFF);
emh203 0:3d9c67d97d6f 1418
emh203 0:3d9c67d97d6f 1419 /* Butterfly process for the i0+3fftLen/4 sample */
emh203 0:3d9c67d97d6f 1420
emh203 0:3d9c67d97d6f 1421 #ifndef ARM_MATH_BIG_ENDIAN
emh203 0:3d9c67d97d6f 1422
emh203 0:3d9c67d97d6f 1423 out1 = __SMUSD(C3, R) >> 16u;
emh203 0:3d9c67d97d6f 1424 out2 = __SMUADX(C3, R);
emh203 0:3d9c67d97d6f 1425
emh203 0:3d9c67d97d6f 1426 #else
emh203 0:3d9c67d97d6f 1427
emh203 0:3d9c67d97d6f 1428 out1 = __SMUADX(C3, R) >> 16u;
emh203 0:3d9c67d97d6f 1429 out2 = __SMUSD(__QSUB16(0, C3), R);
emh203 0:3d9c67d97d6f 1430
emh203 0:3d9c67d97d6f 1431 #endif /* #ifndef ARM_MATH_BIG_ENDIAN */
emh203 0:3d9c67d97d6f 1432
emh203 0:3d9c67d97d6f 1433 /* xd' = (xa-yb-xc+yd)* co3 + (ya+xb-yc-xd)* (si3) */
emh203 0:3d9c67d97d6f 1434 /* yd' = (ya+xb-yc-xd)* co3 - (xa-yb-xc+yd)* (si3) */
emh203 0:3d9c67d97d6f 1435 _SIMD32_OFFSET(pSrc16 + (2u * i3)) =
emh203 0:3d9c67d97d6f 1436 ((out2) & 0xFFFF0000) | (out1 & 0x0000FFFF);
emh203 0:3d9c67d97d6f 1437 }
emh203 0:3d9c67d97d6f 1438 }
emh203 0:3d9c67d97d6f 1439 /* Twiddle coefficients index modifier */
emh203 0:3d9c67d97d6f 1440 twidCoefModifier <<= 2u;
emh203 0:3d9c67d97d6f 1441 }
emh203 0:3d9c67d97d6f 1442 /* end of middle stage process */
emh203 0:3d9c67d97d6f 1443
emh203 0:3d9c67d97d6f 1444 /* data is in 10.6(q6) format for the 1024 point */
emh203 0:3d9c67d97d6f 1445 /* data is in 8.8(q8) format for the 256 point */
emh203 0:3d9c67d97d6f 1446 /* data is in 6.10(q10) format for the 64 point */
emh203 0:3d9c67d97d6f 1447 /* data is in 4.12(q12) format for the 16 point */
emh203 0:3d9c67d97d6f 1448
emh203 0:3d9c67d97d6f 1449 /* Initializations for the last stage */
emh203 0:3d9c67d97d6f 1450 j = fftLen >> 2;
emh203 0:3d9c67d97d6f 1451
emh203 0:3d9c67d97d6f 1452 ptr1 = &pSrc16[0];
emh203 0:3d9c67d97d6f 1453
emh203 0:3d9c67d97d6f 1454 /* start of last stage process */
emh203 0:3d9c67d97d6f 1455
emh203 0:3d9c67d97d6f 1456 /* Butterfly implementation */
emh203 0:3d9c67d97d6f 1457 do
emh203 0:3d9c67d97d6f 1458 {
emh203 0:3d9c67d97d6f 1459 /* Read xa (real), ya(imag) input */
emh203 0:3d9c67d97d6f 1460 xaya = *__SIMD32(ptr1)++;
emh203 0:3d9c67d97d6f 1461
emh203 0:3d9c67d97d6f 1462 /* Read xb (real), yb(imag) input */
emh203 0:3d9c67d97d6f 1463 xbyb = *__SIMD32(ptr1)++;
emh203 0:3d9c67d97d6f 1464
emh203 0:3d9c67d97d6f 1465 /* Read xc (real), yc(imag) input */
emh203 0:3d9c67d97d6f 1466 xcyc = *__SIMD32(ptr1)++;
emh203 0:3d9c67d97d6f 1467
emh203 0:3d9c67d97d6f 1468 /* Read xd (real), yd(imag) input */
emh203 0:3d9c67d97d6f 1469 xdyd = *__SIMD32(ptr1)++;
emh203 0:3d9c67d97d6f 1470
emh203 0:3d9c67d97d6f 1471 /* R = packed((ya + yc), (xa + xc)) */
emh203 0:3d9c67d97d6f 1472 R = __QADD16(xaya, xcyc);
emh203 0:3d9c67d97d6f 1473
emh203 0:3d9c67d97d6f 1474 /* T = packed((yb + yd), (xb + xd)) */
emh203 0:3d9c67d97d6f 1475 T = __QADD16(xbyb, xdyd);
emh203 0:3d9c67d97d6f 1476
emh203 0:3d9c67d97d6f 1477 /* pointer updation for writing */
emh203 0:3d9c67d97d6f 1478 ptr1 = ptr1 - 8u;
emh203 0:3d9c67d97d6f 1479
emh203 0:3d9c67d97d6f 1480
emh203 0:3d9c67d97d6f 1481 /* xa' = xa + xb + xc + xd */
emh203 0:3d9c67d97d6f 1482 /* ya' = ya + yb + yc + yd */
emh203 0:3d9c67d97d6f 1483 *__SIMD32(ptr1)++ = __SHADD16(R, T);
emh203 0:3d9c67d97d6f 1484
emh203 0:3d9c67d97d6f 1485 /* T = packed((yb + yd), (xb + xd)) */
emh203 0:3d9c67d97d6f 1486 T = __QADD16(xbyb, xdyd);
emh203 0:3d9c67d97d6f 1487
emh203 0:3d9c67d97d6f 1488 /* xc' = (xa-xb+xc-xd) */
emh203 0:3d9c67d97d6f 1489 /* yc' = (ya-yb+yc-yd) */
emh203 0:3d9c67d97d6f 1490 *__SIMD32(ptr1)++ = __SHSUB16(R, T);
emh203 0:3d9c67d97d6f 1491
emh203 0:3d9c67d97d6f 1492 /* S = packed((ya - yc), (xa - xc)) */
emh203 0:3d9c67d97d6f 1493 S = __QSUB16(xaya, xcyc);
emh203 0:3d9c67d97d6f 1494
emh203 0:3d9c67d97d6f 1495 /* Read yd (real), xd(imag) input */
emh203 0:3d9c67d97d6f 1496 /* T = packed( (yb - yd), (xb - xd)) */
emh203 0:3d9c67d97d6f 1497 U = __QSUB16(xbyb, xdyd);
emh203 0:3d9c67d97d6f 1498
emh203 0:3d9c67d97d6f 1499 #ifndef ARM_MATH_BIG_ENDIAN
emh203 0:3d9c67d97d6f 1500
emh203 0:3d9c67d97d6f 1501 /* xb' = (xa+yb-xc-yd) */
emh203 0:3d9c67d97d6f 1502 /* yb' = (ya-xb-yc+xd) */
emh203 0:3d9c67d97d6f 1503 *__SIMD32(ptr1)++ = __SHASX(S, U);
emh203 0:3d9c67d97d6f 1504
emh203 0:3d9c67d97d6f 1505
emh203 0:3d9c67d97d6f 1506 /* xd' = (xa-yb-xc+yd) */
emh203 0:3d9c67d97d6f 1507 /* yd' = (ya+xb-yc-xd) */
emh203 0:3d9c67d97d6f 1508 *__SIMD32(ptr1)++ = __SHSAX(S, U);
emh203 0:3d9c67d97d6f 1509
emh203 0:3d9c67d97d6f 1510 #else
emh203 0:3d9c67d97d6f 1511
emh203 0:3d9c67d97d6f 1512 /* xb' = (xa+yb-xc-yd) */
emh203 0:3d9c67d97d6f 1513 /* yb' = (ya-xb-yc+xd) */
emh203 0:3d9c67d97d6f 1514 *__SIMD32(ptr1)++ = __SHSAX(S, U);
emh203 0:3d9c67d97d6f 1515
emh203 0:3d9c67d97d6f 1516
emh203 0:3d9c67d97d6f 1517 /* xd' = (xa-yb-xc+yd) */
emh203 0:3d9c67d97d6f 1518 /* yd' = (ya+xb-yc-xd) */
emh203 0:3d9c67d97d6f 1519 *__SIMD32(ptr1)++ = __SHASX(S, U);
emh203 0:3d9c67d97d6f 1520
emh203 0:3d9c67d97d6f 1521
emh203 0:3d9c67d97d6f 1522 #endif /* #ifndef ARM_MATH_BIG_ENDIAN */
emh203 0:3d9c67d97d6f 1523
emh203 0:3d9c67d97d6f 1524 } while(--j);
emh203 0:3d9c67d97d6f 1525
emh203 0:3d9c67d97d6f 1526 /* end of last stage process */
emh203 0:3d9c67d97d6f 1527
emh203 0:3d9c67d97d6f 1528 /* output is in 11.5(q5) format for the 1024 point */
emh203 0:3d9c67d97d6f 1529 /* output is in 9.7(q7) format for the 256 point */
emh203 0:3d9c67d97d6f 1530 /* output is in 7.9(q9) format for the 64 point */
emh203 0:3d9c67d97d6f 1531 /* output is in 5.11(q11) format for the 16 point */
emh203 0:3d9c67d97d6f 1532
emh203 0:3d9c67d97d6f 1533
emh203 0:3d9c67d97d6f 1534 #else
emh203 0:3d9c67d97d6f 1535
emh203 0:3d9c67d97d6f 1536 /* Run the below code for Cortex-M0 */
emh203 0:3d9c67d97d6f 1537
emh203 0:3d9c67d97d6f 1538 q15_t R0, R1, S0, S1, T0, T1, U0, U1;
emh203 0:3d9c67d97d6f 1539 q15_t Co1, Si1, Co2, Si2, Co3, Si3, out1, out2;
emh203 0:3d9c67d97d6f 1540 uint32_t n1, n2, ic, i0, i1, i2, i3, j, k;
emh203 0:3d9c67d97d6f 1541
emh203 0:3d9c67d97d6f 1542 /* Total process is divided into three stages */
emh203 0:3d9c67d97d6f 1543
emh203 0:3d9c67d97d6f 1544 /* process first stage, middle stages, & last stage */
emh203 0:3d9c67d97d6f 1545
emh203 0:3d9c67d97d6f 1546 /* Initializations for the first stage */
emh203 0:3d9c67d97d6f 1547 n2 = fftLen;
emh203 0:3d9c67d97d6f 1548 n1 = n2;
emh203 0:3d9c67d97d6f 1549
emh203 0:3d9c67d97d6f 1550 /* n2 = fftLen/4 */
emh203 0:3d9c67d97d6f 1551 n2 >>= 2u;
emh203 0:3d9c67d97d6f 1552
emh203 0:3d9c67d97d6f 1553 /* Index for twiddle coefficient */
emh203 0:3d9c67d97d6f 1554 ic = 0u;
emh203 0:3d9c67d97d6f 1555
emh203 0:3d9c67d97d6f 1556 /* Index for input read and output write */
emh203 0:3d9c67d97d6f 1557 i0 = 0u;
emh203 0:3d9c67d97d6f 1558
emh203 0:3d9c67d97d6f 1559 j = n2;
emh203 0:3d9c67d97d6f 1560
emh203 0:3d9c67d97d6f 1561 /* Input is in 1.15(q15) format */
emh203 0:3d9c67d97d6f 1562
emh203 0:3d9c67d97d6f 1563 /* Start of first stage process */
emh203 0:3d9c67d97d6f 1564 do
emh203 0:3d9c67d97d6f 1565 {
emh203 0:3d9c67d97d6f 1566 /* Butterfly implementation */
emh203 0:3d9c67d97d6f 1567
emh203 0:3d9c67d97d6f 1568 /* index calculation for the input as, */
emh203 0:3d9c67d97d6f 1569 /* pSrc16[i0 + 0], pSrc16[i0 + fftLen/4], pSrc16[i0 + fftLen/2], pSrc16[i0 + 3fftLen/4] */
emh203 0:3d9c67d97d6f 1570 i1 = i0 + n2;
emh203 0:3d9c67d97d6f 1571 i2 = i1 + n2;
emh203 0:3d9c67d97d6f 1572 i3 = i2 + n2;
emh203 0:3d9c67d97d6f 1573
emh203 0:3d9c67d97d6f 1574 /* Reading i0, i0+fftLen/2 inputs */
emh203 0:3d9c67d97d6f 1575 /* input is down scale by 4 to avoid overflow */
emh203 0:3d9c67d97d6f 1576 /* Read ya (real), xa(imag) input */
emh203 0:3d9c67d97d6f 1577 T0 = pSrc16[i0 * 2u] >> 2u;
emh203 0:3d9c67d97d6f 1578 T1 = pSrc16[(i0 * 2u) + 1u] >> 2u;
emh203 0:3d9c67d97d6f 1579 /* input is down scale by 4 to avoid overflow */
emh203 0:3d9c67d97d6f 1580 /* Read yc (real), xc(imag) input */
emh203 0:3d9c67d97d6f 1581 S0 = pSrc16[i2 * 2u] >> 2u;
emh203 0:3d9c67d97d6f 1582 S1 = pSrc16[(i2 * 2u) + 1u] >> 2u;
emh203 0:3d9c67d97d6f 1583
emh203 0:3d9c67d97d6f 1584 /* R0 = (ya + yc), R1 = (xa + xc) */
emh203 0:3d9c67d97d6f 1585 R0 = __SSAT(T0 + S0, 16u);
emh203 0:3d9c67d97d6f 1586 R1 = __SSAT(T1 + S1, 16u);
emh203 0:3d9c67d97d6f 1587 /* S0 = (ya - yc), S1 = (xa - xc) */
emh203 0:3d9c67d97d6f 1588 S0 = __SSAT(T0 - S0, 16u);
emh203 0:3d9c67d97d6f 1589 S1 = __SSAT(T1 - S1, 16u);
emh203 0:3d9c67d97d6f 1590
emh203 0:3d9c67d97d6f 1591 /* Reading i0+fftLen/4 , i0+3fftLen/4 inputs */
emh203 0:3d9c67d97d6f 1592 /* input is down scale by 4 to avoid overflow */
emh203 0:3d9c67d97d6f 1593 /* Read yb (real), xb(imag) input */
emh203 0:3d9c67d97d6f 1594 T0 = pSrc16[i1 * 2u] >> 2u;
emh203 0:3d9c67d97d6f 1595 T1 = pSrc16[(i1 * 2u) + 1u] >> 2u;
emh203 0:3d9c67d97d6f 1596 /* Read yd (real), xd(imag) input */
emh203 0:3d9c67d97d6f 1597 /* input is down scale by 4 to avoid overflow */
emh203 0:3d9c67d97d6f 1598 U0 = pSrc16[i3 * 2u] >> 2u;
emh203 0:3d9c67d97d6f 1599 U1 = pSrc16[(i3 * 2u) + 1u] >> 2u;
emh203 0:3d9c67d97d6f 1600
emh203 0:3d9c67d97d6f 1601 /* T0 = (yb + yd), T1 = (xb + xd) */
emh203 0:3d9c67d97d6f 1602 T0 = __SSAT(T0 + U0, 16u);
emh203 0:3d9c67d97d6f 1603 T1 = __SSAT(T1 + U1, 16u);
emh203 0:3d9c67d97d6f 1604
emh203 0:3d9c67d97d6f 1605 /* writing the butterfly processed i0 sample */
emh203 0:3d9c67d97d6f 1606 /* xa' = xa + xb + xc + xd */
emh203 0:3d9c67d97d6f 1607 /* ya' = ya + yb + yc + yd */
emh203 0:3d9c67d97d6f 1608 pSrc16[i0 * 2u] = (R0 >> 1u) + (T0 >> 1u);
emh203 0:3d9c67d97d6f 1609 pSrc16[(i0 * 2u) + 1u] = (R1 >> 1u) + (T1 >> 1u);
emh203 0:3d9c67d97d6f 1610
emh203 0:3d9c67d97d6f 1611 /* R0 = (ya + yc) - (yb + yd), R1 = (xa + xc)- (xb + xd) */
emh203 0:3d9c67d97d6f 1612 R0 = __SSAT(R0 - T0, 16u);
emh203 0:3d9c67d97d6f 1613 R1 = __SSAT(R1 - T1, 16u);
emh203 0:3d9c67d97d6f 1614 /* co2 & si2 are read from Coefficient pointer */
emh203 0:3d9c67d97d6f 1615 Co2 = pCoef16[2u * ic * 2u];
emh203 0:3d9c67d97d6f 1616 Si2 = pCoef16[(2u * ic * 2u) + 1u];
emh203 0:3d9c67d97d6f 1617 /* xc' = (xa-xb+xc-xd)* co2 - (ya-yb+yc-yd)* (si2) */
emh203 0:3d9c67d97d6f 1618 out1 = (q15_t) ((Co2 * R0 - Si2 * R1) >> 16u);
emh203 0:3d9c67d97d6f 1619 /* yc' = (ya-yb+yc-yd)* co2 + (xa-xb+xc-xd)* (si2) */
emh203 0:3d9c67d97d6f 1620 out2 = (q15_t) ((Si2 * R0 + Co2 * R1) >> 16u);
emh203 0:3d9c67d97d6f 1621
emh203 0:3d9c67d97d6f 1622 /* Reading i0+fftLen/4 */
emh203 0:3d9c67d97d6f 1623 /* input is down scale by 4 to avoid overflow */
emh203 0:3d9c67d97d6f 1624 /* T0 = yb, T1 = xb */
emh203 0:3d9c67d97d6f 1625 T0 = pSrc16[i1 * 2u] >> 2u;
emh203 0:3d9c67d97d6f 1626 T1 = pSrc16[(i1 * 2u) + 1u] >> 2u;
emh203 0:3d9c67d97d6f 1627
emh203 0:3d9c67d97d6f 1628 /* writing the butterfly processed i0 + fftLen/4 sample */
emh203 0:3d9c67d97d6f 1629 /* writing output(xc', yc') in little endian format */
emh203 0:3d9c67d97d6f 1630 pSrc16[i1 * 2u] = out1;
emh203 0:3d9c67d97d6f 1631 pSrc16[(i1 * 2u) + 1u] = out2;
emh203 0:3d9c67d97d6f 1632
emh203 0:3d9c67d97d6f 1633 /* Butterfly calculations */
emh203 0:3d9c67d97d6f 1634 /* input is down scale by 4 to avoid overflow */
emh203 0:3d9c67d97d6f 1635 /* U0 = yd, U1 = xd) */
emh203 0:3d9c67d97d6f 1636 U0 = pSrc16[i3 * 2u] >> 2u;
emh203 0:3d9c67d97d6f 1637 U1 = pSrc16[(i3 * 2u) + 1u] >> 2u;
emh203 0:3d9c67d97d6f 1638
emh203 0:3d9c67d97d6f 1639 /* T0 = yb-yd, T1 = xb-xd) */
emh203 0:3d9c67d97d6f 1640 T0 = __SSAT(T0 - U0, 16u);
emh203 0:3d9c67d97d6f 1641 T1 = __SSAT(T1 - U1, 16u);
emh203 0:3d9c67d97d6f 1642 /* R0 = (ya-yc) - (xb- xd) , R1 = (xa-xc) + (yb-yd) */
emh203 0:3d9c67d97d6f 1643 R0 = (q15_t) __SSAT((q31_t) (S0 + T1), 16);
emh203 0:3d9c67d97d6f 1644 R1 = (q15_t) __SSAT((q31_t) (S1 - T0), 16);
emh203 0:3d9c67d97d6f 1645 /* S = (ya-yc) + (xb- xd), S1 = (xa-xc) - (yb-yd) */
emh203 0:3d9c67d97d6f 1646 S0 = (q15_t) __SSAT((q31_t) (S0 - T1), 16);
emh203 0:3d9c67d97d6f 1647 S1 = (q15_t) __SSAT((q31_t) (S1 + T0), 16);
emh203 0:3d9c67d97d6f 1648
emh203 0:3d9c67d97d6f 1649 /* co1 & si1 are read from Coefficient pointer */
emh203 0:3d9c67d97d6f 1650 Co1 = pCoef16[ic * 2u];
emh203 0:3d9c67d97d6f 1651 Si1 = pCoef16[(ic * 2u) + 1u];
emh203 0:3d9c67d97d6f 1652 /* Butterfly process for the i0+fftLen/2 sample */
emh203 0:3d9c67d97d6f 1653 /* xb' = (xa-yb-xc+yd)* co1 - (ya+xb-yc-xd)* (si1) */
emh203 0:3d9c67d97d6f 1654 out1 = (q15_t) ((Co1 * S0 - Si1 * S1) >> 16u);
emh203 0:3d9c67d97d6f 1655 /* yb' = (ya+xb-yc-xd)* co1 + (xa-yb-xc+yd)* (si1) */
emh203 0:3d9c67d97d6f 1656 out2 = (q15_t) ((Si1 * S0 + Co1 * S1) >> 16u);
emh203 0:3d9c67d97d6f 1657 /* writing output(xb', yb') in little endian format */
emh203 0:3d9c67d97d6f 1658 pSrc16[i2 * 2u] = out1;
emh203 0:3d9c67d97d6f 1659 pSrc16[(i2 * 2u) + 1u] = out2;
emh203 0:3d9c67d97d6f 1660
emh203 0:3d9c67d97d6f 1661 /* Co3 & si3 are read from Coefficient pointer */
emh203 0:3d9c67d97d6f 1662 Co3 = pCoef16[3u * ic * 2u];
emh203 0:3d9c67d97d6f 1663 Si3 = pCoef16[(3u * ic * 2u) + 1u];
emh203 0:3d9c67d97d6f 1664 /* Butterfly process for the i0+3fftLen/4 sample */
emh203 0:3d9c67d97d6f 1665 /* xd' = (xa+yb-xc-yd)* Co3 - (ya-xb-yc+xd)* (si3) */
emh203 0:3d9c67d97d6f 1666 out1 = (q15_t) ((Co3 * R0 - Si3 * R1) >> 16u);
emh203 0:3d9c67d97d6f 1667 /* yd' = (ya-xb-yc+xd)* Co3 + (xa+yb-xc-yd)* (si3) */
emh203 0:3d9c67d97d6f 1668 out2 = (q15_t) ((Si3 * R0 + Co3 * R1) >> 16u);
emh203 0:3d9c67d97d6f 1669 /* writing output(xd', yd') in little endian format */
emh203 0:3d9c67d97d6f 1670 pSrc16[i3 * 2u] = out1;
emh203 0:3d9c67d97d6f 1671 pSrc16[(i3 * 2u) + 1u] = out2;
emh203 0:3d9c67d97d6f 1672
emh203 0:3d9c67d97d6f 1673 /* Twiddle coefficients index modifier */
emh203 0:3d9c67d97d6f 1674 ic = ic + twidCoefModifier;
emh203 0:3d9c67d97d6f 1675
emh203 0:3d9c67d97d6f 1676 /* Updating input index */
emh203 0:3d9c67d97d6f 1677 i0 = i0 + 1u;
emh203 0:3d9c67d97d6f 1678
emh203 0:3d9c67d97d6f 1679 } while(--j);
emh203 0:3d9c67d97d6f 1680
emh203 0:3d9c67d97d6f 1681 /* End of first stage process */
emh203 0:3d9c67d97d6f 1682
emh203 0:3d9c67d97d6f 1683 /* data is in 4.11(q11) format */
emh203 0:3d9c67d97d6f 1684
emh203 0:3d9c67d97d6f 1685
emh203 0:3d9c67d97d6f 1686 /* Start of Middle stage process */
emh203 0:3d9c67d97d6f 1687
emh203 0:3d9c67d97d6f 1688 /* Twiddle coefficients index modifier */
emh203 0:3d9c67d97d6f 1689 twidCoefModifier <<= 2u;
emh203 0:3d9c67d97d6f 1690
emh203 0:3d9c67d97d6f 1691 /* Calculation of Middle stage */
emh203 0:3d9c67d97d6f 1692 for (k = fftLen / 4u; k > 4u; k >>= 2u)
emh203 0:3d9c67d97d6f 1693 {
emh203 0:3d9c67d97d6f 1694 /* Initializations for the middle stage */
emh203 0:3d9c67d97d6f 1695 n1 = n2;
emh203 0:3d9c67d97d6f 1696 n2 >>= 2u;
emh203 0:3d9c67d97d6f 1697 ic = 0u;
emh203 0:3d9c67d97d6f 1698
emh203 0:3d9c67d97d6f 1699 for (j = 0u; j <= (n2 - 1u); j++)
emh203 0:3d9c67d97d6f 1700 {
emh203 0:3d9c67d97d6f 1701 /* index calculation for the coefficients */
emh203 0:3d9c67d97d6f 1702 Co1 = pCoef16[ic * 2u];
emh203 0:3d9c67d97d6f 1703 Si1 = pCoef16[(ic * 2u) + 1u];
emh203 0:3d9c67d97d6f 1704 Co2 = pCoef16[2u * ic * 2u];
emh203 0:3d9c67d97d6f 1705 Si2 = pCoef16[2u * ic * 2u + 1u];
emh203 0:3d9c67d97d6f 1706 Co3 = pCoef16[3u * ic * 2u];
emh203 0:3d9c67d97d6f 1707 Si3 = pCoef16[(3u * ic * 2u) + 1u];
emh203 0:3d9c67d97d6f 1708
emh203 0:3d9c67d97d6f 1709 /* Twiddle coefficients index modifier */
emh203 0:3d9c67d97d6f 1710 ic = ic + twidCoefModifier;
emh203 0:3d9c67d97d6f 1711
emh203 0:3d9c67d97d6f 1712 /* Butterfly implementation */
emh203 0:3d9c67d97d6f 1713 for (i0 = j; i0 < fftLen; i0 += n1)
emh203 0:3d9c67d97d6f 1714 {
emh203 0:3d9c67d97d6f 1715 /* index calculation for the input as, */
emh203 0:3d9c67d97d6f 1716 /* pSrc16[i0 + 0], pSrc16[i0 + fftLen/4], pSrc16[i0 + fftLen/2], pSrc16[i0 + 3fftLen/4] */
emh203 0:3d9c67d97d6f 1717 i1 = i0 + n2;
emh203 0:3d9c67d97d6f 1718 i2 = i1 + n2;
emh203 0:3d9c67d97d6f 1719 i3 = i2 + n2;
emh203 0:3d9c67d97d6f 1720
emh203 0:3d9c67d97d6f 1721 /* Reading i0, i0+fftLen/2 inputs */
emh203 0:3d9c67d97d6f 1722 /* Read ya (real), xa(imag) input */
emh203 0:3d9c67d97d6f 1723 T0 = pSrc16[i0 * 2u];
emh203 0:3d9c67d97d6f 1724 T1 = pSrc16[(i0 * 2u) + 1u];
emh203 0:3d9c67d97d6f 1725
emh203 0:3d9c67d97d6f 1726 /* Read yc (real), xc(imag) input */
emh203 0:3d9c67d97d6f 1727 S0 = pSrc16[i2 * 2u];
emh203 0:3d9c67d97d6f 1728 S1 = pSrc16[(i2 * 2u) + 1u];
emh203 0:3d9c67d97d6f 1729
emh203 0:3d9c67d97d6f 1730
emh203 0:3d9c67d97d6f 1731 /* R0 = (ya + yc), R1 = (xa + xc) */
emh203 0:3d9c67d97d6f 1732 R0 = __SSAT(T0 + S0, 16u);
emh203 0:3d9c67d97d6f 1733 R1 = __SSAT(T1 + S1, 16u);
emh203 0:3d9c67d97d6f 1734 /* S0 = (ya - yc), S1 = (xa - xc) */
emh203 0:3d9c67d97d6f 1735 S0 = __SSAT(T0 - S0, 16u);
emh203 0:3d9c67d97d6f 1736 S1 = __SSAT(T1 - S1, 16u);
emh203 0:3d9c67d97d6f 1737
emh203 0:3d9c67d97d6f 1738 /* Reading i0+fftLen/4 , i0+3fftLen/4 inputs */
emh203 0:3d9c67d97d6f 1739 /* Read yb (real), xb(imag) input */
emh203 0:3d9c67d97d6f 1740 T0 = pSrc16[i1 * 2u];
emh203 0:3d9c67d97d6f 1741 T1 = pSrc16[(i1 * 2u) + 1u];
emh203 0:3d9c67d97d6f 1742
emh203 0:3d9c67d97d6f 1743 /* Read yd (real), xd(imag) input */
emh203 0:3d9c67d97d6f 1744 U0 = pSrc16[i3 * 2u];
emh203 0:3d9c67d97d6f 1745 U1 = pSrc16[(i3 * 2u) + 1u];
emh203 0:3d9c67d97d6f 1746
emh203 0:3d9c67d97d6f 1747 /* T0 = (yb + yd), T1 = (xb + xd) */
emh203 0:3d9c67d97d6f 1748 T0 = __SSAT(T0 + U0, 16u);
emh203 0:3d9c67d97d6f 1749 T1 = __SSAT(T1 + U1, 16u);
emh203 0:3d9c67d97d6f 1750
emh203 0:3d9c67d97d6f 1751 /* writing the butterfly processed i0 sample */
emh203 0:3d9c67d97d6f 1752 /* xa' = xa + xb + xc + xd */
emh203 0:3d9c67d97d6f 1753 /* ya' = ya + yb + yc + yd */
emh203 0:3d9c67d97d6f 1754 pSrc16[i0 * 2u] = ((R0 >> 1u) + (T0 >> 1u)) >> 1u;
emh203 0:3d9c67d97d6f 1755 pSrc16[(i0 * 2u) + 1u] = ((R1 >> 1u) + (T1 >> 1u)) >> 1u;
emh203 0:3d9c67d97d6f 1756
emh203 0:3d9c67d97d6f 1757 /* R0 = (ya + yc) - (yb + yd), R1 = (xa + xc) - (xb + xd) */
emh203 0:3d9c67d97d6f 1758 R0 = (R0 >> 1u) - (T0 >> 1u);
emh203 0:3d9c67d97d6f 1759 R1 = (R1 >> 1u) - (T1 >> 1u);
emh203 0:3d9c67d97d6f 1760
emh203 0:3d9c67d97d6f 1761 /* (ya-yb+yc-yd)* (si2) - (xa-xb+xc-xd)* co2 */
emh203 0:3d9c67d97d6f 1762 out1 = (q15_t) ((Co2 * R0 - Si2 * R1) >> 16);
emh203 0:3d9c67d97d6f 1763 /* (ya-yb+yc-yd)* co2 + (xa-xb+xc-xd)* (si2) */
emh203 0:3d9c67d97d6f 1764 out2 = (q15_t) ((Si2 * R0 + Co2 * R1) >> 16);
emh203 0:3d9c67d97d6f 1765
emh203 0:3d9c67d97d6f 1766 /* Reading i0+3fftLen/4 */
emh203 0:3d9c67d97d6f 1767 /* Read yb (real), xb(imag) input */
emh203 0:3d9c67d97d6f 1768 T0 = pSrc16[i1 * 2u];
emh203 0:3d9c67d97d6f 1769 T1 = pSrc16[(i1 * 2u) + 1u];
emh203 0:3d9c67d97d6f 1770
emh203 0:3d9c67d97d6f 1771 /* writing the butterfly processed i0 + fftLen/4 sample */
emh203 0:3d9c67d97d6f 1772 /* xc' = (xa-xb+xc-xd)* co2 - (ya-yb+yc-yd)* (si2) */
emh203 0:3d9c67d97d6f 1773 /* yc' = (ya-yb+yc-yd)* co2 + (xa-xb+xc-xd)* (si2) */
emh203 0:3d9c67d97d6f 1774 pSrc16[i1 * 2u] = out1;
emh203 0:3d9c67d97d6f 1775 pSrc16[(i1 * 2u) + 1u] = out2;
emh203 0:3d9c67d97d6f 1776
emh203 0:3d9c67d97d6f 1777 /* Butterfly calculations */
emh203 0:3d9c67d97d6f 1778 /* Read yd (real), xd(imag) input */
emh203 0:3d9c67d97d6f 1779 U0 = pSrc16[i3 * 2u];
emh203 0:3d9c67d97d6f 1780 U1 = pSrc16[(i3 * 2u) + 1u];
emh203 0:3d9c67d97d6f 1781
emh203 0:3d9c67d97d6f 1782 /* T0 = yb-yd, T1 = xb-xd) */
emh203 0:3d9c67d97d6f 1783 T0 = __SSAT(T0 - U0, 16u);
emh203 0:3d9c67d97d6f 1784 T1 = __SSAT(T1 - U1, 16u);
emh203 0:3d9c67d97d6f 1785
emh203 0:3d9c67d97d6f 1786 /* R0 = (ya-yc) - (xb- xd) , R1 = (xa-xc) + (yb-yd) */
emh203 0:3d9c67d97d6f 1787 R0 = (S0 >> 1u) + (T1 >> 1u);
emh203 0:3d9c67d97d6f 1788 R1 = (S1 >> 1u) - (T0 >> 1u);
emh203 0:3d9c67d97d6f 1789
emh203 0:3d9c67d97d6f 1790 /* S1 = (ya-yc) + (xb- xd), S1 = (xa-xc) - (yb-yd) */
emh203 0:3d9c67d97d6f 1791 S0 = (S0 >> 1u) - (T1 >> 1u);
emh203 0:3d9c67d97d6f 1792 S1 = (S1 >> 1u) + (T0 >> 1u);
emh203 0:3d9c67d97d6f 1793
emh203 0:3d9c67d97d6f 1794 /* Butterfly process for the i0+fftLen/2 sample */
emh203 0:3d9c67d97d6f 1795 out1 = (q15_t) ((Co1 * S0 - Si1 * S1) >> 16u);
emh203 0:3d9c67d97d6f 1796 out2 = (q15_t) ((Si1 * S0 + Co1 * S1) >> 16u);
emh203 0:3d9c67d97d6f 1797 /* xb' = (xa-yb-xc+yd)* co1 - (ya+xb-yc-xd)* (si1) */
emh203 0:3d9c67d97d6f 1798 /* yb' = (ya+xb-yc-xd)* co1 + (xa-yb-xc+yd)* (si1) */
emh203 0:3d9c67d97d6f 1799 pSrc16[i2 * 2u] = out1;
emh203 0:3d9c67d97d6f 1800 pSrc16[(i2 * 2u) + 1u] = out2;
emh203 0:3d9c67d97d6f 1801
emh203 0:3d9c67d97d6f 1802 /* Butterfly process for the i0+3fftLen/4 sample */
emh203 0:3d9c67d97d6f 1803 out1 = (q15_t) ((Co3 * R0 - Si3 * R1) >> 16u);
emh203 0:3d9c67d97d6f 1804
emh203 0:3d9c67d97d6f 1805 out2 = (q15_t) ((Si3 * R0 + Co3 * R1) >> 16u);
emh203 0:3d9c67d97d6f 1806 /* xd' = (xa+yb-xc-yd)* Co3 - (ya-xb-yc+xd)* (si3) */
emh203 0:3d9c67d97d6f 1807 /* yd' = (ya-xb-yc+xd)* Co3 + (xa+yb-xc-yd)* (si3) */
emh203 0:3d9c67d97d6f 1808 pSrc16[i3 * 2u] = out1;
emh203 0:3d9c67d97d6f 1809 pSrc16[(i3 * 2u) + 1u] = out2;
emh203 0:3d9c67d97d6f 1810
emh203 0:3d9c67d97d6f 1811
emh203 0:3d9c67d97d6f 1812 }
emh203 0:3d9c67d97d6f 1813 }
emh203 0:3d9c67d97d6f 1814 /* Twiddle coefficients index modifier */
emh203 0:3d9c67d97d6f 1815 twidCoefModifier <<= 2u;
emh203 0:3d9c67d97d6f 1816 }
emh203 0:3d9c67d97d6f 1817 /* End of Middle stages process */
emh203 0:3d9c67d97d6f 1818
emh203 0:3d9c67d97d6f 1819
emh203 0:3d9c67d97d6f 1820 /* data is in 10.6(q6) format for the 1024 point */
emh203 0:3d9c67d97d6f 1821 /* data is in 8.8(q8) format for the 256 point */
emh203 0:3d9c67d97d6f 1822 /* data is in 6.10(q10) format for the 64 point */
emh203 0:3d9c67d97d6f 1823 /* data is in 4.12(q12) format for the 16 point */
emh203 0:3d9c67d97d6f 1824
emh203 0:3d9c67d97d6f 1825 /* start of last stage process */
emh203 0:3d9c67d97d6f 1826
emh203 0:3d9c67d97d6f 1827
emh203 0:3d9c67d97d6f 1828 /* Initializations for the last stage */
emh203 0:3d9c67d97d6f 1829 n1 = n2;
emh203 0:3d9c67d97d6f 1830 n2 >>= 2u;
emh203 0:3d9c67d97d6f 1831
emh203 0:3d9c67d97d6f 1832 /* Butterfly implementation */
emh203 0:3d9c67d97d6f 1833 for (i0 = 0u; i0 <= (fftLen - n1); i0 += n1)
emh203 0:3d9c67d97d6f 1834 {
emh203 0:3d9c67d97d6f 1835 /* index calculation for the input as, */
emh203 0:3d9c67d97d6f 1836 /* pSrc16[i0 + 0], pSrc16[i0 + fftLen/4], pSrc16[i0 + fftLen/2], pSrc16[i0 + 3fftLen/4] */
emh203 0:3d9c67d97d6f 1837 i1 = i0 + n2;
emh203 0:3d9c67d97d6f 1838 i2 = i1 + n2;
emh203 0:3d9c67d97d6f 1839 i3 = i2 + n2;
emh203 0:3d9c67d97d6f 1840
emh203 0:3d9c67d97d6f 1841 /* Reading i0, i0+fftLen/2 inputs */
emh203 0:3d9c67d97d6f 1842 /* Read ya (real), xa(imag) input */
emh203 0:3d9c67d97d6f 1843 T0 = pSrc16[i0 * 2u];
emh203 0:3d9c67d97d6f 1844 T1 = pSrc16[(i0 * 2u) + 1u];
emh203 0:3d9c67d97d6f 1845 /* Read yc (real), xc(imag) input */
emh203 0:3d9c67d97d6f 1846 S0 = pSrc16[i2 * 2u];
emh203 0:3d9c67d97d6f 1847 S1 = pSrc16[(i2 * 2u) + 1u];
emh203 0:3d9c67d97d6f 1848
emh203 0:3d9c67d97d6f 1849 /* R0 = (ya + yc), R1 = (xa + xc) */
emh203 0:3d9c67d97d6f 1850 R0 = __SSAT(T0 + S0, 16u);
emh203 0:3d9c67d97d6f 1851 R1 = __SSAT(T1 + S1, 16u);
emh203 0:3d9c67d97d6f 1852 /* S0 = (ya - yc), S1 = (xa - xc) */
emh203 0:3d9c67d97d6f 1853 S0 = __SSAT(T0 - S0, 16u);
emh203 0:3d9c67d97d6f 1854 S1 = __SSAT(T1 - S1, 16u);
emh203 0:3d9c67d97d6f 1855
emh203 0:3d9c67d97d6f 1856 /* Reading i0+fftLen/4 , i0+3fftLen/4 inputs */
emh203 0:3d9c67d97d6f 1857 /* Read yb (real), xb(imag) input */
emh203 0:3d9c67d97d6f 1858 T0 = pSrc16[i1 * 2u];
emh203 0:3d9c67d97d6f 1859 T1 = pSrc16[(i1 * 2u) + 1u];
emh203 0:3d9c67d97d6f 1860 /* Read yd (real), xd(imag) input */
emh203 0:3d9c67d97d6f 1861 U0 = pSrc16[i3 * 2u];
emh203 0:3d9c67d97d6f 1862 U1 = pSrc16[(i3 * 2u) + 1u];
emh203 0:3d9c67d97d6f 1863
emh203 0:3d9c67d97d6f 1864 /* T0 = (yb + yd), T1 = (xb + xd) */
emh203 0:3d9c67d97d6f 1865 T0 = __SSAT(T0 + U0, 16u);
emh203 0:3d9c67d97d6f 1866 T1 = __SSAT(T1 + U1, 16u);
emh203 0:3d9c67d97d6f 1867
emh203 0:3d9c67d97d6f 1868 /* writing the butterfly processed i0 sample */
emh203 0:3d9c67d97d6f 1869 /* xa' = xa + xb + xc + xd */
emh203 0:3d9c67d97d6f 1870 /* ya' = ya + yb + yc + yd */
emh203 0:3d9c67d97d6f 1871 pSrc16[i0 * 2u] = (R0 >> 1u) + (T0 >> 1u);
emh203 0:3d9c67d97d6f 1872 pSrc16[(i0 * 2u) + 1u] = (R1 >> 1u) + (T1 >> 1u);
emh203 0:3d9c67d97d6f 1873
emh203 0:3d9c67d97d6f 1874 /* R0 = (ya + yc) - (yb + yd), R1 = (xa + xc) - (xb + xd) */
emh203 0:3d9c67d97d6f 1875 R0 = (R0 >> 1u) - (T0 >> 1u);
emh203 0:3d9c67d97d6f 1876 R1 = (R1 >> 1u) - (T1 >> 1u);
emh203 0:3d9c67d97d6f 1877
emh203 0:3d9c67d97d6f 1878 /* Read yb (real), xb(imag) input */
emh203 0:3d9c67d97d6f 1879 T0 = pSrc16[i1 * 2u];
emh203 0:3d9c67d97d6f 1880 T1 = pSrc16[(i1 * 2u) + 1u];
emh203 0:3d9c67d97d6f 1881
emh203 0:3d9c67d97d6f 1882 /* writing the butterfly processed i0 + fftLen/4 sample */
emh203 0:3d9c67d97d6f 1883 /* xc' = (xa-xb+xc-xd) */
emh203 0:3d9c67d97d6f 1884 /* yc' = (ya-yb+yc-yd) */
emh203 0:3d9c67d97d6f 1885 pSrc16[i1 * 2u] = R0;
emh203 0:3d9c67d97d6f 1886 pSrc16[(i1 * 2u) + 1u] = R1;
emh203 0:3d9c67d97d6f 1887
emh203 0:3d9c67d97d6f 1888 /* Read yd (real), xd(imag) input */
emh203 0:3d9c67d97d6f 1889 U0 = pSrc16[i3 * 2u];
emh203 0:3d9c67d97d6f 1890 U1 = pSrc16[(i3 * 2u) + 1u];
emh203 0:3d9c67d97d6f 1891 /* T0 = (yb - yd), T1 = (xb - xd) */
emh203 0:3d9c67d97d6f 1892 T0 = __SSAT(T0 - U0, 16u);
emh203 0:3d9c67d97d6f 1893 T1 = __SSAT(T1 - U1, 16u);
emh203 0:3d9c67d97d6f 1894
emh203 0:3d9c67d97d6f 1895 /* writing the butterfly processed i0 + fftLen/2 sample */
emh203 0:3d9c67d97d6f 1896 /* xb' = (xa-yb-xc+yd) */
emh203 0:3d9c67d97d6f 1897 /* yb' = (ya+xb-yc-xd) */
emh203 0:3d9c67d97d6f 1898 pSrc16[i2 * 2u] = (S0 >> 1u) - (T1 >> 1u);
emh203 0:3d9c67d97d6f 1899 pSrc16[(i2 * 2u) + 1u] = (S1 >> 1u) + (T0 >> 1u);
emh203 0:3d9c67d97d6f 1900
emh203 0:3d9c67d97d6f 1901
emh203 0:3d9c67d97d6f 1902 /* writing the butterfly processed i0 + 3fftLen/4 sample */
emh203 0:3d9c67d97d6f 1903 /* xd' = (xa+yb-xc-yd) */
emh203 0:3d9c67d97d6f 1904 /* yd' = (ya-xb-yc+xd) */
emh203 0:3d9c67d97d6f 1905 pSrc16[i3 * 2u] = (S0 >> 1u) + (T1 >> 1u);
emh203 0:3d9c67d97d6f 1906 pSrc16[(i3 * 2u) + 1u] = (S1 >> 1u) - (T0 >> 1u);
emh203 0:3d9c67d97d6f 1907 }
emh203 0:3d9c67d97d6f 1908 /* end of last stage process */
emh203 0:3d9c67d97d6f 1909
emh203 0:3d9c67d97d6f 1910 /* output is in 11.5(q5) format for the 1024 point */
emh203 0:3d9c67d97d6f 1911 /* output is in 9.7(q7) format for the 256 point */
emh203 0:3d9c67d97d6f 1912 /* output is in 7.9(q9) format for the 64 point */
emh203 0:3d9c67d97d6f 1913 /* output is in 5.11(q11) format for the 16 point */
emh203 0:3d9c67d97d6f 1914
emh203 0:3d9c67d97d6f 1915 #endif /* #ifndef ARM_MATH_CM0_FAMILY */
emh203 0:3d9c67d97d6f 1916
emh203 0:3d9c67d97d6f 1917 }