• 设计一个2人抢答器。要求如下:
• 设计任务
• 1. 两人抢答,先抢为有效,用发光二极
• 管显示是否抢到优先答题权。
• 2. 每人2位计分显示,答错了不加分, 答
• 错了不加分,答对了可加10分、20 、
• 30分。
• 3. 每题结束后,裁判按复位,可重新抢
• 答下一题。
• 4. 累计加分可由裁判随时清除。
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_signed.all;
entity qd is
port(i1,i2 : in bit; --抢答器两输入端。
reset : in bit; --抢答器复位端。
g10,g20,g30:in bit; --加分输入端10分、20分、
30分。
light1,light2:out bit:='0'; --抢答标志灯。
t11:out std_logic_vector(6 downto 0):= "0111111"; --"t11、t12", 显示第一个人得分。
t12:out std_logic_vector(6 downto 0):= "0111111";
t21:out std_logic_vector(6 downto 0):= "0111111"; --"t21、t22" ,显示第二个人得分。
signal cs2:integer range 0 to 9;
t22:out std_logic_vector(6 downto 0):= "0111111";
clk:in bit; --时钟输入端
cong:in bit --清零控制端
);
end qd;
architecture stru of qd is
signal cs1:integer range 0 to 9;
signal cs2:integer range 0 to 9;
signal a,b:bit:='0';
signal l1,l2:bit:='0';
begin
process(clk)
begin
if clk'event and clk='1' then
if(cong='1') then
if(reset='1') then
if (i1 ='0' and a='0') then l1
elsif ( i2 ='0' and a='0') then l2
end if;
if (g10 ='0' and l1='1' and b='0' ) then cs1
elsif (g20 ='0' and l1='1' and b='0' ) then cs1
elsif (g30 ='0' and l1='1' and b='0' ) then cs1
end if; --完成第一人的加分。
if(g10='0' and l2='1' and b='0') then cs2
elsif(g20='0' and l2='1' and b='0') then cs2
elsif(g30='0' and l2='1' and b='0') then
cs2
end if; --完成第二人的加分。
if (cs1=0) then t11
elsif (cs1=1) then t11
elsif (cs1=2) then t11
elsif (cs1=3) then t11
elsif (cs1=4) then t11
elsif (cs1=5) then t11
elsif (cs1=6) then t11
elsif (cs1=7) then t11
elsif (cs1=8) then t11
elsif (cs1=9) then t11
end if;
if (cs2=0) then t21
elsif (cs2=1) then t21
elsif (cs2=2) then t21
elsif (cs2=3) then t21
elsif (cs2=4) then t21
elsif (cs2=5) then t21
elsif (cs2=6) then t21
elsif (cs2=7) then t21
elsif (cs2=8) then t21
elsif (cs2=9) then t21
end if;
else l1
end if;
else l1
end if;
else cs1
l1
end if;
light1
light2
t12
t22
end if;
end process;
end stru;
程序说明
1 .
此程序主要由3部分组成,即抢答、加分、显示。 2 .
当一个人抢到优先答题权,发光二极管亮,另一 个人再按按键无效。答题结束后,裁判按复位键, 方可再次抢答。
3.
没人有2个数码管显示累加计分情况,分数分为 3档,用按键来区分。
• 设计一个2人抢答器。要求如下:
• 设计任务
• 1. 两人抢答,先抢为有效,用发光二极
• 管显示是否抢到优先答题权。
• 2. 每人2位计分显示,答错了不加分, 答
• 错了不加分,答对了可加10分、20 、
• 30分。
• 3. 每题结束后,裁判按复位,可重新抢
• 答下一题。
• 4. 累计加分可由裁判随时清除。
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_signed.all;
entity qd is
port(i1,i2 : in bit; --抢答器两输入端。
reset : in bit; --抢答器复位端。
g10,g20,g30:in bit; --加分输入端10分、20分、
30分。
light1,light2:out bit:='0'; --抢答标志灯。
t11:out std_logic_vector(6 downto 0):= "0111111"; --"t11、t12", 显示第一个人得分。
t12:out std_logic_vector(6 downto 0):= "0111111";
t21:out std_logic_vector(6 downto 0):= "0111111"; --"t21、t22" ,显示第二个人得分。
signal cs2:integer range 0 to 9;
t22:out std_logic_vector(6 downto 0):= "0111111";
clk:in bit; --时钟输入端
cong:in bit --清零控制端
);
end qd;
architecture stru of qd is
signal cs1:integer range 0 to 9;
signal cs2:integer range 0 to 9;
signal a,b:bit:='0';
signal l1,l2:bit:='0';
begin
process(clk)
begin
if clk'event and clk='1' then
if(cong='1') then
if(reset='1') then
if (i1 ='0' and a='0') then l1
elsif ( i2 ='0' and a='0') then l2
end if;
if (g10 ='0' and l1='1' and b='0' ) then cs1
elsif (g20 ='0' and l1='1' and b='0' ) then cs1
elsif (g30 ='0' and l1='1' and b='0' ) then cs1
end if; --完成第一人的加分。
if(g10='0' and l2='1' and b='0') then cs2
elsif(g20='0' and l2='1' and b='0') then cs2
elsif(g30='0' and l2='1' and b='0') then
cs2
end if; --完成第二人的加分。
if (cs1=0) then t11
elsif (cs1=1) then t11
elsif (cs1=2) then t11
elsif (cs1=3) then t11
elsif (cs1=4) then t11
elsif (cs1=5) then t11
elsif (cs1=6) then t11
elsif (cs1=7) then t11
elsif (cs1=8) then t11
elsif (cs1=9) then t11
end if;
if (cs2=0) then t21
elsif (cs2=1) then t21
elsif (cs2=2) then t21
elsif (cs2=3) then t21
elsif (cs2=4) then t21
elsif (cs2=5) then t21
elsif (cs2=6) then t21
elsif (cs2=7) then t21
elsif (cs2=8) then t21
elsif (cs2=9) then t21
end if;
else l1
end if;
else l1
end if;
else cs1
l1
end if;
light1
light2
t12
t22
end if;
end process;
end stru;
程序说明
1 .
此程序主要由3部分组成,即抢答、加分、显示。 2 .
当一个人抢到优先答题权,发光二极管亮,另一 个人再按按键无效。答题结束后,裁判按复位键, 方可再次抢答。
3.
没人有2个数码管显示累加计分情况,分数分为 3档,用按键来区分。