From: whitequark Date: Wed, 1 Jan 2020 15:26:05 +0000 (+0000) Subject: back.rtlil: do not consider unreachable array elements when legalizing. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ade4524e976bafda03f399c84fb449b68023972c;p=nmigen.git back.rtlil: do not consider unreachable array elements when legalizing. Otherwise we produce invalid RTLIL. --- diff --git a/nmigen/back/rtlil.py b/nmigen/back/rtlil.py index 9869c61..4a994fd 100644 --- a/nmigen/back/rtlil.py +++ b/nmigen/back/rtlil.py @@ -374,7 +374,9 @@ class _ValueCompiler(xfrm.ValueVisitor): elem = value.elems[-1] return self.match_shape(elem, *value.shape()) else: - raise LegalizeValue(value.index, range(len(value.elems)), value.src_loc) + max_index = 1 << len(value.index) + max_elem = len(value.elems) + raise LegalizeValue(value.index, range(min(max_index, max_elem)), value.src_loc) class _RHSValueCompiler(_ValueCompiler):