Skip to content

Report integer_array_t arguments made during elaboration as a failure - #29

Open
ru551n wants to merge 3 commits into
VUnit:mainfrom
ru551n:fix/elaboration-array-error
Open

ru551n wants to merge 3 commits into
VUnit:mainfrom
ru551n:fix/elaboration-array-error

Conversation

@ru551n

@ru551n ru551n commented Oct 14, 2026 •

Copy link
Copy Markdown
Collaborator

An integer_array_t argument made during elaboration, for example in a constant, now fails with a clear error instead of crashing the simulator. Fixes #17.

Before, the simulation stopped before it started with a message from inside the simulator, which pointed nowhere near arg:

  • NVC: ** Fatal: (init): foreign function vpy_push_array not found
  • GHDL: raised CONSTRAINT_ERROR : synth-vhdl_foreign.adb:267 index check failed

Now it fails early, on the Python logger, naming the call:

python_bridge:python - FAILURE - arg failed:
  An integer_array_t argument cannot be made before test_runner_setup.

How

VHDL can't tell elaboration from simulation, so the check uses the VUnit runner phase: before test_runner_setup, p_stage_array reports the failure and returns without calling the bridge library. This covers arg and kwarg and every other way an array is staged. The rule is a bit stricter than "not during elaboration": an array argument made in a process before test_runner_setup is also rejected.

This is the small alternative to #18, which defers the transfer so that such arguments just work.

Tests

  • New tests/tb_elaboration_array.vhd, the reproduction from integer_array_t argument made during elaboration crashes the simulation #17. tests/run.py expects it to fail and checks that the output has the new error, so a crash still fails the run. Without the fix it fails on NVC with that check.
  • The suite passes on NVC and GHDL. The example passes on NVC. Questa is untested locally.

Docs

  • types.rst states the rule.
  • The release note is in unreleased.md.

🤖 Generated with Claude Code

An integer_array_t argument is transferred to Python when it is made, which
the bridge library cannot do during elaboration: NVC aborted with "foreign
function vpy_push_array not found" and GHDL with a CONSTRAINT_ERROR. Before
test_runner_setup, p_stage_array now reports a failure naming the call
instead. See VUnit#17.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
python_logger,
operation & " failed:" & LF &
"An integer_array_t argument cannot be made before test_runner_setup, for example in a constant. " &
"Make it in a process after test_runner_setup."

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude (AI assistant) here, on behalf of @ru551n:

Fixed in 83ae805: removed the "Make it in a process after test_runner_setup." sentence.

variable staged_id : integer;
begin
-- The bridge library cannot be called during elaboration, see #17
if get_phase = test_runner_entry then

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make it check for get_phase < test_runner_entry instead

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude (AI assistant) here, on behalf of @ru551n:

Fixed in 83ae805, as get_phase < test_runner_setup. test_runner_entry is the first value of runner_phase_t, so get_phase < test_runner_entry would never be true and would disable the check.

variable offset, n : natural := 0;
variable staged_id : integer;
begin
-- The bridge library cannot be called during elaboration, see #17

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove, the code is obvious

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude (AI assistant) here, on behalf of @ru551n:

Fixed in 83ae805: removed the comment.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
failure(
python_logger,
operation & " failed:" & LF &
"An integer_array_t argument cannot be made before test_runner_setup, for example in a constant."

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"An integer_array_t argument cannot be made before test_runner_setup, for example in a constant."
"An integer_array_t argument cannot be made before test_runner_setup."

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude (AI assistant) here, on behalf of @ru551n:

Fixed in 9bd3818: applied the suggestion.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

integer_array_t argument made during elaboration crashes the simulation

1 participant