2012-01-09 08:21:54 -05:00
|
|
|
import sys
|
2012-01-06 18:33:28 -05:00
|
|
|
import networkx as nx
|
|
|
|
|
2012-01-10 09:54:51 -05:00
|
|
|
from migen.fhdl import verilog
|
2011-12-22 18:36:07 -05:00
|
|
|
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-06-08 16:49:49 -04:00
|
|
|
g = DataFlowGraph()
|
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)
|
|
|
|
|
2012-01-10 09:54:51 -05:00
|
|
|
frag = c.get_fragment()
|
2012-01-06 18:33:28 -05:00
|
|
|
|
|
|
|
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()
|