1 /* ----------------------------------------------------------------------
2 * Project: CMSIS DSP Library
3 * Title: arm_cfft_radix4_f32.c
4 * Description: Radix-4 Decimation in Frequency CFFT & CIFFT Floating point processing function
6 * $Date: 27. January 2017
9 * Target Processor: Cortex-M cores
10 * -------------------------------------------------------------------- */
12 * Copyright (C) 2010-2017 ARM Limited or its affiliates. All rights reserved.
14 * SPDX-License-Identifier: Apache-2.0
16 * Licensed under the Apache License, Version 2.0 (the License); you may
17 * not use this file except in compliance with the License.
18 * You may obtain a copy of the License at
20 * www.apache.org/licenses/LICENSE-2.0
22 * Unless required by applicable law or agreed to in writing, software
23 * distributed under the License is distributed on an AS IS BASIS, WITHOUT
24 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
25 * See the License for the specific language governing permissions and
26 * limitations under the License.
31 extern void arm_bitreversal_f32(
34 uint16_t bitRevFactor
,
35 uint16_t * pBitRevTab
);
37 void arm_radix4_butterfly_f32(
41 uint16_t twidCoefModifier
);
43 void arm_radix4_butterfly_inverse_f32(
47 uint16_t twidCoefModifier
,
48 float32_t onebyfftLen
);
52 * @ingroup groupTransforms
56 * @addtogroup ComplexFFT
62 * @brief Processing function for the floating-point Radix-4 CFFT/CIFFT.
63 * @deprecated Do not use this function. It has been superseded by \ref arm_cfft_f32 and will be removed
65 * @param[in] *S points to an instance of the floating-point Radix-4 CFFT/CIFFT structure.
66 * @param[in, out] *pSrc points to the complex data buffer of size <code>2*fftLen</code>. Processing occurs in-place.
70 void arm_cfft_radix4_f32(
71 const arm_cfft_radix4_instance_f32
* S
,
74 if (S
->ifftFlag
== 1U)
76 /* Complex IFFT radix-4 */
77 arm_radix4_butterfly_inverse_f32(pSrc
, S
->fftLen
, S
->pTwiddle
, S
->twidCoefModifier
, S
->onebyfftLen
);
81 /* Complex FFT radix-4 */
82 arm_radix4_butterfly_f32(pSrc
, S
->fftLen
, S
->pTwiddle
, S
->twidCoefModifier
);
85 if (S
->bitReverseFlag
== 1U)
88 arm_bitreversal_f32(pSrc
, S
->fftLen
, S
->bitRevFactor
, S
->pBitRevTable
);
94 * @} end of ComplexFFT group
97 /* ----------------------------------------------------------------------
98 * Internal helper function used by the FFTs
99 * ---------------------------------------------------------------------- */
102 * @brief Core function for the floating-point CFFT butterfly process.
103 * @param[in, out] *pSrc points to the in-place buffer of floating-point data type.
104 * @param[in] fftLen length of the FFT.
105 * @param[in] *pCoef points to the twiddle coefficient buffer.
106 * @param[in] twidCoefModifier twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table.
110 void arm_radix4_butterfly_f32(
114 uint16_t twidCoefModifier
)
117 float32_t co1
, co2
, co3
, si1
, si2
, si3
;
118 uint32_t ia1
, ia2
, ia3
;
119 uint32_t i0
, i1
, i2
, i3
;
120 uint32_t n1
, n2
, j
, k
;
122 #if defined (ARM_MATH_DSP)
124 /* Run the below code for Cortex-M4 and Cortex-M3 */
126 float32_t xaIn
, yaIn
, xbIn
, ybIn
, xcIn
, ycIn
, xdIn
, ydIn
;
127 float32_t Xaplusc
, Xbplusd
, Yaplusc
, Ybplusd
, Xaminusc
, Xbminusd
, Yaminusc
,
129 float32_t Xb12C_out
, Yb12C_out
, Xc12C_out
, Yc12C_out
, Xd12C_out
, Yd12C_out
;
130 float32_t Xb12_out
, Yb12_out
, Xc12_out
, Yc12_out
, Xd12_out
, Yd12_out
;
132 float32_t p0
,p1
,p2
,p3
,p4
,p5
;
133 float32_t a0
,a1
,a2
,a3
,a4
,a5
,a6
,a7
;
135 /* Initializations for the first stage */
146 /* Calculation of first stage */
149 /* index calculation for the input as, */
150 /* pSrc[i0 + 0], pSrc[i0 + fftLen/4], pSrc[i0 + fftLen/2], pSrc[i0 + 3fftLen/4] */
155 xaIn
= pSrc
[(2U * i0
)];
156 yaIn
= pSrc
[(2U * i0
) + 1U];
158 xbIn
= pSrc
[(2U * i1
)];
159 ybIn
= pSrc
[(2U * i1
) + 1U];
161 xcIn
= pSrc
[(2U * i2
)];
162 ycIn
= pSrc
[(2U * i2
) + 1U];
164 xdIn
= pSrc
[(2U * i3
)];
165 ydIn
= pSrc
[(2U * i3
) + 1U];
168 Xaplusc
= xaIn
+ xcIn
;
170 Xbplusd
= xbIn
+ xdIn
;
172 Yaplusc
= yaIn
+ ycIn
;
174 Ybplusd
= ybIn
+ ydIn
;
176 /* index calculation for the coefficients */
178 co2
= pCoef
[ia2
* 2U];
179 si2
= pCoef
[(ia2
* 2U) + 1U];
182 Xaminusc
= xaIn
- xcIn
;
184 Xbminusd
= xbIn
- xdIn
;
186 Yaminusc
= yaIn
- ycIn
;
188 Ybminusd
= ybIn
- ydIn
;
190 /* xa' = xa + xb + xc + xd */
191 pSrc
[(2U * i0
)] = Xaplusc
+ Xbplusd
;
192 /* ya' = ya + yb + yc + yd */
193 pSrc
[(2U * i0
) + 1U] = Yaplusc
+ Ybplusd
;
195 /* (xa - xc) + (yb - yd) */
196 Xb12C_out
= (Xaminusc
+ Ybminusd
);
197 /* (ya - yc) + (xb - xd) */
198 Yb12C_out
= (Yaminusc
- Xbminusd
);
199 /* (xa + xc) - (xb + xd) */
200 Xc12C_out
= (Xaplusc
- Xbplusd
);
201 /* (ya + yc) - (yb + yd) */
202 Yc12C_out
= (Yaplusc
- Ybplusd
);
203 /* (xa - xc) - (yb - yd) */
204 Xd12C_out
= (Xaminusc
- Ybminusd
);
205 /* (ya - yc) + (xb - xd) */
206 Yd12C_out
= (Xbminusd
+ Yaminusc
);
208 co1
= pCoef
[ia1
* 2U];
209 si1
= pCoef
[(ia1
* 2U) + 1U];
211 /* index calculation for the coefficients */
213 co3
= pCoef
[ia3
* 2U];
214 si3
= pCoef
[(ia3
* 2U) + 1U];
216 Xb12_out
= Xb12C_out
* co1
;
217 Yb12_out
= Yb12C_out
* co1
;
218 Xc12_out
= Xc12C_out
* co2
;
219 Yc12_out
= Yc12C_out
* co2
;
220 Xd12_out
= Xd12C_out
* co3
;
221 Yd12_out
= Yd12C_out
* co3
;
223 /* xb' = (xa+yb-xc-yd)co1 - (ya-xb-yc+xd)(si1) */
224 //Xb12_out -= Yb12C_out * si1;
225 p0
= Yb12C_out
* si1
;
226 /* yb' = (ya-xb-yc+xd)co1 + (xa+yb-xc-yd)(si1) */
227 //Yb12_out += Xb12C_out * si1;
228 p1
= Xb12C_out
* si1
;
229 /* xc' = (xa-xb+xc-xd)co2 - (ya-yb+yc-yd)(si2) */
230 //Xc12_out -= Yc12C_out * si2;
231 p2
= Yc12C_out
* si2
;
232 /* yc' = (ya-yb+yc-yd)co2 + (xa-xb+xc-xd)(si2) */
233 //Yc12_out += Xc12C_out * si2;
234 p3
= Xc12C_out
* si2
;
235 /* xd' = (xa-yb-xc+yd)co3 - (ya+xb-yc-xd)(si3) */
236 //Xd12_out -= Yd12C_out * si3;
237 p4
= Yd12C_out
* si3
;
238 /* yd' = (ya+xb-yc-xd)co3 + (xa-yb-xc+yd)(si3) */
239 //Yd12_out += Xd12C_out * si3;
240 p5
= Xd12C_out
* si3
;
249 /* xc' = (xa-xb+xc-xd)co2 + (ya-yb+yc-yd)(si2) */
250 pSrc
[2U * i1
] = Xc12_out
;
252 /* yc' = (ya-yb+yc-yd)co2 - (xa-xb+xc-xd)(si2) */
253 pSrc
[(2U * i1
) + 1U] = Yc12_out
;
255 /* xb' = (xa+yb-xc-yd)co1 + (ya-xb-yc+xd)(si1) */
256 pSrc
[2U * i2
] = Xb12_out
;
258 /* yb' = (ya-xb-yc+xd)co1 - (xa+yb-xc-yd)(si1) */
259 pSrc
[(2U * i2
) + 1U] = Yb12_out
;
261 /* xd' = (xa-yb-xc+yd)co3 + (ya+xb-yc-xd)(si3) */
262 pSrc
[2U * i3
] = Xd12_out
;
264 /* yd' = (ya+xb-yc-xd)co3 - (xa-yb-xc+yd)(si3) */
265 pSrc
[(2U * i3
) + 1U] = Yd12_out
;
267 /* Twiddle coefficients index modifier */
268 ia1
+= twidCoefModifier
;
270 /* Updating input index */
276 twidCoefModifier
<<= 2U;
278 /* Calculation of second stage to excluding last stage */
279 for (k
= fftLen
>> 2U; k
> 4U; k
>>= 2U)
281 /* Initializations for the first stage */
286 /* Calculation of first stage */
290 /* index calculation for the coefficients */
293 co1
= pCoef
[ia1
* 2U];
294 si1
= pCoef
[(ia1
* 2U) + 1U];
295 co2
= pCoef
[ia2
* 2U];
296 si2
= pCoef
[(ia2
* 2U) + 1U];
297 co3
= pCoef
[ia3
* 2U];
298 si3
= pCoef
[(ia3
* 2U) + 1U];
300 /* Twiddle coefficients index modifier */
301 ia1
+= twidCoefModifier
;
306 /* index calculation for the input as, */
307 /* pSrc[i0 + 0], pSrc[i0 + fftLen/4], pSrc[i0 + fftLen/2], pSrc[i0 + 3fftLen/4] */
312 xaIn
= pSrc
[(2U * i0
)];
313 yaIn
= pSrc
[(2U * i0
) + 1U];
315 xbIn
= pSrc
[(2U * i1
)];
316 ybIn
= pSrc
[(2U * i1
) + 1U];
318 xcIn
= pSrc
[(2U * i2
)];
319 ycIn
= pSrc
[(2U * i2
) + 1U];
321 xdIn
= pSrc
[(2U * i3
)];
322 ydIn
= pSrc
[(2U * i3
) + 1U];
325 Xaminusc
= xaIn
- xcIn
;
327 Xbminusd
= xbIn
- xdIn
;
329 Yaminusc
= yaIn
- ycIn
;
331 Ybminusd
= ybIn
- ydIn
;
334 Xaplusc
= xaIn
+ xcIn
;
336 Xbplusd
= xbIn
+ xdIn
;
338 Yaplusc
= yaIn
+ ycIn
;
340 Ybplusd
= ybIn
+ ydIn
;
342 /* (xa - xc) + (yb - yd) */
343 Xb12C_out
= (Xaminusc
+ Ybminusd
);
344 /* (ya - yc) - (xb - xd) */
345 Yb12C_out
= (Yaminusc
- Xbminusd
);
346 /* xa + xc -(xb + xd) */
347 Xc12C_out
= (Xaplusc
- Xbplusd
);
348 /* (ya + yc) - (yb + yd) */
349 Yc12C_out
= (Yaplusc
- Ybplusd
);
350 /* (xa - xc) - (yb - yd) */
351 Xd12C_out
= (Xaminusc
- Ybminusd
);
352 /* (ya - yc) + (xb - xd) */
353 Yd12C_out
= (Xbminusd
+ Yaminusc
);
355 pSrc
[(2U * i0
)] = Xaplusc
+ Xbplusd
;
356 pSrc
[(2U * i0
) + 1U] = Yaplusc
+ Ybplusd
;
358 Xb12_out
= Xb12C_out
* co1
;
359 Yb12_out
= Yb12C_out
* co1
;
360 Xc12_out
= Xc12C_out
* co2
;
361 Yc12_out
= Yc12C_out
* co2
;
362 Xd12_out
= Xd12C_out
* co3
;
363 Yd12_out
= Yd12C_out
* co3
;
365 /* xb' = (xa+yb-xc-yd)co1 - (ya-xb-yc+xd)(si1) */
366 //Xb12_out -= Yb12C_out * si1;
367 p0
= Yb12C_out
* si1
;
368 /* yb' = (ya-xb-yc+xd)co1 + (xa+yb-xc-yd)(si1) */
369 //Yb12_out += Xb12C_out * si1;
370 p1
= Xb12C_out
* si1
;
371 /* xc' = (xa-xb+xc-xd)co2 - (ya-yb+yc-yd)(si2) */
372 //Xc12_out -= Yc12C_out * si2;
373 p2
= Yc12C_out
* si2
;
374 /* yc' = (ya-yb+yc-yd)co2 + (xa-xb+xc-xd)(si2) */
375 //Yc12_out += Xc12C_out * si2;
376 p3
= Xc12C_out
* si2
;
377 /* xd' = (xa-yb-xc+yd)co3 - (ya+xb-yc-xd)(si3) */
378 //Xd12_out -= Yd12C_out * si3;
379 p4
= Yd12C_out
* si3
;
380 /* yd' = (ya+xb-yc-xd)co3 + (xa-yb-xc+yd)(si3) */
381 //Yd12_out += Xd12C_out * si3;
382 p5
= Xd12C_out
* si3
;
391 /* xc' = (xa-xb+xc-xd)co2 + (ya-yb+yc-yd)(si2) */
392 pSrc
[2U * i1
] = Xc12_out
;
394 /* yc' = (ya-yb+yc-yd)co2 - (xa-xb+xc-xd)(si2) */
395 pSrc
[(2U * i1
) + 1U] = Yc12_out
;
397 /* xb' = (xa+yb-xc-yd)co1 + (ya-xb-yc+xd)(si1) */
398 pSrc
[2U * i2
] = Xb12_out
;
400 /* yb' = (ya-xb-yc+xd)co1 - (xa+yb-xc-yd)(si1) */
401 pSrc
[(2U * i2
) + 1U] = Yb12_out
;
403 /* xd' = (xa-yb-xc+yd)co3 + (ya+xb-yc-xd)(si3) */
404 pSrc
[2U * i3
] = Xd12_out
;
406 /* yd' = (ya+xb-yc-xd)co3 - (xa-yb-xc+yd)(si3) */
407 pSrc
[(2U * i3
) + 1U] = Yd12_out
;
410 } while (i0
< fftLen
);
412 } while (j
<= (n2
- 1U));
413 twidCoefModifier
<<= 2U;
419 /* Calculations of last stage */
432 Xaplusc
= xaIn
+ xcIn
;
435 Xaminusc
= xaIn
- xcIn
;
438 Yaplusc
= yaIn
+ ycIn
;
441 Yaminusc
= yaIn
- ycIn
;
444 Xbplusd
= xbIn
+ xdIn
;
447 Ybplusd
= ybIn
+ ydIn
;
450 Xbminusd
= xbIn
- xdIn
;
453 Ybminusd
= ybIn
- ydIn
;
455 /* xa' = xa + xb + xc + xd */
456 a0
= (Xaplusc
+ Xbplusd
);
457 /* ya' = ya + yb + yc + yd */
458 a1
= (Yaplusc
+ Ybplusd
);
459 /* xc' = (xa-xb+xc-xd) */
460 a2
= (Xaplusc
- Xbplusd
);
461 /* yc' = (ya-yb+yc-yd) */
462 a3
= (Yaplusc
- Ybplusd
);
463 /* xb' = (xa+yb-xc-yd) */
464 a4
= (Xaminusc
+ Ybminusd
);
465 /* yb' = (ya-xb-yc+xd) */
466 a5
= (Yaminusc
- Xbminusd
);
467 /* xd' = (xa-yb-xc+yd)) */
468 a6
= (Xaminusc
- Ybminusd
);
469 /* yd' = (ya+xb-yc-xd) */
470 a7
= (Xbminusd
+ Yaminusc
);
481 /* increment pointer by 8 */
487 float32_t t1
, t2
, r1
, r2
, s1
, s2
;
489 /* Run the below code for Cortex-M0 */
491 /* Initializations for the fft calculation */
494 for (k
= fftLen
; k
> 1U; k
>>= 2U)
496 /* Initializations for the fft calculation */
501 /* FFT Calculation */
505 /* index calculation for the coefficients */
508 co1
= pCoef
[ia1
* 2U];
509 si1
= pCoef
[(ia1
* 2U) + 1U];
510 co2
= pCoef
[ia2
* 2U];
511 si2
= pCoef
[(ia2
* 2U) + 1U];
512 co3
= pCoef
[ia3
* 2U];
513 si3
= pCoef
[(ia3
* 2U) + 1U];
515 /* Twiddle coefficients index modifier */
516 ia1
= ia1
+ twidCoefModifier
;
521 /* index calculation for the input as, */
522 /* pSrc[i0 + 0], pSrc[i0 + fftLen/4], pSrc[i0 + fftLen/2], pSrc[i0 + 3fftLen/4] */
528 r1
= pSrc
[(2U * i0
)] + pSrc
[(2U * i2
)];
531 r2
= pSrc
[(2U * i0
)] - pSrc
[(2U * i2
)];
534 s1
= pSrc
[(2U * i0
) + 1U] + pSrc
[(2U * i2
) + 1U];
537 s2
= pSrc
[(2U * i0
) + 1U] - pSrc
[(2U * i2
) + 1U];
540 t1
= pSrc
[2U * i1
] + pSrc
[2U * i3
];
542 /* xa' = xa + xb + xc + xd */
543 pSrc
[2U * i0
] = r1
+ t1
;
545 /* xa + xc -(xb + xd) */
549 t2
= pSrc
[(2U * i1
) + 1U] + pSrc
[(2U * i3
) + 1U];
551 /* ya' = ya + yb + yc + yd */
552 pSrc
[(2U * i0
) + 1U] = s1
+ t2
;
554 /* (ya + yc) - (yb + yd) */
558 t1
= pSrc
[(2U * i1
) + 1U] - pSrc
[(2U * i3
) + 1U];
561 t2
= pSrc
[2U * i1
] - pSrc
[2U * i3
];
563 /* xc' = (xa-xb+xc-xd)co2 + (ya-yb+yc-yd)(si2) */
564 pSrc
[2U * i1
] = (r1
* co2
) + (s1
* si2
);
566 /* yc' = (ya-yb+yc-yd)co2 - (xa-xb+xc-xd)(si2) */
567 pSrc
[(2U * i1
) + 1U] = (s1
* co2
) - (r1
* si2
);
569 /* (xa - xc) + (yb - yd) */
572 /* (xa - xc) - (yb - yd) */
575 /* (ya - yc) - (xb - xd) */
578 /* (ya - yc) + (xb - xd) */
581 /* xb' = (xa+yb-xc-yd)co1 + (ya-xb-yc+xd)(si1) */
582 pSrc
[2U * i2
] = (r1
* co1
) + (s1
* si1
);
584 /* yb' = (ya-xb-yc+xd)co1 - (xa+yb-xc-yd)(si1) */
585 pSrc
[(2U * i2
) + 1U] = (s1
* co1
) - (r1
* si1
);
587 /* xd' = (xa-yb-xc+yd)co3 + (ya+xb-yc-xd)(si3) */
588 pSrc
[2U * i3
] = (r2
* co3
) + (s2
* si3
);
590 /* yd' = (ya+xb-yc-xd)co3 - (xa-yb-xc+yd)(si3) */
591 pSrc
[(2U * i3
) + 1U] = (s2
* co3
) - (r2
* si3
);
594 } while ( i0
< fftLen
);
596 } while (j
<= (n2
- 1U));
597 twidCoefModifier
<<= 2U;
600 #endif /* #if defined (ARM_MATH_DSP) */
605 * @brief Core function for the floating-point CIFFT butterfly process.
606 * @param[in, out] *pSrc points to the in-place buffer of floating-point data type.
607 * @param[in] fftLen length of the FFT.
608 * @param[in] *pCoef points to twiddle coefficient buffer.
609 * @param[in] twidCoefModifier twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table.
610 * @param[in] onebyfftLen value of 1/fftLen.
614 void arm_radix4_butterfly_inverse_f32(
618 uint16_t twidCoefModifier
,
619 float32_t onebyfftLen
)
621 float32_t co1
, co2
, co3
, si1
, si2
, si3
;
622 uint32_t ia1
, ia2
, ia3
;
623 uint32_t i0
, i1
, i2
, i3
;
624 uint32_t n1
, n2
, j
, k
;
626 #if defined (ARM_MATH_DSP)
628 float32_t xaIn
, yaIn
, xbIn
, ybIn
, xcIn
, ycIn
, xdIn
, ydIn
;
629 float32_t Xaplusc
, Xbplusd
, Yaplusc
, Ybplusd
, Xaminusc
, Xbminusd
, Yaminusc
,
631 float32_t Xb12C_out
, Yb12C_out
, Xc12C_out
, Yc12C_out
, Xd12C_out
, Yd12C_out
;
632 float32_t Xb12_out
, Yb12_out
, Xc12_out
, Yc12_out
, Xd12_out
, Yd12_out
;
634 float32_t p0
,p1
,p2
,p3
,p4
,p5
,p6
,p7
;
635 float32_t a0
,a1
,a2
,a3
,a4
,a5
,a6
,a7
;
638 /* Initializations for the first stage */
649 /* Calculation of first stage */
652 /* index calculation for the input as, */
653 /* pSrc[i0 + 0], pSrc[i0 + fftLen/4], pSrc[i0 + fftLen/2], pSrc[i0 + 3fftLen/4] */
658 /* Butterfly implementation */
659 xaIn
= pSrc
[(2U * i0
)];
660 yaIn
= pSrc
[(2U * i0
) + 1U];
662 xcIn
= pSrc
[(2U * i2
)];
663 ycIn
= pSrc
[(2U * i2
) + 1U];
665 xbIn
= pSrc
[(2U * i1
)];
666 ybIn
= pSrc
[(2U * i1
) + 1U];
668 xdIn
= pSrc
[(2U * i3
)];
669 ydIn
= pSrc
[(2U * i3
) + 1U];
672 Xaplusc
= xaIn
+ xcIn
;
674 Xbplusd
= xbIn
+ xdIn
;
676 Yaplusc
= yaIn
+ ycIn
;
678 Ybplusd
= ybIn
+ ydIn
;
680 /* index calculation for the coefficients */
682 co2
= pCoef
[ia2
* 2U];
683 si2
= pCoef
[(ia2
* 2U) + 1U];
686 Xaminusc
= xaIn
- xcIn
;
688 Xbminusd
= xbIn
- xdIn
;
690 Yaminusc
= yaIn
- ycIn
;
692 Ybminusd
= ybIn
- ydIn
;
694 /* xa' = xa + xb + xc + xd */
695 pSrc
[(2U * i0
)] = Xaplusc
+ Xbplusd
;
697 /* ya' = ya + yb + yc + yd */
698 pSrc
[(2U * i0
) + 1U] = Yaplusc
+ Ybplusd
;
700 /* (xa - xc) - (yb - yd) */
701 Xb12C_out
= (Xaminusc
- Ybminusd
);
702 /* (ya - yc) + (xb - xd) */
703 Yb12C_out
= (Yaminusc
+ Xbminusd
);
704 /* (xa + xc) - (xb + xd) */
705 Xc12C_out
= (Xaplusc
- Xbplusd
);
706 /* (ya + yc) - (yb + yd) */
707 Yc12C_out
= (Yaplusc
- Ybplusd
);
708 /* (xa - xc) + (yb - yd) */
709 Xd12C_out
= (Xaminusc
+ Ybminusd
);
710 /* (ya - yc) - (xb - xd) */
711 Yd12C_out
= (Yaminusc
- Xbminusd
);
713 co1
= pCoef
[ia1
* 2U];
714 si1
= pCoef
[(ia1
* 2U) + 1U];
716 /* index calculation for the coefficients */
718 co3
= pCoef
[ia3
* 2U];
719 si3
= pCoef
[(ia3
* 2U) + 1U];
721 Xb12_out
= Xb12C_out
* co1
;
722 Yb12_out
= Yb12C_out
* co1
;
723 Xc12_out
= Xc12C_out
* co2
;
724 Yc12_out
= Yc12C_out
* co2
;
725 Xd12_out
= Xd12C_out
* co3
;
726 Yd12_out
= Yd12C_out
* co3
;
728 /* xb' = (xa+yb-xc-yd)co1 - (ya-xb-yc+xd)(si1) */
729 //Xb12_out -= Yb12C_out * si1;
730 p0
= Yb12C_out
* si1
;
731 /* yb' = (ya-xb-yc+xd)co1 + (xa+yb-xc-yd)(si1) */
732 //Yb12_out += Xb12C_out * si1;
733 p1
= Xb12C_out
* si1
;
734 /* xc' = (xa-xb+xc-xd)co2 - (ya-yb+yc-yd)(si2) */
735 //Xc12_out -= Yc12C_out * si2;
736 p2
= Yc12C_out
* si2
;
737 /* yc' = (ya-yb+yc-yd)co2 + (xa-xb+xc-xd)(si2) */
738 //Yc12_out += Xc12C_out * si2;
739 p3
= Xc12C_out
* si2
;
740 /* xd' = (xa-yb-xc+yd)co3 - (ya+xb-yc-xd)(si3) */
741 //Xd12_out -= Yd12C_out * si3;
742 p4
= Yd12C_out
* si3
;
743 /* yd' = (ya+xb-yc-xd)co3 + (xa-yb-xc+yd)(si3) */
744 //Yd12_out += Xd12C_out * si3;
745 p5
= Xd12C_out
* si3
;
754 /* xc' = (xa-xb+xc-xd)co2 - (ya-yb+yc-yd)(si2) */
755 pSrc
[2U * i1
] = Xc12_out
;
757 /* yc' = (ya-yb+yc-yd)co2 + (xa-xb+xc-xd)(si2) */
758 pSrc
[(2U * i1
) + 1U] = Yc12_out
;
760 /* xb' = (xa+yb-xc-yd)co1 - (ya-xb-yc+xd)(si1) */
761 pSrc
[2U * i2
] = Xb12_out
;
763 /* yb' = (ya-xb-yc+xd)co1 + (xa+yb-xc-yd)(si1) */
764 pSrc
[(2U * i2
) + 1U] = Yb12_out
;
766 /* xd' = (xa-yb-xc+yd)co3 - (ya+xb-yc-xd)(si3) */
767 pSrc
[2U * i3
] = Xd12_out
;
769 /* yd' = (ya+xb-yc-xd)co3 + (xa-yb-xc+yd)(si3) */
770 pSrc
[(2U * i3
) + 1U] = Yd12_out
;
772 /* Twiddle coefficients index modifier */
773 ia1
= ia1
+ twidCoefModifier
;
775 /* Updating input index */
780 twidCoefModifier
<<= 2U;
782 /* Calculation of second stage to excluding last stage */
783 for (k
= fftLen
>> 2U; k
> 4U; k
>>= 2U)
785 /* Initializations for the first stage */
790 /* Calculation of first stage */
794 /* index calculation for the coefficients */
797 co1
= pCoef
[ia1
* 2U];
798 si1
= pCoef
[(ia1
* 2U) + 1U];
799 co2
= pCoef
[ia2
* 2U];
800 si2
= pCoef
[(ia2
* 2U) + 1U];
801 co3
= pCoef
[ia3
* 2U];
802 si3
= pCoef
[(ia3
* 2U) + 1U];
804 /* Twiddle coefficients index modifier */
805 ia1
= ia1
+ twidCoefModifier
;
810 /* index calculation for the input as, */
811 /* pSrc[i0 + 0], pSrc[i0 + fftLen/4], pSrc[i0 + fftLen/2], pSrc[i0 + 3fftLen/4] */
816 xaIn
= pSrc
[(2U * i0
)];
817 yaIn
= pSrc
[(2U * i0
) + 1U];
819 xbIn
= pSrc
[(2U * i1
)];
820 ybIn
= pSrc
[(2U * i1
) + 1U];
822 xcIn
= pSrc
[(2U * i2
)];
823 ycIn
= pSrc
[(2U * i2
) + 1U];
825 xdIn
= pSrc
[(2U * i3
)];
826 ydIn
= pSrc
[(2U * i3
) + 1U];
829 Xaminusc
= xaIn
- xcIn
;
831 Xbminusd
= xbIn
- xdIn
;
833 Yaminusc
= yaIn
- ycIn
;
835 Ybminusd
= ybIn
- ydIn
;
838 Xaplusc
= xaIn
+ xcIn
;
840 Xbplusd
= xbIn
+ xdIn
;
842 Yaplusc
= yaIn
+ ycIn
;
844 Ybplusd
= ybIn
+ ydIn
;
846 /* (xa - xc) - (yb - yd) */
847 Xb12C_out
= (Xaminusc
- Ybminusd
);
848 /* (ya - yc) + (xb - xd) */
849 Yb12C_out
= (Yaminusc
+ Xbminusd
);
850 /* xa + xc -(xb + xd) */
851 Xc12C_out
= (Xaplusc
- Xbplusd
);
852 /* (ya + yc) - (yb + yd) */
853 Yc12C_out
= (Yaplusc
- Ybplusd
);
854 /* (xa - xc) + (yb - yd) */
855 Xd12C_out
= (Xaminusc
+ Ybminusd
);
856 /* (ya - yc) - (xb - xd) */
857 Yd12C_out
= (Yaminusc
- Xbminusd
);
859 pSrc
[(2U * i0
)] = Xaplusc
+ Xbplusd
;
860 pSrc
[(2U * i0
) + 1U] = Yaplusc
+ Ybplusd
;
862 Xb12_out
= Xb12C_out
* co1
;
863 Yb12_out
= Yb12C_out
* co1
;
864 Xc12_out
= Xc12C_out
* co2
;
865 Yc12_out
= Yc12C_out
* co2
;
866 Xd12_out
= Xd12C_out
* co3
;
867 Yd12_out
= Yd12C_out
* co3
;
869 /* xb' = (xa+yb-xc-yd)co1 - (ya-xb-yc+xd)(si1) */
870 //Xb12_out -= Yb12C_out * si1;
871 p0
= Yb12C_out
* si1
;
872 /* yb' = (ya-xb-yc+xd)co1 + (xa+yb-xc-yd)(si1) */
873 //Yb12_out += Xb12C_out * si1;
874 p1
= Xb12C_out
* si1
;
875 /* xc' = (xa-xb+xc-xd)co2 - (ya-yb+yc-yd)(si2) */
876 //Xc12_out -= Yc12C_out * si2;
877 p2
= Yc12C_out
* si2
;
878 /* yc' = (ya-yb+yc-yd)co2 + (xa-xb+xc-xd)(si2) */
879 //Yc12_out += Xc12C_out * si2;
880 p3
= Xc12C_out
* si2
;
881 /* xd' = (xa-yb-xc+yd)co3 - (ya+xb-yc-xd)(si3) */
882 //Xd12_out -= Yd12C_out * si3;
883 p4
= Yd12C_out
* si3
;
884 /* yd' = (ya+xb-yc-xd)co3 + (xa-yb-xc+yd)(si3) */
885 //Yd12_out += Xd12C_out * si3;
886 p5
= Xd12C_out
* si3
;
895 /* xc' = (xa-xb+xc-xd)co2 - (ya-yb+yc-yd)(si2) */
896 pSrc
[2U * i1
] = Xc12_out
;
898 /* yc' = (ya-yb+yc-yd)co2 + (xa-xb+xc-xd)(si2) */
899 pSrc
[(2U * i1
) + 1U] = Yc12_out
;
901 /* xb' = (xa+yb-xc-yd)co1 - (ya-xb-yc+xd)(si1) */
902 pSrc
[2U * i2
] = Xb12_out
;
904 /* yb' = (ya-xb-yc+xd)co1 + (xa+yb-xc-yd)(si1) */
905 pSrc
[(2U * i2
) + 1U] = Yb12_out
;
907 /* xd' = (xa-yb-xc+yd)co3 - (ya+xb-yc-xd)(si3) */
908 pSrc
[2U * i3
] = Xd12_out
;
910 /* yd' = (ya+xb-yc-xd)co3 + (xa-yb-xc+yd)(si3) */
911 pSrc
[(2U * i3
) + 1U] = Yd12_out
;
914 } while (i0
< fftLen
);
916 } while (j
<= (n2
- 1U));
917 twidCoefModifier
<<= 2U;
919 /* Initializations of last stage */
924 /* Calculations of last stage */
936 /* Butterfly implementation */
938 Xaplusc
= xaIn
+ xcIn
;
941 Xaminusc
= xaIn
- xcIn
;
944 Yaplusc
= yaIn
+ ycIn
;
947 Yaminusc
= yaIn
- ycIn
;
950 Xbplusd
= xbIn
+ xdIn
;
953 Ybplusd
= ybIn
+ ydIn
;
956 Xbminusd
= xbIn
- xdIn
;
959 Ybminusd
= ybIn
- ydIn
;
961 /* xa' = (xa+xb+xc+xd) * onebyfftLen */
962 a0
= (Xaplusc
+ Xbplusd
);
963 /* ya' = (ya+yb+yc+yd) * onebyfftLen */
964 a1
= (Yaplusc
+ Ybplusd
);
965 /* xc' = (xa-xb+xc-xd) * onebyfftLen */
966 a2
= (Xaplusc
- Xbplusd
);
967 /* yc' = (ya-yb+yc-yd) * onebyfftLen */
968 a3
= (Yaplusc
- Ybplusd
);
969 /* xb' = (xa-yb-xc+yd) * onebyfftLen */
970 a4
= (Xaminusc
- Ybminusd
);
971 /* yb' = (ya+xb-yc-xd) * onebyfftLen */
972 a5
= (Yaminusc
+ Xbminusd
);
973 /* xd' = (xa-yb-xc+yd) * onebyfftLen */
974 a6
= (Xaminusc
+ Ybminusd
);
975 /* yd' = (ya-xb-yc+xd) * onebyfftLen */
976 a7
= (Yaminusc
- Xbminusd
);
978 p0
= a0
* onebyfftLen
;
979 p1
= a1
* onebyfftLen
;
980 p2
= a2
* onebyfftLen
;
981 p3
= a3
* onebyfftLen
;
982 p4
= a4
* onebyfftLen
;
983 p5
= a5
* onebyfftLen
;
984 p6
= a6
* onebyfftLen
;
985 p7
= a7
* onebyfftLen
;
987 /* xa' = (xa+xb+xc+xd) * onebyfftLen */
989 /* ya' = (ya+yb+yc+yd) * onebyfftLen */
991 /* xc' = (xa-xb+xc-xd) * onebyfftLen */
993 /* yc' = (ya-yb+yc-yd) * onebyfftLen */
995 /* xb' = (xa-yb-xc+yd) * onebyfftLen */
997 /* yb' = (ya+xb-yc-xd) * onebyfftLen */
999 /* xd' = (xa-yb-xc+yd) * onebyfftLen */
1001 /* yd' = (ya-xb-yc+xd) * onebyfftLen */
1004 /* increment source pointer by 8 for next calculations */
1011 float32_t t1
, t2
, r1
, r2
, s1
, s2
;
1013 /* Run the below code for Cortex-M0 */
1015 /* Initializations for the first stage */
1019 /* Calculation of first stage */
1020 for (k
= fftLen
; k
> 4U; k
>>= 2U)
1022 /* Initializations for the first stage */
1027 /* Calculation of first stage */
1031 /* index calculation for the coefficients */
1034 co1
= pCoef
[ia1
* 2U];
1035 si1
= pCoef
[(ia1
* 2U) + 1U];
1036 co2
= pCoef
[ia2
* 2U];
1037 si2
= pCoef
[(ia2
* 2U) + 1U];
1038 co3
= pCoef
[ia3
* 2U];
1039 si3
= pCoef
[(ia3
* 2U) + 1U];
1041 /* Twiddle coefficients index modifier */
1042 ia1
= ia1
+ twidCoefModifier
;
1047 /* index calculation for the input as, */
1048 /* pSrc[i0 + 0], pSrc[i0 + fftLen/4], pSrc[i0 + fftLen/2], pSrc[i0 + 3fftLen/4] */
1054 r1
= pSrc
[(2U * i0
)] + pSrc
[(2U * i2
)];
1057 r2
= pSrc
[(2U * i0
)] - pSrc
[(2U * i2
)];
1060 s1
= pSrc
[(2U * i0
) + 1U] + pSrc
[(2U * i2
) + 1U];
1063 s2
= pSrc
[(2U * i0
) + 1U] - pSrc
[(2U * i2
) + 1U];
1066 t1
= pSrc
[2U * i1
] + pSrc
[2U * i3
];
1068 /* xa' = xa + xb + xc + xd */
1069 pSrc
[2U * i0
] = r1
+ t1
;
1071 /* xa + xc -(xb + xd) */
1075 t2
= pSrc
[(2U * i1
) + 1U] + pSrc
[(2U * i3
) + 1U];
1077 /* ya' = ya + yb + yc + yd */
1078 pSrc
[(2U * i0
) + 1U] = s1
+ t2
;
1080 /* (ya + yc) - (yb + yd) */
1084 t1
= pSrc
[(2U * i1
) + 1U] - pSrc
[(2U * i3
) + 1U];
1087 t2
= pSrc
[2U * i1
] - pSrc
[2U * i3
];
1089 /* xc' = (xa-xb+xc-xd)co2 - (ya-yb+yc-yd)(si2) */
1090 pSrc
[2U * i1
] = (r1
* co2
) - (s1
* si2
);
1092 /* yc' = (ya-yb+yc-yd)co2 + (xa-xb+xc-xd)(si2) */
1093 pSrc
[(2U * i1
) + 1U] = (s1
* co2
) + (r1
* si2
);
1095 /* (xa - xc) - (yb - yd) */
1098 /* (xa - xc) + (yb - yd) */
1101 /* (ya - yc) + (xb - xd) */
1104 /* (ya - yc) - (xb - xd) */
1107 /* xb' = (xa+yb-xc-yd)co1 - (ya-xb-yc+xd)(si1) */
1108 pSrc
[2U * i2
] = (r1
* co1
) - (s1
* si1
);
1110 /* yb' = (ya-xb-yc+xd)co1 + (xa+yb-xc-yd)(si1) */
1111 pSrc
[(2U * i2
) + 1U] = (s1
* co1
) + (r1
* si1
);
1113 /* xd' = (xa-yb-xc+yd)co3 - (ya+xb-yc-xd)(si3) */
1114 pSrc
[2U * i3
] = (r2
* co3
) - (s2
* si3
);
1116 /* yd' = (ya+xb-yc-xd)co3 + (xa-yb-xc+yd)(si3) */
1117 pSrc
[(2U * i3
) + 1U] = (s2
* co3
) + (r2
* si3
);
1120 } while ( i0
< fftLen
);
1122 } while (j
<= (n2
- 1U));
1123 twidCoefModifier
<<= 2U;
1125 /* Initializations of last stage */
1129 /* Calculations of last stage */
1130 for (i0
= 0U; i0
<= (fftLen
- n1
); i0
+= n1
)
1132 /* index calculation for the input as, */
1133 /* pSrc[i0 + 0], pSrc[i0 + fftLen/4], pSrc[i0 + fftLen/2], pSrc[i0 + 3fftLen/4] */
1138 /* Butterfly implementation */
1140 r1
= pSrc
[2U * i0
] + pSrc
[2U * i2
];
1143 r2
= pSrc
[2U * i0
] - pSrc
[2U * i2
];
1146 s1
= pSrc
[(2U * i0
) + 1U] + pSrc
[(2U * i2
) + 1U];
1149 s2
= pSrc
[(2U * i0
) + 1U] - pSrc
[(2U * i2
) + 1U];
1152 t1
= pSrc
[2U * i1
] + pSrc
[2U * i3
];
1154 /* xa' = xa + xb + xc + xd */
1155 pSrc
[2U * i0
] = (r1
+ t1
) * onebyfftLen
;
1157 /* (xa + xb) - (xc + xd) */
1161 t2
= pSrc
[(2U * i1
) + 1U] + pSrc
[(2U * i3
) + 1U];
1163 /* ya' = ya + yb + yc + yd */
1164 pSrc
[(2U * i0
) + 1U] = (s1
+ t2
) * onebyfftLen
;
1166 /* (ya + yc) - (yb + yd) */
1170 t1
= pSrc
[(2U * i1
) + 1U] - pSrc
[(2U * i3
) + 1U];
1173 t2
= pSrc
[2U * i1
] - pSrc
[2U * i3
];
1175 /* xc' = (xa-xb+xc-xd)co2 - (ya-yb+yc-yd)(si2) */
1176 pSrc
[2U * i1
] = r1
* onebyfftLen
;
1178 /* yc' = (ya-yb+yc-yd)co2 + (xa-xb+xc-xd)(si2) */
1179 pSrc
[(2U * i1
) + 1U] = s1
* onebyfftLen
;
1181 /* (xa - xc) - (yb-yd) */
1184 /* (xa - xc) + (yb-yd) */
1187 /* (ya - yc) + (xb-xd) */
1190 /* (ya - yc) - (xb-xd) */
1193 /* xb' = (xa+yb-xc-yd)co1 - (ya-xb-yc+xd)(si1) */
1194 pSrc
[2U * i2
] = r1
* onebyfftLen
;
1196 /* yb' = (ya-xb-yc+xd)co1 + (xa+yb-xc-yd)(si1) */
1197 pSrc
[(2U * i2
) + 1U] = s1
* onebyfftLen
;
1199 /* xd' = (xa-yb-xc+yd)co3 - (ya+xb-yc-xd)(si3) */
1200 pSrc
[2U * i3
] = r2
* onebyfftLen
;
1202 /* yd' = (ya+xb-yc-xd)co3 + (xa-yb-xc+yd)(si3) */
1203 pSrc
[(2U * i3
) + 1U] = s2
* onebyfftLen
;
1206 #endif /* #if defined (ARM_MATH_DSP) */