From 3c4d1bbe4eb88de89816b4a1bbea131ebdeea50a Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Tue, 11 Oct 2022 10:45:34 +0200 Subject: [PATCH] Fix $left/$right for C-style unpacked arrays Unpacked array dimensions that are specified with only a single size value (C-style unpacked arrays) have a $left of 0 and a $right of size - 1. E.g. `x[10]` is equivalent to `x[0:9]`. This is defined in the LRM (1800-2017) section 7.4.2 ("Unpacked arrays"). Currently it is implemented the other way around. There are a few contexts where this distinction matters. For example array to array assignments, which are supposed to be done left-to-right. Signed-off-by: Lars-Peter Clausen --- netmisc.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/netmisc.cc b/netmisc.cc index b2ca68a61..b2548d377 100644 --- a/netmisc.cc +++ b/netmisc.cc @@ -1099,8 +1099,8 @@ bool evaluate_range(Design*des, NetScope*scope, const LineInfo*li, if (!dimension_ok) { // bail out } else if (index_l > 0) { - index_l = index_l - 1; - index_r = 0; + index_r = index_l - 1; + index_l = 0; } else { cerr << range.first->get_fileline() << ": error: " "Dimension size must be greater than zero." << endl;