避免在VHDL中使用inout

Kat*_*lou 2 vhdl inout

我想避免在以下代码中使用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;
Run Code Online (Sandbox Code Playgroud)

Mor*_*mer 7

如果目的只是为模块提供C输出的中间值,则有不同的选项可以避免inout.

如果这些工具支持VHDL-2008,您只需更改inoutout,然后C仍然可以在内部读取.

如果工具仅支持VHDL-2002,那么您仍然可以更改inoutout,但是您需要一个内部信号,如:

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;
Run Code Online (Sandbox Code Playgroud)

正如xvan所写的那样,只能inout用于芯片上的顶级端口,或者用于特殊的测试平台,因为inout芯片内部不支持.