1、设计一个三输入或非门电路。
2、三输入三输出电路设计:
???????? 输入A为1时,对应输出为1,A为0时,输出为0;
????? ???输入B为1时,对应输出为0,B为0时,输出为1;
???????? 输入A、B、C有一个为1时,C对应输出为1。
3、十进制数编码电路:把0~9十个数编码成8421BCD码。
编码对象 | 输入端口 | 输出端口 |
I0、I1、I2、I3、I4、I5、I6、I7、I8、I9 | Q8、Q4、Q2、Q1 | |
0 | I0=1,其他为0 | 0000 |
1 | I1=1,其他为0 | 0001 |
2 | I2=1,其他为0 | 0010 |
3 | I3=1,其他为0 | 0011 |
4 | I4=1,其他为0 | 0100 |
5 | I5=1,其他为0 | 0101 |
6 | I6=1,其他为0 | 0110 |
7 | I7=1,其他为0 | 0111 |
8 | I8=1,其他为0 | 1000 |
9 | I9=1,其他为0 | 1001 |
其他情况 | 1111 |
library IEEE;
USE IEEE.STD_logic_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
USE IEEE.STD_logic_unsigned.ALL;
-- 实体声明
ENTITY ShiYan6 IS
PORT(
A,B,C : IN std_logic;
output :out std_logic
);
END ShiYan6;
--结构体说明
ARCHITECTURE behave OF ShiYan6 IS
BEGIN
PROCESS (A, B, C)
BEGIN
--三输入或非门 描述
output <= NOT (A OR B OR C);
END PROCESS;
END behave;
???????? 输入A为1时,对应输出为1,A为0时,输出为0;
????? ???输入B为1时,对应输出为0,B为0时,输出为1;
???????? 输入A、B、C有一个为1时,C对应输出为1。
library IEEE;
USE IEEE.STD_logic_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
USE IEEE.STD_logic_unsigned.ALL;
-- 实体声明
ENTITY ShiYan6 IS
PORT(
A,B,C : IN std_logic;
OUTA :out std_logic;
OUTB :out std_logic;
OUTC :out std_logic
);
END ShiYan6;
--结构体说明
ARCHITECTURE behave OF ShiYan6 IS
BEGIN
PROCESS (A, B, C)
BEGIN
--三输入三输出 描述
OUTA <= A;
OUTB <= NOT B;
OUTC <= A OR B OR C;
END PROCESS;
END behave;
-- 码转换 -case语句
library IEEE;
USE IEEE.STD_logic_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
USE IEEE.STD_logic_unsigned.ALL;
-- 实体声明
ENTITY ShiYan6 IS
PORT(
input : IN STD_logic_vector(9 downto 0);
output :out STD_logic_vector(3 downto 0)
);
END ShiYan6;
--结构体说明
ARCHITECTURE behave OF ShiYan6 IS
BEGIN
PROCESS (input)
BEGIN
--十进制数编码电路:把0~9十个数编码成8421BCD码
CASE input IS
WHEN "0000000001" => output <= "0000";
WHEN "0000000010" => output <= "0001";
WHEN "0000000100" => output <= "0010";
WHEN "0000001000" => output <= "0011";
WHEN "0000010000" => output <= "0100";
WHEN "0000100000" => output <= "0101";
WHEN "0001000000" => output <= "0110";
WHEN "0010000000" => output <= "0111";
WHEN "0100000000" => output <= "1000";
WHEN "1000000000" => output <= "1001";
when others => output <= "1111";
END CASE;
END PROCESS;
END behave;