EDA中用VHDL语言设计五人抢答器
要求:1、五人参赛每人一个按钮,主持人一个按钮,按下就复位重新开始;2、每人一个发光二极管,抢中者灯亮;3、抢答开始时,抢答时间为10秒,十秒内有人抢答,则自己的发光二极...
要求:1、五人参赛每人一个按钮,主持人一个按钮,按下就复位重新开始;
2、每人一个发光二极管,抢中者灯亮;
3、抢答开始时,抢答时间为10秒,十秒内有人抢答,则自己的发光二极管亮,同时喇叭发出两秒声响,若10秒内无人抢答,则答题无效,重新开始;
4、有人抢答时,答题时限为10秒钟,从有人抢答开始,用一个数码管倒计时间,0、9、8、7、6、5、4、3、2、1、0,倒计到0时,喇叭发出两秒声响。
(请大家自己回答,不要摘录别人的,是五人抢答器,不是四人,也不是八人。) 展开
2、每人一个发光二极管,抢中者灯亮;
3、抢答开始时,抢答时间为10秒,十秒内有人抢答,则自己的发光二极管亮,同时喇叭发出两秒声响,若10秒内无人抢答,则答题无效,重新开始;
4、有人抢答时,答题时限为10秒钟,从有人抢答开始,用一个数码管倒计时间,0、9、8、7、6、5、4、3、2、1、0,倒计到0时,喇叭发出两秒声响。
(请大家自己回答,不要摘录别人的,是五人抢答器,不是四人,也不是八人。) 展开
展开全部
五人抢答器:
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
USE IEEE.STD_LOGIC_UNSIGNED.ALL;
ENTITY QDQ5 IS
PORT(CLK,CLR:IN STD_LOGIC; --时钟(1HZ)和复位(开始)信号--
A,B,C,D,E:IN STD_LOGIC; --抢答的五个人--
LB:OUT STD_LOGIC; --喇叭--
LCD,LCD1,LCD2,LCD3,LCD4,LCD5:OUT STD_LOGIC; --LCD灯--
SG:OUT STD_LOGIC_VECTOR(6 DOWNTO 0)); --输出到数码管显示--
END;
ARCHITECTURE ONE OF QDQ5 IS
BEGIN
PROCESS(CLR,CLK,A,B,C,D,E)
VARIABLE CNT_LB:STD_LOGIC_VECTOR(1 DOWNTO 0);
VARIABLE CNT:STD_LOGIC_VECTOR(9 DOWNTO 0);
BEGIN
IF CLR='1' THEN
CNT:=(OTHERS=>'0');
ELSIF CLK'EVENT AND CLK='1' THEN
IF CNT<9 THEN CNT:=CNT+1;CNT_LB:=CNT_LB+1;
END IF;
END IF; --时钟升沿到达时加1--
IF CNT<9 THEN
IF A='1' THEN LCD1<='1';LCD2<='0';LCD3<='0';LCD4<='0';LCD5<='0';END IF;
IF B='1' THEN LCD1<='0';LCD2<='1';LCD3<='0';LCD4<='0';LCD5<='0';END IF;
IF C='1' THEN LCD1<='0';LCD2<='0';LCD3<='1';LCD4<='0';LCD5<='0';END IF;
IF D='1' THEN LCD1<='0';LCD2<='0';LCD3<='0';LCD4<='1';LCD5<='0';END IF;
IF E='1' THEN LCD1<='0';LCD2<='0';LCD3<='0';LCD4<='0';LCD5<='1';END IF;
ELSIF CNT=9 THEN
LCD<='1';
END IF; --抢答过程--
IF A='1' AND B='1' AND C='1' AND D='1' AND E='1' AND CNT=9 THEN
IF CLK'EVENT AND CLK='1' THEN
IF CNT_LB<"10" THEN LB<='1'; --喇叭响--
ELSE LB<='0';
END IF;
END IF;
END IF;
CASE CNT IS
WHEN "0000000000" => SG<="1111011";
WHEN "0000000001" => SG<="1111111";
WHEN "0000000010" => SG<="1110000";
WHEN "0000000011" => SG<="1011111";
WHEN "0000000100" => SG<="1011011";
WHEN "0000000101" => SG<="0110011";
WHEN "0000000110" => SG<="1111001";
WHEN "0000000111" => SG<="1101101";
WHEN "0000001000" => SG<="0110000";
WHEN "0000001001" => SG<="1111110";
WHEN OTHERS =>SG<="0000000";
END CASE; -- 显示--
END PROCESS ;
END;
这个程序是我自己写的,没有错误。你试试看有没有用!
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
USE IEEE.STD_LOGIC_UNSIGNED.ALL;
ENTITY QDQ5 IS
PORT(CLK,CLR:IN STD_LOGIC; --时钟(1HZ)和复位(开始)信号--
A,B,C,D,E:IN STD_LOGIC; --抢答的五个人--
LB:OUT STD_LOGIC; --喇叭--
LCD,LCD1,LCD2,LCD3,LCD4,LCD5:OUT STD_LOGIC; --LCD灯--
SG:OUT STD_LOGIC_VECTOR(6 DOWNTO 0)); --输出到数码管显示--
END;
ARCHITECTURE ONE OF QDQ5 IS
BEGIN
PROCESS(CLR,CLK,A,B,C,D,E)
VARIABLE CNT_LB:STD_LOGIC_VECTOR(1 DOWNTO 0);
VARIABLE CNT:STD_LOGIC_VECTOR(9 DOWNTO 0);
BEGIN
IF CLR='1' THEN
CNT:=(OTHERS=>'0');
ELSIF CLK'EVENT AND CLK='1' THEN
IF CNT<9 THEN CNT:=CNT+1;CNT_LB:=CNT_LB+1;
END IF;
END IF; --时钟升沿到达时加1--
IF CNT<9 THEN
IF A='1' THEN LCD1<='1';LCD2<='0';LCD3<='0';LCD4<='0';LCD5<='0';END IF;
IF B='1' THEN LCD1<='0';LCD2<='1';LCD3<='0';LCD4<='0';LCD5<='0';END IF;
IF C='1' THEN LCD1<='0';LCD2<='0';LCD3<='1';LCD4<='0';LCD5<='0';END IF;
IF D='1' THEN LCD1<='0';LCD2<='0';LCD3<='0';LCD4<='1';LCD5<='0';END IF;
IF E='1' THEN LCD1<='0';LCD2<='0';LCD3<='0';LCD4<='0';LCD5<='1';END IF;
ELSIF CNT=9 THEN
LCD<='1';
END IF; --抢答过程--
IF A='1' AND B='1' AND C='1' AND D='1' AND E='1' AND CNT=9 THEN
IF CLK'EVENT AND CLK='1' THEN
IF CNT_LB<"10" THEN LB<='1'; --喇叭响--
ELSE LB<='0';
END IF;
END IF;
END IF;
CASE CNT IS
WHEN "0000000000" => SG<="1111011";
WHEN "0000000001" => SG<="1111111";
WHEN "0000000010" => SG<="1110000";
WHEN "0000000011" => SG<="1011111";
WHEN "0000000100" => SG<="1011011";
WHEN "0000000101" => SG<="0110011";
WHEN "0000000110" => SG<="1111001";
WHEN "0000000111" => SG<="1101101";
WHEN "0000001000" => SG<="0110000";
WHEN "0000001001" => SG<="1111110";
WHEN OTHERS =>SG<="0000000";
END CASE; -- 显示--
END PROCESS ;
END;
这个程序是我自己写的,没有错误。你试试看有没有用!
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询