graph.py 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. # Include definitions from the Python package to define data types for the IOs
  2. # and to access to the classes for the Graph Graph.
  3. from cmsisdsp.cg.scheduler import *
  4. # Include definition of the processing nodes defined in 'nodes.py'.
  5. from nodes import *
  6. # Define data type 'float' used for all IOs in this example
  7. floatType=CType(F32)
  8. # Instantiate a Source processing node that creates a packet of 5 samples.
  9. # Each execution of the C function "source" generates 5 samples.
  10. src=Source("source",floatType,5)
  11. # Instantiate a binary operation processing node with 2 inputs and 1 output.
  12. # Each execution of the C function "arm_offset_f32" consumes and produces 7 samples.
  13. processing=Binary("arm_offset_f32",floatType,7)
  14. # Instantiate a processing node that produces a constant value which is defined
  15. # with the C identifier "OFFSET_VALUE".
  16. offsetValue=Constant("OFFSET_VALUE")
  17. # Instantiate a Sink processing node that consumes a packet of 5 samples.
  18. # Each execution of the C function "sink" gets 5 samples as input.
  19. sink=Sink("sink",floatType,5)
  20. # Create a Compute Graph object.
  21. the_graph = Graph()
  22. # Connect the source output to the input ia of the processing node.
  23. the_graph.connect(src.o,processing.ia)
  24. # Connect the constant offsetValues to the input ib of the processing node.
  25. the_graph.connect(offsetValue,processing.ib)
  26. # Connect the ouput of the processing node to the input of the sink.
  27. the_graph.connect(processing.o,sink.i)