【发布时间】:2017-09-13 20:29:01
【问题描述】:
我正在做一个需要双向三态缓冲区的项目。 我根据我在这个社区和其他一些网站上的搜索开发了一个 VHDL 代码。但它不能正常工作。下面是VHDL代码。
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity Inter_Con_Mod is
generic(WL: integer := 8);
port(In1: in signed(WL-1 downto 0);
RW: in std_logic;
Data_IO1: inout signed(WL-1 downto 0);
Out1: out signed(WL-1 downto 0));
end Inter_Con_Mod;
architecture Behav of Inter_Con_Mod is
begin
Data_IO1 <= In1 when RW = '1' else
(others => 'Z');
Out1 <= Data_IO1;
end Behav;
这是测试台代码:
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
USE ieee.numeric_std.ALL;
ENTITY InterCon_test IS
END InterCon_test;
ARCHITECTURE behavior OF InterCon_test IS
-- Component Declaration for the Unit Under Test (UUT)
COMPONENT Inter_Con_Mod
PORT(
In1 : IN signed(7 downto 0);
RW : IN std_logic;
Data_IO1 : INOUT signed(7 downto 0);
Out1 : OUT signed(7 downto 0)
);
END COMPONENT;
--Inputs
signal In1 : signed(7 downto 0) := (others => '0');
signal RW : std_logic := '0';
--BiDirs
signal Data_IO1 : signed(7 downto 0);
--Outputs
signal Out1 : signed(7 downto 0);
-- No clocks detected in port list. Replace <clock> below with
-- appropriate port name
--constant <clock>_period : time := 10 ns;
BEGIN
-- Instantiate the Unit Under Test (UUT)
uut: Inter_Con_Mod PORT MAP (
In1 => In1,
RW => RW,
Data_IO1 => Data_IO1,
Out1 => Out1
);
-- Clock process definitions
-- Stimulus process
stim_proc: process
begin
-- hold reset state for 100 ns.
wait for 5 ns;
In1 <= "01111111";
wait for 5 ns;
RW <= '1';
wait for 5 ns;
RW <= '0';
wait for 20 ns;
Data_IO1 <= "00101010";
wait;
end process;
END;
但是看看模拟结果中发生了什么:
我不明白为什么它会忽略我在将 RW 设置为 0 之前提供的测试台刺激。
提前致谢。
【问题讨论】:
-
事实是当我删除 Data_IO1
-
如果您在一根线上有两个驱动器以防止争用,则一次只能驱动其中一个,而另一个必须是高阻抗 ('Z')。您需要在测试平台中适当时分配“Z”。您还可以使用基于对“Z”的不同控制和对行驶时间的控制的单个控制线进行争用。
-
哇。谢谢!我不知道。不幸的是,我找不到像你那样讨论这个问题的任何东西。我用你的评论解决了。
-
期待硬件思维似乎很常见。发布答案。
-
是的。我会发布一个答案。还有一件事。当我想合成这样一个模块时,实际上“Z”分配是自动推断的(因为它意味着高阻抗),但是在测试台中我需要手动完成,是吗?
标签: io vhdl bidirectional inout tri-state-logic