graph.py 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import numpy as np
  2. from cmsisdsp.cg.scheduler import *
  3. class Processing(GenericNode):
  4. def __init__(self,name,outLength):
  5. GenericNode.__init__(self,name)
  6. self.addInput("i",CType(Q15),outLength)
  7. self.addOutput("o",CType(Q15),outLength)
  8. @property
  9. def typeName(self):
  10. return "Processing"
  11. BUFSIZE=128
  12. ### Define nodes
  13. src=VHTSource("src",BUFSIZE,0)
  14. processing=Processing("proc",BUFSIZE)
  15. sink=VHTSink("sink",BUFSIZE,0)
  16. g = Graph()
  17. g.connect(src.o, processing.i)
  18. g.connect(processing.o, sink.i)
  19. print("Generate graphviz and code")
  20. conf=Configuration()
  21. #conf.dumpSchedule = True
  22. sched = g.computeSchedule(conf)
  23. #print(sched.schedule)
  24. print("Schedule length = %d" % sched.scheduleLength)
  25. print("Memory usage %d bytes" % sched.memory)
  26. #
  27. # Pass the source and sink objects used to communicate with the VHT Modelica block
  28. #conf.pyOptionalArgs=""
  29. conf.pathToSDFModule="C:\\\\benchresults\\\\cmsis_docker\\\\CMSIS\\\\DSP\\\\SDFTools"
  30. #conf.dumpFIFO=True
  31. #conf.prefix="sched1"
  32. sched.pythoncode(".",config=conf)
  33. with open("test.dot","w") as f:
  34. sched.graphviz(f)