Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 2 | mjames | 1 | /* ---------------------------------------------------------------------- |
| 2 | * Copyright (C) 2010-2014 ARM Limited. All rights reserved. |
||
| 3 | * |
||
| 4 | * $Date: 19. March 2015 |
||
| 5 | * $Revision: V.1.4.5 |
||
| 6 | * |
||
| 7 | * Project: CMSIS DSP Library |
||
| 8 | * Title: arm_cfft_radix4_f32.c |
||
| 9 | * |
||
| 10 | * Description: Radix-4 Decimation in Frequency CFFT & CIFFT Floating point processing function |
||
| 11 | * |
||
| 12 | * |
||
| 13 | * Target Processor: Cortex-M4/Cortex-M3/Cortex-M0 |
||
| 14 | * |
||
| 15 | * Redistribution and use in source and binary forms, with or without |
||
| 16 | * modification, are permitted provided that the following conditions |
||
| 17 | * are met: |
||
| 18 | * - Redistributions of source code must retain the above copyright |
||
| 19 | * notice, this list of conditions and the following disclaimer. |
||
| 20 | * - Redistributions in binary form must reproduce the above copyright |
||
| 21 | * notice, this list of conditions and the following disclaimer in |
||
| 22 | * the documentation and/or other materials provided with the |
||
| 23 | * distribution. |
||
| 24 | * - Neither the name of ARM LIMITED nor the names of its contributors |
||
| 25 | * may be used to endorse or promote products derived from this |
||
| 26 | * software without specific prior written permission. |
||
| 27 | * |
||
| 28 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||
| 29 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||
| 30 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
||
| 31 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
||
| 32 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
||
| 33 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
||
| 34 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
||
| 35 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
||
| 36 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
||
| 37 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
||
| 38 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
||
| 39 | * POSSIBILITY OF SUCH DAMAGE. |
||
| 40 | * -------------------------------------------------------------------- */ |
||
| 41 | |||
| 42 | #include "arm_math.h" |
||
| 43 | |||
| 44 | extern void arm_bitreversal_f32( |
||
| 45 | float32_t * pSrc, |
||
| 46 | uint16_t fftSize, |
||
| 47 | uint16_t bitRevFactor, |
||
| 48 | uint16_t * pBitRevTab); |
||
| 49 | |||
| 50 | /** |
||
| 51 | * @ingroup groupTransforms |
||
| 52 | */ |
||
| 53 | |||
| 54 | /* ---------------------------------------------------------------------- |
||
| 55 | ** Internal helper function used by the FFTs |
||
| 56 | ** ------------------------------------------------------------------- */ |
||
| 57 | |||
| 58 | /* |
||
| 59 | * @brief Core function for the floating-point CFFT butterfly process. |
||
| 60 | * @param[in, out] *pSrc points to the in-place buffer of floating-point data type. |
||
| 61 | * @param[in] fftLen length of the FFT. |
||
| 62 | * @param[in] *pCoef points to the twiddle coefficient buffer. |
||
| 63 | * @param[in] twidCoefModifier twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. |
||
| 64 | * @return none. |
||
| 65 | */ |
||
| 66 | |||
| 67 | void arm_radix4_butterfly_f32( |
||
| 68 | float32_t * pSrc, |
||
| 69 | uint16_t fftLen, |
||
| 70 | float32_t * pCoef, |
||
| 71 | uint16_t twidCoefModifier) |
||
| 72 | { |
||
| 73 | |||
| 74 | float32_t co1, co2, co3, si1, si2, si3; |
||
| 75 | uint32_t ia1, ia2, ia3; |
||
| 76 | uint32_t i0, i1, i2, i3; |
||
| 77 | uint32_t n1, n2, j, k; |
||
| 78 | |||
| 79 | #ifndef ARM_MATH_CM0_FAMILY_FAMILY |
||
| 80 | |||
| 81 | /* Run the below code for Cortex-M4 and Cortex-M3 */ |
||
| 82 | |||
| 83 | float32_t xaIn, yaIn, xbIn, ybIn, xcIn, ycIn, xdIn, ydIn; |
||
| 84 | float32_t Xaplusc, Xbplusd, Yaplusc, Ybplusd, Xaminusc, Xbminusd, Yaminusc, |
||
| 85 | Ybminusd; |
||
| 86 | float32_t Xb12C_out, Yb12C_out, Xc12C_out, Yc12C_out, Xd12C_out, Yd12C_out; |
||
| 87 | float32_t Xb12_out, Yb12_out, Xc12_out, Yc12_out, Xd12_out, Yd12_out; |
||
| 88 | float32_t *ptr1; |
||
| 89 | float32_t p0,p1,p2,p3,p4,p5; |
||
| 90 | float32_t a0,a1,a2,a3,a4,a5,a6,a7; |
||
| 91 | |||
| 92 | /* Initializations for the first stage */ |
||
| 93 | n2 = fftLen; |
||
| 94 | n1 = n2; |
||
| 95 | |||
| 96 | /* n2 = fftLen/4 */ |
||
| 97 | n2 >>= 2u; |
||
| 98 | i0 = 0u; |
||
| 99 | ia1 = 0u; |
||
| 100 | |||
| 101 | j = n2; |
||
| 102 | |||
| 103 | /* Calculation of first stage */ |
||
| 104 | do |
||
| 105 | { |
||
| 106 | /* index calculation for the input as, */ |
||
| 107 | /* pSrc[i0 + 0], pSrc[i0 + fftLen/4], pSrc[i0 + fftLen/2], pSrc[i0 + 3fftLen/4] */ |
||
| 108 | i1 = i0 + n2; |
||
| 109 | i2 = i1 + n2; |
||
| 110 | i3 = i2 + n2; |
||
| 111 | |||
| 112 | xaIn = pSrc[(2u * i0)]; |
||
| 113 | yaIn = pSrc[(2u * i0) + 1u]; |
||
| 114 | |||
| 115 | xbIn = pSrc[(2u * i1)]; |
||
| 116 | ybIn = pSrc[(2u * i1) + 1u]; |
||
| 117 | |||
| 118 | xcIn = pSrc[(2u * i2)]; |
||
| 119 | ycIn = pSrc[(2u * i2) + 1u]; |
||
| 120 | |||
| 121 | xdIn = pSrc[(2u * i3)]; |
||
| 122 | ydIn = pSrc[(2u * i3) + 1u]; |
||
| 123 | |||
| 124 | /* xa + xc */ |
||
| 125 | Xaplusc = xaIn + xcIn; |
||
| 126 | /* xb + xd */ |
||
| 127 | Xbplusd = xbIn + xdIn; |
||
| 128 | /* ya + yc */ |
||
| 129 | Yaplusc = yaIn + ycIn; |
||
| 130 | /* yb + yd */ |
||
| 131 | Ybplusd = ybIn + ydIn; |
||
| 132 | |||
| 133 | /* index calculation for the coefficients */ |
||
| 134 | ia2 = ia1 + ia1; |
||
| 135 | co2 = pCoef[ia2 * 2u]; |
||
| 136 | si2 = pCoef[(ia2 * 2u) + 1u]; |
||
| 137 | |||
| 138 | /* xa - xc */ |
||
| 139 | Xaminusc = xaIn - xcIn; |
||
| 140 | /* xb - xd */ |
||
| 141 | Xbminusd = xbIn - xdIn; |
||
| 142 | /* ya - yc */ |
||
| 143 | Yaminusc = yaIn - ycIn; |
||
| 144 | /* yb - yd */ |
||
| 145 | Ybminusd = ybIn - ydIn; |
||
| 146 | |||
| 147 | /* xa' = xa + xb + xc + xd */ |
||
| 148 | pSrc[(2u * i0)] = Xaplusc + Xbplusd; |
||
| 149 | /* ya' = ya + yb + yc + yd */ |
||
| 150 | pSrc[(2u * i0) + 1u] = Yaplusc + Ybplusd; |
||
| 151 | |||
| 152 | /* (xa - xc) + (yb - yd) */ |
||
| 153 | Xb12C_out = (Xaminusc + Ybminusd); |
||
| 154 | /* (ya - yc) + (xb - xd) */ |
||
| 155 | Yb12C_out = (Yaminusc - Xbminusd); |
||
| 156 | /* (xa + xc) - (xb + xd) */ |
||
| 157 | Xc12C_out = (Xaplusc - Xbplusd); |
||
| 158 | /* (ya + yc) - (yb + yd) */ |
||
| 159 | Yc12C_out = (Yaplusc - Ybplusd); |
||
| 160 | /* (xa - xc) - (yb - yd) */ |
||
| 161 | Xd12C_out = (Xaminusc - Ybminusd); |
||
| 162 | /* (ya - yc) + (xb - xd) */ |
||
| 163 | Yd12C_out = (Xbminusd + Yaminusc); |
||
| 164 | |||
| 165 | co1 = pCoef[ia1 * 2u]; |
||
| 166 | si1 = pCoef[(ia1 * 2u) + 1u]; |
||
| 167 | |||
| 168 | /* index calculation for the coefficients */ |
||
| 169 | ia3 = ia2 + ia1; |
||
| 170 | co3 = pCoef[ia3 * 2u]; |
||
| 171 | si3 = pCoef[(ia3 * 2u) + 1u]; |
||
| 172 | |||
| 173 | Xb12_out = Xb12C_out * co1; |
||
| 174 | Yb12_out = Yb12C_out * co1; |
||
| 175 | Xc12_out = Xc12C_out * co2; |
||
| 176 | Yc12_out = Yc12C_out * co2; |
||
| 177 | Xd12_out = Xd12C_out * co3; |
||
| 178 | Yd12_out = Yd12C_out * co3; |
||
| 179 | |||
| 180 | /* xb' = (xa+yb-xc-yd)co1 - (ya-xb-yc+xd)(si1) */ |
||
| 181 | //Xb12_out -= Yb12C_out * si1; |
||
| 182 | p0 = Yb12C_out * si1; |
||
| 183 | /* yb' = (ya-xb-yc+xd)co1 + (xa+yb-xc-yd)(si1) */ |
||
| 184 | //Yb12_out += Xb12C_out * si1; |
||
| 185 | p1 = Xb12C_out * si1; |
||
| 186 | /* xc' = (xa-xb+xc-xd)co2 - (ya-yb+yc-yd)(si2) */ |
||
| 187 | //Xc12_out -= Yc12C_out * si2; |
||
| 188 | p2 = Yc12C_out * si2; |
||
| 189 | /* yc' = (ya-yb+yc-yd)co2 + (xa-xb+xc-xd)(si2) */ |
||
| 190 | //Yc12_out += Xc12C_out * si2; |
||
| 191 | p3 = Xc12C_out * si2; |
||
| 192 | /* xd' = (xa-yb-xc+yd)co3 - (ya+xb-yc-xd)(si3) */ |
||
| 193 | //Xd12_out -= Yd12C_out * si3; |
||
| 194 | p4 = Yd12C_out * si3; |
||
| 195 | /* yd' = (ya+xb-yc-xd)co3 + (xa-yb-xc+yd)(si3) */ |
||
| 196 | //Yd12_out += Xd12C_out * si3; |
||
| 197 | p5 = Xd12C_out * si3; |
||
| 198 | |||
| 199 | Xb12_out += p0; |
||
| 200 | Yb12_out -= p1; |
||
| 201 | Xc12_out += p2; |
||
| 202 | Yc12_out -= p3; |
||
| 203 | Xd12_out += p4; |
||
| 204 | Yd12_out -= p5; |
||
| 205 | |||
| 206 | /* xc' = (xa-xb+xc-xd)co2 + (ya-yb+yc-yd)(si2) */ |
||
| 207 | pSrc[2u * i1] = Xc12_out; |
||
| 208 | |||
| 209 | /* yc' = (ya-yb+yc-yd)co2 - (xa-xb+xc-xd)(si2) */ |
||
| 210 | pSrc[(2u * i1) + 1u] = Yc12_out; |
||
| 211 | |||
| 212 | /* xb' = (xa+yb-xc-yd)co1 + (ya-xb-yc+xd)(si1) */ |
||
| 213 | pSrc[2u * i2] = Xb12_out; |
||
| 214 | |||
| 215 | /* yb' = (ya-xb-yc+xd)co1 - (xa+yb-xc-yd)(si1) */ |
||
| 216 | pSrc[(2u * i2) + 1u] = Yb12_out; |
||
| 217 | |||
| 218 | /* xd' = (xa-yb-xc+yd)co3 + (ya+xb-yc-xd)(si3) */ |
||
| 219 | pSrc[2u * i3] = Xd12_out; |
||
| 220 | |||
| 221 | /* yd' = (ya+xb-yc-xd)co3 - (xa-yb-xc+yd)(si3) */ |
||
| 222 | pSrc[(2u * i3) + 1u] = Yd12_out; |
||
| 223 | |||
| 224 | /* Twiddle coefficients index modifier */ |
||
| 225 | ia1 += twidCoefModifier; |
||
| 226 | |||
| 227 | /* Updating input index */ |
||
| 228 | i0++; |
||
| 229 | |||
| 230 | } |
||
| 231 | while(--j); |
||
| 232 | |||
| 233 | twidCoefModifier <<= 2u; |
||
| 234 | |||
| 235 | /* Calculation of second stage to excluding last stage */ |
||
| 236 | for (k = fftLen >> 2u; k > 4u; k >>= 2u) |
||
| 237 | { |
||
| 238 | /* Initializations for the first stage */ |
||
| 239 | n1 = n2; |
||
| 240 | n2 >>= 2u; |
||
| 241 | ia1 = 0u; |
||
| 242 | |||
| 243 | /* Calculation of first stage */ |
||
| 244 | j = 0; |
||
| 245 | do |
||
| 246 | { |
||
| 247 | /* index calculation for the coefficients */ |
||
| 248 | ia2 = ia1 + ia1; |
||
| 249 | ia3 = ia2 + ia1; |
||
| 250 | co1 = pCoef[ia1 * 2u]; |
||
| 251 | si1 = pCoef[(ia1 * 2u) + 1u]; |
||
| 252 | co2 = pCoef[ia2 * 2u]; |
||
| 253 | si2 = pCoef[(ia2 * 2u) + 1u]; |
||
| 254 | co3 = pCoef[ia3 * 2u]; |
||
| 255 | si3 = pCoef[(ia3 * 2u) + 1u]; |
||
| 256 | |||
| 257 | /* Twiddle coefficients index modifier */ |
||
| 258 | ia1 += twidCoefModifier; |
||
| 259 | |||
| 260 | i0 = j; |
||
| 261 | do |
||
| 262 | { |
||
| 263 | /* index calculation for the input as, */ |
||
| 264 | /* pSrc[i0 + 0], pSrc[i0 + fftLen/4], pSrc[i0 + fftLen/2], pSrc[i0 + 3fftLen/4] */ |
||
| 265 | i1 = i0 + n2; |
||
| 266 | i2 = i1 + n2; |
||
| 267 | i3 = i2 + n2; |
||
| 268 | |||
| 269 | xaIn = pSrc[(2u * i0)]; |
||
| 270 | yaIn = pSrc[(2u * i0) + 1u]; |
||
| 271 | |||
| 272 | xbIn = pSrc[(2u * i1)]; |
||
| 273 | ybIn = pSrc[(2u * i1) + 1u]; |
||
| 274 | |||
| 275 | xcIn = pSrc[(2u * i2)]; |
||
| 276 | ycIn = pSrc[(2u * i2) + 1u]; |
||
| 277 | |||
| 278 | xdIn = pSrc[(2u * i3)]; |
||
| 279 | ydIn = pSrc[(2u * i3) + 1u]; |
||
| 280 | |||
| 281 | /* xa - xc */ |
||
| 282 | Xaminusc = xaIn - xcIn; |
||
| 283 | /* (xb - xd) */ |
||
| 284 | Xbminusd = xbIn - xdIn; |
||
| 285 | /* ya - yc */ |
||
| 286 | Yaminusc = yaIn - ycIn; |
||
| 287 | /* (yb - yd) */ |
||
| 288 | Ybminusd = ybIn - ydIn; |
||
| 289 | |||
| 290 | /* xa + xc */ |
||
| 291 | Xaplusc = xaIn + xcIn; |
||
| 292 | /* xb + xd */ |
||
| 293 | Xbplusd = xbIn + xdIn; |
||
| 294 | /* ya + yc */ |
||
| 295 | Yaplusc = yaIn + ycIn; |
||
| 296 | /* yb + yd */ |
||
| 297 | Ybplusd = ybIn + ydIn; |
||
| 298 | |||
| 299 | /* (xa - xc) + (yb - yd) */ |
||
| 300 | Xb12C_out = (Xaminusc + Ybminusd); |
||
| 301 | /* (ya - yc) - (xb - xd) */ |
||
| 302 | Yb12C_out = (Yaminusc - Xbminusd); |
||
| 303 | /* xa + xc -(xb + xd) */ |
||
| 304 | Xc12C_out = (Xaplusc - Xbplusd); |
||
| 305 | /* (ya + yc) - (yb + yd) */ |
||
| 306 | Yc12C_out = (Yaplusc - Ybplusd); |
||
| 307 | /* (xa - xc) - (yb - yd) */ |
||
| 308 | Xd12C_out = (Xaminusc - Ybminusd); |
||
| 309 | /* (ya - yc) + (xb - xd) */ |
||
| 310 | Yd12C_out = (Xbminusd + Yaminusc); |
||
| 311 | |||
| 312 | pSrc[(2u * i0)] = Xaplusc + Xbplusd; |
||
| 313 | pSrc[(2u * i0) + 1u] = Yaplusc + Ybplusd; |
||
| 314 | |||
| 315 | Xb12_out = Xb12C_out * co1; |
||
| 316 | Yb12_out = Yb12C_out * co1; |
||
| 317 | Xc12_out = Xc12C_out * co2; |
||
| 318 | Yc12_out = Yc12C_out * co2; |
||
| 319 | Xd12_out = Xd12C_out * co3; |
||
| 320 | Yd12_out = Yd12C_out * co3; |
||
| 321 | |||
| 322 | /* xb' = (xa+yb-xc-yd)co1 - (ya-xb-yc+xd)(si1) */ |
||
| 323 | //Xb12_out -= Yb12C_out * si1; |
||
| 324 | p0 = Yb12C_out * si1; |
||
| 325 | /* yb' = (ya-xb-yc+xd)co1 + (xa+yb-xc-yd)(si1) */ |
||
| 326 | //Yb12_out += Xb12C_out * si1; |
||
| 327 | p1 = Xb12C_out * si1; |
||
| 328 | /* xc' = (xa-xb+xc-xd)co2 - (ya-yb+yc-yd)(si2) */ |
||
| 329 | //Xc12_out -= Yc12C_out * si2; |
||
| 330 | p2 = Yc12C_out * si2; |
||
| 331 | /* yc' = (ya-yb+yc-yd)co2 + (xa-xb+xc-xd)(si2) */ |
||
| 332 | //Yc12_out += Xc12C_out * si2; |
||
| 333 | p3 = Xc12C_out * si2; |
||
| 334 | /* xd' = (xa-yb-xc+yd)co3 - (ya+xb-yc-xd)(si3) */ |
||
| 335 | //Xd12_out -= Yd12C_out * si3; |
||
| 336 | p4 = Yd12C_out * si3; |
||
| 337 | /* yd' = (ya+xb-yc-xd)co3 + (xa-yb-xc+yd)(si3) */ |
||
| 338 | //Yd12_out += Xd12C_out * si3; |
||
| 339 | p5 = Xd12C_out * si3; |
||
| 340 | |||
| 341 | Xb12_out += p0; |
||
| 342 | Yb12_out -= p1; |
||
| 343 | Xc12_out += p2; |
||
| 344 | Yc12_out -= p3; |
||
| 345 | Xd12_out += p4; |
||
| 346 | Yd12_out -= p5; |
||
| 347 | |||
| 348 | /* xc' = (xa-xb+xc-xd)co2 + (ya-yb+yc-yd)(si2) */ |
||
| 349 | pSrc[2u * i1] = Xc12_out; |
||
| 350 | |||
| 351 | /* yc' = (ya-yb+yc-yd)co2 - (xa-xb+xc-xd)(si2) */ |
||
| 352 | pSrc[(2u * i1) + 1u] = Yc12_out; |
||
| 353 | |||
| 354 | /* xb' = (xa+yb-xc-yd)co1 + (ya-xb-yc+xd)(si1) */ |
||
| 355 | pSrc[2u * i2] = Xb12_out; |
||
| 356 | |||
| 357 | /* yb' = (ya-xb-yc+xd)co1 - (xa+yb-xc-yd)(si1) */ |
||
| 358 | pSrc[(2u * i2) + 1u] = Yb12_out; |
||
| 359 | |||
| 360 | /* xd' = (xa-yb-xc+yd)co3 + (ya+xb-yc-xd)(si3) */ |
||
| 361 | pSrc[2u * i3] = Xd12_out; |
||
| 362 | |||
| 363 | /* yd' = (ya+xb-yc-xd)co3 - (xa-yb-xc+yd)(si3) */ |
||
| 364 | pSrc[(2u * i3) + 1u] = Yd12_out; |
||
| 365 | |||
| 366 | i0 += n1; |
||
| 367 | } while(i0 < fftLen); |
||
| 368 | j++; |
||
| 369 | } while(j <= (n2 - 1u)); |
||
| 370 | twidCoefModifier <<= 2u; |
||
| 371 | } |
||
| 372 | |||
| 373 | j = fftLen >> 2; |
||
| 374 | ptr1 = &pSrc[0]; |
||
| 375 | |||
| 376 | /* Calculations of last stage */ |
||
| 377 | do |
||
| 378 | { |
||
| 379 | xaIn = ptr1[0]; |
||
| 380 | yaIn = ptr1[1]; |
||
| 381 | xbIn = ptr1[2]; |
||
| 382 | ybIn = ptr1[3]; |
||
| 383 | xcIn = ptr1[4]; |
||
| 384 | ycIn = ptr1[5]; |
||
| 385 | xdIn = ptr1[6]; |
||
| 386 | ydIn = ptr1[7]; |
||
| 387 | |||
| 388 | /* xa + xc */ |
||
| 389 | Xaplusc = xaIn + xcIn; |
||
| 390 | |||
| 391 | /* xa - xc */ |
||
| 392 | Xaminusc = xaIn - xcIn; |
||
| 393 | |||
| 394 | /* ya + yc */ |
||
| 395 | Yaplusc = yaIn + ycIn; |
||
| 396 | |||
| 397 | /* ya - yc */ |
||
| 398 | Yaminusc = yaIn - ycIn; |
||
| 399 | |||
| 400 | /* xb + xd */ |
||
| 401 | Xbplusd = xbIn + xdIn; |
||
| 402 | |||
| 403 | /* yb + yd */ |
||
| 404 | Ybplusd = ybIn + ydIn; |
||
| 405 | |||
| 406 | /* (xb-xd) */ |
||
| 407 | Xbminusd = xbIn - xdIn; |
||
| 408 | |||
| 409 | /* (yb-yd) */ |
||
| 410 | Ybminusd = ybIn - ydIn; |
||
| 411 | |||
| 412 | /* xa' = xa + xb + xc + xd */ |
||
| 413 | a0 = (Xaplusc + Xbplusd); |
||
| 414 | /* ya' = ya + yb + yc + yd */ |
||
| 415 | a1 = (Yaplusc + Ybplusd); |
||
| 416 | /* xc' = (xa-xb+xc-xd) */ |
||
| 417 | a2 = (Xaplusc - Xbplusd); |
||
| 418 | /* yc' = (ya-yb+yc-yd) */ |
||
| 419 | a3 = (Yaplusc - Ybplusd); |
||
| 420 | /* xb' = (xa+yb-xc-yd) */ |
||
| 421 | a4 = (Xaminusc + Ybminusd); |
||
| 422 | /* yb' = (ya-xb-yc+xd) */ |
||
| 423 | a5 = (Yaminusc - Xbminusd); |
||
| 424 | /* xd' = (xa-yb-xc+yd)) */ |
||
| 425 | a6 = (Xaminusc - Ybminusd); |
||
| 426 | /* yd' = (ya+xb-yc-xd) */ |
||
| 427 | a7 = (Xbminusd + Yaminusc); |
||
| 428 | |||
| 429 | ptr1[0] = a0; |
||
| 430 | ptr1[1] = a1; |
||
| 431 | ptr1[2] = a2; |
||
| 432 | ptr1[3] = a3; |
||
| 433 | ptr1[4] = a4; |
||
| 434 | ptr1[5] = a5; |
||
| 435 | ptr1[6] = a6; |
||
| 436 | ptr1[7] = a7; |
||
| 437 | |||
| 438 | /* increment pointer by 8 */ |
||
| 439 | ptr1 += 8u; |
||
| 440 | } while(--j); |
||
| 441 | |||
| 442 | #else |
||
| 443 | |||
| 444 | float32_t t1, t2, r1, r2, s1, s2; |
||
| 445 | |||
| 446 | /* Run the below code for Cortex-M0 */ |
||
| 447 | |||
| 448 | /* Initializations for the fft calculation */ |
||
| 449 | n2 = fftLen; |
||
| 450 | n1 = n2; |
||
| 451 | for (k = fftLen; k > 1u; k >>= 2u) |
||
| 452 | { |
||
| 453 | /* Initializations for the fft calculation */ |
||
| 454 | n1 = n2; |
||
| 455 | n2 >>= 2u; |
||
| 456 | ia1 = 0u; |
||
| 457 | |||
| 458 | /* FFT Calculation */ |
||
| 459 | j = 0; |
||
| 460 | do |
||
| 461 | { |
||
| 462 | /* index calculation for the coefficients */ |
||
| 463 | ia2 = ia1 + ia1; |
||
| 464 | ia3 = ia2 + ia1; |
||
| 465 | co1 = pCoef[ia1 * 2u]; |
||
| 466 | si1 = pCoef[(ia1 * 2u) + 1u]; |
||
| 467 | co2 = pCoef[ia2 * 2u]; |
||
| 468 | si2 = pCoef[(ia2 * 2u) + 1u]; |
||
| 469 | co3 = pCoef[ia3 * 2u]; |
||
| 470 | si3 = pCoef[(ia3 * 2u) + 1u]; |
||
| 471 | |||
| 472 | /* Twiddle coefficients index modifier */ |
||
| 473 | ia1 = ia1 + twidCoefModifier; |
||
| 474 | |||
| 475 | i0 = j; |
||
| 476 | do |
||
| 477 | { |
||
| 478 | /* index calculation for the input as, */ |
||
| 479 | /* pSrc[i0 + 0], pSrc[i0 + fftLen/4], pSrc[i0 + fftLen/2], pSrc[i0 + 3fftLen/4] */ |
||
| 480 | i1 = i0 + n2; |
||
| 481 | i2 = i1 + n2; |
||
| 482 | i3 = i2 + n2; |
||
| 483 | |||
| 484 | /* xa + xc */ |
||
| 485 | r1 = pSrc[(2u * i0)] + pSrc[(2u * i2)]; |
||
| 486 | |||
| 487 | /* xa - xc */ |
||
| 488 | r2 = pSrc[(2u * i0)] - pSrc[(2u * i2)]; |
||
| 489 | |||
| 490 | /* ya + yc */ |
||
| 491 | s1 = pSrc[(2u * i0) + 1u] + pSrc[(2u * i2) + 1u]; |
||
| 492 | |||
| 493 | /* ya - yc */ |
||
| 494 | s2 = pSrc[(2u * i0) + 1u] - pSrc[(2u * i2) + 1u]; |
||
| 495 | |||
| 496 | /* xb + xd */ |
||
| 497 | t1 = pSrc[2u * i1] + pSrc[2u * i3]; |
||
| 498 | |||
| 499 | /* xa' = xa + xb + xc + xd */ |
||
| 500 | pSrc[2u * i0] = r1 + t1; |
||
| 501 | |||
| 502 | /* xa + xc -(xb + xd) */ |
||
| 503 | r1 = r1 - t1; |
||
| 504 | |||
| 505 | /* yb + yd */ |
||
| 506 | t2 = pSrc[(2u * i1) + 1u] + pSrc[(2u * i3) + 1u]; |
||
| 507 | |||
| 508 | /* ya' = ya + yb + yc + yd */ |
||
| 509 | pSrc[(2u * i0) + 1u] = s1 + t2; |
||
| 510 | |||
| 511 | /* (ya + yc) - (yb + yd) */ |
||
| 512 | s1 = s1 - t2; |
||
| 513 | |||
| 514 | /* (yb - yd) */ |
||
| 515 | t1 = pSrc[(2u * i1) + 1u] - pSrc[(2u * i3) + 1u]; |
||
| 516 | |||
| 517 | /* (xb - xd) */ |
||
| 518 | t2 = pSrc[2u * i1] - pSrc[2u * i3]; |
||
| 519 | |||
| 520 | /* xc' = (xa-xb+xc-xd)co2 + (ya-yb+yc-yd)(si2) */ |
||
| 521 | pSrc[2u * i1] = (r1 * co2) + (s1 * si2); |
||
| 522 | |||
| 523 | /* yc' = (ya-yb+yc-yd)co2 - (xa-xb+xc-xd)(si2) */ |
||
| 524 | pSrc[(2u * i1) + 1u] = (s1 * co2) - (r1 * si2); |
||
| 525 | |||
| 526 | /* (xa - xc) + (yb - yd) */ |
||
| 527 | r1 = r2 + t1; |
||
| 528 | |||
| 529 | /* (xa - xc) - (yb - yd) */ |
||
| 530 | r2 = r2 - t1; |
||
| 531 | |||
| 532 | /* (ya - yc) - (xb - xd) */ |
||
| 533 | s1 = s2 - t2; |
||
| 534 | |||
| 535 | /* (ya - yc) + (xb - xd) */ |
||
| 536 | s2 = s2 + t2; |
||
| 537 | |||
| 538 | /* xb' = (xa+yb-xc-yd)co1 + (ya-xb-yc+xd)(si1) */ |
||
| 539 | pSrc[2u * i2] = (r1 * co1) + (s1 * si1); |
||
| 540 | |||
| 541 | /* yb' = (ya-xb-yc+xd)co1 - (xa+yb-xc-yd)(si1) */ |
||
| 542 | pSrc[(2u * i2) + 1u] = (s1 * co1) - (r1 * si1); |
||
| 543 | |||
| 544 | /* xd' = (xa-yb-xc+yd)co3 + (ya+xb-yc-xd)(si3) */ |
||
| 545 | pSrc[2u * i3] = (r2 * co3) + (s2 * si3); |
||
| 546 | |||
| 547 | /* yd' = (ya+xb-yc-xd)co3 - (xa-yb-xc+yd)(si3) */ |
||
| 548 | pSrc[(2u * i3) + 1u] = (s2 * co3) - (r2 * si3); |
||
| 549 | |||
| 550 | i0 += n1; |
||
| 551 | } while( i0 < fftLen); |
||
| 552 | j++; |
||
| 553 | } while(j <= (n2 - 1u)); |
||
| 554 | twidCoefModifier <<= 2u; |
||
| 555 | } |
||
| 556 | |||
| 557 | #endif /* #ifndef ARM_MATH_CM0_FAMILY_FAMILY */ |
||
| 558 | |||
| 559 | } |
||
| 560 | |||
| 561 | /* |
||
| 562 | * @brief Core function for the floating-point CIFFT butterfly process. |
||
| 563 | * @param[in, out] *pSrc points to the in-place buffer of floating-point data type. |
||
| 564 | * @param[in] fftLen length of the FFT. |
||
| 565 | * @param[in] *pCoef points to twiddle coefficient buffer. |
||
| 566 | * @param[in] twidCoefModifier twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. |
||
| 567 | * @param[in] onebyfftLen value of 1/fftLen. |
||
| 568 | * @return none. |
||
| 569 | */ |
||
| 570 | |||
| 571 | void arm_radix4_butterfly_inverse_f32( |
||
| 572 | float32_t * pSrc, |
||
| 573 | uint16_t fftLen, |
||
| 574 | float32_t * pCoef, |
||
| 575 | uint16_t twidCoefModifier, |
||
| 576 | float32_t onebyfftLen) |
||
| 577 | { |
||
| 578 | float32_t co1, co2, co3, si1, si2, si3; |
||
| 579 | uint32_t ia1, ia2, ia3; |
||
| 580 | uint32_t i0, i1, i2, i3; |
||
| 581 | uint32_t n1, n2, j, k; |
||
| 582 | |||
| 583 | #ifndef ARM_MATH_CM0_FAMILY_FAMILY |
||
| 584 | |||
| 585 | float32_t xaIn, yaIn, xbIn, ybIn, xcIn, ycIn, xdIn, ydIn; |
||
| 586 | float32_t Xaplusc, Xbplusd, Yaplusc, Ybplusd, Xaminusc, Xbminusd, Yaminusc, |
||
| 587 | Ybminusd; |
||
| 588 | float32_t Xb12C_out, Yb12C_out, Xc12C_out, Yc12C_out, Xd12C_out, Yd12C_out; |
||
| 589 | float32_t Xb12_out, Yb12_out, Xc12_out, Yc12_out, Xd12_out, Yd12_out; |
||
| 590 | float32_t *ptr1; |
||
| 591 | float32_t p0,p1,p2,p3,p4,p5,p6,p7; |
||
| 592 | float32_t a0,a1,a2,a3,a4,a5,a6,a7; |
||
| 593 | |||
| 594 | |||
| 595 | /* Initializations for the first stage */ |
||
| 596 | n2 = fftLen; |
||
| 597 | n1 = n2; |
||
| 598 | |||
| 599 | /* n2 = fftLen/4 */ |
||
| 600 | n2 >>= 2u; |
||
| 601 | i0 = 0u; |
||
| 602 | ia1 = 0u; |
||
| 603 | |||
| 604 | j = n2; |
||
| 605 | |||
| 606 | /* Calculation of first stage */ |
||
| 607 | do |
||
| 608 | { |
||
| 609 | /* index calculation for the input as, */ |
||
| 610 | /* pSrc[i0 + 0], pSrc[i0 + fftLen/4], pSrc[i0 + fftLen/2], pSrc[i0 + 3fftLen/4] */ |
||
| 611 | i1 = i0 + n2; |
||
| 612 | i2 = i1 + n2; |
||
| 613 | i3 = i2 + n2; |
||
| 614 | |||
| 615 | /* Butterfly implementation */ |
||
| 616 | xaIn = pSrc[(2u * i0)]; |
||
| 617 | yaIn = pSrc[(2u * i0) + 1u]; |
||
| 618 | |||
| 619 | xcIn = pSrc[(2u * i2)]; |
||
| 620 | ycIn = pSrc[(2u * i2) + 1u]; |
||
| 621 | |||
| 622 | xbIn = pSrc[(2u * i1)]; |
||
| 623 | ybIn = pSrc[(2u * i1) + 1u]; |
||
| 624 | |||
| 625 | xdIn = pSrc[(2u * i3)]; |
||
| 626 | ydIn = pSrc[(2u * i3) + 1u]; |
||
| 627 | |||
| 628 | /* xa + xc */ |
||
| 629 | Xaplusc = xaIn + xcIn; |
||
| 630 | /* xb + xd */ |
||
| 631 | Xbplusd = xbIn + xdIn; |
||
| 632 | /* ya + yc */ |
||
| 633 | Yaplusc = yaIn + ycIn; |
||
| 634 | /* yb + yd */ |
||
| 635 | Ybplusd = ybIn + ydIn; |
||
| 636 | |||
| 637 | /* index calculation for the coefficients */ |
||
| 638 | ia2 = ia1 + ia1; |
||
| 639 | co2 = pCoef[ia2 * 2u]; |
||
| 640 | si2 = pCoef[(ia2 * 2u) + 1u]; |
||
| 641 | |||
| 642 | /* xa - xc */ |
||
| 643 | Xaminusc = xaIn - xcIn; |
||
| 644 | /* xb - xd */ |
||
| 645 | Xbminusd = xbIn - xdIn; |
||
| 646 | /* ya - yc */ |
||
| 647 | Yaminusc = yaIn - ycIn; |
||
| 648 | /* yb - yd */ |
||
| 649 | Ybminusd = ybIn - ydIn; |
||
| 650 | |||
| 651 | /* xa' = xa + xb + xc + xd */ |
||
| 652 | pSrc[(2u * i0)] = Xaplusc + Xbplusd; |
||
| 653 | |||
| 654 | /* ya' = ya + yb + yc + yd */ |
||
| 655 | pSrc[(2u * i0) + 1u] = Yaplusc + Ybplusd; |
||
| 656 | |||
| 657 | /* (xa - xc) - (yb - yd) */ |
||
| 658 | Xb12C_out = (Xaminusc - Ybminusd); |
||
| 659 | /* (ya - yc) + (xb - xd) */ |
||
| 660 | Yb12C_out = (Yaminusc + Xbminusd); |
||
| 661 | /* (xa + xc) - (xb + xd) */ |
||
| 662 | Xc12C_out = (Xaplusc - Xbplusd); |
||
| 663 | /* (ya + yc) - (yb + yd) */ |
||
| 664 | Yc12C_out = (Yaplusc - Ybplusd); |
||
| 665 | /* (xa - xc) + (yb - yd) */ |
||
| 666 | Xd12C_out = (Xaminusc + Ybminusd); |
||
| 667 | /* (ya - yc) - (xb - xd) */ |
||
| 668 | Yd12C_out = (Yaminusc - Xbminusd); |
||
| 669 | |||
| 670 | co1 = pCoef[ia1 * 2u]; |
||
| 671 | si1 = pCoef[(ia1 * 2u) + 1u]; |
||
| 672 | |||
| 673 | /* index calculation for the coefficients */ |
||
| 674 | ia3 = ia2 + ia1; |
||
| 675 | co3 = pCoef[ia3 * 2u]; |
||
| 676 | si3 = pCoef[(ia3 * 2u) + 1u]; |
||
| 677 | |||
| 678 | Xb12_out = Xb12C_out * co1; |
||
| 679 | Yb12_out = Yb12C_out * co1; |
||
| 680 | Xc12_out = Xc12C_out * co2; |
||
| 681 | Yc12_out = Yc12C_out * co2; |
||
| 682 | Xd12_out = Xd12C_out * co3; |
||
| 683 | Yd12_out = Yd12C_out * co3; |
||
| 684 | |||
| 685 | /* xb' = (xa+yb-xc-yd)co1 - (ya-xb-yc+xd)(si1) */ |
||
| 686 | //Xb12_out -= Yb12C_out * si1; |
||
| 687 | p0 = Yb12C_out * si1; |
||
| 688 | /* yb' = (ya-xb-yc+xd)co1 + (xa+yb-xc-yd)(si1) */ |
||
| 689 | //Yb12_out += Xb12C_out * si1; |
||
| 690 | p1 = Xb12C_out * si1; |
||
| 691 | /* xc' = (xa-xb+xc-xd)co2 - (ya-yb+yc-yd)(si2) */ |
||
| 692 | //Xc12_out -= Yc12C_out * si2; |
||
| 693 | p2 = Yc12C_out * si2; |
||
| 694 | /* yc' = (ya-yb+yc-yd)co2 + (xa-xb+xc-xd)(si2) */ |
||
| 695 | //Yc12_out += Xc12C_out * si2; |
||
| 696 | p3 = Xc12C_out * si2; |
||
| 697 | /* xd' = (xa-yb-xc+yd)co3 - (ya+xb-yc-xd)(si3) */ |
||
| 698 | //Xd12_out -= Yd12C_out * si3; |
||
| 699 | p4 = Yd12C_out * si3; |
||
| 700 | /* yd' = (ya+xb-yc-xd)co3 + (xa-yb-xc+yd)(si3) */ |
||
| 701 | //Yd12_out += Xd12C_out * si3; |
||
| 702 | p5 = Xd12C_out * si3; |
||
| 703 | |||
| 704 | Xb12_out -= p0; |
||
| 705 | Yb12_out += p1; |
||
| 706 | Xc12_out -= p2; |
||
| 707 | Yc12_out += p3; |
||
| 708 | Xd12_out -= p4; |
||
| 709 | Yd12_out += p5; |
||
| 710 | |||
| 711 | /* xc' = (xa-xb+xc-xd)co2 - (ya-yb+yc-yd)(si2) */ |
||
| 712 | pSrc[2u * i1] = Xc12_out; |
||
| 713 | |||
| 714 | /* yc' = (ya-yb+yc-yd)co2 + (xa-xb+xc-xd)(si2) */ |
||
| 715 | pSrc[(2u * i1) + 1u] = Yc12_out; |
||
| 716 | |||
| 717 | /* xb' = (xa+yb-xc-yd)co1 - (ya-xb-yc+xd)(si1) */ |
||
| 718 | pSrc[2u * i2] = Xb12_out; |
||
| 719 | |||
| 720 | /* yb' = (ya-xb-yc+xd)co1 + (xa+yb-xc-yd)(si1) */ |
||
| 721 | pSrc[(2u * i2) + 1u] = Yb12_out; |
||
| 722 | |||
| 723 | /* xd' = (xa-yb-xc+yd)co3 - (ya+xb-yc-xd)(si3) */ |
||
| 724 | pSrc[2u * i3] = Xd12_out; |
||
| 725 | |||
| 726 | /* yd' = (ya+xb-yc-xd)co3 + (xa-yb-xc+yd)(si3) */ |
||
| 727 | pSrc[(2u * i3) + 1u] = Yd12_out; |
||
| 728 | |||
| 729 | /* Twiddle coefficients index modifier */ |
||
| 730 | ia1 = ia1 + twidCoefModifier; |
||
| 731 | |||
| 732 | /* Updating input index */ |
||
| 733 | i0 = i0 + 1u; |
||
| 734 | |||
| 735 | } while(--j); |
||
| 736 | |||
| 737 | twidCoefModifier <<= 2u; |
||
| 738 | |||
| 739 | /* Calculation of second stage to excluding last stage */ |
||
| 740 | for (k = fftLen >> 2u; k > 4u; k >>= 2u) |
||
| 741 | { |
||
| 742 | /* Initializations for the first stage */ |
||
| 743 | n1 = n2; |
||
| 744 | n2 >>= 2u; |
||
| 745 | ia1 = 0u; |
||
| 746 | |||
| 747 | /* Calculation of first stage */ |
||
| 748 | j = 0; |
||
| 749 | do |
||
| 750 | { |
||
| 751 | /* index calculation for the coefficients */ |
||
| 752 | ia2 = ia1 + ia1; |
||
| 753 | ia3 = ia2 + ia1; |
||
| 754 | co1 = pCoef[ia1 * 2u]; |
||
| 755 | si1 = pCoef[(ia1 * 2u) + 1u]; |
||
| 756 | co2 = pCoef[ia2 * 2u]; |
||
| 757 | si2 = pCoef[(ia2 * 2u) + 1u]; |
||
| 758 | co3 = pCoef[ia3 * 2u]; |
||
| 759 | si3 = pCoef[(ia3 * 2u) + 1u]; |
||
| 760 | |||
| 761 | /* Twiddle coefficients index modifier */ |
||
| 762 | ia1 = ia1 + twidCoefModifier; |
||
| 763 | |||
| 764 | i0 = j; |
||
| 765 | do |
||
| 766 | { |
||
| 767 | /* index calculation for the input as, */ |
||
| 768 | /* pSrc[i0 + 0], pSrc[i0 + fftLen/4], pSrc[i0 + fftLen/2], pSrc[i0 + 3fftLen/4] */ |
||
| 769 | i1 = i0 + n2; |
||
| 770 | i2 = i1 + n2; |
||
| 771 | i3 = i2 + n2; |
||
| 772 | |||
| 773 | xaIn = pSrc[(2u * i0)]; |
||
| 774 | yaIn = pSrc[(2u * i0) + 1u]; |
||
| 775 | |||
| 776 | xbIn = pSrc[(2u * i1)]; |
||
| 777 | ybIn = pSrc[(2u * i1) + 1u]; |
||
| 778 | |||
| 779 | xcIn = pSrc[(2u * i2)]; |
||
| 780 | ycIn = pSrc[(2u * i2) + 1u]; |
||
| 781 | |||
| 782 | xdIn = pSrc[(2u * i3)]; |
||
| 783 | ydIn = pSrc[(2u * i3) + 1u]; |
||
| 784 | |||
| 785 | /* xa - xc */ |
||
| 786 | Xaminusc = xaIn - xcIn; |
||
| 787 | /* (xb - xd) */ |
||
| 788 | Xbminusd = xbIn - xdIn; |
||
| 789 | /* ya - yc */ |
||
| 790 | Yaminusc = yaIn - ycIn; |
||
| 791 | /* (yb - yd) */ |
||
| 792 | Ybminusd = ybIn - ydIn; |
||
| 793 | |||
| 794 | /* xa + xc */ |
||
| 795 | Xaplusc = xaIn + xcIn; |
||
| 796 | /* xb + xd */ |
||
| 797 | Xbplusd = xbIn + xdIn; |
||
| 798 | /* ya + yc */ |
||
| 799 | Yaplusc = yaIn + ycIn; |
||
| 800 | /* yb + yd */ |
||
| 801 | Ybplusd = ybIn + ydIn; |
||
| 802 | |||
| 803 | /* (xa - xc) - (yb - yd) */ |
||
| 804 | Xb12C_out = (Xaminusc - Ybminusd); |
||
| 805 | /* (ya - yc) + (xb - xd) */ |
||
| 806 | Yb12C_out = (Yaminusc + Xbminusd); |
||
| 807 | /* xa + xc -(xb + xd) */ |
||
| 808 | Xc12C_out = (Xaplusc - Xbplusd); |
||
| 809 | /* (ya + yc) - (yb + yd) */ |
||
| 810 | Yc12C_out = (Yaplusc - Ybplusd); |
||
| 811 | /* (xa - xc) + (yb - yd) */ |
||
| 812 | Xd12C_out = (Xaminusc + Ybminusd); |
||
| 813 | /* (ya - yc) - (xb - xd) */ |
||
| 814 | Yd12C_out = (Yaminusc - Xbminusd); |
||
| 815 | |||
| 816 | pSrc[(2u * i0)] = Xaplusc + Xbplusd; |
||
| 817 | pSrc[(2u * i0) + 1u] = Yaplusc + Ybplusd; |
||
| 818 | |||
| 819 | Xb12_out = Xb12C_out * co1; |
||
| 820 | Yb12_out = Yb12C_out * co1; |
||
| 821 | Xc12_out = Xc12C_out * co2; |
||
| 822 | Yc12_out = Yc12C_out * co2; |
||
| 823 | Xd12_out = Xd12C_out * co3; |
||
| 824 | Yd12_out = Yd12C_out * co3; |
||
| 825 | |||
| 826 | /* xb' = (xa+yb-xc-yd)co1 - (ya-xb-yc+xd)(si1) */ |
||
| 827 | //Xb12_out -= Yb12C_out * si1; |
||
| 828 | p0 = Yb12C_out * si1; |
||
| 829 | /* yb' = (ya-xb-yc+xd)co1 + (xa+yb-xc-yd)(si1) */ |
||
| 830 | //Yb12_out += Xb12C_out * si1; |
||
| 831 | p1 = Xb12C_out * si1; |
||
| 832 | /* xc' = (xa-xb+xc-xd)co2 - (ya-yb+yc-yd)(si2) */ |
||
| 833 | //Xc12_out -= Yc12C_out * si2; |
||
| 834 | p2 = Yc12C_out * si2; |
||
| 835 | /* yc' = (ya-yb+yc-yd)co2 + (xa-xb+xc-xd)(si2) */ |
||
| 836 | //Yc12_out += Xc12C_out * si2; |
||
| 837 | p3 = Xc12C_out * si2; |
||
| 838 | /* xd' = (xa-yb-xc+yd)co3 - (ya+xb-yc-xd)(si3) */ |
||
| 839 | //Xd12_out -= Yd12C_out * si3; |
||
| 840 | p4 = Yd12C_out * si3; |
||
| 841 | /* yd' = (ya+xb-yc-xd)co3 + (xa-yb-xc+yd)(si3) */ |
||
| 842 | //Yd12_out += Xd12C_out * si3; |
||
| 843 | p5 = Xd12C_out * si3; |
||
| 844 | |||
| 845 | Xb12_out -= p0; |
||
| 846 | Yb12_out += p1; |
||
| 847 | Xc12_out -= p2; |
||
| 848 | Yc12_out += p3; |
||
| 849 | Xd12_out -= p4; |
||
| 850 | Yd12_out += p5; |
||
| 851 | |||
| 852 | /* xc' = (xa-xb+xc-xd)co2 - (ya-yb+yc-yd)(si2) */ |
||
| 853 | pSrc[2u * i1] = Xc12_out; |
||
| 854 | |||
| 855 | /* yc' = (ya-yb+yc-yd)co2 + (xa-xb+xc-xd)(si2) */ |
||
| 856 | pSrc[(2u * i1) + 1u] = Yc12_out; |
||
| 857 | |||
| 858 | /* xb' = (xa+yb-xc-yd)co1 - (ya-xb-yc+xd)(si1) */ |
||
| 859 | pSrc[2u * i2] = Xb12_out; |
||
| 860 | |||
| 861 | /* yb' = (ya-xb-yc+xd)co1 + (xa+yb-xc-yd)(si1) */ |
||
| 862 | pSrc[(2u * i2) + 1u] = Yb12_out; |
||
| 863 | |||
| 864 | /* xd' = (xa-yb-xc+yd)co3 - (ya+xb-yc-xd)(si3) */ |
||
| 865 | pSrc[2u * i3] = Xd12_out; |
||
| 866 | |||
| 867 | /* yd' = (ya+xb-yc-xd)co3 + (xa-yb-xc+yd)(si3) */ |
||
| 868 | pSrc[(2u * i3) + 1u] = Yd12_out; |
||
| 869 | |||
| 870 | i0 += n1; |
||
| 871 | } while(i0 < fftLen); |
||
| 872 | j++; |
||
| 873 | } while(j <= (n2 - 1u)); |
||
| 874 | twidCoefModifier <<= 2u; |
||
| 875 | } |
||
| 876 | /* Initializations of last stage */ |
||
| 877 | |||
| 878 | j = fftLen >> 2; |
||
| 879 | ptr1 = &pSrc[0]; |
||
| 880 | |||
| 881 | /* Calculations of last stage */ |
||
| 882 | do |
||
| 883 | { |
||
| 884 | xaIn = ptr1[0]; |
||
| 885 | yaIn = ptr1[1]; |
||
| 886 | xbIn = ptr1[2]; |
||
| 887 | ybIn = ptr1[3]; |
||
| 888 | xcIn = ptr1[4]; |
||
| 889 | ycIn = ptr1[5]; |
||
| 890 | xdIn = ptr1[6]; |
||
| 891 | ydIn = ptr1[7]; |
||
| 892 | |||
| 893 | /* Butterfly implementation */ |
||
| 894 | /* xa + xc */ |
||
| 895 | Xaplusc = xaIn + xcIn; |
||
| 896 | |||
| 897 | /* xa - xc */ |
||
| 898 | Xaminusc = xaIn - xcIn; |
||
| 899 | |||
| 900 | /* ya + yc */ |
||
| 901 | Yaplusc = yaIn + ycIn; |
||
| 902 | |||
| 903 | /* ya - yc */ |
||
| 904 | Yaminusc = yaIn - ycIn; |
||
| 905 | |||
| 906 | /* xb + xd */ |
||
| 907 | Xbplusd = xbIn + xdIn; |
||
| 908 | |||
| 909 | /* yb + yd */ |
||
| 910 | Ybplusd = ybIn + ydIn; |
||
| 911 | |||
| 912 | /* (xb-xd) */ |
||
| 913 | Xbminusd = xbIn - xdIn; |
||
| 914 | |||
| 915 | /* (yb-yd) */ |
||
| 916 | Ybminusd = ybIn - ydIn; |
||
| 917 | |||
| 918 | /* xa' = (xa+xb+xc+xd) * onebyfftLen */ |
||
| 919 | a0 = (Xaplusc + Xbplusd); |
||
| 920 | /* ya' = (ya+yb+yc+yd) * onebyfftLen */ |
||
| 921 | a1 = (Yaplusc + Ybplusd); |
||
| 922 | /* xc' = (xa-xb+xc-xd) * onebyfftLen */ |
||
| 923 | a2 = (Xaplusc - Xbplusd); |
||
| 924 | /* yc' = (ya-yb+yc-yd) * onebyfftLen */ |
||
| 925 | a3 = (Yaplusc - Ybplusd); |
||
| 926 | /* xb' = (xa-yb-xc+yd) * onebyfftLen */ |
||
| 927 | a4 = (Xaminusc - Ybminusd); |
||
| 928 | /* yb' = (ya+xb-yc-xd) * onebyfftLen */ |
||
| 929 | a5 = (Yaminusc + Xbminusd); |
||
| 930 | /* xd' = (xa-yb-xc+yd) * onebyfftLen */ |
||
| 931 | a6 = (Xaminusc + Ybminusd); |
||
| 932 | /* yd' = (ya-xb-yc+xd) * onebyfftLen */ |
||
| 933 | a7 = (Yaminusc - Xbminusd); |
||
| 934 | |||
| 935 | p0 = a0 * onebyfftLen; |
||
| 936 | p1 = a1 * onebyfftLen; |
||
| 937 | p2 = a2 * onebyfftLen; |
||
| 938 | p3 = a3 * onebyfftLen; |
||
| 939 | p4 = a4 * onebyfftLen; |
||
| 940 | p5 = a5 * onebyfftLen; |
||
| 941 | p6 = a6 * onebyfftLen; |
||
| 942 | p7 = a7 * onebyfftLen; |
||
| 943 | |||
| 944 | /* xa' = (xa+xb+xc+xd) * onebyfftLen */ |
||
| 945 | ptr1[0] = p0; |
||
| 946 | /* ya' = (ya+yb+yc+yd) * onebyfftLen */ |
||
| 947 | ptr1[1] = p1; |
||
| 948 | /* xc' = (xa-xb+xc-xd) * onebyfftLen */ |
||
| 949 | ptr1[2] = p2; |
||
| 950 | /* yc' = (ya-yb+yc-yd) * onebyfftLen */ |
||
| 951 | ptr1[3] = p3; |
||
| 952 | /* xb' = (xa-yb-xc+yd) * onebyfftLen */ |
||
| 953 | ptr1[4] = p4; |
||
| 954 | /* yb' = (ya+xb-yc-xd) * onebyfftLen */ |
||
| 955 | ptr1[5] = p5; |
||
| 956 | /* xd' = (xa-yb-xc+yd) * onebyfftLen */ |
||
| 957 | ptr1[6] = p6; |
||
| 958 | /* yd' = (ya-xb-yc+xd) * onebyfftLen */ |
||
| 959 | ptr1[7] = p7; |
||
| 960 | |||
| 961 | /* increment source pointer by 8 for next calculations */ |
||
| 962 | ptr1 = ptr1 + 8u; |
||
| 963 | |||
| 964 | } while(--j); |
||
| 965 | |||
| 966 | #else |
||
| 967 | |||
| 968 | float32_t t1, t2, r1, r2, s1, s2; |
||
| 969 | |||
| 970 | /* Run the below code for Cortex-M0 */ |
||
| 971 | |||
| 972 | /* Initializations for the first stage */ |
||
| 973 | n2 = fftLen; |
||
| 974 | n1 = n2; |
||
| 975 | |||
| 976 | /* Calculation of first stage */ |
||
| 977 | for (k = fftLen; k > 4u; k >>= 2u) |
||
| 978 | { |
||
| 979 | /* Initializations for the first stage */ |
||
| 980 | n1 = n2; |
||
| 981 | n2 >>= 2u; |
||
| 982 | ia1 = 0u; |
||
| 983 | |||
| 984 | /* Calculation of first stage */ |
||
| 985 | j = 0; |
||
| 986 | do |
||
| 987 | { |
||
| 988 | /* index calculation for the coefficients */ |
||
| 989 | ia2 = ia1 + ia1; |
||
| 990 | ia3 = ia2 + ia1; |
||
| 991 | co1 = pCoef[ia1 * 2u]; |
||
| 992 | si1 = pCoef[(ia1 * 2u) + 1u]; |
||
| 993 | co2 = pCoef[ia2 * 2u]; |
||
| 994 | si2 = pCoef[(ia2 * 2u) + 1u]; |
||
| 995 | co3 = pCoef[ia3 * 2u]; |
||
| 996 | si3 = pCoef[(ia3 * 2u) + 1u]; |
||
| 997 | |||
| 998 | /* Twiddle coefficients index modifier */ |
||
| 999 | ia1 = ia1 + twidCoefModifier; |
||
| 1000 | |||
| 1001 | i0 = j; |
||
| 1002 | do |
||
| 1003 | { |
||
| 1004 | /* index calculation for the input as, */ |
||
| 1005 | /* pSrc[i0 + 0], pSrc[i0 + fftLen/4], pSrc[i0 + fftLen/2], pSrc[i0 + 3fftLen/4] */ |
||
| 1006 | i1 = i0 + n2; |
||
| 1007 | i2 = i1 + n2; |
||
| 1008 | i3 = i2 + n2; |
||
| 1009 | |||
| 1010 | /* xa + xc */ |
||
| 1011 | r1 = pSrc[(2u * i0)] + pSrc[(2u * i2)]; |
||
| 1012 | |||
| 1013 | /* xa - xc */ |
||
| 1014 | r2 = pSrc[(2u * i0)] - pSrc[(2u * i2)]; |
||
| 1015 | |||
| 1016 | /* ya + yc */ |
||
| 1017 | s1 = pSrc[(2u * i0) + 1u] + pSrc[(2u * i2) + 1u]; |
||
| 1018 | |||
| 1019 | /* ya - yc */ |
||
| 1020 | s2 = pSrc[(2u * i0) + 1u] - pSrc[(2u * i2) + 1u]; |
||
| 1021 | |||
| 1022 | /* xb + xd */ |
||
| 1023 | t1 = pSrc[2u * i1] + pSrc[2u * i3]; |
||
| 1024 | |||
| 1025 | /* xa' = xa + xb + xc + xd */ |
||
| 1026 | pSrc[2u * i0] = r1 + t1; |
||
| 1027 | |||
| 1028 | /* xa + xc -(xb + xd) */ |
||
| 1029 | r1 = r1 - t1; |
||
| 1030 | |||
| 1031 | /* yb + yd */ |
||
| 1032 | t2 = pSrc[(2u * i1) + 1u] + pSrc[(2u * i3) + 1u]; |
||
| 1033 | |||
| 1034 | /* ya' = ya + yb + yc + yd */ |
||
| 1035 | pSrc[(2u * i0) + 1u] = s1 + t2; |
||
| 1036 | |||
| 1037 | /* (ya + yc) - (yb + yd) */ |
||
| 1038 | s1 = s1 - t2; |
||
| 1039 | |||
| 1040 | /* (yb - yd) */ |
||
| 1041 | t1 = pSrc[(2u * i1) + 1u] - pSrc[(2u * i3) + 1u]; |
||
| 1042 | |||
| 1043 | /* (xb - xd) */ |
||
| 1044 | t2 = pSrc[2u * i1] - pSrc[2u * i3]; |
||
| 1045 | |||
| 1046 | /* xc' = (xa-xb+xc-xd)co2 - (ya-yb+yc-yd)(si2) */ |
||
| 1047 | pSrc[2u * i1] = (r1 * co2) - (s1 * si2); |
||
| 1048 | |||
| 1049 | /* yc' = (ya-yb+yc-yd)co2 + (xa-xb+xc-xd)(si2) */ |
||
| 1050 | pSrc[(2u * i1) + 1u] = (s1 * co2) + (r1 * si2); |
||
| 1051 | |||
| 1052 | /* (xa - xc) - (yb - yd) */ |
||
| 1053 | r1 = r2 - t1; |
||
| 1054 | |||
| 1055 | /* (xa - xc) + (yb - yd) */ |
||
| 1056 | r2 = r2 + t1; |
||
| 1057 | |||
| 1058 | /* (ya - yc) + (xb - xd) */ |
||
| 1059 | s1 = s2 + t2; |
||
| 1060 | |||
| 1061 | /* (ya - yc) - (xb - xd) */ |
||
| 1062 | s2 = s2 - t2; |
||
| 1063 | |||
| 1064 | /* xb' = (xa+yb-xc-yd)co1 - (ya-xb-yc+xd)(si1) */ |
||
| 1065 | pSrc[2u * i2] = (r1 * co1) - (s1 * si1); |
||
| 1066 | |||
| 1067 | /* yb' = (ya-xb-yc+xd)co1 + (xa+yb-xc-yd)(si1) */ |
||
| 1068 | pSrc[(2u * i2) + 1u] = (s1 * co1) + (r1 * si1); |
||
| 1069 | |||
| 1070 | /* xd' = (xa-yb-xc+yd)co3 - (ya+xb-yc-xd)(si3) */ |
||
| 1071 | pSrc[2u * i3] = (r2 * co3) - (s2 * si3); |
||
| 1072 | |||
| 1073 | /* yd' = (ya+xb-yc-xd)co3 + (xa-yb-xc+yd)(si3) */ |
||
| 1074 | pSrc[(2u * i3) + 1u] = (s2 * co3) + (r2 * si3); |
||
| 1075 | |||
| 1076 | i0 += n1; |
||
| 1077 | } while( i0 < fftLen); |
||
| 1078 | j++; |
||
| 1079 | } while(j <= (n2 - 1u)); |
||
| 1080 | twidCoefModifier <<= 2u; |
||
| 1081 | } |
||
| 1082 | /* Initializations of last stage */ |
||
| 1083 | n1 = n2; |
||
| 1084 | n2 >>= 2u; |
||
| 1085 | |||
| 1086 | /* Calculations of last stage */ |
||
| 1087 | for (i0 = 0u; i0 <= (fftLen - n1); i0 += n1) |
||
| 1088 | { |
||
| 1089 | /* index calculation for the input as, */ |
||
| 1090 | /* pSrc[i0 + 0], pSrc[i0 + fftLen/4], pSrc[i0 + fftLen/2], pSrc[i0 + 3fftLen/4] */ |
||
| 1091 | i1 = i0 + n2; |
||
| 1092 | i2 = i1 + n2; |
||
| 1093 | i3 = i2 + n2; |
||
| 1094 | |||
| 1095 | /* Butterfly implementation */ |
||
| 1096 | /* xa + xc */ |
||
| 1097 | r1 = pSrc[2u * i0] + pSrc[2u * i2]; |
||
| 1098 | |||
| 1099 | /* xa - xc */ |
||
| 1100 | r2 = pSrc[2u * i0] - pSrc[2u * i2]; |
||
| 1101 | |||
| 1102 | /* ya + yc */ |
||
| 1103 | s1 = pSrc[(2u * i0) + 1u] + pSrc[(2u * i2) + 1u]; |
||
| 1104 | |||
| 1105 | /* ya - yc */ |
||
| 1106 | s2 = pSrc[(2u * i0) + 1u] - pSrc[(2u * i2) + 1u]; |
||
| 1107 | |||
| 1108 | /* xc + xd */ |
||
| 1109 | t1 = pSrc[2u * i1] + pSrc[2u * i3]; |
||
| 1110 | |||
| 1111 | /* xa' = xa + xb + xc + xd */ |
||
| 1112 | pSrc[2u * i0] = (r1 + t1) * onebyfftLen; |
||
| 1113 | |||
| 1114 | /* (xa + xb) - (xc + xd) */ |
||
| 1115 | r1 = r1 - t1; |
||
| 1116 | |||
| 1117 | /* yb + yd */ |
||
| 1118 | t2 = pSrc[(2u * i1) + 1u] + pSrc[(2u * i3) + 1u]; |
||
| 1119 | |||
| 1120 | /* ya' = ya + yb + yc + yd */ |
||
| 1121 | pSrc[(2u * i0) + 1u] = (s1 + t2) * onebyfftLen; |
||
| 1122 | |||
| 1123 | /* (ya + yc) - (yb + yd) */ |
||
| 1124 | s1 = s1 - t2; |
||
| 1125 | |||
| 1126 | /* (yb-yd) */ |
||
| 1127 | t1 = pSrc[(2u * i1) + 1u] - pSrc[(2u * i3) + 1u]; |
||
| 1128 | |||
| 1129 | /* (xb-xd) */ |
||
| 1130 | t2 = pSrc[2u * i1] - pSrc[2u * i3]; |
||
| 1131 | |||
| 1132 | /* xc' = (xa-xb+xc-xd)co2 - (ya-yb+yc-yd)(si2) */ |
||
| 1133 | pSrc[2u * i1] = r1 * onebyfftLen; |
||
| 1134 | |||
| 1135 | /* yc' = (ya-yb+yc-yd)co2 + (xa-xb+xc-xd)(si2) */ |
||
| 1136 | pSrc[(2u * i1) + 1u] = s1 * onebyfftLen; |
||
| 1137 | |||
| 1138 | /* (xa - xc) - (yb-yd) */ |
||
| 1139 | r1 = r2 - t1; |
||
| 1140 | |||
| 1141 | /* (xa - xc) + (yb-yd) */ |
||
| 1142 | r2 = r2 + t1; |
||
| 1143 | |||
| 1144 | /* (ya - yc) + (xb-xd) */ |
||
| 1145 | s1 = s2 + t2; |
||
| 1146 | |||
| 1147 | /* (ya - yc) - (xb-xd) */ |
||
| 1148 | s2 = s2 - t2; |
||
| 1149 | |||
| 1150 | /* xb' = (xa+yb-xc-yd)co1 - (ya-xb-yc+xd)(si1) */ |
||
| 1151 | pSrc[2u * i2] = r1 * onebyfftLen; |
||
| 1152 | |||
| 1153 | /* yb' = (ya-xb-yc+xd)co1 + (xa+yb-xc-yd)(si1) */ |
||
| 1154 | pSrc[(2u * i2) + 1u] = s1 * onebyfftLen; |
||
| 1155 | |||
| 1156 | /* xd' = (xa-yb-xc+yd)co3 - (ya+xb-yc-xd)(si3) */ |
||
| 1157 | pSrc[2u * i3] = r2 * onebyfftLen; |
||
| 1158 | |||
| 1159 | /* yd' = (ya+xb-yc-xd)co3 + (xa-yb-xc+yd)(si3) */ |
||
| 1160 | pSrc[(2u * i3) + 1u] = s2 * onebyfftLen; |
||
| 1161 | } |
||
| 1162 | |||
| 1163 | #endif /* #ifndef ARM_MATH_CM0_FAMILY_FAMILY */ |
||
| 1164 | } |
||
| 1165 | |||
| 1166 | /** |
||
| 1167 | * @addtogroup ComplexFFT |
||
| 1168 | * @{ |
||
| 1169 | */ |
||
| 1170 | |||
| 1171 | /** |
||
| 1172 | * @details |
||
| 1173 | * @brief Processing function for the floating-point Radix-4 CFFT/CIFFT. |
||
| 1174 | * @deprecated Do not use this function. It has been superseded by \ref arm_cfft_f32 and will be removed |
||
| 1175 | * in the future. |
||
| 1176 | * @param[in] *S points to an instance of the floating-point Radix-4 CFFT/CIFFT structure. |
||
| 1177 | * @param[in, out] *pSrc points to the complex data buffer of size <code>2*fftLen</code>. Processing occurs in-place. |
||
| 1178 | * @return none. |
||
| 1179 | */ |
||
| 1180 | |||
| 1181 | void arm_cfft_radix4_f32( |
||
| 1182 | const arm_cfft_radix4_instance_f32 * S, |
||
| 1183 | float32_t * pSrc) |
||
| 1184 | { |
||
| 1185 | |||
| 1186 | if(S->ifftFlag == 1u) |
||
| 1187 | { |
||
| 1188 | /* Complex IFFT radix-4 */ |
||
| 1189 | arm_radix4_butterfly_inverse_f32(pSrc, S->fftLen, S->pTwiddle, |
||
| 1190 | S->twidCoefModifier, S->onebyfftLen); |
||
| 1191 | } |
||
| 1192 | else |
||
| 1193 | { |
||
| 1194 | /* Complex FFT radix-4 */ |
||
| 1195 | arm_radix4_butterfly_f32(pSrc, S->fftLen, S->pTwiddle, |
||
| 1196 | S->twidCoefModifier); |
||
| 1197 | } |
||
| 1198 | |||
| 1199 | if(S->bitReverseFlag == 1u) |
||
| 1200 | { |
||
| 1201 | /* Bit Reversal */ |
||
| 1202 | arm_bitreversal_f32(pSrc, S->fftLen, S->bitRevFactor, S->pBitRevTable); |
||
| 1203 | } |
||
| 1204 | |||
| 1205 | } |
||
| 1206 | |||
| 1207 | /** |
||
| 1208 | * @} end of ComplexFFT group |
||
| 1209 | */ |
||
| 1210 |