from migen.fhdl.structure import _Operator, _Slice, _Assign, _ArrayProxy
from migen.fhdl.visit import NodeVisitor, NodeTransformer
+def flat_iteration(l):
+ for element in l:
+ if isinstance(element, (list, tuple)):
+ for element2 in flat_iteration(element):
+ yield element2
+ else:
+ yield element
+
class _SignalLister(NodeVisitor):
def __init__(self):
self.output_list = set()
def group_by_targets(sl):
groups = []
- for statement in sl:
+ for statement in flat_iteration(sl):
targets = list_targets(statement)
processed = False
for g in groups:
else:
assignment = " <= "
return "\t"*level + _printexpr(ns, node.l)[0] + assignment + _printexpr(ns, node.r)[0] + ";\n"
- elif isinstance(node, list):
+ elif isinstance(node, (list, tuple)):
return "".join(list(map(partial(_printnode, ns, at, level), node)))
elif isinstance(node, If):
r = "\t"*level + "if (" + _printexpr(ns, node.cond)[0] + ") begin\n"
self.visit_Case(node)
elif isinstance(node, Fragment):
self.visit_Fragment(node)
- elif isinstance(node, list):
+ elif isinstance(node, (list, tuple)):
self.visit_statements(node)
elif isinstance(node, dict):
self.visit_clock_domains(node)
return self.visit_Case(node)
elif isinstance(node, Fragment):
return self.visit_Fragment(node)
- elif isinstance(node, list):
+ elif isinstance(node, (list, tuple)):
return self.visit_statements(node)
elif isinstance(node, dict):
return self.visit_clock_domains(node)
r.sync = self.visit(node.sync)
return r
+ # NOTE: this will always return a list, even if node is a tuple
def visit_statements(self, node):
return [self.visit(statement) for statement in node]