arm_cfft_init_f16.c 16 KB

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