From: whitequark Date: Mon, 31 Dec 2018 03:43:34 +0000 (+0000) Subject: back.rtlil: match shape of Array elements to ArrayProxy shape. X-Git-Tag: working~108 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ae3c5834ed8484925d8bafe468530e789791c01e;p=nmigen.git back.rtlil: match shape of Array elements to ArrayProxy shape. Fixes #15. --- diff --git a/nmigen/back/rtlil.py b/nmigen/back/rtlil.py index 10ff80f..83a7d17 100644 --- a/nmigen/back/rtlil.py +++ b/nmigen/back/rtlil.py @@ -328,9 +328,10 @@ class _ValueCompiler(xfrm.ValueVisitor): index = self.s.expand(value.index) if isinstance(index, ast.Const): if index.value < len(value.elems): - return self(value.elems[index.value]) + elem = value.elems[index.value] else: - return self(value.elems[-1]) + elem = value.elems[-1] + return self.match_shape(elem, *value.shape()) else: raise LegalizeValue(value.index, range(len(value.elems))) @@ -503,6 +504,10 @@ class _LHSValueCompiler(_ValueCompiler): def on_Operator(self, value): raise TypeError # :nocov: + def match_shape(self, value, new_bits, new_sign): + assert value.shape() == (new_bits, new_sign) + return self(value) + def on_Signal(self, value): wire_curr, wire_next = self.s.resolve(value) if wire_next is None: