sched.py 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. #
  2. # Generated with CMSIS-DSP SDF Scripts.
  3. # The generated code is not covered by CMSIS-DSP license.
  4. #
  5. # The support classes and code is covered by CMSIS-DSP license.
  6. #
  7. import sys
  8. import numpy as np
  9. import cmsisdsp as dsp
  10. from cmsisdsp.sdf.nodes.simu import *
  11. from appnodes import *
  12. from custom import *
  13. DEBUGSCHED=False
  14. #
  15. # FIFO buffers
  16. #
  17. FIFOSIZE0=256
  18. buf0=np.zeros(FIFOSIZE0,dtype=np.float32)
  19. FIFOSIZE1=256
  20. buf1=np.zeros(FIFOSIZE1,dtype=np.float32)
  21. FIFOSIZE2=256
  22. buf2=np.zeros(FIFOSIZE2,dtype=np.float32)
  23. FIFOSIZE3=512
  24. buf3=np.zeros(FIFOSIZE3,dtype=np.float32)
  25. FIFOSIZE4=512
  26. buf4=np.zeros(FIFOSIZE4,dtype=np.float32)
  27. FIFOSIZE5=512
  28. buf5=np.zeros(FIFOSIZE5,dtype=np.float32)
  29. FIFOSIZE6=256
  30. buf6=np.zeros(FIFOSIZE6,dtype=np.float32)
  31. FIFOSIZE7=256
  32. buf7=np.zeros(FIFOSIZE7,dtype=np.float32)
  33. def scheduler(dispbuf):
  34. sdfError=0
  35. nbSchedule=0
  36. debugCounter=42
  37. #
  38. # Create FIFOs objects
  39. #
  40. fifo0=FIFO(FIFOSIZE0,buf0)
  41. fifo1=FIFO(FIFOSIZE1,buf1)
  42. fifo2=FIFO(FIFOSIZE2,buf2)
  43. fifo3=FIFO(FIFOSIZE3,buf3)
  44. fifo4=FIFO(FIFOSIZE4,buf4)
  45. fifo5=FIFO(FIFOSIZE5,buf5)
  46. fifo6=FIFO(FIFOSIZE6,buf6)
  47. fifo7=FIFO(FIFOSIZE7,buf7)
  48. #
  49. # Create node objects
  50. #
  51. audioOverlap = OverlapAdd(256,128,fifo6,fifo7)
  52. audioWin = SlidingBuffer(256,128,fifo0,fifo1)
  53. cfft = CFFT(512,512,fifo3,fifo4)
  54. icfft = ICFFT(512,512,fifo4,fifo5)
  55. sink = FileSink(192,fifo7,"output_example3.txt",dispbuf)
  56. src = FileSource(192,fifo0,"input_example3.txt")
  57. toCmplx = ToComplex(256,512,fifo2,fifo3)
  58. toReal = ToReal(512,256,fifo5,fifo6)
  59. while((sdfError==0) and (debugCounter > 0)):
  60. nbSchedule = nbSchedule + 1
  61. sdfError = src.run()
  62. if sdfError < 0:
  63. break
  64. sdfError = audioWin.run()
  65. if sdfError < 0:
  66. break
  67. i0=fifo1.getReadBuffer(256)
  68. o2=fifo2.getWriteBuffer(256)
  69. o2[:]=dsp.arm_mult_f32(i0,HANN)
  70. sdfError = 0
  71. if sdfError < 0:
  72. break
  73. sdfError = toCmplx.run()
  74. if sdfError < 0:
  75. break
  76. sdfError = cfft.run()
  77. if sdfError < 0:
  78. break
  79. sdfError = icfft.run()
  80. if sdfError < 0:
  81. break
  82. sdfError = toReal.run()
  83. if sdfError < 0:
  84. break
  85. sdfError = audioOverlap.run()
  86. if sdfError < 0:
  87. break
  88. sdfError = src.run()
  89. if sdfError < 0:
  90. break
  91. sdfError = audioWin.run()
  92. if sdfError < 0:
  93. break
  94. i0=fifo1.getReadBuffer(256)
  95. o2=fifo2.getWriteBuffer(256)
  96. o2[:]=dsp.arm_mult_f32(i0,HANN)
  97. sdfError = 0
  98. if sdfError < 0:
  99. break
  100. sdfError = toCmplx.run()
  101. if sdfError < 0:
  102. break
  103. sdfError = cfft.run()
  104. if sdfError < 0:
  105. break
  106. sdfError = icfft.run()
  107. if sdfError < 0:
  108. break
  109. sdfError = toReal.run()
  110. if sdfError < 0:
  111. break
  112. sdfError = audioWin.run()
  113. if sdfError < 0:
  114. break
  115. i0=fifo1.getReadBuffer(256)
  116. o2=fifo2.getWriteBuffer(256)
  117. o2[:]=dsp.arm_mult_f32(i0,HANN)
  118. sdfError = 0
  119. if sdfError < 0:
  120. break
  121. sdfError = toCmplx.run()
  122. if sdfError < 0:
  123. break
  124. sdfError = cfft.run()
  125. if sdfError < 0:
  126. break
  127. sdfError = icfft.run()
  128. if sdfError < 0:
  129. break
  130. sdfError = audioOverlap.run()
  131. if sdfError < 0:
  132. break
  133. sdfError = sink.run()
  134. if sdfError < 0:
  135. break
  136. sdfError = toReal.run()
  137. if sdfError < 0:
  138. break
  139. sdfError = audioOverlap.run()
  140. if sdfError < 0:
  141. break
  142. sdfError = sink.run()
  143. if sdfError < 0:
  144. break
  145. debugCounter = debugCounter - 1
  146. return(nbSchedule,sdfError)