litex/examples/dataflow.py

24 lines
532 B
Python
Raw Normal View History

2012-01-09 08:21:54 -05:00
import sys
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 18:33:28 -05:00
from migen.flow.network import *
2012-01-08 07:56:11 -05:00
from migen.flow.composer import *
2012-01-06 11:24:05 -05:00
2012-01-06 18:33:28 -05:00
g = nx.MultiDiGraph()
2012-01-08 07:56:11 -05:00
a1 = make_composable(g, Add(BV(16)))
a2 = make_composable(g, Add(BV(16)))
a3 = make_composable(g, Add(BV(16)))
c3 = (a1 + a2)*a3
2012-01-06 18:33:28 -05:00
c = CompositeActor(g)
frag = c.get_control_fragment() + c.get_process_fragment()
print(verilog.convert(frag))
2012-01-09 08:21:54 -05:00
if len(sys.argv) > 1 and sys.argv[1] == "draw":
import matplotlib.pyplot as plt
nx.draw(g)
plt.show()