Fix bit select on signed multi-dimensional packed array

Bit selects on packed arrays are always unsigned and have a width of 1.
Element selects on a multi-dimensional packed array are always unsigned and
have the width of the element.

At the moment a element or bit select on the last level element of a
multi-dimensional signed array will incorrectly yield a signed expression.

Commit 40b36337e2 ("Fix some bugs with packed array dimensions") added
some special checks to fix the width on multi-dimensional array element
selects. But this removed the unsigned attribute from bit selects.

Commit 81947edaa5 ("A bit select is not the same as selecting part of a
packed array") fixed this for single dimensional packed array, but left it
broken for multi-dimensional arrays.

Commit 7c024d6cab ("Fix width calculation for bit/part selects of
multi-dimensioned packed arrays.") added some additional fixes for the
width calculation, which make the special checks in the first commit
unnecessary.

We can now remove those checks which will give us the correct behavior in
terms of the signedness of bit and element selects on both single- and
multi-dimensional packed arrays.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
This commit is contained in:
Lars-Peter Clausen 2023-06-25 19:36:19 -07:00
parent bb39325fe9
commit 61381fd9cd
1 changed files with 1 additions and 6 deletions

View File

@ -4321,12 +4321,7 @@ unsigned PEIdent::test_width(Design*des, NetScope*scope, width_mode_t&mode)
const index_component_t&index_tail = name_tail.index.back();
ivl_assert(*this, index_tail.msb);
}
// If we have a net in hand, then we can predict what the
// slice width will be. If not, then assume it will be a
// simple bit select. If the net only has a single dimension
// then this is still a simple bit select.
if ((sr.net == 0) || (sr.net->packed_dimensions() <= 1))
use_width = 1;
use_width = 1;
break;
case index_component_t::SEL_BIT_LAST:
if (debug_elaborate) {