Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update handling of single-element arrays. #1115

Merged
merged 1 commit into from
Apr 16, 2024

Conversation

grebe
Copy link
Contributor

@grebe grebe commented Apr 12, 2024

Also, add a test. This fixes #1113.

@grebe
Copy link
Contributor Author

grebe commented Apr 12, 2024

I'm new to the codebase and only sort-of understand what this is doing, so feel free to give feedback if I should do something else.

@martinwhitaker
Copy link
Collaborator

From vvp's point of view your fix converts the array into a single vector. This gives the correct behaviour for simulation, but does affect the VPI view of the design. I think a better fix would be

--- a/tgt-vvp/vvp_scope.c
+++ b/tgt-vvp/vvp_scope.c
@@ -697,7 +697,8 @@ static void draw_net_in_scope(ivl_signal_t sig)
                       so the word count for the signal and the alias
                       *must* match. */
 
-                 if (word_count == ivl_signal_array_count(nex_data->net)) {
+                 if ((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)),

Note that the if (iword == 0) must be retained, otherwise the alias will be repeated for every word in the array. It's hard to demonstrate that though, as AFAICT the compiler never generates an alias for an entire array.

@grebe
Copy link
Contributor Author

grebe commented Apr 15, 2024

Ah, that makes sense. I've just pushed the fix you proposed.

@martinwhitaker martinwhitaker merged commit 35f344a into steveicarus:master Apr 16, 2024
4 checks passed
@martinwhitaker
Copy link
Collaborator

Merged. Thanks for your contribution.

@grebe grebe deleted the single_element_array branch August 5, 2024 17:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

vvp: array.cc:1561: void compile_array_alias(char*, char*, char*): Assertion `mem' failed.
2 participants