litex/examples/dataflow.py

24 lines
627 B
Python
Raw Normal View History

2012-01-06 18:33:28 -05:00
import networkx as nx
2011-12-22 18:36:07 -05:00
from migen.fhdl import verilog
from migen.flow.ala import *
2012-01-06 11:24:05 -05:00
from migen.flow.plumbing import *
2012-01-06 18:33:28 -05:00
from migen.flow.network import *
def get_actor_fragments(*actors):
return sum([a.get_control_fragment() + a.get_process_fragment() for a in actors], Fragment())
2011-12-22 18:36:07 -05:00
2012-01-06 11:24:05 -05:00
act = Adder(32)
2012-01-06 18:33:28 -05:00
comb = Combinator(act.operands.template(), ["a"], ["b"])
2012-01-06 11:24:05 -05:00
outbuf = Buffer(act.result.template())
2012-01-06 18:33:28 -05:00
g = nx.MultiDiGraph()
g.add_nodes_from([act, comb, outbuf])
add_connection(g, comb, act)
add_connection(g, act, outbuf)
c = CompositeActor(g)
frag = c.get_control_fragment() + c.get_process_fragment()
print(verilog.convert(frag))