graph.py 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. # Include definitions from the Python package to
  2. # define datatype for the IOs and to have access to the
  3. # Graph class
  4. from cmsisdsp.cg.scheduler import *
  5. # Include definition of the nodes
  6. from nodes import *
  7. # Define the datatype we are using for all the IOs in this
  8. # example
  9. floatType=CType(F32)
  10. # Instantiate a Source node with a float datatype and
  11. # working with packet of 5 samples (each execution of the
  12. # source in the C code will generate 5 samples)
  13. # "source" is the name of the C variable that will identify
  14. # this node
  15. src=Source("source",floatType,5)
  16. # Instantiate a Processing node using a float data type for
  17. # both the input and output. The number of samples consumed
  18. # on the input and produced on the output is 7 each time
  19. # the node is executed in the C code
  20. # "processing" is the name of the C variable that will identify
  21. # this node
  22. processing=ProcessingNode("processing",floatType,7,7)
  23. # Instantiate a Sink node with a float datatype and consuming
  24. # 5 samples each time the node is executed in the C code
  25. # "sink" is the name of the C variable that will identify
  26. # this node
  27. sink=Sink("sink",floatType,5)
  28. # Create a Graph object
  29. the_graph = Graph()
  30. # Connect the source to the processing node
  31. the_graph.connect(src.o,processing.i)
  32. # Connect the processing node to the sink
  33. the_graph.connect(processing.o,sink.i)