我想避免在以下代码中使用 inout。
有什么办法可以做到吗?例如帮助信号?
entity LA_Unit is
Port ( Cin : in STD_LOGIC;
P : in STD_LOGIC_VECTOR (3 downto 0);
G : in STD_LOGIC_VECTOR (3 downto 0);
C3 : out STD_LOGIC;
C : inout STD_LOGIC_VECTOR (2 downto 0));
end LA_Unit;
architecture Behavioral of LA_Unit is
begin
C(0) <= (P(0) and Cin) xor G(0);
C(1) <= (P(1) and C(0)) xor G(1);
C(2) <= (P(2) and C(1)) xor G(2);
C3 <= (P(3) and C(2)) xor G(3);
end Behavioral;
最佳答案
如果目的只是将 C
的中间值作为输出提供给模块,则有不同的选项可以避免 inout
。
如果工具支持VHDL-2008,只需将inout
改成out
,内部仍然可以读取C
。
如果工具只支持 VHDL-2002,那么您仍然可以将 inout
更改为 out
,但是您需要一个内部信号,例如:
architecture Behavioral of LA_Unit is
signal C_int : std_logic_vector(2 downto 0);
begin
C_int(0) <= (P(0) and Cin) xor G(0);
C_int(1) <= (P(1) and C_int(0)) xor G(1);
C_int(2) <= (P(2) and C_int(1)) xor G(2);
C3 <= (P(3) and C_int(2)) xor G(3);
C <= C_int;
end Behavioral;
正如 xvan 也写的那样,仅将 inout
用于芯片上的顶层端口,或用于特殊测试台使用,因为芯片内部不支持 inout
。
关于vhdl - 避免在 VHDL 中使用 inout,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35831656/