graph.py 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import numpy as np
  2. from cmsisdsp.sdf.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. #print(g.nullVector())
  21. sched = g.computeSchedule()
  22. #print(sched.schedule)
  23. print("Schedule length = %d" % sched.scheduleLength)
  24. print("Memory usage %d bytes" % sched.memory)
  25. #
  26. conf=Configuration()
  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)