Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
12 years ago

Generic parameter with variable size

Hi all

My design requires a parameter defined at compilation time that can range from 1 to 128 bytes. It isn't possible to create a generic based on another generic like this:

generic (

es_size : natural range 1 to 128 := 2;

es_info : bidim_array_t(es_size-1 downto 0) := (x"00",x"00"));

)

Where bidim_array_t is defined inside a package:

type bidim_array_t is array(natural range <>) of std_logic_vector(7 downto 0);

With this code Quartus reports the following error:

***generic "es_size" cannot be used in its own interface list***

Removing the es_size and fixating the size of es_info to 128 could be one solution but I would like to know if there is anything more elegant to do in this case.

Thank you

Best regards

Thiago

1 Reply

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    --- Quote Start ---

    Hi all

    My design requires a parameter defined at compilation time that can range from 1 to 128 bytes. It isn't possible to create a generic based on another generic like this:

    generic (

    es_size : natural range 1 to 128 := 2;

    es_info : bidim_array_t(es_size-1 downto 0) := (x"00",x"00"));

    )

    Where bidim_array_t is defined inside a package:

    type bidim_array_t is array(natural range <>) of std_logic_vector(7 downto 0);

    With this code Quartus reports the following error:

    ***generic "es_size" cannot be used in its own interface list***

    Removing the es_size and fixating the size of es_info to 128 could be one solution but I would like to know if there is anything more elegant to do in this case.

    Thank you

    Best regards

    Thiago

    --- Quote End ---

    I think generic should be a constant so that compiler knows what to do.

    Your second declaration of bidim_array should be an input