74ls138实现四人表决器
时间: 2023-12-12 13:35:51 浏览: 293
74ls138可以实现四人表决器,具体实现方法如下:
1.将四个按键分别连接到74ls138的三个使能端(G1、G2A、G2B)和一个地址端(A0、A1、A2)上,将74ls138的输出端(Y0~Y7)连接到一个四输入与非门74ls20的输入端上。
2.将74ls20的输出端连接到指示灯F上。
3.当四个按键中有三个或以上按下时,74ls138的输出端会输出一个低电平,74ls20的输入端会接收到至少三个低电平,此时74ls20的输出端会输出一个高电平,指示灯F会亮起来。
4.当四个按键中有两个或以下按下时,74ls138的输出端会输出一个高电平,74ls20的输入端会接收到至少一个高电平,此时74ls20的输出端会输出一个低电平,指示灯F会熄灭。
```vhdl
-- 74ls138实现四人表决器
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity vote is
Port ( A : in STD_LOGIC_VECTOR (2 downto 0);
G1 : in STD_LOGIC;
G2A : in STD_LOGIC;
G2B : in STD_LOGIC;
F : out STD_LOGIC);
end vote;
architecture Behavioral of vote is
signal Y : std_logic_vector(7 downto 0);
begin
Y(0) <= not (A(2) and A(1) and A(0) and G1 and G2A and G2B);
Y(1) <= not (A(2) and A(1) and not A(0) and G1 and G2A and not G2B);
Y(2) <= not (A(2) and not A(1) and A(0) and G1 and not G2A and G2B);
Y(3) <= not (A(2) and not A(1) and not A(0) and G1 and not G2A and not G2B);
Y(4) <= not (not A(2) and A(1) and A(0) and not G1 and G2A and G2B);
Y(5) <= not (not A(2) and A(1) and not A(0) and not G1 and G2A and not G2B);
Y(6) <= not (not A(2) and not A(1) and A(0) and not G1 and not G2A and G2B);
Y(7) <= not (not A(2) and not A(1) and not A(0) and not G1 and not G2A and not G2B);
F <= not (Y(0) and Y(1) and Y(2) and Y(3) and Y(4) and Y(5) and Y(6) and Y(7));
end Behavioral;
```
阅读全文