Skip to content

Commit

Permalink
fhdl/verilog: fix case value sort
Browse files Browse the repository at this point in the history
  • Loading branch information
sbourdeauducq committed Sep 17, 2015
1 parent e940c6d commit f5ab734
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion migen/fhdl/verilog.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ def _printnode(ns, at, level, node):
elif isinstance(node, Case):
if node.cases:
r = "\t"*level + "case (" + _printexpr(ns, node.test)[0] + ")\n"
css = sorted([(k, v) for (k, v) in node.cases.items() if isinstance(k, Constant)], key=itemgetter(0))
css = [(k, v) for k, v in node.cases.items() if isinstance(k, Constant)]
css = sorted(css, key=lambda x: x[0].value)
for choice, statements in css:
r += "\t"*(level + 1) + _printexpr(ns, choice)[0] + ": begin\n"
r += _printnode(ns, at, level + 2, statements)
Expand Down

0 comments on commit f5ab734

Please sign in to comment.