From cccbc07e52a1bf650e0e9f1c27d54da9f9d1ba44 Mon Sep 17 00:00:00 2001 From: whitequark Date: Sun, 21 Apr 2019 06:41:35 +0000 Subject: [PATCH] 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. --- nmigen/back/rtlil.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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) -- 2.30.2