ComplexAppNodes.h 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  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 <cstring>
  31. #include <cstdio>
  32. template<typename IN, int inputSize>
  33. class Sink;
  34. template<int inputSize>
  35. class Sink<float32_t,inputSize>:
  36. public GenericSink<float32_t, inputSize>
  37. {
  38. public:
  39. Sink(FIFOBase<float32_t> &src):
  40. GenericSink<float32_t,inputSize>(src){
  41. };
  42. int prepareForRunning() final
  43. {
  44. if (this->willUnderflow())
  45. {
  46. return(CG_SKIP_EXECUTION_ID_CODE); // Skip execution
  47. }
  48. return(0);
  49. };
  50. int run() final
  51. {
  52. float32_t *b=this->getReadBuffer();
  53. (void)b;
  54. return(0);
  55. };
  56. };
  57. template<typename OUT,int outputSize>
  58. class Source;
  59. template<int outputSize>
  60. class Source<float32_t,outputSize>: GenericSource<float32_t,outputSize>
  61. {
  62. public:
  63. Source(FIFOBase<float32_t> &dst):
  64. GenericSource<float32_t,outputSize>(dst){};
  65. int prepareForRunning() final
  66. {
  67. if (this->willOverflow())
  68. {
  69. return(CG_SKIP_EXECUTION_ID_CODE); // Skip execution
  70. }
  71. return(0);
  72. };
  73. int run() final{
  74. float32_t *b=this->getWriteBuffer();
  75. (void)b;
  76. return(0);
  77. };
  78. };
  79. template<typename IN, int inputSize,typename OUT,int outputSize>
  80. class ProcessingNode;
  81. template<int inputSize,int outputSize>
  82. class ProcessingNode<float32_t,inputSize,
  83. float32_t,outputSize>:
  84. public GenericNode<float32_t,inputSize,
  85. float32_t,outputSize>
  86. {
  87. public:
  88. ProcessingNode(FIFOBase<float32_t> &src,
  89. FIFOBase<float32_t> &dst):
  90. GenericNode<float32_t,inputSize,
  91. float32_t,outputSize>(src,dst){};
  92. int prepareForRunning() final
  93. {
  94. if (this->willOverflow() ||
  95. this->willUnderflow())
  96. {
  97. return(CG_SKIP_EXECUTION_ID_CODE); // Skip execution
  98. }
  99. return(0);
  100. };
  101. int run() final{
  102. float32_t *a=this->getReadBuffer();
  103. float32_t *b=this->getWriteBuffer();
  104. (void)a;
  105. (void)b;
  106. return(0);
  107. };
  108. };
  109. template<typename IN, int inputSize,
  110. typename OUTA,int outputSizeA,
  111. typename OUTB,int outputSizeB>
  112. class ProcessingNode12:public GenericNode12<IN, inputSize,
  113. OUTA,outputSizeA,
  114. OUTB,outputSizeB>
  115. {
  116. public:
  117. ProcessingNode12(FIFOBase<IN> &src,
  118. FIFOBase<OUTA> &dst1,
  119. FIFOBase<OUTB> &dst2):
  120. GenericNode12<IN,inputSize,
  121. OUTA,outputSizeA,
  122. OUTB,outputSizeB>(src,dst1,dst2){};
  123. int prepareForRunning() final
  124. {
  125. if (this->willOverflow1() ||
  126. this->willOverflow2() ||
  127. this->willUnderflow())
  128. {
  129. return(CG_SKIP_EXECUTION_ID_CODE); // Skip execution
  130. }
  131. return(0);
  132. };
  133. int run() final{
  134. IN *a=this->getReadBuffer();
  135. OUTA *ba=this->getWriteBuffer1();
  136. OUTB *bb=this->getWriteBuffer2();
  137. (void)a;
  138. (void)ba;
  139. (void)bb;
  140. return(0);
  141. };
  142. };
  143. template<typename IN, int inputSize,
  144. typename OUTA,int outputSizeA,
  145. typename OUTB,int outputSizeB,
  146. typename OUTC,int outputSizeC>
  147. class ProcessingNode13:public GenericNode13<IN,inputSize,
  148. OUTA,outputSizeA,
  149. OUTB,outputSizeB,
  150. OUTC,outputSizeC>
  151. {
  152. public:
  153. ProcessingNode13(FIFOBase<IN> &src,
  154. FIFOBase<OUTA> &dst1,
  155. FIFOBase<OUTB> &dst2,
  156. FIFOBase<OUTC> &dst3):
  157. GenericNode13<IN,inputSize,
  158. OUTA,outputSizeA,
  159. OUTB,outputSizeB,
  160. OUTC,outputSizeC>(src,dst1,dst2,dst3){};
  161. int prepareForRunning() final
  162. {
  163. if (this->willOverflow1() ||
  164. this->willOverflow2() ||
  165. this->willOverflow3() ||
  166. this->willUnderflow())
  167. {
  168. return(CG_SKIP_EXECUTION_ID_CODE); // Skip execution
  169. }
  170. return(0);
  171. };
  172. int run() final{
  173. IN *a=this->getReadBuffer();
  174. OUTA *ba=this->getWriteBuffer1();
  175. OUTB *bb=this->getWriteBuffer2();
  176. OUTC *bc=this->getWriteBuffer3();
  177. (void)a;
  178. (void)ba;
  179. (void)bb;
  180. (void)bc;
  181. return(0);
  182. };
  183. };
  184. template<typename INA, int inputSizeA,
  185. typename INB, int inputSizeB,
  186. typename OUT, int outputSize
  187. >
  188. class ProcessingNode21:
  189. public GenericNode21<INA,inputSizeA,
  190. INB,inputSizeB,
  191. OUT,outputSize>
  192. {
  193. public:
  194. ProcessingNode21(FIFOBase<INA> &srcA,
  195. FIFOBase<INB> &srcB,
  196. FIFOBase<OUT> &dst):GenericNode21<INA,inputSizeA,
  197. INB,inputSizeB,
  198. OUT,outputSize>(srcA,srcB,dst){};
  199. int prepareForRunning() final
  200. {
  201. if (this->willOverflow() ||
  202. this->willUnderflow1() ||
  203. this->willUnderflow2())
  204. {
  205. return(CG_SKIP_EXECUTION_ID_CODE); // Skip execution
  206. }
  207. return(0);
  208. };
  209. int run() final{
  210. printf("ProcessingNode\n");
  211. INA *a=this->getReadBuffer1();
  212. INB *b=this->getReadBuffer2();
  213. OUT *c=this->getWriteBuffer();
  214. (void)a;
  215. (void)b;
  216. (void)c;
  217. return(0);
  218. };
  219. };
  220. #endif