• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* ----------------------------------------------------------------------
2  * Project:      CMSIS DSP Library
3  * Title:        arm_rfft_fast_init_f16.c
4  * Description:  Split Radix Decimation in Frequency CFFT Floating point processing function
5  *
6  * $Date:        23 April 2021
7  * $Revision:    V1.9.0
8  *
9  * Target Processor: Cortex-M and Cortex-A cores
10  * -------------------------------------------------------------------- */
11 /*
12  * Copyright (C) 2010-2021 ARM Limited or its affiliates. All rights reserved.
13  *
14  * SPDX-License-Identifier: Apache-2.0
15  *
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
19  *
20  * www.apache.org/licenses/LICENSE-2.0
21  *
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.
27  */
28 
29 #include "dsp/transform_functions_f16.h"
30 #include "arm_common_tables_f16.h"
31 #include "arm_const_structs_f16.h"
32 
33 #if defined(ARM_FLOAT16_SUPPORTED)
34 
35 /**
36   @ingroup groupTransforms
37  */
38 
39 /**
40   @addtogroup RealFFT
41   @{
42  */
43 
44 #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || (defined(ARM_TABLE_TWIDDLECOEF_F16_16) && defined(ARM_TABLE_BITREVIDX_FLT_16) && defined(ARM_TABLE_TWIDDLECOEF_RFFT_F16_32))
45 
46 /**
47   @private
48   @brief         Initialization function for the 32pt floating-point real FFT.
49   @param[in,out] S  points to an arm_rfft_fast_instance_f16 structure
50   @return        execution status
51                    - \ref ARM_MATH_SUCCESS        : Operation successful
52                    - \ref ARM_MATH_ARGUMENT_ERROR : an error is detected
53  */
54 
arm_rfft_32_fast_init_f16(arm_rfft_fast_instance_f16 * S)55 static arm_status arm_rfft_32_fast_init_f16( arm_rfft_fast_instance_f16 * S ) {
56 
57   arm_status status;
58 
59   if( !S ) return ARM_MATH_ARGUMENT_ERROR;
60 
61   status=arm_cfft_init_f16(&(S->Sint),16);
62   if (status != ARM_MATH_SUCCESS)
63   {
64     return(status);
65   }
66 
67   S->fftLenRFFT = 32U;
68   S->pTwiddleRFFT    = (float16_t *) twiddleCoefF16_rfft_32;
69 
70   return ARM_MATH_SUCCESS;
71 }
72 #endif
73 
74 #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || (defined(ARM_TABLE_TWIDDLECOEF_F16_32) && defined(ARM_TABLE_BITREVIDX_FLT_32) && defined(ARM_TABLE_TWIDDLECOEF_RFFT_F16_64))
75 
76 /**
77   @private
78   @brief         Initialization function for the 64pt floating-point real FFT.
79   @param[in,out] S  points to an arm_rfft_fast_instance_f16 structure
80   @return        execution status
81                    - \ref ARM_MATH_SUCCESS        : Operation successful
82                    - \ref ARM_MATH_ARGUMENT_ERROR : an error is detected
83  */
84 
arm_rfft_64_fast_init_f16(arm_rfft_fast_instance_f16 * S)85 static arm_status arm_rfft_64_fast_init_f16( arm_rfft_fast_instance_f16 * S ) {
86 
87   arm_status status;
88 
89   if( !S ) return ARM_MATH_ARGUMENT_ERROR;
90 
91   status=arm_cfft_init_f16(&(S->Sint),32);
92   if (status != ARM_MATH_SUCCESS)
93   {
94     return(status);
95   }
96   S->fftLenRFFT = 64U;
97 
98   S->pTwiddleRFFT    = (float16_t *) twiddleCoefF16_rfft_64;
99 
100   return ARM_MATH_SUCCESS;
101 }
102 #endif
103 
104 #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || (defined(ARM_TABLE_TWIDDLECOEF_F16_64) && defined(ARM_TABLE_BITREVIDX_FLT_64) && defined(ARM_TABLE_TWIDDLECOEF_RFFT_F16_128))
105 
106 /**
107   @private
108   @brief         Initialization function for the 128pt floating-point real FFT.
109   @param[in,out] S  points to an arm_rfft_fast_instance_f16 structure
110   @return        execution status
111                    - \ref ARM_MATH_SUCCESS        : Operation successful
112                    - \ref ARM_MATH_ARGUMENT_ERROR : an error is detected
113  */
114 
arm_rfft_128_fast_init_f16(arm_rfft_fast_instance_f16 * S)115 static arm_status arm_rfft_128_fast_init_f16( arm_rfft_fast_instance_f16 * S ) {
116 
117   arm_status status;
118 
119   if( !S ) return ARM_MATH_ARGUMENT_ERROR;
120 
121   status=arm_cfft_init_f16(&(S->Sint),64);
122   if (status != ARM_MATH_SUCCESS)
123   {
124     return(status);
125   }
126   S->fftLenRFFT = 128;
127 
128   S->pTwiddleRFFT    = (float16_t *) twiddleCoefF16_rfft_128;
129 
130   return ARM_MATH_SUCCESS;
131 }
132 #endif
133 
134 #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || (defined(ARM_TABLE_TWIDDLECOEF_F16_128) && defined(ARM_TABLE_BITREVIDX_FLT_128) && defined(ARM_TABLE_TWIDDLECOEF_RFFT_F16_256))
135 
136 /**
137   @private
138   @brief         Initialization function for the 256pt floating-point real FFT.
139   @param[in,out] S  points to an arm_rfft_fast_instance_f16 structure
140   @return        execution status
141                    - \ref ARM_MATH_SUCCESS        : Operation successful
142                    - \ref ARM_MATH_ARGUMENT_ERROR : an error is detected
143 */
144 
arm_rfft_256_fast_init_f16(arm_rfft_fast_instance_f16 * S)145 static arm_status arm_rfft_256_fast_init_f16( arm_rfft_fast_instance_f16 * S ) {
146 
147   arm_status status;
148 
149   if( !S ) return ARM_MATH_ARGUMENT_ERROR;
150 
151   status=arm_cfft_init_f16(&(S->Sint),128);
152   if (status != ARM_MATH_SUCCESS)
153   {
154     return(status);
155   }
156   S->fftLenRFFT = 256U;
157 
158   S->pTwiddleRFFT    = (float16_t *) twiddleCoefF16_rfft_256;
159 
160   return ARM_MATH_SUCCESS;
161 }
162 #endif
163 
164 #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || (defined(ARM_TABLE_TWIDDLECOEF_F16_256) && defined(ARM_TABLE_BITREVIDX_FLT_256) && defined(ARM_TABLE_TWIDDLECOEF_RFFT_F16_512))
165 
166 /**
167   @private
168   @brief         Initialization function for the 512pt floating-point real FFT.
169   @param[in,out] S  points to an arm_rfft_fast_instance_f16 structure
170   @return        execution status
171                    - \ref ARM_MATH_SUCCESS        : Operation successful
172                    - \ref ARM_MATH_ARGUMENT_ERROR : an error is detected
173  */
174 
arm_rfft_512_fast_init_f16(arm_rfft_fast_instance_f16 * S)175 static arm_status arm_rfft_512_fast_init_f16( arm_rfft_fast_instance_f16 * S ) {
176 
177   arm_status status;
178 
179   if( !S ) return ARM_MATH_ARGUMENT_ERROR;
180 
181   status=arm_cfft_init_f16(&(S->Sint),256);
182   if (status != ARM_MATH_SUCCESS)
183   {
184     return(status);
185   }
186   S->fftLenRFFT = 512U;
187 
188   S->pTwiddleRFFT    = (float16_t *) twiddleCoefF16_rfft_512;
189 
190   return ARM_MATH_SUCCESS;
191 }
192 #endif
193 
194 #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || (defined(ARM_TABLE_TWIDDLECOEF_F16_512) && defined(ARM_TABLE_BITREVIDX_FLT_512) && defined(ARM_TABLE_TWIDDLECOEF_RFFT_F16_1024))
195 /**
196   @private
197   @brief         Initialization function for the 1024pt floating-point real FFT.
198   @param[in,out] S  points to an arm_rfft_fast_instance_f16 structure
199   @return        execution status
200                    - \ref ARM_MATH_SUCCESS        : Operation successful
201                    - \ref ARM_MATH_ARGUMENT_ERROR : an error is detected
202  */
203 
arm_rfft_1024_fast_init_f16(arm_rfft_fast_instance_f16 * S)204 static arm_status arm_rfft_1024_fast_init_f16( arm_rfft_fast_instance_f16 * S ) {
205 
206   arm_status status;
207 
208   if( !S ) return ARM_MATH_ARGUMENT_ERROR;
209 
210   status=arm_cfft_init_f16(&(S->Sint),512);
211   if (status != ARM_MATH_SUCCESS)
212   {
213     return(status);
214   }
215   S->fftLenRFFT = 1024U;
216 
217   S->pTwiddleRFFT    = (float16_t *) twiddleCoefF16_rfft_1024;
218 
219   return ARM_MATH_SUCCESS;
220 }
221 #endif
222 
223 #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || (defined(ARM_TABLE_TWIDDLECOEF_F16_1024) && defined(ARM_TABLE_BITREVIDX_FLT_1024) && defined(ARM_TABLE_TWIDDLECOEF_RFFT_F16_2048))
224 /**
225   @private
226   @brief         Initialization function for the 2048pt floating-point real FFT.
227   @param[in,out] S  points to an arm_rfft_fast_instance_f16 structure
228   @return        execution status
229                    - \ref ARM_MATH_SUCCESS        : Operation successful
230                    - \ref ARM_MATH_ARGUMENT_ERROR : an error is detected
231  */
arm_rfft_2048_fast_init_f16(arm_rfft_fast_instance_f16 * S)232 static arm_status arm_rfft_2048_fast_init_f16( arm_rfft_fast_instance_f16 * S ) {
233 
234   arm_status status;
235 
236   if( !S ) return ARM_MATH_ARGUMENT_ERROR;
237 
238   status=arm_cfft_init_f16(&(S->Sint),1024);
239   if (status != ARM_MATH_SUCCESS)
240   {
241     return(status);
242   }
243   S->fftLenRFFT = 2048U;
244 
245   S->pTwiddleRFFT    = (float16_t *) twiddleCoefF16_rfft_2048;
246 
247   return ARM_MATH_SUCCESS;
248 }
249 #endif
250 
251 #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || (defined(ARM_TABLE_TWIDDLECOEF_F16_2048) && defined(ARM_TABLE_BITREVIDX_FLT_2048) && defined(ARM_TABLE_TWIDDLECOEF_RFFT_F16_4096))
252 /**
253   @private
254 * @brief         Initialization function for the 4096pt floating-point real FFT.
255 * @param[in,out] S  points to an arm_rfft_fast_instance_f16 structure
256   @return        execution status
257                    - \ref ARM_MATH_SUCCESS        : Operation successful
258                    - \ref ARM_MATH_ARGUMENT_ERROR : an error is detected
259  */
260 
arm_rfft_4096_fast_init_f16(arm_rfft_fast_instance_f16 * S)261 static arm_status arm_rfft_4096_fast_init_f16( arm_rfft_fast_instance_f16 * S ) {
262 
263   arm_status status;
264 
265   if( !S ) return ARM_MATH_ARGUMENT_ERROR;
266 
267   status=arm_cfft_init_f16(&(S->Sint),2048);
268   if (status != ARM_MATH_SUCCESS)
269   {
270     return(status);
271   }
272   S->fftLenRFFT = 4096U;
273 
274   S->pTwiddleRFFT    = (float16_t *) twiddleCoefF16_rfft_4096;
275 
276   return ARM_MATH_SUCCESS;
277 }
278 #endif
279 
280 /**
281   @brief         Initialization function for the floating-point real FFT.
282   @param[in,out] S       points to an arm_rfft_fast_instance_f16 structure
283   @param[in]     fftLen  length of the Real Sequence
284   @return        execution status
285                    - \ref ARM_MATH_SUCCESS        : Operation successful
286                    - \ref ARM_MATH_ARGUMENT_ERROR : <code>fftLen</code> is not a supported length
287 
288   @par           Description
289                    The parameter <code>fftLen</code> specifies the length of RFFT/CIFFT process.
290                    Supported FFT Lengths are 32, 64, 128, 256, 512, 1024, 2048, 4096.
291   @par
292                    This Function also initializes Twiddle factor table pointer and Bit reversal table pointer.
293  */
294 
arm_rfft_fast_init_f16(arm_rfft_fast_instance_f16 * S,uint16_t fftLen)295 arm_status arm_rfft_fast_init_f16(
296   arm_rfft_fast_instance_f16 * S,
297   uint16_t fftLen)
298 {
299   typedef arm_status(*fft_init_ptr)( arm_rfft_fast_instance_f16 *);
300   fft_init_ptr fptr = 0x0;
301 
302   switch (fftLen)
303   {
304 #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || (defined(ARM_TABLE_TWIDDLECOEF_F16_2048) && defined(ARM_TABLE_BITREVIDX_FLT_2048) && defined(ARM_TABLE_TWIDDLECOEF_RFFT_F16_4096))
305   case 4096U:
306     fptr = arm_rfft_4096_fast_init_f16;
307     break;
308 #endif
309 #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || (defined(ARM_TABLE_TWIDDLECOEF_F16_1024) && defined(ARM_TABLE_BITREVIDX_FLT_1024) && defined(ARM_TABLE_TWIDDLECOEF_RFFT_F16_2048))
310   case 2048U:
311     fptr = arm_rfft_2048_fast_init_f16;
312     break;
313 #endif
314 #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || (defined(ARM_TABLE_TWIDDLECOEF_F16_512) && defined(ARM_TABLE_BITREVIDX_FLT_512) && defined(ARM_TABLE_TWIDDLECOEF_RFFT_F16_1024))
315   case 1024U:
316     fptr = arm_rfft_1024_fast_init_f16;
317     break;
318 #endif
319 #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || (defined(ARM_TABLE_TWIDDLECOEF_F16_256) && defined(ARM_TABLE_BITREVIDX_FLT_256) && defined(ARM_TABLE_TWIDDLECOEF_RFFT_F16_512))
320   case 512U:
321     fptr = arm_rfft_512_fast_init_f16;
322     break;
323 #endif
324 #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || (defined(ARM_TABLE_TWIDDLECOEF_F16_128) && defined(ARM_TABLE_BITREVIDX_FLT_128) && defined(ARM_TABLE_TWIDDLECOEF_RFFT_F16_256))
325   case 256U:
326     fptr = arm_rfft_256_fast_init_f16;
327     break;
328 #endif
329 #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || (defined(ARM_TABLE_TWIDDLECOEF_F16_64) && defined(ARM_TABLE_BITREVIDX_FLT_64) && defined(ARM_TABLE_TWIDDLECOEF_RFFT_F16_128))
330   case 128U:
331     fptr = arm_rfft_128_fast_init_f16;
332     break;
333 #endif
334 #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || (defined(ARM_TABLE_TWIDDLECOEF_F16_32) && defined(ARM_TABLE_BITREVIDX_FLT_32) && defined(ARM_TABLE_TWIDDLECOEF_RFFT_F16_64))
335   case 64U:
336     fptr = arm_rfft_64_fast_init_f16;
337     break;
338 #endif
339 #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || (defined(ARM_TABLE_TWIDDLECOEF_F16_16) && defined(ARM_TABLE_BITREVIDX_FLT_16) && defined(ARM_TABLE_TWIDDLECOEF_RFFT_F16_32))
340   case 32U:
341     fptr = arm_rfft_32_fast_init_f16;
342     break;
343 #endif
344   default:
345     return ARM_MATH_ARGUMENT_ERROR;
346   }
347 
348   if( ! fptr ) return ARM_MATH_ARGUMENT_ERROR;
349   return fptr( S );
350 
351 }
352 
353 /**
354   @} end of RealFFT group
355  */
356 
357 #endif /*  #if defined(ARM_FLOAT16_SUPPORTED) */