vhdl - 避免在 VHDL 中使用 inout

标签 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;

最佳答案

如果目的只是将 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/

相关文章:

用于触发上升沿 Action 的 VHDL 简写形式

swift - 为什么我不能将隐式解包的可选项作为 UnsafeMutablePointer 传递?

swift - 在实例函数中初始化实例变量

ios - 不能在 inout 函数中使用 SKShapeNode

ios - 无法将 'NSObject' 类型的不可变值作为 inout 参数传递

vhdl - 如何使用 Tcl 脚本对波形进行简单的 Aldec Active-HDL 仿真?

vhdl - 如何创建将单个信号映射到 std_logic_vector 的 1 位的端口映射?

performance - 是否可以为 RTL 创建基于硬件的合成器?

没有clk的Vhdl

swift - swift inout参数是变量还是指针?