Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
flow: add AbstractActor busy signals
  • Loading branch information
Sebastien Bourdeauducq committed Oct 25, 2013
1 parent 99c53ed commit 892c12b
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion migen/flow/network.py
Expand Up @@ -14,6 +14,7 @@ def __init__(self, actor_class, parameters=dict(), name=None):
self.actor_class = actor_class
self.parameters = parameters
self.name = name
self.busy = Signal()

def create_instance(self):
return self.actor_class(**self.parameters)
Expand All @@ -30,6 +31,7 @@ class DataFlowGraph(MultiDiGraph):
def __init__(self):
MultiDiGraph.__init__(self)
self.elaborated = False
self.abstract_busy_signals = dict()

def add_connection(self, source_node, sink_node,
source_ep=None, sink_ep=None, # default: assume nodes have 1 source/sink and use that one
Expand Down Expand Up @@ -71,7 +73,9 @@ def replace_actor(self, old, new):
self.remove_node(old)

def instantiate(self, actor):
self.replace_actor(actor, actor.create_instance())
inst = actor.create_instance()
self.abstract_busy_signals[id(inst)] = actor.busy
self.replace_actor(actor, inst)

# Returns a dictionary
# source -> [sink1, ..., sinkn]
Expand Down Expand Up @@ -237,6 +241,15 @@ def __init__(self, dfg):
assert(not hasattr(self, k))
setattr(self, k, v)

# connect abstract busy signals
for node in dfg:
try:
abstract_busy_signal = dfg.abstract_busy_signals[id(node)]
except KeyError:
pass
else:
self.comb += abstract_busy_signal.eq(node.busy)

# generate busy signal
self.busy = Signal()
self.comb += self.busy.eq(optree("|", [node.busy for node in dfg]))
Expand Down

0 comments on commit 892c12b

Please sign in to comment.