介绍
哈哈哈哈,这个实在太简单了,但是毕竟做了一下,就在这记录一下了,哈哈哈哈。
这个器件的实现的主要功能是,当信号ena是低电平时,输出等于输入,反之,输出高阻态。
设计文件
library ieee;
use ieee.std_logic_1164.all;
entity tri_state is
port(ena : in bit;
input : in std_logic_vector(7 downto 0);
output : out std_logic_vector(7 downto 0));
end tri_state;
architecture tri_state of tri_state is
begin
output <= input when (ena = '0')else
(others => 'Z');
end tri_state;
测试文件
library ieee;
use ieee.std_logic_1164.all;
entity tb_tri_state is
end tb_tri_state;
architecture tri_state of tb_tri_state is
component tri_state is
port(ena : in bit;
input : in std_logic_vector(7 downto 0);
output : out std_logic_vector(7 downto 0));
end component tri_state;
signal ena : bit;
signal input : std_logic_vector(7 downto 0);
signal output : std_logic_vector(7 downto 0);
begin
dut : tri_state
port map(
ena,input,output);
process
begin
ena <= '0';
input <= "01100011";
wait for 20ns;
ena <= '1';
wait for 20ns;
input <= "00110001";
ena <= '0';
wait for 20ns;
ena <= '1';
wait;
end process;
end tri_state;
仿真结果
结语
哈哈哈哈,有什么问题欢迎留言哈。