| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- from cmsisdsp.cg.scheduler import *
- ### Define new types of Nodes
- class Node(GenericNode):
- def __init__(self,name,theType,inLength,outLength):
- GenericNode.__init__(self,name)
- self.addInput("i",theType,inLength)
- self.addOutput("o",theType,outLength)
- class Sink(GenericSink):
- def __init__(self,name,theType,inLength):
- GenericSink.__init__(self,name)
- self.addInput("i",theType,inLength)
- @property
- def typeName(self):
- return "Sink"
- class Source(GenericSource):
- def __init__(self,name,theType,inLength):
- GenericSource.__init__(self,name)
- self.addOutput("o",theType,inLength)
- @property
- def typeName(self):
- return "Source"
- class ProcessingNode(Node):
- @property
- def typeName(self):
- return "ProcessingNode"
- ### Define nodes
- floatType=CType(F32)
- src=Source("source",floatType,5)
- b=ProcessingNode("filter",floatType,7,5)
- b.addLiteralArg(4,"Test")
- b.addVariableArg("someVariable")
- sink=Sink("sink",floatType,5)
- g = Graph()
- g.connect(src.o,b.i)
- g.connect(b.o,sink.i)
- print("Generate graphviz and code")
- conf=Configuration()
- conf.debugLimit=1
- conf.cOptionalArgs="int someVariable"
- #conf.displayFIFOSizes=True
- # Prefix for global FIFO buffers
- #conf.prefix="sched1"
- #conf.dumpSchedule = True
- sched = g.computeSchedule(config=conf)
- #print(sched.schedule)
- print("Schedule length = %d" % sched.scheduleLength)
- print("Memory usage %d bytes" % sched.memory)
- #
- #conf.postCustomCName = "post.h"
- #conf.CAPI = True
- #conf.prefix="global"
- #conf.dumpFIFO = True
- #conf.CMSISDSP = False
- #conf.switchCase = False
- sched.ccode("generated",conf)
- with open("test.dot","w") as f:
- sched.graphviz(f)
|