• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* ----------------------------------------------------------------------
2  * Project:      CMSIS DSP Library
3  * Title:        arm_cfft_init_f16.c
4  * Description:  Initialization function for cfft f16 instance
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-2023 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 
30 /**
31  * @defgroup ComplexFFTF16 Complex FFT F16
32  */
33 
34 /**
35   @ingroup groupTransforms
36  */
37 
38 /**
39   @addtogroup ComplexFFT
40   @{
41  */
42 
43 /**
44   @addtogroup ComplexFFTF16
45   @{
46  */
47 
48 
49 
50 #include "dsp/transform_functions_f16.h"
51 #include "arm_common_tables_f16.h"
52 #include "arm_const_structs_f16.h"
53 
54 
55 #if defined(ARM_MATH_MVE_FLOAT16) && !defined(ARM_MATH_AUTOVECTORIZE)
56 
57 #include "arm_vec_fft.h"
58 #include "arm_mve_tables_f16.h"
59 
60 #define CFFT_RADIX4BY2_REARRANGE_TWIDDLES_F16(LEN)                                           \
61 static arm_status arm_cfft_radix4by2_rearrange_twiddles_##LEN##_f16(arm_cfft_instance_f16 *S)\
62 {                                                                                            \
63    S->rearranged_twiddle_tab_stride1_arr = rearranged_twiddle_tab_stride1_arr_##LEN##_f16;   \
64    S->rearranged_twiddle_stride1  =  rearranged_twiddle_stride1_##LEN##_f16;                 \
65                                                                                              \
66    S->rearranged_twiddle_tab_stride2_arr = rearranged_twiddle_tab_stride2_arr_##LEN##_f16;   \
67    S->rearranged_twiddle_stride2  =  rearranged_twiddle_stride2_##LEN##_f16;                 \
68                                                                                              \
69    S->rearranged_twiddle_tab_stride3_arr = rearranged_twiddle_tab_stride3_arr_##LEN##_f16;   \
70    S->rearranged_twiddle_stride3  =  rearranged_twiddle_stride3_##LEN##_f16;                 \
71    return(ARM_MATH_SUCCESS);                                                                 \
72 }
73 
74 CFFT_RADIX4BY2_REARRANGE_TWIDDLES_F16(4096);
75 CFFT_RADIX4BY2_REARRANGE_TWIDDLES_F16(1024);
76 CFFT_RADIX4BY2_REARRANGE_TWIDDLES_F16(256);
77 CFFT_RADIX4BY2_REARRANGE_TWIDDLES_F16(64);
78 CFFT_RADIX4BY2_REARRANGE_TWIDDLES_F16(16);
79 
80 
81 
82 #define CFFTINIT_F16(LEN,LENTWIDDLE)                                   \
83 arm_status arm_cfft_init_##LEN##_f16(                                  \
84   arm_cfft_instance_f16 * S)                                           \
85 {                                                                      \
86     /*  Initialise the default arm status */                           \
87     arm_status status = ARM_MATH_SUCCESS;                              \
88                                                                        \
89     /*  Initialise the FFT length */                                   \
90     S->fftLen = LEN;                                                   \
91                                                                        \
92     /*  Initialise the Twiddle coefficient pointer */                  \
93     S->pTwiddle = NULL;                                                \
94                                                                        \
95     /*  Initialise the bit reversal table modifier */                  \
96     S->bitRevLength = ARMBITREVINDEXTABLE_FIXED_##LEN##_TABLE_LENGTH;  \
97     S->pBitRevTable = (uint16_t *)armBitRevIndexTable_fixed_##LEN;     \
98     S->pTwiddle = (float16_t *)twiddleCoefF16_##LEN;                   \
99     status=arm_cfft_radix4by2_rearrange_twiddles_##LENTWIDDLE##_f16(S);\
100                                                                        \
101     return (status);                                                   \
102 };
103 
104 #else
105 
106 #if defined(ARM_FLOAT16_SUPPORTED)
107 
108 #define FFTINIT(EXT,SIZE)                                           \
109   S->bitRevLength = arm_cfft_sR_##EXT##_len##SIZE.bitRevLength;        \
110   S->pBitRevTable = arm_cfft_sR_##EXT##_len##SIZE.pBitRevTable;         \
111   S->pTwiddle = arm_cfft_sR_##EXT##_len##SIZE.pTwiddle;
112 
113 #define CFFTINIT_F16(LEN,LENTWIDDLE)                                                       \
114 arm_status arm_cfft_init_##LEN##_f16(arm_cfft_instance_f16 * S)                 \
115 {                                                                               \
116         /*  Initialise the default arm status */                                \
117         arm_status status = ARM_MATH_SUCCESS;                                   \
118                                                                                 \
119         /*  Initialise the FFT length */                                        \
120         S->fftLen = LEN;                                                        \
121                                                                                 \
122         /*  Initialise the Twiddle coefficient pointer */                       \
123         S->pTwiddle = NULL;                                                     \
124                                                                                 \
125         /*  Initializations of Instance structure depending on the FFT length */\
126         FFTINIT(f16,LEN);                                                       \
127                                                                                 \
128         return (status);                                                        \
129 };
130 
131 
132 #endif /* #if defined(ARM_FLOAT16_SUPPORTED) */
133 #endif /* defined(ARM_MATH_MVEF) && !defined(ARM_MATH_AUTOVECTORIZE) */
134 
135 #if defined(ARM_MATH_MVE_FLOAT16) || defined(ARM_FLOAT16_SUPPORTED)
136 /**
137   @brief         Initialization function for the cfft f16 function with 4096 samples
138   @param[in,out] S              points to an instance of the floating-point CFFT structure
139   @return        execution status
140                    - \ref ARM_MATH_SUCCESS        : Operation successful
141                    - \ref ARM_MATH_ARGUMENT_ERROR : an error is detected
142 
143   @par          Use of this function is mandatory only for the MVE version of the FFT.
144                 Other versions can still initialize directly the data structure using
145                 variables declared in arm_const_structs.h
146  */
147 CFFTINIT_F16(4096,4096);
148 
149 /**
150   @brief         Initialization function for the cfft f16 function with 2048 samples
151   @param[in,out] S              points to an instance of the floating-point CFFT structure
152   @return        execution status
153                    - \ref ARM_MATH_SUCCESS        : Operation successful
154                    - \ref ARM_MATH_ARGUMENT_ERROR : an error is detected
155 
156   @par          Use of this function is mandatory only for the MVE version of the FFT.
157                 Other versions can still initialize directly the data structure using
158                 variables declared in arm_const_structs.h
159  */
160 CFFTINIT_F16(2048,1024);
161 
162 
163 /**
164   @brief         Initialization function for the cfft f16 function with 1024 samples
165   @param[in,out] S              points to an instance of the floating-point CFFT structure
166   @return        execution status
167                    - \ref ARM_MATH_SUCCESS        : Operation successful
168                    - \ref ARM_MATH_ARGUMENT_ERROR : an error is detected
169 
170   @par          Use of this function is mandatory only for the MVE version of the FFT.
171                 Other versions can still initialize directly the data structure using
172                 variables declared in arm_const_structs.h
173  */
174 CFFTINIT_F16(1024,1024);
175 
176 
177 /**
178   @brief         Initialization function for the cfft f16 function with 512 samples
179   @param[in,out] S              points to an instance of the floating-point CFFT structure
180   @return        execution status
181                    - \ref ARM_MATH_SUCCESS        : Operation successful
182                    - \ref ARM_MATH_ARGUMENT_ERROR : an error is detected
183 
184   @par          Use of this function is mandatory only for the MVE version of the FFT.
185                 Other versions can still initialize directly the data structure using
186                 variables declared in arm_const_structs.h
187  */
188 CFFTINIT_F16(512,256);
189 
190 
191 /**
192   @brief         Initialization function for the cfft f16 function with 256 samples
193   @param[in,out] S              points to an instance of the floating-point CFFT structure
194   @return        execution status
195                    - \ref ARM_MATH_SUCCESS        : Operation successful
196                    - \ref ARM_MATH_ARGUMENT_ERROR : an error is detected
197 
198   @par          Use of this function is mandatory only for the MVE version of the FFT.
199                 Other versions can still initialize directly the data structure using
200                 variables declared in arm_const_structs.h
201  */
202 CFFTINIT_F16(256,256);
203 
204 
205 /**
206   @brief         Initialization function for the cfft f16 function with 128 samples
207   @param[in,out] S              points to an instance of the floating-point CFFT structure
208   @return        execution status
209                    - \ref ARM_MATH_SUCCESS        : Operation successful
210                    - \ref ARM_MATH_ARGUMENT_ERROR : an error is detected
211 
212   @par          Use of this function is mandatory only for the MVE version of the FFT.
213                 Other versions can still initialize directly the data structure using
214                 variables declared in arm_const_structs.h
215  */
216 CFFTINIT_F16(128,64);
217 
218 
219 /**
220   @brief         Initialization function for the cfft f16 function with 64 samples
221   @param[in,out] S              points to an instance of the floating-point CFFT structure
222   @return        execution status
223                    - \ref ARM_MATH_SUCCESS        : Operation successful
224                    - \ref ARM_MATH_ARGUMENT_ERROR : an error is detected
225 
226   @par          Use of this function is mandatory only for the MVE version of the FFT.
227                 Other versions can still initialize directly the data structure using
228                 variables declared in arm_const_structs.h
229  */
230 CFFTINIT_F16(64,64);
231 
232 
233 /**
234   @brief         Initialization function for the cfft f16 function with 32 samples
235   @param[in,out] S              points to an instance of the floating-point CFFT structure
236   @return        execution status
237                    - \ref ARM_MATH_SUCCESS        : Operation successful
238                    - \ref ARM_MATH_ARGUMENT_ERROR : an error is detected
239 
240   @par          Use of this function is mandatory only for the MVE version of the FFT.
241                 Other versions can still initialize directly the data structure using
242                 variables declared in arm_const_structs.h
243  */
244 CFFTINIT_F16(32,16);
245 
246 
247 /**
248   @brief         Initialization function for the cfft f16 function with 16 samples
249   @param[in,out] S              points to an instance of the floating-point CFFT structure
250   @return        execution status
251                    - \ref ARM_MATH_SUCCESS        : Operation successful
252                    - \ref ARM_MATH_ARGUMENT_ERROR : an error is detected
253 
254   @par          Use of this function is mandatory only for the MVE version of the FFT.
255                 Other versions can still initialize directly the data structure using
256                 variables declared in arm_const_structs.h
257  */
258 CFFTINIT_F16(16,16);
259 
260 
261 /**
262   @brief         Generic initialization function for the cfft f16 function
263   @param[in,out] S              points to an instance of the floating-point CFFT structure
264   @param[in]     fftLen         fft length (number of complex samples)
265   @return        execution status
266                    - \ref ARM_MATH_SUCCESS        : Operation successful
267                    - \ref ARM_MATH_ARGUMENT_ERROR : an error is detected
268 
269   @par          Use of this function is mandatory only for the MVE version of the FFT.
270                 Other versions can still initialize directly the data structure using
271                 variables declared in arm_const_structs.h
272 
273   @par
274                 This function should be used only if you don't know the FFT sizes that
275                 you'll need at build time. The use of this function will prevent the
276                 linker from removing the FFT tables that are not needed and the library
277                 code size will be bigger than needed.
278 
279   @par
280                 If you use CMSIS-DSP as a static library, and if you know the FFT sizes
281                 that you need at build time, then it is better to use the initialization
282                 functions defined for each FFT size.
283  */
arm_cfft_init_f16(arm_cfft_instance_f16 * S,uint16_t fftLen)284 arm_status arm_cfft_init_f16(
285   arm_cfft_instance_f16 * S,
286   uint16_t fftLen)
287 {
288 
289         /*  Initialise the default arm status */
290         arm_status status = ARM_MATH_SUCCESS;
291 
292         /*  Initializations of Instance structure depending on the FFT length */
293         switch (fftLen) {
294             /*  Initializations of structure parameters for 4096 point FFT */
295         case 4096U:
296             /*  Initialise the bit reversal table modifier */
297             status=arm_cfft_init_4096_f16(S);
298             break;
299 
300             /*  Initializations of structure parameters for 2048 point FFT */
301         case 2048U:
302             /*  Initialise the bit reversal table modifier */
303             status=arm_cfft_init_2048_f16(S);
304             break;
305 
306             /*  Initializations of structure parameters for 1024 point FFT */
307         case 1024U:
308             /*  Initialise the bit reversal table modifier */
309             status=arm_cfft_init_1024_f16(S);
310             break;
311 
312             /*  Initializations of structure parameters for 512 point FFT */
313         case 512U:
314             /*  Initialise the bit reversal table modifier */
315             status=arm_cfft_init_512_f16(S);
316             break;
317 
318         case 256U:
319             status=arm_cfft_init_256_f16(S);
320             break;
321 
322         case 128U:
323             status=arm_cfft_init_128_f16(S);
324             break;
325 
326         case 64U:
327             status=arm_cfft_init_64_f16(S);
328             break;
329 
330         case 32U:
331             status=arm_cfft_init_32_f16(S);
332             break;
333 
334         case 16U:
335             /*  Initializations of structure parameters for 16 point FFT */
336             status=arm_cfft_init_16_f16(S);
337             break;
338 
339         default:
340             /*  Reporting argument error if fftSize is not valid value */
341             status = ARM_MATH_ARGUMENT_ERROR;
342             break;
343         }
344 
345 
346         return (status);
347 }
348 #endif /* Float 16 used*/
349 
350 /**
351   @} end of ComplexFFTF16 group
352  */
353 
354 /**
355   @} end of ComplexFFT group
356  */