如何在vhdl子模块中使用用户定义的类型?

如何在vhdl子模块中使用用户定义的类型?,vhdl,user-defined-types,Vhdl,User Defined Types,假设我的顶层.vhd文件中有以下内容 entity toplevel is .... end toplevel; architecture behave of toplevel is type state is (A, B, C); signal cur_state : state; ... E1 : entity submodule_entity port map( ... cur_state => cur_state); ... end behave; 在我的第二个文件的实体/架构对

假设我的顶层.vhd文件中有以下内容

entity toplevel is
....
end toplevel;
architecture behave of toplevel is
type state is (A, B, C);
signal cur_state : state;
...
E1 : entity submodule_entity port map(
...
cur_state => cur_state);
...
end behave;
在我的第二个文件的实体/架构对中,我有以下内容

entity submodule_entity is
port(
    ...
    cur_state : in state);
end entity;

合成器抱怨子模块_实体中没有定义类型状态(这很有意义)。如何在另一个模块中使用用户定义的类型?

您需要将自定义类型放入一个包中,然后将其包含在两个实体中。

如何将参数传递给包?假设自定义类型也使用通用参数,您将如何考虑?我的意思是如何准确地将参数传递给包?