From: Sebastien Bourdeauducq Date: Thu, 17 Sep 2015 00:03:48 +0000 (+0800) Subject: fhdl/verilog: fix case value sort X-Git-Tag: 24jan2021_ls180~2099^2~3^2~90 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=f5ab734bdf24cb56545d3d21649e7bf64eb09ac5;p=litex.git fhdl/verilog: fix case value sort --- diff --git a/migen/fhdl/verilog.py b/migen/fhdl/verilog.py index 8a2b8b46..009c7e1f 100644 --- a/migen/fhdl/verilog.py +++ b/migen/fhdl/verilog.py @@ -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)