From: whitequark Date: Sun, 21 Apr 2019 06:41:35 +0000 (+0000) Subject: back.rtlil: only expand legalized values in Array/Part context on RHS. X-Git-Tag: working~10 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=083016d747f25b67a6e06fab9d29fa46b4fe4d1b;p=nmigen.git back.rtlil: only expand legalized values in Array/Part context on RHS. Otherwise the following code fails to compile: index = Signal(1) array = Array(range(2)) with m.If(0 == array[index]): m.d.sync += index.eq(0) Fixes #51. --- diff --git a/nmigen/back/rtlil.py b/nmigen/back/rtlil.py index fd3bfe8..9778f4b 100644 --- a/nmigen/back/rtlil.py +++ b/nmigen/back/rtlil.py @@ -299,9 +299,6 @@ class _ValueCompiler(xfrm.ValueVisitor): def __init__(self, state): self.s = state - def on_value(self, value): - return super().on_value(self.s.expand(value)) - def on_unknown(self, value): if value is None: return None @@ -375,6 +372,9 @@ class _RHSValueCompiler(_ValueCompiler): (3, "m"): "$mux", } + def on_value(self, value): + return super().on_value(self.s.expand(value)) + def on_Const(self, value): if isinstance(value.value, str): return "{}'{}".format(value.nbits, value.value)