Skip to content

[BUG/CLARIFICATION/FEATURE] Record as generic type triggers mismatched_kinds error despite valid VHDL #389

@nselvara

Description

@nselvara

Bug/Clarification/Feature Request

Hi there,
Thanks again for the recent fixes in issues #348 and #379. I believe I’ve encountered a related edge case or possibly a follow-up issue.

When passing a record type as a generic, I receive the following warning: Type 'test_settings_t' may not be the prefix of a selected name [vhdl_ls(mismatched_kinds)]

As per AMD's clarification, this construct is valid VHDL. However, it seems the analyser doesn't resolve the generic type correctly and fails to trace its fields - possibly due to limitations in how generic types are resolved or internally tracked.


Minimal Reproducible Example (MRE)

Package:

library ieee;
use ieee.std_logic_1164.all;

package custom_types is
    type test_settings_t is record
        mode: std_ulogic;
        bits: std_ulogic_vector(2 downto 0);
    end record;
end package;

generic_record_consumer:

library ieee;
use ieee.std_logic_1164.all;
use work.custom_types.all;

entity generic_record_consumer is
    generic (
        type test_config_t -- Generic record type
    );
    port (
        config: in test_config_t;
        some_out: out std_ulogic
    );
end entity;

architecture rtl of generic_record_consumer is
begin
    process (config)
    begin
        -- Accessing record field, triggers `mismatched_kinds`
        some_out <= config.mode;
    end process;
end architecture;

Instantiation:

library ieee;
use ieee.std_logic_1164.all;
use work.custom_types.all;

entity top is end entity;
architecture test of top is
    signal my_cfg : test_settings_t := (
        mode => '1',
        bits => "000"
    );
begin
    uut: entity work.generic_record_consumer
        generic map (
            test_config_t => test_settings_t
        )
        port map (
            config => my_cfg,
            some_out => open
        );
end architecture;

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions