CMSIS DSP library
Dependents: performance_timer Surfboard_ gps2rtty Capstone ... more
arm_cfft_radix4_f32.c
00001 /* ---------------------------------------------------------------------- 00002 * Copyright (C) 2010-2014 ARM Limited. All rights reserved. 00003 * 00004 * $Date: 19. March 2015 00005 * $Revision: V.1.4.5 00006 * 00007 * Project: CMSIS DSP Library 00008 * Title: arm_cfft_radix4_f32.c 00009 * 00010 * Description: Radix-4 Decimation in Frequency CFFT & CIFFT Floating point processing function 00011 * 00012 * 00013 * Target Processor: Cortex-M4/Cortex-M3/Cortex-M0 00014 * 00015 * Redistribution and use in source and binary forms, with or without 00016 * modification, are permitted provided that the following conditions 00017 * are met: 00018 * - Redistributions of source code must retain the above copyright 00019 * notice, this list of conditions and the following disclaimer. 00020 * - Redistributions in binary form must reproduce the above copyright 00021 * notice, this list of conditions and the following disclaimer in 00022 * the documentation and/or other materials provided with the 00023 * distribution. 00024 * - Neither the name of ARM LIMITED nor the names of its contributors 00025 * may be used to endorse or promote products derived from this 00026 * software without specific prior written permission. 00027 * 00028 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00029 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00030 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 00031 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 00032 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 00033 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 00034 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00035 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00036 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00037 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 00038 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00039 * POSSIBILITY OF SUCH DAMAGE. 00040 * -------------------------------------------------------------------- */ 00041 00042 #include "arm_math.h" 00043 00044 extern void arm_bitreversal_f32( 00045 float32_t * pSrc, 00046 uint16_t fftSize, 00047 uint16_t bitRevFactor, 00048 uint16_t * pBitRevTab); 00049 00050 /** 00051 * @ingroup groupTransforms 00052 */ 00053 00054 /* ---------------------------------------------------------------------- 00055 ** Internal helper function used by the FFTs 00056 ** ------------------------------------------------------------------- */ 00057 00058 /* 00059 * @brief Core function for the floating-point CFFT butterfly process. 00060 * @param[in, out] *pSrc points to the in-place buffer of floating-point data type. 00061 * @param[in] fftLen length of the FFT. 00062 * @param[in] *pCoef points to the twiddle coefficient buffer. 00063 * @param[in] twidCoefModifier twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. 00064 * @return none. 00065 */ 00066 00067 void arm_radix4_butterfly_f32( 00068 float32_t * pSrc, 00069 uint16_t fftLen, 00070 float32_t * pCoef, 00071 uint16_t twidCoefModifier) 00072 { 00073 00074 float32_t co1, co2, co3, si1, si2, si3; 00075 uint32_t ia1, ia2, ia3; 00076 uint32_t i0, i1, i2, i3; 00077 uint32_t n1, n2, j, k; 00078 00079 #ifndef ARM_MATH_CM0_FAMILY_FAMILY 00080 00081 /* Run the below code for Cortex-M4 and Cortex-M3 */ 00082 00083 float32_t xaIn, yaIn, xbIn, ybIn, xcIn, ycIn, xdIn, ydIn; 00084 float32_t Xaplusc, Xbplusd, Yaplusc, Ybplusd, Xaminusc, Xbminusd, Yaminusc, 00085 Ybminusd; 00086 float32_t Xb12C_out, Yb12C_out, Xc12C_out, Yc12C_out, Xd12C_out, Yd12C_out; 00087 float32_t Xb12_out, Yb12_out, Xc12_out, Yc12_out, Xd12_out, Yd12_out; 00088 float32_t *ptr1; 00089 float32_t p0,p1,p2,p3,p4,p5; 00090 float32_t a0,a1,a2,a3,a4,a5,a6,a7; 00091 00092 /* Initializations for the first stage */ 00093 n2 = fftLen; 00094 n1 = n2; 00095 00096 /* n2 = fftLen/4 */ 00097 n2 >>= 2u; 00098 i0 = 0u; 00099 ia1 = 0u; 00100 00101 j = n2; 00102 00103 /* Calculation of first stage */ 00104 do 00105 { 00106 /* index calculation for the input as, */ 00107 /* pSrc[i0 + 0], pSrc[i0 + fftLen/4], pSrc[i0 + fftLen/2], pSrc[i0 + 3fftLen/4] */ 00108 i1 = i0 + n2; 00109 i2 = i1 + n2; 00110 i3 = i2 + n2; 00111 00112 xaIn = pSrc[(2u * i0)]; 00113 yaIn = pSrc[(2u * i0) + 1u]; 00114 00115 xbIn = pSrc[(2u * i1)]; 00116 ybIn = pSrc[(2u * i1) + 1u]; 00117 00118 xcIn = pSrc[(2u * i2)]; 00119 ycIn = pSrc[(2u * i2) + 1u]; 00120 00121 xdIn = pSrc[(2u * i3)]; 00122 ydIn = pSrc[(2u * i3) + 1u]; 00123 00124 /* xa + xc */ 00125 Xaplusc = xaIn + xcIn; 00126 /* xb + xd */ 00127 Xbplusd = xbIn + xdIn; 00128 /* ya + yc */ 00129 Yaplusc = yaIn + ycIn; 00130 /* yb + yd */ 00131 Ybplusd = ybIn + ydIn; 00132 00133 /* index calculation for the coefficients */ 00134 ia2 = ia1 + ia1; 00135 co2 = pCoef[ia2 * 2u]; 00136 si2 = pCoef[(ia2 * 2u) + 1u]; 00137 00138 /* xa - xc */ 00139 Xaminusc = xaIn - xcIn; 00140 /* xb - xd */ 00141 Xbminusd = xbIn - xdIn; 00142 /* ya - yc */ 00143 Yaminusc = yaIn - ycIn; 00144 /* yb - yd */ 00145 Ybminusd = ybIn - ydIn; 00146 00147 /* xa' = xa + xb + xc + xd */ 00148 pSrc[(2u * i0)] = Xaplusc + Xbplusd; 00149 /* ya' = ya + yb + yc + yd */ 00150 pSrc[(2u * i0) + 1u] = Yaplusc + Ybplusd; 00151 00152 /* (xa - xc) + (yb - yd) */ 00153 Xb12C_out = (Xaminusc + Ybminusd); 00154 /* (ya - yc) + (xb - xd) */ 00155 Yb12C_out = (Yaminusc - Xbminusd); 00156 /* (xa + xc) - (xb + xd) */ 00157 Xc12C_out = (Xaplusc - Xbplusd); 00158 /* (ya + yc) - (yb + yd) */ 00159 Yc12C_out = (Yaplusc - Ybplusd); 00160 /* (xa - xc) - (yb - yd) */ 00161 Xd12C_out = (Xaminusc - Ybminusd); 00162 /* (ya - yc) + (xb - xd) */ 00163 Yd12C_out = (Xbminusd + Yaminusc); 00164 00165 co1 = pCoef[ia1 * 2u]; 00166 si1 = pCoef[(ia1 * 2u) + 1u]; 00167 00168 /* index calculation for the coefficients */ 00169 ia3 = ia2 + ia1; 00170 co3 = pCoef[ia3 * 2u]; 00171 si3 = pCoef[(ia3 * 2u) + 1u]; 00172 00173 Xb12_out = Xb12C_out * co1; 00174 Yb12_out = Yb12C_out * co1; 00175 Xc12_out = Xc12C_out * co2; 00176 Yc12_out = Yc12C_out * co2; 00177 Xd12_out = Xd12C_out * co3; 00178 Yd12_out = Yd12C_out * co3; 00179 00180 /* xb' = (xa+yb-xc-yd)co1 - (ya-xb-yc+xd)(si1) */ 00181 //Xb12_out -= Yb12C_out * si1; 00182 p0 = Yb12C_out * si1; 00183 /* yb' = (ya-xb-yc+xd)co1 + (xa+yb-xc-yd)(si1) */ 00184 //Yb12_out += Xb12C_out * si1; 00185 p1 = Xb12C_out * si1; 00186 /* xc' = (xa-xb+xc-xd)co2 - (ya-yb+yc-yd)(si2) */ 00187 //Xc12_out -= Yc12C_out * si2; 00188 p2 = Yc12C_out * si2; 00189 /* yc' = (ya-yb+yc-yd)co2 + (xa-xb+xc-xd)(si2) */ 00190 //Yc12_out += Xc12C_out * si2; 00191 p3 = Xc12C_out * si2; 00192 /* xd' = (xa-yb-xc+yd)co3 - (ya+xb-yc-xd)(si3) */ 00193 //Xd12_out -= Yd12C_out * si3; 00194 p4 = Yd12C_out * si3; 00195 /* yd' = (ya+xb-yc-xd)co3 + (xa-yb-xc+yd)(si3) */ 00196 //Yd12_out += Xd12C_out * si3; 00197 p5 = Xd12C_out * si3; 00198 00199 Xb12_out += p0; 00200 Yb12_out -= p1; 00201 Xc12_out += p2; 00202 Yc12_out -= p3; 00203 Xd12_out += p4; 00204 Yd12_out -= p5; 00205 00206 /* xc' = (xa-xb+xc-xd)co2 + (ya-yb+yc-yd)(si2) */ 00207 pSrc[2u * i1] = Xc12_out; 00208 00209 /* yc' = (ya-yb+yc-yd)co2 - (xa-xb+xc-xd)(si2) */ 00210 pSrc[(2u * i1) + 1u] = Yc12_out; 00211 00212 /* xb' = (xa+yb-xc-yd)co1 + (ya-xb-yc+xd)(si1) */ 00213 pSrc[2u * i2] = Xb12_out; 00214 00215 /* yb' = (ya-xb-yc+xd)co1 - (xa+yb-xc-yd)(si1) */ 00216 pSrc[(2u * i2) + 1u] = Yb12_out; 00217 00218 /* xd' = (xa-yb-xc+yd)co3 + (ya+xb-yc-xd)(si3) */ 00219 pSrc[2u * i3] = Xd12_out; 00220 00221 /* yd' = (ya+xb-yc-xd)co3 - (xa-yb-xc+yd)(si3) */ 00222 pSrc[(2u * i3) + 1u] = Yd12_out; 00223 00224 /* Twiddle coefficients index modifier */ 00225 ia1 += twidCoefModifier; 00226 00227 /* Updating input index */ 00228 i0++; 00229 00230 } 00231 while(--j); 00232 00233 twidCoefModifier <<= 2u; 00234 00235 /* Calculation of second stage to excluding last stage */ 00236 for (k = fftLen >> 2u; k > 4u; k >>= 2u) 00237 { 00238 /* Initializations for the first stage */ 00239 n1 = n2; 00240 n2 >>= 2u; 00241 ia1 = 0u; 00242 00243 /* Calculation of first stage */ 00244 j = 0; 00245 do 00246 { 00247 /* index calculation for the coefficients */ 00248 ia2 = ia1 + ia1; 00249 ia3 = ia2 + ia1; 00250 co1 = pCoef[ia1 * 2u]; 00251 si1 = pCoef[(ia1 * 2u) + 1u]; 00252 co2 = pCoef[ia2 * 2u]; 00253 si2 = pCoef[(ia2 * 2u) + 1u]; 00254 co3 = pCoef[ia3 * 2u]; 00255 si3 = pCoef[(ia3 * 2u) + 1u]; 00256 00257 /* Twiddle coefficients index modifier */ 00258 ia1 += twidCoefModifier; 00259 00260 i0 = j; 00261 do 00262 { 00263 /* index calculation for the input as, */ 00264 /* pSrc[i0 + 0], pSrc[i0 + fftLen/4], pSrc[i0 + fftLen/2], pSrc[i0 + 3fftLen/4] */ 00265 i1 = i0 + n2; 00266 i2 = i1 + n2; 00267 i3 = i2 + n2; 00268 00269 xaIn = pSrc[(2u * i0)]; 00270 yaIn = pSrc[(2u * i0) + 1u]; 00271 00272 xbIn = pSrc[(2u * i1)]; 00273 ybIn = pSrc[(2u * i1) + 1u]; 00274 00275 xcIn = pSrc[(2u * i2)]; 00276 ycIn = pSrc[(2u * i2) + 1u]; 00277 00278 xdIn = pSrc[(2u * i3)]; 00279 ydIn = pSrc[(2u * i3) + 1u]; 00280 00281 /* xa - xc */ 00282 Xaminusc = xaIn - xcIn; 00283 /* (xb - xd) */ 00284 Xbminusd = xbIn - xdIn; 00285 /* ya - yc */ 00286 Yaminusc = yaIn - ycIn; 00287 /* (yb - yd) */ 00288 Ybminusd = ybIn - ydIn; 00289 00290 /* xa + xc */ 00291 Xaplusc = xaIn + xcIn; 00292 /* xb + xd */ 00293 Xbplusd = xbIn + xdIn; 00294 /* ya + yc */ 00295 Yaplusc = yaIn + ycIn; 00296 /* yb + yd */ 00297 Ybplusd = ybIn + ydIn; 00298 00299 /* (xa - xc) + (yb - yd) */ 00300 Xb12C_out = (Xaminusc + Ybminusd); 00301 /* (ya - yc) - (xb - xd) */ 00302 Yb12C_out = (Yaminusc - Xbminusd); 00303 /* xa + xc -(xb + xd) */ 00304 Xc12C_out = (Xaplusc - Xbplusd); 00305 /* (ya + yc) - (yb + yd) */ 00306 Yc12C_out = (Yaplusc - Ybplusd); 00307 /* (xa - xc) - (yb - yd) */ 00308 Xd12C_out = (Xaminusc - Ybminusd); 00309 /* (ya - yc) + (xb - xd) */ 00310 Yd12C_out = (Xbminusd + Yaminusc); 00311 00312 pSrc[(2u * i0)] = Xaplusc + Xbplusd; 00313 pSrc[(2u * i0) + 1u] = Yaplusc + Ybplusd; 00314 00315 Xb12_out = Xb12C_out * co1; 00316 Yb12_out = Yb12C_out * co1; 00317 Xc12_out = Xc12C_out * co2; 00318 Yc12_out = Yc12C_out * co2; 00319 Xd12_out = Xd12C_out * co3; 00320 Yd12_out = Yd12C_out * co3; 00321 00322 /* xb' = (xa+yb-xc-yd)co1 - (ya-xb-yc+xd)(si1) */ 00323 //Xb12_out -= Yb12C_out * si1; 00324 p0 = Yb12C_out * si1; 00325 /* yb' = (ya-xb-yc+xd)co1 + (xa+yb-xc-yd)(si1) */ 00326 //Yb12_out += Xb12C_out * si1; 00327 p1 = Xb12C_out * si1; 00328 /* xc' = (xa-xb+xc-xd)co2 - (ya-yb+yc-yd)(si2) */ 00329 //Xc12_out -= Yc12C_out * si2; 00330 p2 = Yc12C_out * si2; 00331 /* yc' = (ya-yb+yc-yd)co2 + (xa-xb+xc-xd)(si2) */ 00332 //Yc12_out += Xc12C_out * si2; 00333 p3 = Xc12C_out * si2; 00334 /* xd' = (xa-yb-xc+yd)co3 - (ya+xb-yc-xd)(si3) */ 00335 //Xd12_out -= Yd12C_out * si3; 00336 p4 = Yd12C_out * si3; 00337 /* yd' = (ya+xb-yc-xd)co3 + (xa-yb-xc+yd)(si3) */ 00338 //Yd12_out += Xd12C_out * si3; 00339 p5 = Xd12C_out * si3; 00340 00341 Xb12_out += p0; 00342 Yb12_out -= p1; 00343 Xc12_out += p2; 00344 Yc12_out -= p3; 00345 Xd12_out += p4; 00346 Yd12_out -= p5; 00347 00348 /* xc' = (xa-xb+xc-xd)co2 + (ya-yb+yc-yd)(si2) */ 00349 pSrc[2u * i1] = Xc12_out; 00350 00351 /* yc' = (ya-yb+yc-yd)co2 - (xa-xb+xc-xd)(si2) */ 00352 pSrc[(2u * i1) + 1u] = Yc12_out; 00353 00354 /* xb' = (xa+yb-xc-yd)co1 + (ya-xb-yc+xd)(si1) */ 00355 pSrc[2u * i2] = Xb12_out; 00356 00357 /* yb' = (ya-xb-yc+xd)co1 - (xa+yb-xc-yd)(si1) */ 00358 pSrc[(2u * i2) + 1u] = Yb12_out; 00359 00360 /* xd' = (xa-yb-xc+yd)co3 + (ya+xb-yc-xd)(si3) */ 00361 pSrc[2u * i3] = Xd12_out; 00362 00363 /* yd' = (ya+xb-yc-xd)co3 - (xa-yb-xc+yd)(si3) */ 00364 pSrc[(2u * i3) + 1u] = Yd12_out; 00365 00366 i0 += n1; 00367 } while(i0 < fftLen); 00368 j++; 00369 } while(j <= (n2 - 1u)); 00370 twidCoefModifier <<= 2u; 00371 } 00372 00373 j = fftLen >> 2; 00374 ptr1 = &pSrc[0]; 00375 00376 /* Calculations of last stage */ 00377 do 00378 { 00379 xaIn = ptr1[0]; 00380 yaIn = ptr1[1]; 00381 xbIn = ptr1[2]; 00382 ybIn = ptr1[3]; 00383 xcIn = ptr1[4]; 00384 ycIn = ptr1[5]; 00385 xdIn = ptr1[6]; 00386 ydIn = ptr1[7]; 00387 00388 /* xa + xc */ 00389 Xaplusc = xaIn + xcIn; 00390 00391 /* xa - xc */ 00392 Xaminusc = xaIn - xcIn; 00393 00394 /* ya + yc */ 00395 Yaplusc = yaIn + ycIn; 00396 00397 /* ya - yc */ 00398 Yaminusc = yaIn - ycIn; 00399 00400 /* xb + xd */ 00401 Xbplusd = xbIn + xdIn; 00402 00403 /* yb + yd */ 00404 Ybplusd = ybIn + ydIn; 00405 00406 /* (xb-xd) */ 00407 Xbminusd = xbIn - xdIn; 00408 00409 /* (yb-yd) */ 00410 Ybminusd = ybIn - ydIn; 00411 00412 /* xa' = xa + xb + xc + xd */ 00413 a0 = (Xaplusc + Xbplusd); 00414 /* ya' = ya + yb + yc + yd */ 00415 a1 = (Yaplusc + Ybplusd); 00416 /* xc' = (xa-xb+xc-xd) */ 00417 a2 = (Xaplusc - Xbplusd); 00418 /* yc' = (ya-yb+yc-yd) */ 00419 a3 = (Yaplusc - Ybplusd); 00420 /* xb' = (xa+yb-xc-yd) */ 00421 a4 = (Xaminusc + Ybminusd); 00422 /* yb' = (ya-xb-yc+xd) */ 00423 a5 = (Yaminusc - Xbminusd); 00424 /* xd' = (xa-yb-xc+yd)) */ 00425 a6 = (Xaminusc - Ybminusd); 00426 /* yd' = (ya+xb-yc-xd) */ 00427 a7 = (Xbminusd + Yaminusc); 00428 00429 ptr1[0] = a0; 00430 ptr1[1] = a1; 00431 ptr1[2] = a2; 00432 ptr1[3] = a3; 00433 ptr1[4] = a4; 00434 ptr1[5] = a5; 00435 ptr1[6] = a6; 00436 ptr1[7] = a7; 00437 00438 /* increment pointer by 8 */ 00439 ptr1 += 8u; 00440 } while(--j); 00441 00442 #else 00443 00444 float32_t t1, t2, r1, r2, s1, s2; 00445 00446 /* Run the below code for Cortex-M0 */ 00447 00448 /* Initializations for the fft calculation */ 00449 n2 = fftLen; 00450 n1 = n2; 00451 for (k = fftLen; k > 1u; k >>= 2u) 00452 { 00453 /* Initializations for the fft calculation */ 00454 n1 = n2; 00455 n2 >>= 2u; 00456 ia1 = 0u; 00457 00458 /* FFT Calculation */ 00459 j = 0; 00460 do 00461 { 00462 /* index calculation for the coefficients */ 00463 ia2 = ia1 + ia1; 00464 ia3 = ia2 + ia1; 00465 co1 = pCoef[ia1 * 2u]; 00466 si1 = pCoef[(ia1 * 2u) + 1u]; 00467 co2 = pCoef[ia2 * 2u]; 00468 si2 = pCoef[(ia2 * 2u) + 1u]; 00469 co3 = pCoef[ia3 * 2u]; 00470 si3 = pCoef[(ia3 * 2u) + 1u]; 00471 00472 /* Twiddle coefficients index modifier */ 00473 ia1 = ia1 + twidCoefModifier; 00474 00475 i0 = j; 00476 do 00477 { 00478 /* index calculation for the input as, */ 00479 /* pSrc[i0 + 0], pSrc[i0 + fftLen/4], pSrc[i0 + fftLen/2], pSrc[i0 + 3fftLen/4] */ 00480 i1 = i0 + n2; 00481 i2 = i1 + n2; 00482 i3 = i2 + n2; 00483 00484 /* xa + xc */ 00485 r1 = pSrc[(2u * i0)] + pSrc[(2u * i2)]; 00486 00487 /* xa - xc */ 00488 r2 = pSrc[(2u * i0)] - pSrc[(2u * i2)]; 00489 00490 /* ya + yc */ 00491 s1 = pSrc[(2u * i0) + 1u] + pSrc[(2u * i2) + 1u]; 00492 00493 /* ya - yc */ 00494 s2 = pSrc[(2u * i0) + 1u] - pSrc[(2u * i2) + 1u]; 00495 00496 /* xb + xd */ 00497 t1 = pSrc[2u * i1] + pSrc[2u * i3]; 00498 00499 /* xa' = xa + xb + xc + xd */ 00500 pSrc[2u * i0] = r1 + t1; 00501 00502 /* xa + xc -(xb + xd) */ 00503 r1 = r1 - t1; 00504 00505 /* yb + yd */ 00506 t2 = pSrc[(2u * i1) + 1u] + pSrc[(2u * i3) + 1u]; 00507 00508 /* ya' = ya + yb + yc + yd */ 00509 pSrc[(2u * i0) + 1u] = s1 + t2; 00510 00511 /* (ya + yc) - (yb + yd) */ 00512 s1 = s1 - t2; 00513 00514 /* (yb - yd) */ 00515 t1 = pSrc[(2u * i1) + 1u] - pSrc[(2u * i3) + 1u]; 00516 00517 /* (xb - xd) */ 00518 t2 = pSrc[2u * i1] - pSrc[2u * i3]; 00519 00520 /* xc' = (xa-xb+xc-xd)co2 + (ya-yb+yc-yd)(si2) */ 00521 pSrc[2u * i1] = (r1 * co2) + (s1 * si2); 00522 00523 /* yc' = (ya-yb+yc-yd)co2 - (xa-xb+xc-xd)(si2) */ 00524 pSrc[(2u * i1) + 1u] = (s1 * co2) - (r1 * si2); 00525 00526 /* (xa - xc) + (yb - yd) */ 00527 r1 = r2 + t1; 00528 00529 /* (xa - xc) - (yb - yd) */ 00530 r2 = r2 - t1; 00531 00532 /* (ya - yc) - (xb - xd) */ 00533 s1 = s2 - t2; 00534 00535 /* (ya - yc) + (xb - xd) */ 00536 s2 = s2 + t2; 00537 00538 /* xb' = (xa+yb-xc-yd)co1 + (ya-xb-yc+xd)(si1) */ 00539 pSrc[2u * i2] = (r1 * co1) + (s1 * si1); 00540 00541 /* yb' = (ya-xb-yc+xd)co1 - (xa+yb-xc-yd)(si1) */ 00542 pSrc[(2u * i2) + 1u] = (s1 * co1) - (r1 * si1); 00543 00544 /* xd' = (xa-yb-xc+yd)co3 + (ya+xb-yc-xd)(si3) */ 00545 pSrc[2u * i3] = (r2 * co3) + (s2 * si3); 00546 00547 /* yd' = (ya+xb-yc-xd)co3 - (xa-yb-xc+yd)(si3) */ 00548 pSrc[(2u * i3) + 1u] = (s2 * co3) - (r2 * si3); 00549 00550 i0 += n1; 00551 } while( i0 < fftLen); 00552 j++; 00553 } while(j <= (n2 - 1u)); 00554 twidCoefModifier <<= 2u; 00555 } 00556 00557 #endif /* #ifndef ARM_MATH_CM0_FAMILY_FAMILY */ 00558 00559 } 00560 00561 /* 00562 * @brief Core function for the floating-point CIFFT butterfly process. 00563 * @param[in, out] *pSrc points to the in-place buffer of floating-point data type. 00564 * @param[in] fftLen length of the FFT. 00565 * @param[in] *pCoef points to twiddle coefficient buffer. 00566 * @param[in] twidCoefModifier twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. 00567 * @param[in] onebyfftLen value of 1/fftLen. 00568 * @return none. 00569 */ 00570 00571 void arm_radix4_butterfly_inverse_f32( 00572 float32_t * pSrc, 00573 uint16_t fftLen, 00574 float32_t * pCoef, 00575 uint16_t twidCoefModifier, 00576 float32_t onebyfftLen) 00577 { 00578 float32_t co1, co2, co3, si1, si2, si3; 00579 uint32_t ia1, ia2, ia3; 00580 uint32_t i0, i1, i2, i3; 00581 uint32_t n1, n2, j, k; 00582 00583 #ifndef ARM_MATH_CM0_FAMILY_FAMILY 00584 00585 float32_t xaIn, yaIn, xbIn, ybIn, xcIn, ycIn, xdIn, ydIn; 00586 float32_t Xaplusc, Xbplusd, Yaplusc, Ybplusd, Xaminusc, Xbminusd, Yaminusc, 00587 Ybminusd; 00588 float32_t Xb12C_out, Yb12C_out, Xc12C_out, Yc12C_out, Xd12C_out, Yd12C_out; 00589 float32_t Xb12_out, Yb12_out, Xc12_out, Yc12_out, Xd12_out, Yd12_out; 00590 float32_t *ptr1; 00591 float32_t p0,p1,p2,p3,p4,p5,p6,p7; 00592 float32_t a0,a1,a2,a3,a4,a5,a6,a7; 00593 00594 00595 /* Initializations for the first stage */ 00596 n2 = fftLen; 00597 n1 = n2; 00598 00599 /* n2 = fftLen/4 */ 00600 n2 >>= 2u; 00601 i0 = 0u; 00602 ia1 = 0u; 00603 00604 j = n2; 00605 00606 /* Calculation of first stage */ 00607 do 00608 { 00609 /* index calculation for the input as, */ 00610 /* pSrc[i0 + 0], pSrc[i0 + fftLen/4], pSrc[i0 + fftLen/2], pSrc[i0 + 3fftLen/4] */ 00611 i1 = i0 + n2; 00612 i2 = i1 + n2; 00613 i3 = i2 + n2; 00614 00615 /* Butterfly implementation */ 00616 xaIn = pSrc[(2u * i0)]; 00617 yaIn = pSrc[(2u * i0) + 1u]; 00618 00619 xcIn = pSrc[(2u * i2)]; 00620 ycIn = pSrc[(2u * i2) + 1u]; 00621 00622 xbIn = pSrc[(2u * i1)]; 00623 ybIn = pSrc[(2u * i1) + 1u]; 00624 00625 xdIn = pSrc[(2u * i3)]; 00626 ydIn = pSrc[(2u * i3) + 1u]; 00627 00628 /* xa + xc */ 00629 Xaplusc = xaIn + xcIn; 00630 /* xb + xd */ 00631 Xbplusd = xbIn + xdIn; 00632 /* ya + yc */ 00633 Yaplusc = yaIn + ycIn; 00634 /* yb + yd */ 00635 Ybplusd = ybIn + ydIn; 00636 00637 /* index calculation for the coefficients */ 00638 ia2 = ia1 + ia1; 00639 co2 = pCoef[ia2 * 2u]; 00640 si2 = pCoef[(ia2 * 2u) + 1u]; 00641 00642 /* xa - xc */ 00643 Xaminusc = xaIn - xcIn; 00644 /* xb - xd */ 00645 Xbminusd = xbIn - xdIn; 00646 /* ya - yc */ 00647 Yaminusc = yaIn - ycIn; 00648 /* yb - yd */ 00649 Ybminusd = ybIn - ydIn; 00650 00651 /* xa' = xa + xb + xc + xd */ 00652 pSrc[(2u * i0)] = Xaplusc + Xbplusd; 00653 00654 /* ya' = ya + yb + yc + yd */ 00655 pSrc[(2u * i0) + 1u] = Yaplusc + Ybplusd; 00656 00657 /* (xa - xc) - (yb - yd) */ 00658 Xb12C_out = (Xaminusc - Ybminusd); 00659 /* (ya - yc) + (xb - xd) */ 00660 Yb12C_out = (Yaminusc + Xbminusd); 00661 /* (xa + xc) - (xb + xd) */ 00662 Xc12C_out = (Xaplusc - Xbplusd); 00663 /* (ya + yc) - (yb + yd) */ 00664 Yc12C_out = (Yaplusc - Ybplusd); 00665 /* (xa - xc) + (yb - yd) */ 00666 Xd12C_out = (Xaminusc + Ybminusd); 00667 /* (ya - yc) - (xb - xd) */ 00668 Yd12C_out = (Yaminusc - Xbminusd); 00669 00670 co1 = pCoef[ia1 * 2u]; 00671 si1 = pCoef[(ia1 * 2u) + 1u]; 00672 00673 /* index calculation for the coefficients */ 00674 ia3 = ia2 + ia1; 00675 co3 = pCoef[ia3 * 2u]; 00676 si3 = pCoef[(ia3 * 2u) + 1u]; 00677 00678 Xb12_out = Xb12C_out * co1; 00679 Yb12_out = Yb12C_out * co1; 00680 Xc12_out = Xc12C_out * co2; 00681 Yc12_out = Yc12C_out * co2; 00682 Xd12_out = Xd12C_out * co3; 00683 Yd12_out = Yd12C_out * co3; 00684 00685 /* xb' = (xa+yb-xc-yd)co1 - (ya-xb-yc+xd)(si1) */ 00686 //Xb12_out -= Yb12C_out * si1; 00687 p0 = Yb12C_out * si1; 00688 /* yb' = (ya-xb-yc+xd)co1 + (xa+yb-xc-yd)(si1) */ 00689 //Yb12_out += Xb12C_out * si1; 00690 p1 = Xb12C_out * si1; 00691 /* xc' = (xa-xb+xc-xd)co2 - (ya-yb+yc-yd)(si2) */ 00692 //Xc12_out -= Yc12C_out * si2; 00693 p2 = Yc12C_out * si2; 00694 /* yc' = (ya-yb+yc-yd)co2 + (xa-xb+xc-xd)(si2) */ 00695 //Yc12_out += Xc12C_out * si2; 00696 p3 = Xc12C_out * si2; 00697 /* xd' = (xa-yb-xc+yd)co3 - (ya+xb-yc-xd)(si3) */ 00698 //Xd12_out -= Yd12C_out * si3; 00699 p4 = Yd12C_out * si3; 00700 /* yd' = (ya+xb-yc-xd)co3 + (xa-yb-xc+yd)(si3) */ 00701 //Yd12_out += Xd12C_out * si3; 00702 p5 = Xd12C_out * si3; 00703 00704 Xb12_out -= p0; 00705 Yb12_out += p1; 00706 Xc12_out -= p2; 00707 Yc12_out += p3; 00708 Xd12_out -= p4; 00709 Yd12_out += p5; 00710 00711 /* xc' = (xa-xb+xc-xd)co2 - (ya-yb+yc-yd)(si2) */ 00712 pSrc[2u * i1] = Xc12_out; 00713 00714 /* yc' = (ya-yb+yc-yd)co2 + (xa-xb+xc-xd)(si2) */ 00715 pSrc[(2u * i1) + 1u] = Yc12_out; 00716 00717 /* xb' = (xa+yb-xc-yd)co1 - (ya-xb-yc+xd)(si1) */ 00718 pSrc[2u * i2] = Xb12_out; 00719 00720 /* yb' = (ya-xb-yc+xd)co1 + (xa+yb-xc-yd)(si1) */ 00721 pSrc[(2u * i2) + 1u] = Yb12_out; 00722 00723 /* xd' = (xa-yb-xc+yd)co3 - (ya+xb-yc-xd)(si3) */ 00724 pSrc[2u * i3] = Xd12_out; 00725 00726 /* yd' = (ya+xb-yc-xd)co3 + (xa-yb-xc+yd)(si3) */ 00727 pSrc[(2u * i3) + 1u] = Yd12_out; 00728 00729 /* Twiddle coefficients index modifier */ 00730 ia1 = ia1 + twidCoefModifier; 00731 00732 /* Updating input index */ 00733 i0 = i0 + 1u; 00734 00735 } while(--j); 00736 00737 twidCoefModifier <<= 2u; 00738 00739 /* Calculation of second stage to excluding last stage */ 00740 for (k = fftLen >> 2u; k > 4u; k >>= 2u) 00741 { 00742 /* Initializations for the first stage */ 00743 n1 = n2; 00744 n2 >>= 2u; 00745 ia1 = 0u; 00746 00747 /* Calculation of first stage */ 00748 j = 0; 00749 do 00750 { 00751 /* index calculation for the coefficients */ 00752 ia2 = ia1 + ia1; 00753 ia3 = ia2 + ia1; 00754 co1 = pCoef[ia1 * 2u]; 00755 si1 = pCoef[(ia1 * 2u) + 1u]; 00756 co2 = pCoef[ia2 * 2u]; 00757 si2 = pCoef[(ia2 * 2u) + 1u]; 00758 co3 = pCoef[ia3 * 2u]; 00759 si3 = pCoef[(ia3 * 2u) + 1u]; 00760 00761 /* Twiddle coefficients index modifier */ 00762 ia1 = ia1 + twidCoefModifier; 00763 00764 i0 = j; 00765 do 00766 { 00767 /* index calculation for the input as, */ 00768 /* pSrc[i0 + 0], pSrc[i0 + fftLen/4], pSrc[i0 + fftLen/2], pSrc[i0 + 3fftLen/4] */ 00769 i1 = i0 + n2; 00770 i2 = i1 + n2; 00771 i3 = i2 + n2; 00772 00773 xaIn = pSrc[(2u * i0)]; 00774 yaIn = pSrc[(2u * i0) + 1u]; 00775 00776 xbIn = pSrc[(2u * i1)]; 00777 ybIn = pSrc[(2u * i1) + 1u]; 00778 00779 xcIn = pSrc[(2u * i2)]; 00780 ycIn = pSrc[(2u * i2) + 1u]; 00781 00782 xdIn = pSrc[(2u * i3)]; 00783 ydIn = pSrc[(2u * i3) + 1u]; 00784 00785 /* xa - xc */ 00786 Xaminusc = xaIn - xcIn; 00787 /* (xb - xd) */ 00788 Xbminusd = xbIn - xdIn; 00789 /* ya - yc */ 00790 Yaminusc = yaIn - ycIn; 00791 /* (yb - yd) */ 00792 Ybminusd = ybIn - ydIn; 00793 00794 /* xa + xc */ 00795 Xaplusc = xaIn + xcIn; 00796 /* xb + xd */ 00797 Xbplusd = xbIn + xdIn; 00798 /* ya + yc */ 00799 Yaplusc = yaIn + ycIn; 00800 /* yb + yd */ 00801 Ybplusd = ybIn + ydIn; 00802 00803 /* (xa - xc) - (yb - yd) */ 00804 Xb12C_out = (Xaminusc - Ybminusd); 00805 /* (ya - yc) + (xb - xd) */ 00806 Yb12C_out = (Yaminusc + Xbminusd); 00807 /* xa + xc -(xb + xd) */ 00808 Xc12C_out = (Xaplusc - Xbplusd); 00809 /* (ya + yc) - (yb + yd) */ 00810 Yc12C_out = (Yaplusc - Ybplusd); 00811 /* (xa - xc) + (yb - yd) */ 00812 Xd12C_out = (Xaminusc + Ybminusd); 00813 /* (ya - yc) - (xb - xd) */ 00814 Yd12C_out = (Yaminusc - Xbminusd); 00815 00816 pSrc[(2u * i0)] = Xaplusc + Xbplusd; 00817 pSrc[(2u * i0) + 1u] = Yaplusc + Ybplusd; 00818 00819 Xb12_out = Xb12C_out * co1; 00820 Yb12_out = Yb12C_out * co1; 00821 Xc12_out = Xc12C_out * co2; 00822 Yc12_out = Yc12C_out * co2; 00823 Xd12_out = Xd12C_out * co3; 00824 Yd12_out = Yd12C_out * co3; 00825 00826 /* xb' = (xa+yb-xc-yd)co1 - (ya-xb-yc+xd)(si1) */ 00827 //Xb12_out -= Yb12C_out * si1; 00828 p0 = Yb12C_out * si1; 00829 /* yb' = (ya-xb-yc+xd)co1 + (xa+yb-xc-yd)(si1) */ 00830 //Yb12_out += Xb12C_out * si1; 00831 p1 = Xb12C_out * si1; 00832 /* xc' = (xa-xb+xc-xd)co2 - (ya-yb+yc-yd)(si2) */ 00833 //Xc12_out -= Yc12C_out * si2; 00834 p2 = Yc12C_out * si2; 00835 /* yc' = (ya-yb+yc-yd)co2 + (xa-xb+xc-xd)(si2) */ 00836 //Yc12_out += Xc12C_out * si2; 00837 p3 = Xc12C_out * si2; 00838 /* xd' = (xa-yb-xc+yd)co3 - (ya+xb-yc-xd)(si3) */ 00839 //Xd12_out -= Yd12C_out * si3; 00840 p4 = Yd12C_out * si3; 00841 /* yd' = (ya+xb-yc-xd)co3 + (xa-yb-xc+yd)(si3) */ 00842 //Yd12_out += Xd12C_out * si3; 00843 p5 = Xd12C_out * si3; 00844 00845 Xb12_out -= p0; 00846 Yb12_out += p1; 00847 Xc12_out -= p2; 00848 Yc12_out += p3; 00849 Xd12_out -= p4; 00850 Yd12_out += p5; 00851 00852 /* xc' = (xa-xb+xc-xd)co2 - (ya-yb+yc-yd)(si2) */ 00853 pSrc[2u * i1] = Xc12_out; 00854 00855 /* yc' = (ya-yb+yc-yd)co2 + (xa-xb+xc-xd)(si2) */ 00856 pSrc[(2u * i1) + 1u] = Yc12_out; 00857 00858 /* xb' = (xa+yb-xc-yd)co1 - (ya-xb-yc+xd)(si1) */ 00859 pSrc[2u * i2] = Xb12_out; 00860 00861 /* yb' = (ya-xb-yc+xd)co1 + (xa+yb-xc-yd)(si1) */ 00862 pSrc[(2u * i2) + 1u] = Yb12_out; 00863 00864 /* xd' = (xa-yb-xc+yd)co3 - (ya+xb-yc-xd)(si3) */ 00865 pSrc[2u * i3] = Xd12_out; 00866 00867 /* yd' = (ya+xb-yc-xd)co3 + (xa-yb-xc+yd)(si3) */ 00868 pSrc[(2u * i3) + 1u] = Yd12_out; 00869 00870 i0 += n1; 00871 } while(i0 < fftLen); 00872 j++; 00873 } while(j <= (n2 - 1u)); 00874 twidCoefModifier <<= 2u; 00875 } 00876 /* Initializations of last stage */ 00877 00878 j = fftLen >> 2; 00879 ptr1 = &pSrc[0]; 00880 00881 /* Calculations of last stage */ 00882 do 00883 { 00884 xaIn = ptr1[0]; 00885 yaIn = ptr1[1]; 00886 xbIn = ptr1[2]; 00887 ybIn = ptr1[3]; 00888 xcIn = ptr1[4]; 00889 ycIn = ptr1[5]; 00890 xdIn = ptr1[6]; 00891 ydIn = ptr1[7]; 00892 00893 /* Butterfly implementation */ 00894 /* xa + xc */ 00895 Xaplusc = xaIn + xcIn; 00896 00897 /* xa - xc */ 00898 Xaminusc = xaIn - xcIn; 00899 00900 /* ya + yc */ 00901 Yaplusc = yaIn + ycIn; 00902 00903 /* ya - yc */ 00904 Yaminusc = yaIn - ycIn; 00905 00906 /* xb + xd */ 00907 Xbplusd = xbIn + xdIn; 00908 00909 /* yb + yd */ 00910 Ybplusd = ybIn + ydIn; 00911 00912 /* (xb-xd) */ 00913 Xbminusd = xbIn - xdIn; 00914 00915 /* (yb-yd) */ 00916 Ybminusd = ybIn - ydIn; 00917 00918 /* xa' = (xa+xb+xc+xd) * onebyfftLen */ 00919 a0 = (Xaplusc + Xbplusd); 00920 /* ya' = (ya+yb+yc+yd) * onebyfftLen */ 00921 a1 = (Yaplusc + Ybplusd); 00922 /* xc' = (xa-xb+xc-xd) * onebyfftLen */ 00923 a2 = (Xaplusc - Xbplusd); 00924 /* yc' = (ya-yb+yc-yd) * onebyfftLen */ 00925 a3 = (Yaplusc - Ybplusd); 00926 /* xb' = (xa-yb-xc+yd) * onebyfftLen */ 00927 a4 = (Xaminusc - Ybminusd); 00928 /* yb' = (ya+xb-yc-xd) * onebyfftLen */ 00929 a5 = (Yaminusc + Xbminusd); 00930 /* xd' = (xa-yb-xc+yd) * onebyfftLen */ 00931 a6 = (Xaminusc + Ybminusd); 00932 /* yd' = (ya-xb-yc+xd) * onebyfftLen */ 00933 a7 = (Yaminusc - Xbminusd); 00934 00935 p0 = a0 * onebyfftLen; 00936 p1 = a1 * onebyfftLen; 00937 p2 = a2 * onebyfftLen; 00938 p3 = a3 * onebyfftLen; 00939 p4 = a4 * onebyfftLen; 00940 p5 = a5 * onebyfftLen; 00941 p6 = a6 * onebyfftLen; 00942 p7 = a7 * onebyfftLen; 00943 00944 /* xa' = (xa+xb+xc+xd) * onebyfftLen */ 00945 ptr1[0] = p0; 00946 /* ya' = (ya+yb+yc+yd) * onebyfftLen */ 00947 ptr1[1] = p1; 00948 /* xc' = (xa-xb+xc-xd) * onebyfftLen */ 00949 ptr1[2] = p2; 00950 /* yc' = (ya-yb+yc-yd) * onebyfftLen */ 00951 ptr1[3] = p3; 00952 /* xb' = (xa-yb-xc+yd) * onebyfftLen */ 00953 ptr1[4] = p4; 00954 /* yb' = (ya+xb-yc-xd) * onebyfftLen */ 00955 ptr1[5] = p5; 00956 /* xd' = (xa-yb-xc+yd) * onebyfftLen */ 00957 ptr1[6] = p6; 00958 /* yd' = (ya-xb-yc+xd) * onebyfftLen */ 00959 ptr1[7] = p7; 00960 00961 /* increment source pointer by 8 for next calculations */ 00962 ptr1 = ptr1 + 8u; 00963 00964 } while(--j); 00965 00966 #else 00967 00968 float32_t t1, t2, r1, r2, s1, s2; 00969 00970 /* Run the below code for Cortex-M0 */ 00971 00972 /* Initializations for the first stage */ 00973 n2 = fftLen; 00974 n1 = n2; 00975 00976 /* Calculation of first stage */ 00977 for (k = fftLen; k > 4u; k >>= 2u) 00978 { 00979 /* Initializations for the first stage */ 00980 n1 = n2; 00981 n2 >>= 2u; 00982 ia1 = 0u; 00983 00984 /* Calculation of first stage */ 00985 j = 0; 00986 do 00987 { 00988 /* index calculation for the coefficients */ 00989 ia2 = ia1 + ia1; 00990 ia3 = ia2 + ia1; 00991 co1 = pCoef[ia1 * 2u]; 00992 si1 = pCoef[(ia1 * 2u) + 1u]; 00993 co2 = pCoef[ia2 * 2u]; 00994 si2 = pCoef[(ia2 * 2u) + 1u]; 00995 co3 = pCoef[ia3 * 2u]; 00996 si3 = pCoef[(ia3 * 2u) + 1u]; 00997 00998 /* Twiddle coefficients index modifier */ 00999 ia1 = ia1 + twidCoefModifier; 01000 01001 i0 = j; 01002 do 01003 { 01004 /* index calculation for the input as, */ 01005 /* pSrc[i0 + 0], pSrc[i0 + fftLen/4], pSrc[i0 + fftLen/2], pSrc[i0 + 3fftLen/4] */ 01006 i1 = i0 + n2; 01007 i2 = i1 + n2; 01008 i3 = i2 + n2; 01009 01010 /* xa + xc */ 01011 r1 = pSrc[(2u * i0)] + pSrc[(2u * i2)]; 01012 01013 /* xa - xc */ 01014 r2 = pSrc[(2u * i0)] - pSrc[(2u * i2)]; 01015 01016 /* ya + yc */ 01017 s1 = pSrc[(2u * i0) + 1u] + pSrc[(2u * i2) + 1u]; 01018 01019 /* ya - yc */ 01020 s2 = pSrc[(2u * i0) + 1u] - pSrc[(2u * i2) + 1u]; 01021 01022 /* xb + xd */ 01023 t1 = pSrc[2u * i1] + pSrc[2u * i3]; 01024 01025 /* xa' = xa + xb + xc + xd */ 01026 pSrc[2u * i0] = r1 + t1; 01027 01028 /* xa + xc -(xb + xd) */ 01029 r1 = r1 - t1; 01030 01031 /* yb + yd */ 01032 t2 = pSrc[(2u * i1) + 1u] + pSrc[(2u * i3) + 1u]; 01033 01034 /* ya' = ya + yb + yc + yd */ 01035 pSrc[(2u * i0) + 1u] = s1 + t2; 01036 01037 /* (ya + yc) - (yb + yd) */ 01038 s1 = s1 - t2; 01039 01040 /* (yb - yd) */ 01041 t1 = pSrc[(2u * i1) + 1u] - pSrc[(2u * i3) + 1u]; 01042 01043 /* (xb - xd) */ 01044 t2 = pSrc[2u * i1] - pSrc[2u * i3]; 01045 01046 /* xc' = (xa-xb+xc-xd)co2 - (ya-yb+yc-yd)(si2) */ 01047 pSrc[2u * i1] = (r1 * co2) - (s1 * si2); 01048 01049 /* yc' = (ya-yb+yc-yd)co2 + (xa-xb+xc-xd)(si2) */ 01050 pSrc[(2u * i1) + 1u] = (s1 * co2) + (r1 * si2); 01051 01052 /* (xa - xc) - (yb - yd) */ 01053 r1 = r2 - t1; 01054 01055 /* (xa - xc) + (yb - yd) */ 01056 r2 = r2 + t1; 01057 01058 /* (ya - yc) + (xb - xd) */ 01059 s1 = s2 + t2; 01060 01061 /* (ya - yc) - (xb - xd) */ 01062 s2 = s2 - t2; 01063 01064 /* xb' = (xa+yb-xc-yd)co1 - (ya-xb-yc+xd)(si1) */ 01065 pSrc[2u * i2] = (r1 * co1) - (s1 * si1); 01066 01067 /* yb' = (ya-xb-yc+xd)co1 + (xa+yb-xc-yd)(si1) */ 01068 pSrc[(2u * i2) + 1u] = (s1 * co1) + (r1 * si1); 01069 01070 /* xd' = (xa-yb-xc+yd)co3 - (ya+xb-yc-xd)(si3) */ 01071 pSrc[2u * i3] = (r2 * co3) - (s2 * si3); 01072 01073 /* yd' = (ya+xb-yc-xd)co3 + (xa-yb-xc+yd)(si3) */ 01074 pSrc[(2u * i3) + 1u] = (s2 * co3) + (r2 * si3); 01075 01076 i0 += n1; 01077 } while( i0 < fftLen); 01078 j++; 01079 } while(j <= (n2 - 1u)); 01080 twidCoefModifier <<= 2u; 01081 } 01082 /* Initializations of last stage */ 01083 n1 = n2; 01084 n2 >>= 2u; 01085 01086 /* Calculations of last stage */ 01087 for (i0 = 0u; i0 <= (fftLen - n1); i0 += n1) 01088 { 01089 /* index calculation for the input as, */ 01090 /* pSrc[i0 + 0], pSrc[i0 + fftLen/4], pSrc[i0 + fftLen/2], pSrc[i0 + 3fftLen/4] */ 01091 i1 = i0 + n2; 01092 i2 = i1 + n2; 01093 i3 = i2 + n2; 01094 01095 /* Butterfly implementation */ 01096 /* xa + xc */ 01097 r1 = pSrc[2u * i0] + pSrc[2u * i2]; 01098 01099 /* xa - xc */ 01100 r2 = pSrc[2u * i0] - pSrc[2u * i2]; 01101 01102 /* ya + yc */ 01103 s1 = pSrc[(2u * i0) + 1u] + pSrc[(2u * i2) + 1u]; 01104 01105 /* ya - yc */ 01106 s2 = pSrc[(2u * i0) + 1u] - pSrc[(2u * i2) + 1u]; 01107 01108 /* xc + xd */ 01109 t1 = pSrc[2u * i1] + pSrc[2u * i3]; 01110 01111 /* xa' = xa + xb + xc + xd */ 01112 pSrc[2u * i0] = (r1 + t1) * onebyfftLen; 01113 01114 /* (xa + xb) - (xc + xd) */ 01115 r1 = r1 - t1; 01116 01117 /* yb + yd */ 01118 t2 = pSrc[(2u * i1) + 1u] + pSrc[(2u * i3) + 1u]; 01119 01120 /* ya' = ya + yb + yc + yd */ 01121 pSrc[(2u * i0) + 1u] = (s1 + t2) * onebyfftLen; 01122 01123 /* (ya + yc) - (yb + yd) */ 01124 s1 = s1 - t2; 01125 01126 /* (yb-yd) */ 01127 t1 = pSrc[(2u * i1) + 1u] - pSrc[(2u * i3) + 1u]; 01128 01129 /* (xb-xd) */ 01130 t2 = pSrc[2u * i1] - pSrc[2u * i3]; 01131 01132 /* xc' = (xa-xb+xc-xd)co2 - (ya-yb+yc-yd)(si2) */ 01133 pSrc[2u * i1] = r1 * onebyfftLen; 01134 01135 /* yc' = (ya-yb+yc-yd)co2 + (xa-xb+xc-xd)(si2) */ 01136 pSrc[(2u * i1) + 1u] = s1 * onebyfftLen; 01137 01138 /* (xa - xc) - (yb-yd) */ 01139 r1 = r2 - t1; 01140 01141 /* (xa - xc) + (yb-yd) */ 01142 r2 = r2 + t1; 01143 01144 /* (ya - yc) + (xb-xd) */ 01145 s1 = s2 + t2; 01146 01147 /* (ya - yc) - (xb-xd) */ 01148 s2 = s2 - t2; 01149 01150 /* xb' = (xa+yb-xc-yd)co1 - (ya-xb-yc+xd)(si1) */ 01151 pSrc[2u * i2] = r1 * onebyfftLen; 01152 01153 /* yb' = (ya-xb-yc+xd)co1 + (xa+yb-xc-yd)(si1) */ 01154 pSrc[(2u * i2) + 1u] = s1 * onebyfftLen; 01155 01156 /* xd' = (xa-yb-xc+yd)co3 - (ya+xb-yc-xd)(si3) */ 01157 pSrc[2u * i3] = r2 * onebyfftLen; 01158 01159 /* yd' = (ya+xb-yc-xd)co3 + (xa-yb-xc+yd)(si3) */ 01160 pSrc[(2u * i3) + 1u] = s2 * onebyfftLen; 01161 } 01162 01163 #endif /* #ifndef ARM_MATH_CM0_FAMILY_FAMILY */ 01164 } 01165 01166 /** 01167 * @addtogroup ComplexFFT 01168 * @{ 01169 */ 01170 01171 /** 01172 * @details 01173 * @brief Processing function for the floating-point Radix-4 CFFT/CIFFT. 01174 * @deprecated Do not use this function. It has been superseded by \ref arm_cfft_f32 and will be removed 01175 * in the future. 01176 * @param[in] *S points to an instance of the floating-point Radix-4 CFFT/CIFFT structure. 01177 * @param[in, out] *pSrc points to the complex data buffer of size <code>2*fftLen</code>. Processing occurs in-place. 01178 * @return none. 01179 */ 01180 01181 void arm_cfft_radix4_f32( 01182 const arm_cfft_radix4_instance_f32 * S, 01183 float32_t * pSrc) 01184 { 01185 01186 if(S->ifftFlag == 1u) 01187 { 01188 /* Complex IFFT radix-4 */ 01189 arm_radix4_butterfly_inverse_f32(pSrc, S->fftLen, S->pTwiddle, 01190 S->twidCoefModifier, S->onebyfftLen); 01191 } 01192 else 01193 { 01194 /* Complex FFT radix-4 */ 01195 arm_radix4_butterfly_f32(pSrc, S->fftLen, S->pTwiddle, 01196 S->twidCoefModifier); 01197 } 01198 01199 if(S->bitReverseFlag == 1u) 01200 { 01201 /* Bit Reversal */ 01202 arm_bitreversal_f32(pSrc, S->fftLen, S->bitRevFactor, S->pBitRevTable); 01203 } 01204 01205 } 01206 01207 /** 01208 * @} end of ComplexFFT group 01209 */ 01210
Generated on Tue Jul 12 2022 11:59:15 by 1.7.2