ICFFT.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /* ----------------------------------------------------------------------
  2. * Project: CMSIS DSP Library
  3. * Title: ICFFT.h
  4. * Description: Node for CMSIS-DSP icfft
  5. *
  6. * $Date: 30 July 2021
  7. * $Revision: V1.10.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. #ifndef _ICFFT_H_
  29. #define _ICFFT_H_
  30. template<typename IN, int inputSize,typename OUT,int outputSize>
  31. class ICFFT;
  32. /*
  33. The CMSIS-DSP ICFFT F32
  34. */
  35. template<int inputSize>
  36. class ICFFT<float32_t,inputSize,float32_t,inputSize>: public GenericNode<float32_t,inputSize,float32_t,inputSize>
  37. {
  38. public:
  39. ICFFT(FIFOBase<float32_t> &src,FIFOBase<float32_t> &dst):GenericNode<float32_t,inputSize,float32_t,inputSize>(src,dst){
  40. arm_status status;
  41. status=arm_cfft_init_f32(&sifft,inputSize>>1);
  42. };
  43. int run(){
  44. float32_t *a=this->getReadBuffer();
  45. float32_t *b=this->getWriteBuffer();
  46. memcpy((void*)b,(void*)a,inputSize*sizeof(float32_t));
  47. arm_cfft_f32(&sifft,b,1,1);
  48. return(0);
  49. };
  50. arm_cfft_instance_f32 sifft;
  51. };
  52. #if defined(ARM_FLOAT16_SUPPORTED)
  53. /*
  54. The CMSIS-DSP ICFFT F32
  55. */
  56. template<int inputSize>
  57. class ICFFT<float16_t,inputSize,float16_t,inputSize>: public GenericNode<float16_t,inputSize,float16_t,inputSize>
  58. {
  59. public:
  60. ICFFT(FIFOBase<float16_t> &src,FIFOBase<float16_t> &dst):GenericNode<float16_t,inputSize,float16_t,inputSize>(src,dst){
  61. arm_status status;
  62. status=arm_cfft_init_f16(&sifft,inputSize>>1);
  63. };
  64. int run(){
  65. float16_t *a=this->getReadBuffer();
  66. float16_t *b=this->getWriteBuffer();
  67. memcpy((void*)b,(void*)a,inputSize*sizeof(float16_t));
  68. arm_cfft_f16(&sifft,b,1,1);
  69. return(0);
  70. };
  71. arm_cfft_instance_f16 sifft;
  72. };
  73. #endif
  74. /*
  75. The CMSIS-DSP ICFFT Q15
  76. */
  77. template<int inputSize>
  78. class ICFFT<q15_t,inputSize,q15_t,inputSize>: public GenericNode<q15_t,inputSize,q15_t,inputSize>
  79. {
  80. public:
  81. ICFFT(FIFOBase<q15_t> &src,FIFOBase<q15_t> &dst):GenericNode<q15_t,inputSize,q15_t,inputSize>(src,dst){
  82. arm_status status;
  83. status=arm_cfft_init_q15(&sifft,inputSize>>1);
  84. };
  85. int run(){
  86. q15_t *a=this->getReadBuffer();
  87. q15_t *b=this->getWriteBuffer();
  88. memcpy((void*)b,(void*)a,inputSize*sizeof(q15_t));
  89. arm_cfft_q15(&sifft,b,1,1);
  90. return(0);
  91. };
  92. arm_cfft_instance_f32 sifft;
  93. };
  94. #endif