from migen.flow.network import *
from migen.flow.composer import *
-g = nx.MultiDiGraph()
+g = DataFlowGraph()
a1 = make_composable(g, Add(BV(16)))
a2 = make_composable(g, Add(BV(16)))
a3 = make_composable(g, Add(BV(16)))
-import networkx as nx
from random import Random
from migen.fhdl import verilog
adrgen = SimActor(adrgen_gen(), ("address", Source, [("a", BV(30))]))
reader = dma_wishbone.Reader()
dumper = SimActor(dumper_gen(), ("data", Sink, [("d", BV(32))]))
- g = nx.MultiDiGraph()
- add_connection(g, adrgen, reader)
- add_connection(g, reader, dumper)
+ g = DataFlowGraph()
+ g.add_connection(adrgen, reader)
+ g.add_connection(reader, dumper)
comp = CompositeActor(g)
peripheral = MyPeripheral()
print("*** Testing writer")
trgen = SimActor(trgen_gen(), ("address_data", Source, [("a", BV(30)), ("d", BV(32))]))
writer = dma_wishbone.Writer()
- g = nx.MultiDiGraph()
- add_connection(g, trgen, writer)
+ g = DataFlowGraph()
+ g.add_connection(trgen, writer)
comp = CompositeActor(g)
peripheral = MyPeripheral()
-import networkx as nx
-
from migen.fhdl.structure import *
from migen.flow.actor import *
from migen.flow.network import *
def main():
source = SimActor(source_gen(), ("source", Source, [("value", BV(32))]))
sink = SimActor(sink_gen(), ("sink", Sink, [("value", BV(32))]))
- g = nx.MultiDiGraph()
- add_connection(g, source, sink)
+ g = DataFlowGraph()
+ g.add_connection(source, sink)
comp = CompositeActor(g)
def end_simulation(s):
s.interrupt = source.done
-import networkx as nx
-
from migen.flow.actor import *
from migen.flow.ala import *
from migen.flow.plumbing import *
signed = signal_self.bv.signed and signal_other.bv.signed
actor = actor_class(BV(width, signed))
combinator = Combinator(actor.token("operands").layout(), ["a"], ["b"])
- add_connection(a.dfg, combinator, actor)
- add_connection(a.dfg, a.actor, combinator, a.endp, "sink0")
- add_connection(a.dfg, b.actor, combinator, b.endp, "sink1")
+ a.dfg.add_connection(combinator, actor)
+ a.dfg.add_connection(a.actor, combinator, a.endp, "sink0")
+ a.dfg.add_connection(b.actor, combinator, b.endp, "sink1")
return make_composable(a.dfg, actor)
class ComposableSource():
-import networkx as nx
+from networkx import MultiDiGraph
from migen.fhdl.structure import *
from migen.flow.actor import *
from migen.corelogic.misc import optree
+class DataFlowGraph(MultiDiGraph):
+ def add_connection(self, source_node, sink_node, source_ep=None, sink_ep=None):
+ if source_ep is None:
+ source_eps = source_node.sources()
+ assert(len(source_eps) == 1)
+ source_ep = source_eps[0]
+ if sink_ep is None:
+ sink_eps = sink_node.sinks()
+ assert(len(sink_eps) == 1)
+ sink_ep = sink_eps[0]
+ self.add_edge(source_node, sink_node, source=source_ep, sink=sink_ep)
+
class CompositeActor(Actor):
def __init__(self, dfg): # TODO: endpoints
self.dfg = dfg
others = sum([node.get_fragment() for node in self.dfg], Fragment())
busy = Fragment([self.busy.eq(optree("|", [node.busy for node in self.dfg]))])
return this + others + busy
-
-def add_connection(dfg, source_node, sink_node, source_ep=None, sink_ep=None):
- if source_ep is None:
- source_eps = source_node.sources()
- assert(len(source_eps) == 1)
- source_ep = source_eps[0]
- if sink_ep is None:
- sink_eps = sink_node.sinks()
- assert(len(sink_eps) == 1)
- sink_ep = sink_eps[0]
- dfg.add_edge(source_node, sink_node, source=source_ep, sink=sink_ep)