From: whitequark Date: Sat, 15 Dec 2018 00:10:54 +0000 (+0000) Subject: compat.fhdl.structure: handle If/Elif with multi-bit condition. X-Git-Tag: working~233 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=9010805040ee59629002ada1b9ab9dc3bb29761a;p=nmigen.git compat.fhdl.structure: handle If/Elif with multi-bit condition. --- 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)