flow/network: option to add debugger
authorSebastien Bourdeauducq <sebastien@milkymist.org>
Fri, 3 Aug 2012 16:49:35 +0000 (18:49 +0200)
committerSebastien Bourdeauducq <sebastien@milkymist.org>
Fri, 3 Aug 2012 16:49:35 +0000 (18:49 +0200)
migen/flow/network.py

index 65f0514f81fa0fba27690b18cffffa5cc1959cca..f735ecccf57198ba4da0dbce1ad95bd2d0e49d33 100644 (file)
@@ -1,9 +1,10 @@
 from networkx import MultiDiGraph
 
 from migen.fhdl.structure import *
+from migen.corelogic.misc import optree
 from migen.flow.actor import *
 from migen.flow import plumbing
-from migen.corelogic.misc import optree
+from migen.flow.isd import DFGReporter
 
 # Graph nodes can be either:
 #  (1) a reference to an existing actor
@@ -211,11 +212,20 @@ class DataFlowGraph(MultiDiGraph):
                self._instantiate_actors()
 
 class CompositeActor(Actor):
-       def __init__(self, dfg):
+       def __init__(self, dfg, debugger=False, debugger_nbits=48):
                dfg.elaborate()
                self.dfg = dfg
+               if debugger:
+                       self.debugger = DFGReporter(self.dfg, debugger_nbits)
                super().__init__()
        
+       def get_registers(self):
+               if hasattr(self, "debugger"):
+                       self.debugger.print_map()
+                       return self.debugger.get_registers()
+               else:
+                       return []
+       
        def get_fragment(self):
                comb = [self.busy.eq(optree("|", [node.actor.busy for node in self.dfg]))]
                fragment = Fragment(comb)
@@ -225,4 +235,6 @@ class CompositeActor(Actor):
                        ep_src = u.actor.endpoints[d["source"]]
                        ep_dst = v.actor.endpoints[d["sink"]]
                        fragment += get_conn_fragment(ep_src, ep_dst)
+               if hasattr(self, "debugger"):
+                       fragment += self.debugger.get_fragment()
                return fragment