Fix vvp code generator for array word alias corner case (issue #1155)

When multiple words in one array were connected to the same nexus as a
single word array, the code generator was sometimes failing to generate
all the necessary aliases. This was highly dependent on the elaboration
order.

This fix should be more robust, but there are currently no tests in the
test suite that cause the compiler to generate whole-array aliases, and
I can't think of a way to make it do so as we don't yet support unpacked
arrays in module ports, so that branch of the code is currently untested.
This commit is contained in:
Martin Whitaker 2024-09-03 21:06:46 +01:00
parent cbdaa865a1
commit d99add9dbe
1 changed files with 3 additions and 4 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2001-2023 Stephen Williams (steve@icarus.com)
* Copyright (c) 2001-2024 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -696,14 +696,13 @@ static void draw_net_in_scope(ivl_signal_t sig)
so the word count for the signal and the alias
*must* match. */
if (ivl_signal_dimensions(nex_data->net) > 0 &&
if (iword == 0 && ivl_signal_dimensions(nex_data->net) > 0 &&
word_count == ivl_signal_array_count(nex_data->net)) {
if (iword == 0) {
fprintf(vvp_out, "v%p .array \"%s\", v%p; Alias to %s \n",
sig, vvp_mangle_name(ivl_signal_basename(sig)),
nex_data->net,
ivl_signal_basename(nex_data->net));
}
break;
/* An alias for an individual word. */
} else {
if (iword == 0) {