fhdl/verilog: fix case value sort

This commit is contained in:
Sebastien Bourdeauducq 2015-09-17 08:03:48 +08:00
parent e940c6d9b9
commit f5ab734bdf
1 changed files with 2 additions and 1 deletions

View File

@ -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)