nsinor<=not(a or b or c or d); start<=s_start; process(sta,nsinor) is begin
if (sta='1') then s_start<='1';
elsif(nsinor'event and nsinor='1')then s_start<='0'; end if; end process;
process(rst,sta,sinor,nsinor) is begin
if(rst='1' or sta='1' or nsinor='1')then a1<='0';b1<='0';c1<='0';d1<='0'; elsif(sinor'event and sinor='1')then if(s_start='1')then if(a='1')then
a1<='1';b1<='0';c1<='0';d1<='0'; elsif(b='1')then
a1<='0';b1<='1';c1<='0';d1<='0'; elsif(c='1')then
a1<='0';b1<='0';c1<='1';d1<='0'; elsif(d='1')then
a1<='0';b1<='0';c1<='0';d1<='1'; end if; end if; end if; end process; process(sinor) is
6
begin
if(rst='1')then states<=\
elsif(sinor'event and sinor='1')then if(s_start='1')then if(a='1')then states<=w1; elsif(b='1')then states<=w2; elsif(c='1')then states<=w3; elsif(d='1')then states<=w4; end if; end if; end if; end process;
end architecture art;
7
3.1.3抢答鉴别模块的时序仿真图
图 4.1
抢答开始后,A组按下抢答键,抢答成功
8
3.2抢答器的抢答计时模块
3.2.1抢答计时模块的功能
主持人宣布抢答成功后,按下EN键,选手开始回答,系统开始计时。TA和TB键选择计时的时间(TA:9秒,TB:7秒)
3.2.2 抢答计时模块的源程序
library ieee;
use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity js is
port(clr,ldn,en,clk:in std_logic; ta,tb: in std_logic;
qa: out std_logic_vector(3 downto 0); qb: out std_logic_vector(3 downto 0)); end entity js;
architecture art of js is
signal da: std_logic_vector(3 downto 0); signal db: std_logic_vector(3 downto 0); begin
process(ta,clr) is begin
if(clr='1')then da<=\
elsif(ta'event and ta='1')then if(ldn='1')then if(da=\ da<=\
9
else
da<=da-1; end if; end if; end if; end process; process(tb,clr) is begin
if(clr='1')then db<=\
elsif(tb'event and tb='1')then if(ldn='1')then if db=\ db<=\ else
db<=db-1; end if; end if; end if; end process; process(clk) is
variable tmpa: std_logic_vector(3 downto 0); variable tmpb: std_logic_vector(3 downto 0); begin
if(clr='1')then tmpa:=\ tmpb:=\
elsif clk'event and clk='1' then if en='1'then
10