scheduler.cpp 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. /*
  2. Generated with CMSIS-DSP SDF 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. /* List of nodes */
  12. static NodeBase *nodeArray[7]={0};
  13. /*
  14. Description of the scheduling. It is a list of nodes to call.
  15. The values are indexes in the previous array.
  16. */
  17. static unsigned int schedule[151]=
  18. {
  19. 6,0,1,6,0,1,6,0,1,6,0,1,6,0,1,6,0,1,6,0,1,6,0,1,6,0,1,6,0,1,6,0,1,6,0,1,6,0,1,6,
  20. 0,1,6,0,1,6,0,1,6,0,1,6,0,1,6,0,1,6,0,1,6,0,1,6,0,1,6,0,1,6,0,1,6,0,1,6,0,1,6,0,
  21. 1,6,0,1,6,0,1,6,0,1,6,0,1,6,0,1,6,0,1,6,0,1,6,0,1,6,0,1,6,0,1,6,0,1,6,0,1,6,0,1,
  22. 6,0,1,6,0,1,6,0,1,6,0,1,6,0,1,6,0,1,6,0,1,6,0,1,6,0,1,2,3,4,5,
  23. };
  24. /***********
  25. FIFO buffers
  26. ************/
  27. #define FIFOSIZE0 160
  28. #define FIFOSIZE1 400
  29. #define FIFOSIZE2 49
  30. #define FIFOSIZE3 98
  31. #define FIFOSIZE4 98
  32. #define FIFOSIZE5 1
  33. #define BUFFERSIZE0 160
  34. q15_t buf0[BUFFERSIZE0]={0};
  35. #define BUFFERSIZE1 400
  36. q15_t buf1[BUFFERSIZE1]={0};
  37. #define BUFFERSIZE2 49
  38. q15_t buf2[BUFFERSIZE2]={0};
  39. #define BUFFERSIZE3 98
  40. q15_t buf3[BUFFERSIZE3]={0};
  41. #define BUFFERSIZE4 98
  42. q15_t buf4[BUFFERSIZE4]={0};
  43. #define BUFFERSIZE5 1
  44. q15_t buf5[BUFFERSIZE5]={0};
  45. /**************
  46. Classes created for pure function calls (like some CMSIS-DSP functions)
  47. ***************/
  48. uint32_t scheduler(int *error,const q15_t *window,
  49. const q15_t *coef_q15,
  50. const int coef_shift,
  51. const q15_t intercept_q15,
  52. const int intercept_shift)
  53. {
  54. int sdfError=0;
  55. uint32_t nbSchedule=0;
  56. /*
  57. Create FIFOs objects
  58. */
  59. FIFO<q15_t,FIFOSIZE0,1> fifo0(buf0);
  60. FIFO<q15_t,FIFOSIZE1,1> fifo1(buf1);
  61. FIFO<q15_t,FIFOSIZE2,0> fifo2(buf2);
  62. FIFO<q15_t,FIFOSIZE3,1> fifo3(buf3);
  63. FIFO<q15_t,FIFOSIZE4,1> fifo4(buf4);
  64. FIFO<q15_t,FIFOSIZE5,1> fifo5(buf5);
  65. /*
  66. Create node objects
  67. */
  68. SlidingBuffer<q15_t,400,240> audioWin(fifo0,fifo1);
  69. nodeArray[0]=(NodeBase*)&audioWin;
  70. Feature<q15_t,400,q15_t,1> feature(fifo1,fifo2,window);
  71. nodeArray[1]=(NodeBase*)&feature;
  72. SlidingBuffer<q15_t,98,49> featureWin(fifo2,fifo3);
  73. nodeArray[2]=(NodeBase*)&featureWin;
  74. FIR<q15_t,98,q15_t,98> fir(fifo3,fifo4);
  75. nodeArray[3]=(NodeBase*)&fir;
  76. KWS<q15_t,98,q15_t,1> kws(fifo4,fifo5,coef_q15,coef_shift,intercept_q15,intercept_shift);
  77. nodeArray[4]=(NodeBase*)&kws;
  78. Sink<q15_t,1> sink(fifo5);
  79. nodeArray[5]=(NodeBase*)&sink;
  80. Source<q15_t,160> src(fifo0);
  81. nodeArray[6]=(NodeBase*)&src;
  82. /* Run several schedule iterations */
  83. while(sdfError==0)
  84. {
  85. /* Run a schedule iteration */
  86. for(unsigned long id=0 ; id < 151; id++)
  87. {
  88. unsigned int nodeId = schedule[id];
  89. sdfError = nodeArray[nodeId]->run();
  90. CHECKERROR;
  91. }
  92. nbSchedule++;
  93. }
  94. *error=sdfError;
  95. return(nbSchedule);
  96. }