BenchAppNodes.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /* ----------------------------------------------------------------------
  2. * Project: CMSIS DSP Library
  3. * Title: AppNodes.h
  4. * Description: Application nodes for Example 1
  5. *
  6. * $Date: 29 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 _APPNODES_H_
  29. #define _APPNODES_H_
  30. #include <cstdio>
  31. #include "arm_math.h"
  32. #include "cg_status.h"
  33. #include "CFFT.h"
  34. #include "ICFFT.h"
  35. #include "ToComplex.h"
  36. #include "ToReal.h"
  37. #include "SlidingBuffer.h"
  38. #include "OverlapAndAdd.h"
  39. template<typename IN, int inputSize>
  40. class ArraySink:public GenericSink<IN, inputSize>
  41. {
  42. public:
  43. ArraySink(FIFOBase<IN> &src,IN* outputBuf):
  44. GenericSink<IN,inputSize>(src),mOutputBuf(outputBuf){
  45. };
  46. int prepareForRunning() final
  47. {
  48. if (this->willUnderflow())
  49. {
  50. return(CG_SKIP_EXECUTION_ID_CODE); // Skip execution
  51. }
  52. return(0);
  53. };
  54. int run() final
  55. {
  56. IN *b=this->getReadBuffer();
  57. memcpy(mOutputBuf,b,sizeof(IN)*inputSize);
  58. return(0);
  59. };
  60. protected:
  61. IN* mOutputBuf;
  62. };
  63. template<typename OUT,int outputSize>
  64. class ArraySource: GenericSource<OUT,outputSize>
  65. {
  66. public:
  67. ArraySource(FIFOBase<OUT> &dst, OUT *inputBuf):
  68. GenericSource<OUT,outputSize>(dst),mInputBuf(inputBuf){};
  69. int prepareForRunning() final
  70. {
  71. if (this->willOverflow())
  72. {
  73. return(CG_SKIP_EXECUTION_ID_CODE); // Skip execution
  74. }
  75. return(0);
  76. };
  77. int run() final{
  78. OUT *b=this->getWriteBuffer();
  79. memcpy(b,mInputBuf,sizeof(OUT)*outputSize);
  80. return(0);
  81. };
  82. protected:
  83. OUT *mInputBuf;
  84. };
  85. #endif