ToReal.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /* ----------------------------------------------------------------------
  2. * Project: CMSIS DSP Library
  3. * Title: ToReal.h
  4. * Description: Node to convert complex to reals
  5. *
  6. *
  7. * Target Processor: Cortex-M and Cortex-A cores
  8. * --------------------------------------------------------------------
  9. *
  10. * Copyright (C) 2021-2023 ARM Limited or its affiliates. All rights reserved.
  11. *
  12. * SPDX-License-Identifier: Apache-2.0
  13. *
  14. * Licensed under the Apache License, Version 2.0 (the License); you may
  15. * not use this file except in compliance with the License.
  16. * You may obtain a copy of the License at
  17. *
  18. * www.apache.org/licenses/LICENSE-2.0
  19. *
  20. * Unless required by applicable law or agreed to in writing, software
  21. * distributed under the License is distributed on an AS IS BASIS, WITHOUT
  22. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  23. * See the License for the specific language governing permissions and
  24. * limitations under the License.
  25. */
  26. #ifndef _TOREAL_H_
  27. #define _TOREAL_H_
  28. /*
  29. Convert a stream of complex a 0 b 0 c 0 ...
  30. to reals a b c ...
  31. */
  32. template<typename IN, int inputSize,typename OUT,int outputSize>
  33. class ToReal;
  34. template<typename IN, int inputSize,int outputSize>
  35. class ToReal<IN,inputSize,IN,outputSize>: public GenericNode<IN,inputSize,IN,outputSize>
  36. {
  37. public:
  38. ToReal(FIFOBase<IN> &src,FIFOBase<IN> &dst):GenericNode<IN,inputSize,IN,outputSize>(src,dst){
  39. };
  40. int prepareForRunning() final
  41. {
  42. if (this->willOverflow() ||
  43. this->willUnderflow()
  44. )
  45. {
  46. return(CG_SKIP_EXECUTION_ID_CODE); // Skip execution
  47. }
  48. return(0);
  49. };
  50. int run() final
  51. {
  52. IN *a=this->getReadBuffer();
  53. IN *b=this->getWriteBuffer();
  54. for(int i=0;i<outputSize;i++)
  55. {
  56. b[i]=a[2*i];
  57. }
  58. return(0);
  59. };
  60. };
  61. #endif