I would like to to have a package that contains types that depend on generics so that I can use them on a project. However I am having trouble using those dependent types in port declarations:
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
package dependent_types is
generic (generic_value : natural);
subtype dependent_type is std_ulogic_vector (generic_value - 1 downto 0);
end package;
use work.all;
entity dependent_entity_with_dependent_port is
generic (generic_value : natural);
package instantiated_types is new dependent_types
generic map (generic_value => generic_value);
use instantiated_types.all;
port (dependent_port : out dependent_type);
end dependent_entity_with_dependent_port;
It seems that entity declarative parts (package instantiation, use clause) must come after the port declaration. This prevents using types defined in generic packages that depend on the entity's generics.
Is there any way to achieve this?
dependent_portcan be constructed fromgeneric_value-library ieee; use ieee.std_logic_1164.all; entity with_dependent_port is generic ( generic_value: positive); port ( dependent_port: out std_ulogic_vector(generic_value - 1 downto 0)); end entity;- user1155120