避免在VHDL中使用inout
我希望避免在以下代码中使用inout 我有什么办法可以做吗?例如帮助信号避免在VHDL中使用inout,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 : in
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;
实体LAU单元为
端口(Cin:标准_逻辑中;
P:标准逻辑向量(3到0);
G:标准逻辑向量(3到0);
C3:输出标准逻辑;
C:inout标准逻辑向量(2到0);
结束拉乌单位;
LA_单元的架构是
开始
C(0)使用信号作为C(0)和C(1)的中间值
inout只能用于硬件io端口,如gpio端口或内存总线上的数据端口。如果目的只是提供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;
LA_单元的架构行为是
信号C_int:std_逻辑_向量(2到0);
开始
C_int(0)有两种解决方案:
使用缓冲区模式而不是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 : buffer 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;
实体LAU单元为
端口(Cin:标准_逻辑中;
P:标准逻辑向量(3到0);
G:标准逻辑向量(3到0);
C3:输出标准逻辑;
C:缓冲器标准逻辑向量(2到0);
结束拉乌单位;
LA_单元的架构是
开始
C(0)在第二个示例中,端口C
应具有模式out
。@MartinZabel修复了它:)。如果一个答案解决了您的问题,请将其中一个答案标记为“解决方案”。
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 : out STD_LOGIC_VECTOR (2 downto 0)
);
end entity;
architecture rtl of LA_Unit is
signal C_i : STD_LOGIC_VECTOR(3 downto 0);
begin
C_i(0) <= (P(0) and Cin) xor G(0);
C_i(1) <= (P(1) and C_i(0)) xor G(1);
C_i(2) <= (P(2) and C_i(1)) xor G(2);
C_i(3) <= (P(3) and C_i(2)) xor G(3);
C <= C_i(2 downto 0);
C3 <= C_i(3);
end architecture