verilog, sim: accept iterables in FHDL statements
authorSebastien Bourdeauducq <sb@m-labs.hk>
Mon, 19 Oct 2015 11:17:26 +0000 (19:17 +0800)
committerSebastien Bourdeauducq <sb@m-labs.hk>
Mon, 19 Oct 2015 11:17:26 +0000 (19:17 +0800)
migen/fhdl/verilog.py
migen/sim/core.py

index 259899b96c6712b725a926e7af98de3a899f844f..72888999c73a9a11e5ddb7e8afce777444ae164a 100644 (file)
@@ -1,5 +1,6 @@
 from functools import partial
 from operator import itemgetter
+import collections
 
 from migen.fhdl.structure import *
 from migen.fhdl.structure import _Operator, _Slice, _Assign, _Fragment
@@ -128,7 +129,7 @@ def _printnode(ns, at, level, node):
         else:
             assignment = " <= "
         return "\t"*level + _printexpr(ns, node.l)[0] + assignment + _printexpr(ns, node.r)[0] + ";\n"
-    elif isinstance(node, (list, tuple)):
+    elif isinstance(node, collections.Iterable):
         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"
index af3f3734f97debc4bb3184c97ee78af32c9e75fb..4c30c39a656ea801151e747f6bdf759296ffcc25 100644 (file)
@@ -1,4 +1,5 @@
 import operator
+import collections
 
 from migen.fhdl.structure import *
 from migen.fhdl.structure import (_Value, _Statement,
@@ -193,7 +194,7 @@ class Evaluator:
                         return
                 if "default" in s.cases:
                     self.execute(s.cases["default"])
-            elif isinstance(s, list):
+            elif isinstance(s, collections.Iterable):
                 self.execute(s)
             else:
                 raise NotImplementedError