1 /* ----------------------------------------------------------------------
2 * Project: CMSIS DSP Library
3 * Title: arm_cfft_radix8_f32.c
4 * Description: Radix-8 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.
32 /* ----------------------------------------------------------------------
33 * Internal helper function used by the FFTs
34 * -------------------------------------------------------------------- */
37 * @brief Core function for the floating-point CFFT butterfly process.
38 * @param[in, out] *pSrc points to the in-place buffer of floating-point data type.
39 * @param[in] fftLen length of the FFT.
40 * @param[in] *pCoef points to the twiddle coefficient buffer.
41 * @param[in] twidCoefModifier twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table.
45 void arm_radix8_butterfly_f32(
48 const float32_t
* pCoef
,
49 uint16_t twidCoefModifier
)
51 uint32_t ia1
, ia2
, ia3
, ia4
, ia5
, ia6
, ia7
;
52 uint32_t i1
, i2
, i3
, i4
, i5
, i6
, i7
, i8
;
56 float32_t r1
, r2
, r3
, r4
, r5
, r6
, r7
, r8
;
58 float32_t s1
, s2
, s3
, s4
, s5
, s6
, s7
, s8
;
59 float32_t p1
, p2
, p3
, p4
;
60 float32_t co2
, co3
, co4
, co5
, co6
, co7
, co8
;
61 float32_t si2
, si3
, si4
, si5
, si6
, si7
, si8
;
62 const float32_t C81
= 0.70710678118f
;
81 r1
= pSrc
[2 * i1
] + pSrc
[2 * i5
];
82 r5
= pSrc
[2 * i1
] - pSrc
[2 * i5
];
83 r2
= pSrc
[2 * i2
] + pSrc
[2 * i6
];
84 r6
= pSrc
[2 * i2
] - pSrc
[2 * i6
];
85 r3
= pSrc
[2 * i3
] + pSrc
[2 * i7
];
86 r7
= pSrc
[2 * i3
] - pSrc
[2 * i7
];
87 r4
= pSrc
[2 * i4
] + pSrc
[2 * i8
];
88 r8
= pSrc
[2 * i4
] - pSrc
[2 * i8
];
93 pSrc
[2 * i1
] = r1
+ r2
;
94 pSrc
[2 * i5
] = r1
- r2
;
95 r1
= pSrc
[2 * i1
+ 1] + pSrc
[2 * i5
+ 1];
96 s5
= pSrc
[2 * i1
+ 1] - pSrc
[2 * i5
+ 1];
97 r2
= pSrc
[2 * i2
+ 1] + pSrc
[2 * i6
+ 1];
98 s6
= pSrc
[2 * i2
+ 1] - pSrc
[2 * i6
+ 1];
99 s3
= pSrc
[2 * i3
+ 1] + pSrc
[2 * i7
+ 1];
100 s7
= pSrc
[2 * i3
+ 1] - pSrc
[2 * i7
+ 1];
101 r4
= pSrc
[2 * i4
+ 1] + pSrc
[2 * i8
+ 1];
102 s8
= pSrc
[2 * i4
+ 1] - pSrc
[2 * i8
+ 1];
107 pSrc
[2 * i1
+ 1] = r1
+ r2
;
108 pSrc
[2 * i5
+ 1] = r1
- r2
;
109 pSrc
[2 * i3
] = t1
+ s3
;
110 pSrc
[2 * i7
] = t1
- s3
;
111 pSrc
[2 * i3
+ 1] = t2
- r3
;
112 pSrc
[2 * i7
+ 1] = t2
+ r3
;
113 r1
= (r6
- r8
) * C81
;
114 r6
= (r6
+ r8
) * C81
;
115 r2
= (s6
- s8
) * C81
;
116 s6
= (s6
+ s8
) * C81
;
125 pSrc
[2 * i2
] = r5
+ s7
;
126 pSrc
[2 * i8
] = r5
- s7
;
127 pSrc
[2 * i6
] = t1
+ s8
;
128 pSrc
[2 * i4
] = t1
- s8
;
129 pSrc
[2 * i2
+ 1] = s5
- r7
;
130 pSrc
[2 * i8
+ 1] = s5
+ r7
;
131 pSrc
[2 * i6
+ 1] = t2
- r8
;
132 pSrc
[2 * i4
+ 1] = t2
+ r8
;
135 } while (i1
< fftLen
);
145 /* index calculation for the coefficients */
146 id
= ia1
+ twidCoefModifier
;
155 co2
= pCoef
[2 * ia1
];
156 co3
= pCoef
[2 * ia2
];
157 co4
= pCoef
[2 * ia3
];
158 co5
= pCoef
[2 * ia4
];
159 co6
= pCoef
[2 * ia5
];
160 co7
= pCoef
[2 * ia6
];
161 co8
= pCoef
[2 * ia7
];
162 si2
= pCoef
[2 * ia1
+ 1];
163 si3
= pCoef
[2 * ia2
+ 1];
164 si4
= pCoef
[2 * ia3
+ 1];
165 si5
= pCoef
[2 * ia4
+ 1];
166 si6
= pCoef
[2 * ia5
+ 1];
167 si7
= pCoef
[2 * ia6
+ 1];
168 si8
= pCoef
[2 * ia7
+ 1];
174 /* index calculation for the input */
182 r1
= pSrc
[2 * i1
] + pSrc
[2 * i5
];
183 r5
= pSrc
[2 * i1
] - pSrc
[2 * i5
];
184 r2
= pSrc
[2 * i2
] + pSrc
[2 * i6
];
185 r6
= pSrc
[2 * i2
] - pSrc
[2 * i6
];
186 r3
= pSrc
[2 * i3
] + pSrc
[2 * i7
];
187 r7
= pSrc
[2 * i3
] - pSrc
[2 * i7
];
188 r4
= pSrc
[2 * i4
] + pSrc
[2 * i8
];
189 r8
= pSrc
[2 * i4
] - pSrc
[2 * i8
];
194 pSrc
[2 * i1
] = r1
+ r2
;
196 s1
= pSrc
[2 * i1
+ 1] + pSrc
[2 * i5
+ 1];
197 s5
= pSrc
[2 * i1
+ 1] - pSrc
[2 * i5
+ 1];
198 s2
= pSrc
[2 * i2
+ 1] + pSrc
[2 * i6
+ 1];
199 s6
= pSrc
[2 * i2
+ 1] - pSrc
[2 * i6
+ 1];
200 s3
= pSrc
[2 * i3
+ 1] + pSrc
[2 * i7
+ 1];
201 s7
= pSrc
[2 * i3
+ 1] - pSrc
[2 * i7
+ 1];
202 s4
= pSrc
[2 * i4
+ 1] + pSrc
[2 * i8
+ 1];
203 s8
= pSrc
[2 * i4
+ 1] - pSrc
[2 * i8
+ 1];
210 pSrc
[2 * i1
+ 1] = s1
+ s2
;
218 pSrc
[2 * i5
] = p1
+ p2
;
219 pSrc
[2 * i5
+ 1] = p3
- p4
;
224 pSrc
[2 * i3
] = p1
+ p2
;
225 pSrc
[2 * i3
+ 1] = p3
- p4
;
230 pSrc
[2 * i7
] = p1
+ p2
;
231 pSrc
[2 * i7
+ 1] = p3
- p4
;
232 r1
= (r6
- r8
) * C81
;
233 r6
= (r6
+ r8
) * C81
;
234 s1
= (s6
- s8
) * C81
;
235 s6
= (s6
+ s8
) * C81
;
256 pSrc
[2 * i2
] = p1
+ p2
;
257 pSrc
[2 * i2
+ 1] = p3
- p4
;
262 pSrc
[2 * i8
] = p1
+ p2
;
263 pSrc
[2 * i8
+ 1] = p3
- p4
;
268 pSrc
[2 * i6
] = p1
+ p2
;
269 pSrc
[2 * i6
+ 1] = p3
- p4
;
274 pSrc
[2 * i4
] = p1
+ p2
;
275 pSrc
[2 * i4
+ 1] = p3
- p4
;
278 } while (i1
< fftLen
);
283 twidCoefModifier
<<= 3;