scheduler.cpp 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  1. /*
  2. Generated with CMSIS-DSP Compute Graph Scripts.
  3. The generated code is not covered by CMSIS-DSP license.
  4. The support classes and code is covered by CMSIS-DSP license.
  5. */
  6. #include "arm_math.h"
  7. #include "custom.h"
  8. #include "GenericNodes.h"
  9. #include "AppNodes.h"
  10. #include "scheduler.h"
  11. #if !defined(CHECKERROR)
  12. #define CHECKERROR if (cgStaticError < 0) \
  13. {\
  14. goto errorHandling;\
  15. }
  16. #endif
  17. #if !defined(CG_BEFORE_ITERATION)
  18. #define CG_BEFORE_ITERATION
  19. #endif
  20. #if !defined(CG_AFTER_ITERATION)
  21. #define CG_AFTER_ITERATION
  22. #endif
  23. #if !defined(CG_BEFORE_SCHEDULE)
  24. #define CG_BEFORE_SCHEDULE
  25. #endif
  26. #if !defined(CG_AFTER_SCHEDULE)
  27. #define CG_AFTER_SCHEDULE
  28. #endif
  29. #if !defined(CG_BEFORE_BUFFER)
  30. #define CG_BEFORE_BUFFER
  31. #endif
  32. #if !defined(CG_BEFORE_FIFO_BUFFERS)
  33. #define CG_BEFORE_FIFO_BUFFERS
  34. #endif
  35. #if !defined(CG_BEFORE_FIFO_INIT)
  36. #define CG_BEFORE_FIFO_INIT
  37. #endif
  38. #if !defined(CG_BEFORE_NODE_INIT)
  39. #define CG_BEFORE_NODE_INIT
  40. #endif
  41. #if !defined(CG_AFTER_INCLUDES)
  42. #define CG_AFTER_INCLUDES
  43. #endif
  44. #if !defined(CG_BEFORE_SCHEDULER_FUNCTION)
  45. #define CG_BEFORE_SCHEDULER_FUNCTION
  46. #endif
  47. #if !defined(CG_BEFORE_NODE_EXECUTION)
  48. #define CG_BEFORE_NODE_EXECUTION
  49. #endif
  50. #if !defined(CG_AFTER_NODE_EXECUTION)
  51. #define CG_AFTER_NODE_EXECUTION
  52. #endif
  53. CG_AFTER_INCLUDES
  54. /*
  55. Description of the scheduling.
  56. */
  57. static unsigned int schedule[25]=
  58. {
  59. 6,2,0,7,3,4,8,1,6,2,0,7,3,4,8,1,5,2,0,7,3,4,8,1,5,
  60. };
  61. CG_BEFORE_FIFO_BUFFERS
  62. /***********
  63. FIFO buffers
  64. ************/
  65. #define FIFOSIZE0 256
  66. #define FIFOSIZE1 256
  67. #define FIFOSIZE2 256
  68. #define FIFOSIZE3 512
  69. #define FIFOSIZE4 512
  70. #define FIFOSIZE5 512
  71. #define FIFOSIZE6 256
  72. #define FIFOSIZE7 256
  73. #define BUFFERSIZE1 256
  74. CG_BEFORE_BUFFER
  75. float32_t buf1[BUFFERSIZE1]={0};
  76. #define BUFFERSIZE2 256
  77. CG_BEFORE_BUFFER
  78. float32_t buf2[BUFFERSIZE2]={0};
  79. #define BUFFERSIZE3 256
  80. CG_BEFORE_BUFFER
  81. float32_t buf3[BUFFERSIZE3]={0};
  82. #define BUFFERSIZE4 512
  83. CG_BEFORE_BUFFER
  84. float32_t buf4[BUFFERSIZE4]={0};
  85. #define BUFFERSIZE5 512
  86. CG_BEFORE_BUFFER
  87. float32_t buf5[BUFFERSIZE5]={0};
  88. #define BUFFERSIZE6 512
  89. CG_BEFORE_BUFFER
  90. float32_t buf6[BUFFERSIZE6]={0};
  91. #define BUFFERSIZE7 256
  92. CG_BEFORE_BUFFER
  93. float32_t buf7[BUFFERSIZE7]={0};
  94. #define BUFFERSIZE8 256
  95. CG_BEFORE_BUFFER
  96. float32_t buf8[BUFFERSIZE8]={0};
  97. CG_BEFORE_SCHEDULER_FUNCTION
  98. uint32_t scheduler(int *error)
  99. {
  100. int cgStaticError=0;
  101. uint32_t nbSchedule=0;
  102. int32_t debugCounter=40;
  103. CG_BEFORE_FIFO_INIT;
  104. /*
  105. Create FIFOs objects
  106. */
  107. FIFO<float32_t,FIFOSIZE0,0,1> fifo0(buf1);
  108. FIFO<float32_t,FIFOSIZE1,0,1> fifo1(buf2);
  109. FIFO<float32_t,FIFOSIZE2,0,1> fifo2(buf3);
  110. FIFO<float32_t,FIFOSIZE3,0,1> fifo3(buf4);
  111. FIFO<float32_t,FIFOSIZE4,0,1> fifo4(buf5);
  112. FIFO<float32_t,FIFOSIZE5,0,1> fifo5(buf6);
  113. FIFO<float32_t,FIFOSIZE6,0,1> fifo6(buf7);
  114. FIFO<float32_t,FIFOSIZE7,0,1> fifo7(buf8);
  115. CG_BEFORE_NODE_INIT;
  116. /*
  117. Create node objects
  118. */
  119. OverlapAdd<float32_t,256,128> audioOverlap(fifo6,fifo7);
  120. SlidingBuffer<float32_t,256,128> audioWin(fifo0,fifo1);
  121. CFFT<float32_t,512,float32_t,512> cfft(fifo3,fifo4);
  122. ICFFT<float32_t,512,float32_t,512> icfft(fifo4,fifo5);
  123. FileSink<float32_t,192> sink(fifo7,"output_example3.txt");
  124. FileSource<float32_t,192> src(fifo0,"input_example3.txt");
  125. ToComplex<float32_t,256,float32_t,512> toCmplx(fifo2,fifo3);
  126. ToReal<float32_t,512,float32_t,256> toReal(fifo5,fifo6);
  127. /* Run several schedule iterations */
  128. CG_BEFORE_SCHEDULE;
  129. while((cgStaticError==0) && (debugCounter > 0))
  130. {
  131. /* Run a schedule iteration */
  132. CG_BEFORE_ITERATION;
  133. for(unsigned long id=0 ; id < 25; id++)
  134. {
  135. CG_BEFORE_NODE_EXECUTION;
  136. cgStaticError = 0;
  137. switch(schedule[id])
  138. {
  139. case 0:
  140. {
  141. bool canRun=true;
  142. canRun &= !fifo1.willUnderflowWith(256);
  143. canRun &= !fifo2.willOverflowWith(256);
  144. if (!canRun)
  145. {
  146. cgStaticError = CG_SKIP_EXECUTION_ID_CODE;
  147. }
  148. else
  149. {
  150. cgStaticError = 0;
  151. }
  152. }
  153. break;
  154. case 1:
  155. {
  156. cgStaticError = audioOverlap.prepareForRunning();
  157. }
  158. break;
  159. case 2:
  160. {
  161. cgStaticError = audioWin.prepareForRunning();
  162. }
  163. break;
  164. case 3:
  165. {
  166. cgStaticError = cfft.prepareForRunning();
  167. }
  168. break;
  169. case 4:
  170. {
  171. cgStaticError = icfft.prepareForRunning();
  172. }
  173. break;
  174. case 5:
  175. {
  176. cgStaticError = sink.prepareForRunning();
  177. }
  178. break;
  179. case 6:
  180. {
  181. cgStaticError = src.prepareForRunning();
  182. }
  183. break;
  184. case 7:
  185. {
  186. cgStaticError = toCmplx.prepareForRunning();
  187. }
  188. break;
  189. case 8:
  190. {
  191. cgStaticError = toReal.prepareForRunning();
  192. }
  193. break;
  194. default:
  195. break;
  196. }
  197. if (cgStaticError == CG_SKIP_EXECUTION_ID_CODE)
  198. continue;
  199. CHECKERROR;
  200. switch(schedule[id])
  201. {
  202. case 0:
  203. {
  204. {
  205. float32_t* i0;
  206. float32_t* o2;
  207. i0=fifo1.getReadBuffer(256);
  208. o2=fifo2.getWriteBuffer(256);
  209. arm_mult_f32(i0,HANN,o2,256);
  210. cgStaticError = 0;
  211. }
  212. }
  213. break;
  214. case 1:
  215. {
  216. cgStaticError = audioOverlap.run();
  217. }
  218. break;
  219. case 2:
  220. {
  221. cgStaticError = audioWin.run();
  222. }
  223. break;
  224. case 3:
  225. {
  226. cgStaticError = cfft.run();
  227. }
  228. break;
  229. case 4:
  230. {
  231. cgStaticError = icfft.run();
  232. }
  233. break;
  234. case 5:
  235. {
  236. cgStaticError = sink.run();
  237. }
  238. break;
  239. case 6:
  240. {
  241. cgStaticError = src.run();
  242. }
  243. break;
  244. case 7:
  245. {
  246. cgStaticError = toCmplx.run();
  247. }
  248. break;
  249. case 8:
  250. {
  251. cgStaticError = toReal.run();
  252. }
  253. break;
  254. default:
  255. break;
  256. }
  257. CG_AFTER_NODE_EXECUTION;
  258. CHECKERROR;
  259. }
  260. debugCounter--;
  261. CG_AFTER_ITERATION;
  262. nbSchedule++;
  263. }
  264. errorHandling:
  265. CG_AFTER_SCHEDULE;
  266. *error=cgStaticError;
  267. return(nbSchedule);
  268. }