AppNodes.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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 <iostream>
  31. template<typename IN, int inputSize>
  32. class Sink: public GenericSink<IN, inputSize>
  33. {
  34. public:
  35. Sink(FIFOBase<IN> &src):GenericSink<IN,inputSize>(src){};
  36. int run()
  37. {
  38. IN *b=this->getReadBuffer();
  39. printf("Sink\n");
  40. for(int i=0;i<inputSize;i++)
  41. {
  42. std::cout << (int)b[i] << std::endl;
  43. }
  44. return(0);
  45. };
  46. };
  47. template<typename OUT,int outputSize>
  48. class Source: GenericSource<OUT,outputSize>
  49. {
  50. public:
  51. Source(FIFOBase<OUT> &dst):GenericSource<OUT,outputSize>(dst),mCounter(0){};
  52. int run(){
  53. OUT *b=this->getWriteBuffer();
  54. printf("Source\n");
  55. for(int i=0;i<outputSize;i++)
  56. {
  57. b[i] = (OUT)mCounter++;
  58. }
  59. return(0);
  60. };
  61. int mCounter;
  62. };
  63. template<typename IN, int inputSize,typename OUT,int outputSize>
  64. class ProcessingNode: public GenericNode<IN,inputSize,OUT,outputSize>
  65. {
  66. public:
  67. ProcessingNode(FIFOBase<IN> &src,FIFOBase<OUT> &dst,int,const char*,int):GenericNode<IN,inputSize,OUT,outputSize>(src,dst){};
  68. int run(){
  69. printf("ProcessingNode\n");
  70. IN *a=this->getReadBuffer();
  71. OUT *b=this->getWriteBuffer();
  72. b[0] =(OUT)a[3];
  73. return(0);
  74. };
  75. };
  76. #endif