graph.py 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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=Binary("arm_offset_f32",floatType,7)
  23. offsetValue=Constant("OFFSET_VALUE")
  24. # Instantiate a Sink node with a float datatype and consuming
  25. # 5 samples each time the node is executed in the C code
  26. # "sink" is the name of the C variable that will identify
  27. # this node
  28. sink=Sink("sink",floatType,5)
  29. # Create a Graph object
  30. the_graph = Graph()
  31. # Connect the source to the processing node
  32. the_graph.connect(src.o,processing.ia)
  33. the_graph.connect(offsetValue,processing.ib)
  34. # Connect the processing node to the sink
  35. the_graph.connect(processing.o,sink.i)