arm_cfft_radix2_init_f16.c 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. /* ----------------------------------------------------------------------
  2. * Project: CMSIS DSP Library
  3. * Title: arm_cfft_radix2_init_f16.c
  4. * Description: Radix-2 Decimation in Frequency Floating-point CFFT & CIFFT Initialization 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. #include "dsp/transform_functions_f16.h"
  29. #include "arm_common_tables.h"
  30. #include "arm_common_tables_f16.h"
  31. /**
  32. @addtogroup ComplexFFTDeprecated
  33. @{
  34. */
  35. /**
  36. @brief Initialization function for the floating-point CFFT/CIFFT.
  37. @deprecated Do not use this function. It has been superseded by \ref arm_cfft_f16 and will be removed in the future.
  38. @param[in,out] S points to an instance of the floating-point CFFT/CIFFT structure
  39. @param[in] fftLen length of the FFT
  40. @param[in] ifftFlag flag that selects transform direction
  41. - value = 0: forward transform
  42. - value = 1: inverse transform
  43. @param[in] bitReverseFlag flag that enables / disables bit reversal of output
  44. - value = 0: disables bit reversal of output
  45. - value = 1: enables bit reversal of output
  46. @return execution status
  47. - \ref ARM_MATH_SUCCESS : Operation successful
  48. - \ref ARM_MATH_ARGUMENT_ERROR : <code>fftLen</code> is not a supported length
  49. @par Details
  50. The parameter <code>ifftFlag</code> controls whether a forward or inverse transform is computed.
  51. Set(=1) ifftFlag for calculation of CIFFT otherwise CFFT is calculated
  52. @par
  53. The parameter <code>bitReverseFlag</code> controls whether output is in normal order or bit reversed order.
  54. Set(=1) bitReverseFlag for output to be in normal order otherwise output is in bit reversed order.
  55. @par
  56. The parameter <code>fftLen</code> Specifies length of CFFT/CIFFT process. Supported FFT Lengths are 16, 64, 256, 1024.
  57. @par
  58. This Function also initializes Twiddle factor table pointer and Bit reversal table pointer.
  59. */
  60. #if defined(ARM_FLOAT16_SUPPORTED)
  61. arm_status arm_cfft_radix2_init_f16(
  62. arm_cfft_radix2_instance_f16 * S,
  63. uint16_t fftLen,
  64. uint8_t ifftFlag,
  65. uint8_t bitReverseFlag)
  66. {
  67. /* Initialise the default arm status */
  68. arm_status status = ARM_MATH_ARGUMENT_ERROR;
  69. /* Initialise the default arm status */
  70. status = ARM_MATH_SUCCESS;
  71. /* Initialise the FFT length */
  72. S->fftLen = fftLen;
  73. /* Initialise the Twiddle coefficient pointer */
  74. S->pTwiddle = (float16_t *) twiddleCoefF16_4096;
  75. /* Initialise the Flag for selection of CFFT or CIFFT */
  76. S->ifftFlag = ifftFlag;
  77. /* Initialise the Flag for calculation Bit reversal or not */
  78. S->bitReverseFlag = bitReverseFlag;
  79. /* Initializations of structure parameters depending on the FFT length */
  80. switch (S->fftLen)
  81. {
  82. case 4096U:
  83. /* Initializations of structure parameters for 4096 point FFT */
  84. /* Initialise the twiddle coef modifier value */
  85. S->twidCoefModifier = 1U;
  86. /* Initialise the bit reversal table modifier */
  87. S->bitRevFactor = 1U;
  88. /* Initialise the bit reversal table pointer */
  89. S->pBitRevTable = (uint16_t *) armBitRevTable;
  90. /* Initialise the 1/fftLen Value */
  91. S->onebyfftLen = 0.000244140625;
  92. break;
  93. case 2048U:
  94. /* Initializations of structure parameters for 2048 point FFT */
  95. /* Initialise the twiddle coef modifier value */
  96. S->twidCoefModifier = 2U;
  97. /* Initialise the bit reversal table modifier */
  98. S->bitRevFactor = 2U;
  99. /* Initialise the bit reversal table pointer */
  100. S->pBitRevTable = (uint16_t *) & armBitRevTable[1];
  101. /* Initialise the 1/fftLen Value */
  102. S->onebyfftLen = 0.00048828125;
  103. break;
  104. case 1024U:
  105. /* Initializations of structure parameters for 1024 point FFT */
  106. /* Initialise the twiddle coef modifier value */
  107. S->twidCoefModifier = 4U;
  108. /* Initialise the bit reversal table modifier */
  109. S->bitRevFactor = 4U;
  110. /* Initialise the bit reversal table pointer */
  111. S->pBitRevTable = (uint16_t *) & armBitRevTable[3];
  112. /* Initialise the 1/fftLen Value */
  113. S->onebyfftLen = 0.0009765625f;
  114. break;
  115. case 512U:
  116. /* Initializations of structure parameters for 512 point FFT */
  117. /* Initialise the twiddle coef modifier value */
  118. S->twidCoefModifier = 8U;
  119. /* Initialise the bit reversal table modifier */
  120. S->bitRevFactor = 8U;
  121. /* Initialise the bit reversal table pointer */
  122. S->pBitRevTable = (uint16_t *) & armBitRevTable[7];
  123. /* Initialise the 1/fftLen Value */
  124. S->onebyfftLen = 0.001953125;
  125. break;
  126. case 256U:
  127. /* Initializations of structure parameters for 256 point FFT */
  128. S->twidCoefModifier = 16U;
  129. S->bitRevFactor = 16U;
  130. S->pBitRevTable = (uint16_t *) & armBitRevTable[15];
  131. S->onebyfftLen = 0.00390625f;
  132. break;
  133. case 128U:
  134. /* Initializations of structure parameters for 128 point FFT */
  135. S->twidCoefModifier = 32U;
  136. S->bitRevFactor = 32U;
  137. S->pBitRevTable = (uint16_t *) & armBitRevTable[31];
  138. S->onebyfftLen = 0.0078125;
  139. break;
  140. case 64U:
  141. /* Initializations of structure parameters for 64 point FFT */
  142. S->twidCoefModifier = 64U;
  143. S->bitRevFactor = 64U;
  144. S->pBitRevTable = (uint16_t *) & armBitRevTable[63];
  145. S->onebyfftLen = 0.015625f;
  146. break;
  147. case 32U:
  148. /* Initializations of structure parameters for 64 point FFT */
  149. S->twidCoefModifier = 128U;
  150. S->bitRevFactor = 128U;
  151. S->pBitRevTable = (uint16_t *) & armBitRevTable[127];
  152. S->onebyfftLen = 0.03125;
  153. break;
  154. case 16U:
  155. /* Initializations of structure parameters for 16 point FFT */
  156. S->twidCoefModifier = 256U;
  157. S->bitRevFactor = 256U;
  158. S->pBitRevTable = (uint16_t *) & armBitRevTable[255];
  159. S->onebyfftLen = 0.0625f;
  160. break;
  161. default:
  162. /* Reporting argument error if fftSize is not valid value */
  163. status = ARM_MATH_ARGUMENT_ERROR;
  164. break;
  165. }
  166. return (status);
  167. }
  168. #endif /* #if defined(ARM_FLOAT16_SUPPORTED) */
  169. /**
  170. @} end of ComplexFFTDeprecated group
  171. */