Io 双向三态缓冲器
我正在做一个项目,我需要一个双向三态缓冲区。 我根据我在这个社区和其他一些网站上的搜索开发了一个VHDL代码。但它并没有发挥应有的作用。下面是VHDL代码Io 双向三态缓冲器,io,vhdl,bidirectional,inout,tri-state-logic,Io,Vhdl,Bidirectional,Inout,Tri State Logic,我正在做一个项目,我需要一个双向三态缓冲区。 我根据我在这个社区和其他一些网站上的搜索开发了一个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);
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;
ieee库;
使用ieee.std_logic_1164.all;
使用ieee.numeric_std.all;
实体内部控制模块为
通用(WL:整数:=8);
端口(In1:in已签名(WL-1向下至0);
RW:标准逻辑中;
数据_IO1:inout signed(WL-1下降到0);
Out1:签出(WL-1下降到0);
结束内部控制模块;
Inter_Con_Mod的架构行为是
开始
数据_IO1'Z');
Out1'0');
信号RW:std_逻辑:='0';
--比迪尔斯
信号数据_IO1:有符号(7到0);
--输出
信号输出1:已签名(7到0);
--端口列表中未检测到时钟。将下面替换为
--适当的端口名
--恒定周期:时间:=10纳秒;
开始
--实例化被测单元(UUT)
uut:Inter_Con_Mod端口映射(
In1=>In1,
RW=>RW,
Data_IO1=>Data_IO1,
Out1=>Out1
);
--时钟进程定义
--刺激过程
刺激程序:过程
开始
--保持复位状态100纳秒。
等待5ns;
由于@user1155120,问题得以解决。我已将整个代码更改为下面的内容
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity Inter_Con_Mod is
generic(WL: integer := 8);
port(PortL,PortR: inout signed(WL-1 downto 0);
RW: in std_logic);
end Inter_Con_Mod;
architecture Behav of Inter_Con_Mod is
begin
PortR <= PortL when RW = '0' else
(others => 'Z');
PortL <= PortR when RW = '1' else
(others => 'Z');
end Behav;
ieee库;
使用ieee.std_logic_1164.all;
使用ieee.numeric_std.all;
实体内部控制模块为
通用(WL:整数:=8);
端口(端口L,端口R:inout signed(WL-1下降到0);
RW:标准逻辑中);
结束内部控制模块;
Inter_Con_Mod的架构行为是
开始
波尔图'Z');
端口‘Z’;
结束行为;
所以我有两个输入端口和一个选择输入端口。问题不在模块的代码中。它在试验台上。为了避免线路上的数据干扰,我必须驱动作为输出的输入输出端口。下面是测试台代码:
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;
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
USE ieee.numeric_std.ALL;
ENTITY Test IS
END Test;
ARCHITECTURE behavior OF Test IS
-- Component Declaration for the Unit Under Test (UUT)
COMPONENT Inter_Con_Mod
PORT(
PortL : INOUT signed(7 downto 0);
PortR : INOUT signed(7 downto 0);
RW : IN std_logic
);
END COMPONENT;
--Inputs
signal RW : std_logic := '0';
--BiDirs
signal PortL : signed(7 downto 0);
signal PortR : signed(7 downto 0);
-- No clocks detected in port list. Replace <clock> below with
-- appropriate port name
BEGIN
-- Instantiate the Unit Under Test (UUT)
uut: Inter_Con_Mod PORT MAP (
PortL => PortL,
PortR => PortR,
RW => RW
);
-- Stimulus process
stim_proc: process
begin
PortL <= "01111111";
PortR <= (others => 'Z');
wait for 5 ns;
RW <= '1';
wait for 5 ns;
PortR <= "01111100";
PortL <= (others => 'Z');
wait for 20 ns;
wait;
wait;
end process;
END;
ieee库;
使用ieee.std_logic_1164.ALL;
使用ieee.numeric_std.ALL;
实体测试是
结束试验;
测试的架构行为是
--被测单元(UUT)的组件声明
组件内部控制模块
港口(
端口:INOUT签名(7到0);
端口:INOUT签名(7到0);
RW:在标准逻辑中
);
端部元件;
--投入
信号RW:std_逻辑:='0';
--比迪尔斯
信号端口:已签名(7到0);
信号端口:已签名(7到0);
--端口列表中未检测到时钟。将下面替换为
--适当的端口名
开始
--实例化被测单元(UUT)
uut:Inter_Con_Mod端口映射(
PortL=>PortL,
PortR=>PortR,
RW=>RW
);
--刺激过程
刺激程序:过程
开始
PortL事实上,当我删除数据时,如果一条线路上有两个驱动器,防止争用只需要其中一个驱动器一次可以驱动,另一个必须是高阻抗('Z')。您需要在适当的时候在测试台上指定“Z”。您还可以使用单个控制线进行争用,该控制线基于对“Z”的不同控制和对驱动时间的不同控制。哇。谢谢我不知道。不幸的是,我找不到像你那样讨论这件事的任何东西。我通过你的评论解决了这个问题。期待硬件思维似乎很常见。发布一个答案。是的。我会发布一个答案。还有一件事。当我想要合成这样一个模块时,实际上“Z”赋值是自动推断的(因为它意味着高阻抗),但在测试台上,我需要手动完成,是吗?