nickg / nvc

VHDL compiler and simulator
https://www.nickg.me.uk/nvc/
GNU General Public License v3.0
631 stars 77 forks source link

Procedure definition inside a process declarative part causes an assertion failure during elaboration #882

Closed leksiso closed 5 months ago

leksiso commented 5 months ago

Hello,

I ran into an assertion failure when running the elaboration command for a model that has a procedure declaration inside a process statement. The following code snippet demonstrates the problem:

entity test is
end entity;

architecture arch of test is
    signal my_a : integer := 0;
    signal my_b : integer := 1;

begin
    process (all) is
        procedure do_thing (signal a : in integer; signal b : out integer) is
        begin
            b <= a;
        end procedure;
    begin

        my_b <= my_a;
    end process;
end architecture;

nvc -e test output:

Assertion failed: (n < a->count), function reg_array_nth_ptr, file vcode.c, line 158.

*** Caught signal 6 (SIGABRT) ***

[0x10dc98667] signal_handler+0x167
[0x7ff80c05ffdc] (/usr/lib/system/libsystem_platform.dylib) _sigtramp+0x1c
[0x7ff80bff814b] (/usr/lib/system/libsystem_kernel.dylib) __pthread_kill+0xb
[0x7ff80c030ebd] (/usr/lib/system/libsystem_pthread.dylib) pthread_kill+0x106
[0x7ff80bf56a39] (/usr/lib/system/libsystem_c.dylib) abort+0x7e
[0x7ff80bf55d1c] (/usr/lib/system/libsystem_c.dylib) err
[0x10dd73bcd] reg_array_nth_ptr+0x4d
[0x10dd62108] vcode_reg_data+0xa8
[0x10dd62053] vcode_reg_type+0x13
[0x10dd32763] lower_array_data+0x13
[0x10dd32d29] lower_sched_event+0xc9
[0x10dd3194b] lower_process+0x58b
[0x10dd0b8cb] elab_process+0x4b
[0x10dd09fc9] elab_stmts+0x139
[0x10dd084ce] elab_architecture+0x37e
[0x10dd0697b] elab_top_level+0xeb
[0x10dd0657a] elab+0x26a
[0x10dc8fbc7] elaborate+0x377
[0x10dc8f248] process_command+0xd8
[0x10dc8e7cd] main+0x2bd

The problem doesn't seem to happen if I move the procedure into the architecture declarative part or if I remove the signal assignment statement from the process body.

nickg commented 5 months ago

Should be fixed now. Thanks for reporting.