From b1af0601fa325be226188c4050e57f368e5df4c5 Mon Sep 17 00:00:00 2001 From: whitequark Date: Tue, 25 Jun 2019 21:52:03 +0000 Subject: [PATCH] compat.fhdl.structure: simplify handling of default case. --- nmigen/compat/fhdl/structure.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/nmigen/compat/fhdl/structure.py b/nmigen/compat/fhdl/structure.py index 0a58d74..4a99195 100644 --- a/nmigen/compat/fhdl/structure.py +++ b/nmigen/compat/fhdl/structure.py @@ -92,8 +92,7 @@ class Case(ast.Switch): k = k.value new_cases.append((k, v)) if default is not None: - k = "-" * len(ast.Value.wrap(test)) - new_cases.append((k, default)) + new_cases.append((None, default)) super().__init__(test, OrderedDict(new_cases)) @deprecated("instead of `Case(...).makedefault()`, use an explicit default case: " @@ -106,12 +105,12 @@ class Case(ast.Switch): or choice > key): key = choice elif isinstance(key, str) and key == "default": - key = "-" * len(self.test) + key = None else: key = "{:0{}b}".format(wrap(key).value, len(self.test)) stmts = self.cases[key] del self.cases[key] - self.cases["-" * len(self.test)] = stmts + self.cases[None] = stmts return self -- 2.30.2