古博姚青华 发表于 2005-6-11 19:41:52
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity qiangdaa is
port(rst:in std_logic; 复位键
a1,a2,a3,a4,a5:in std_logic;五个抢答按键
cade:out std_logic_vector(3 downto 0));
end entity qiangdaa;
architecture behav of qiangdaa is
signal a:std_logic_vector(4 downto 0);
signal scade:std_logic_vector(3 downto 0);
begin
process(rst,a1,a2,a3,a4,a5)
begin
if rst='0' then a<="00000";
elsif (a1='0')and(a2='1')and(a3='1')and(a4='1')and(a5='1')and(scade=0) then
a<=a1&a2&a3&a4&a5;
elsif (a1='1')and(a2='0')and(a3='1')and(a4='1')and(a5='1')and(scade=0) then
a<=a1&a2&a3&a4&a5;
elsif (a1='1')and(a2='1')and(a3='0')and(a4='1')and(a5='1')and(scade=0) then
a<=a1&a2&a3&a4&a5;
elsif (a1='1')and(a2='1')and(a3='1')and(a4='0')and(a5='1')and(scade=0) then
a<=a1&a2&a3&a4&a5;
elsif (a1='1')and(a2='1')and(a3='1')and(a4='1')and(a5='0')and(scade=0) then
a<=a1&a2&a3&a4&a5;
end if;
end process;
process(a)
begin
case a is
when "01111"=>scade<="0001";参赛者号码
when "10111"=>scade<="0010";
when "11011"=>scade<="0011";
when "11101"=>scade<="0100";
when "11110"=>scade<="0101";
when others=>scade<="0000";
end case;
cade<=scade;
end process;
end;
电脑抢答器网 抢答器设计与制作的专业网站 大学生课程设计的园地 |