From 476ce15f041cbca08ba8bea10b05e75834c4074a Mon Sep 17 00:00:00 2001 From: whitequark Date: Wed, 1 Jan 2020 15:26:05 +0000 Subject: [PATCH] back.rtlil: do not consider unreachable array elements when legalizing. Otherwise we produce invalid RTLIL. --- nmigen/back/rtlil.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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): -- 2.30.2