From 9010805040ee59629002ada1b9ab9dc3bb29761a Mon Sep 17 00:00:00 2001 From: whitequark Date: Sat, 15 Dec 2018 00:10:54 +0000 Subject: [PATCH] compat.fhdl.structure: handle If/Elif with multi-bit condition. --- nmigen/compat/fhdl/structure.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/nmigen/compat/fhdl/structure.py b/nmigen/compat/fhdl/structure.py index 4f89080..5a4d9fa 100644 --- a/nmigen/compat/fhdl/structure.py +++ b/nmigen/compat/fhdl/structure.py @@ -29,10 +29,12 @@ def Constant(value, bits_sign=None): class If(ast.Switch): @deprecated("instead of `If(cond, ...)`, use `with m.If(cond): ...`") def __init__(self, cond, *stmts): + cond = Value.wrap(cond).bool() super().__init__(cond, {"1": ast.Statement.wrap(stmts)}) @deprecated("instead of `.Elif(cond, ...)`, use `with m.Elif(cond): ...`") def Elif(self, cond, *stmts): + cond = Value.wrap(cond).bool() self.cases = OrderedDict(("-" + k, v) for k, v in self.cases.items()) self.cases["1" + "-" * len(self.test)] = ast.Statement.wrap(stmts) self.test = Cat(self.test, cond) -- 2.30.2