Skip to content

Crash when assigning individual elements of generic array type in port map #1201

@maltaisn

Description

@maltaisn

The following code causes a crash:

foo.vhd

library ieee;
use ieee.std_logic_1164.all;

entity Foo is
    generic (
        type DATA_TYPE;
        type DATA_ARRAY_TYPE is array (natural range <>) of data_type;
        INPUTS : positive);
    port (
        selector : in std_ulogic_vector(INPUTS-1 downto 0);
        input : in data_array_type(0 to INPUTS-1);
        output : out data_type);
end entity;

architecture rtl of Foo is

begin

end architecture;

bar.vhd`

library ieee;
use ieee.std_logic_1164.all;

library std;
use std.env.all;

entity Bar is
end entity;

architecture rtl of Bar is

    constant INPUTS : positive := 3;

    subtype data_type is std_ulogic_vector(7 downto 0);
    type data_array_type is array (0 to INPUTS - 1) of data_type;

    signal selector : std_ulogic_vector(INPUTS - 1 downto 0) := (others => '0');
    signal input : data_array_type := (others => (others => '0'));
    signal output : data_type;

begin

    foo_inst : entity work.Foo
        generic map (
            DATA_TYPE => data_type,
            DATA_ARRAY_TYPE => data_array_type,
            INPUTS => INPUTS)
        port map (
            selector => selector,
            input(0) => input(0),
            input(1) => input(1),
            input(2) => input(2),
            output => output);

end architecture;

It works if assigning it simply as input => input.

The crash report:

nvc --std=2019 -e Mux_One_Hot_Test

*** Caught signal 11 (SEGV_MAPERR) [address=(nil), ip=0x62d3557173c4] ***

[0x62d3556d9655] ../src/util.c:906 signal_handler.lto_priv.0
[0x7a25f6a4532f] (/usr/lib/x86_64-linux-gnu/libc.so.6)
[0x62d3557173c4] ../src/type.c:633 type_base_kind
[0x62d3557173c4] ../src/type.c:641 type_is_array
[0x62d355760def] ../src/lower.c:565 lower_array_total_len.lto_priv.0
[0x62d35577e43d] ../src/lower.c:11733 lower_map_signal.lto_priv.0
[0x62d355732889] ../src/lower.c:12412 lower_instance
[0x62d355732889] ../src/lower.c:1345 elab_lower.lto_priv.0
[0x62d3557338ec] ../src/elab.c:1463 elab_architecture.lto_priv.0
[0x62d35573a0d7] ../src/elab.c:1638 elab_stmts.lto_priv.0
[0x62d355733902] ../src/elab.c:1465 elab_architecture.lto_priv.0
[0x62d3556d414e] ../src/elab.c:2211 elab
[0x62d3556d414e] ../src/elab.c:549 elaborate
[0x62d3556d0799] ../src/nvc.c:2430 process_command
[0x62d3556ccdea] ../src/nvc.c:2600 main

nvc 1.16.0 (Using LLVM 18.1.3) [x86_64-pc-linux-gnu]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions