scheduler.cpp 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  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_bench.h"
  8. #include "GenericNodes.h"
  9. #include "BenchAppNodes.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,float32_t* inputArray,
  99. float32_t* outputArray)
  100. {
  101. int cgStaticError=0;
  102. uint32_t nbSchedule=0;
  103. int32_t debugCounter=10;
  104. CG_BEFORE_FIFO_INIT;
  105. /*
  106. Create FIFOs objects
  107. */
  108. FIFO<float32_t,FIFOSIZE0,0,1> fifo0(buf1);
  109. FIFO<float32_t,FIFOSIZE1,0,1> fifo1(buf2);
  110. FIFO<float32_t,FIFOSIZE2,0,1> fifo2(buf3);
  111. FIFO<float32_t,FIFOSIZE3,0,1> fifo3(buf4);
  112. FIFO<float32_t,FIFOSIZE4,0,1> fifo4(buf5);
  113. FIFO<float32_t,FIFOSIZE5,0,1> fifo5(buf6);
  114. FIFO<float32_t,FIFOSIZE6,0,1> fifo6(buf7);
  115. FIFO<float32_t,FIFOSIZE7,0,1> fifo7(buf8);
  116. CG_BEFORE_NODE_INIT;
  117. /*
  118. Create node objects
  119. */
  120. OverlapAdd<float32_t,256,128> audioOverlap(fifo6,fifo7);
  121. SlidingBuffer<float32_t,256,128> audioWin(fifo0,fifo1);
  122. CFFT<float32_t,512,float32_t,512> cfft(fifo3,fifo4);
  123. ICFFT<float32_t,512,float32_t,512> icfft(fifo4,fifo5);
  124. ArraySink<float32_t,192> sink(fifo7,outputArray);
  125. ArraySource<float32_t,192> src(fifo0,inputArray);
  126. ToComplex<float32_t,256,float32_t,512> toCmplx(fifo2,fifo3);
  127. ToReal<float32_t,512,float32_t,256> toReal(fifo5,fifo6);
  128. /* Run several schedule iterations */
  129. CG_BEFORE_SCHEDULE;
  130. while((cgStaticError==0) && (debugCounter > 0))
  131. {
  132. /* Run a schedule iteration */
  133. CG_BEFORE_ITERATION;
  134. for(unsigned long id=0 ; id < 25; id++)
  135. {
  136. CG_BEFORE_NODE_EXECUTION;
  137. cgStaticError = 0;
  138. switch(schedule[id])
  139. {
  140. case 0:
  141. {
  142. bool canRun=true;
  143. canRun &= !fifo1.willUnderflowWith(256);
  144. canRun &= !fifo2.willOverflowWith(256);
  145. if (!canRun)
  146. {
  147. cgStaticError = CG_SKIP_EXECUTION_ID_CODE;
  148. }
  149. else
  150. {
  151. cgStaticError = 0;
  152. }
  153. }
  154. break;
  155. case 1:
  156. {
  157. cgStaticError = audioOverlap.prepareForRunning();
  158. }
  159. break;
  160. case 2:
  161. {
  162. cgStaticError = audioWin.prepareForRunning();
  163. }
  164. break;
  165. case 3:
  166. {
  167. cgStaticError = cfft.prepareForRunning();
  168. }
  169. break;
  170. case 4:
  171. {
  172. cgStaticError = icfft.prepareForRunning();
  173. }
  174. break;
  175. case 5:
  176. {
  177. cgStaticError = sink.prepareForRunning();
  178. }
  179. break;
  180. case 6:
  181. {
  182. cgStaticError = src.prepareForRunning();
  183. }
  184. break;
  185. case 7:
  186. {
  187. cgStaticError = toCmplx.prepareForRunning();
  188. }
  189. break;
  190. case 8:
  191. {
  192. cgStaticError = toReal.prepareForRunning();
  193. }
  194. break;
  195. default:
  196. break;
  197. }
  198. if (cgStaticError == CG_SKIP_EXECUTION_ID_CODE)
  199. {
  200. cgStaticError = 0;
  201. continue;
  202. }
  203. CHECKERROR;
  204. switch(schedule[id])
  205. {
  206. case 0:
  207. {
  208. {
  209. float32_t* i0;
  210. float32_t* o2;
  211. i0=fifo1.getReadBuffer(256);
  212. o2=fifo2.getWriteBuffer(256);
  213. arm_mult_f32(i0,HANN,o2,256);
  214. cgStaticError = 0;
  215. }
  216. }
  217. break;
  218. case 1:
  219. {
  220. cgStaticError = audioOverlap.run();
  221. }
  222. break;
  223. case 2:
  224. {
  225. cgStaticError = audioWin.run();
  226. }
  227. break;
  228. case 3:
  229. {
  230. cgStaticError = cfft.run();
  231. }
  232. break;
  233. case 4:
  234. {
  235. cgStaticError = icfft.run();
  236. }
  237. break;
  238. case 5:
  239. {
  240. cgStaticError = sink.run();
  241. }
  242. break;
  243. case 6:
  244. {
  245. cgStaticError = src.run();
  246. }
  247. break;
  248. case 7:
  249. {
  250. cgStaticError = toCmplx.run();
  251. }
  252. break;
  253. case 8:
  254. {
  255. cgStaticError = toReal.run();
  256. }
  257. break;
  258. default:
  259. break;
  260. }
  261. CG_AFTER_NODE_EXECUTION;
  262. CHECKERROR;
  263. }
  264. debugCounter--;
  265. CG_AFTER_ITERATION;
  266. nbSchedule++;
  267. }
  268. errorHandling:
  269. CG_AFTER_SCHEDULE;
  270. *error=cgStaticError;
  271. return(nbSchedule);
  272. }