VHDL四人抢答器代码
library ieee;
use ieee.std_logic_1164.all;
entity qiangdaqi is
port
(
clk ,rest,allow : in std_logic;
answer : in std_logic_vector(3 downto 0);
stop_lamp,allow_lamp,co,q : out std_logic;
answer_success,answer_foul : out std_logic_vector(3 downto 0)
);
end entity;
architecture rtl of qiangdaqi is
signal alamp : std_logic;
signal foul : std_logic_vector(3 downto 0);
begin
nclk:process (clk,allow) is
begin
if(rest='1')then
q<="0000";
co<='0';
else
if(allow_lamp='1')then
if(clk'event and clk='1') and (answer_success="0000")then
if(q="1111")then
q<="0000";
co<='1';
else
q<=q+'1';
co<='0';
end if;
end if;
end if;
end if;
end process;
lemp_rest_allow:process(rest,allow,co)is
begin
if(rest='1')then
stop_lamp<='1';
allow_lamp<='0'
lemp_answer:
process(allow_lamp,answer,rest,alamp)is
begin
if(rest='1')then
answer_success<="0000";--抢答成功灯的清零设置
lemp_foul:process(stop_lamp,answer)is
begin
if(rest='1')then
answer_foul<="0000";--抢答犯规灯的清零设置
if(allow='1')then
allow_lamp<='1';
stop_lamp<='0';
end if;
end if;
if(co='1')then
allow_lamp<='0';
stop_lamp<='1';
end if;
lemp_answer:process(allow_lamp,answer,rest,alamp)is
begin
if(rest='1')then
answer_success<="0000";
alamp<='0'; -- 清零部分
else
if(allow_lamp='1')then
if((alamp='0')and (answer(0)='1')and(foul(0)='0'))then
answer_success(0)<='1';
alamp<='1';
elsif((alamp='0') and (answer(1)='1')and(foul(1)='0'))then
answer_success(1)<='1';
alamp<='1';
elsif((alamp='0') and( answer(2)='1')and(foul(2)='0'))then
answer_success(2)<='1';
alamp<='1';
elsif((alamp='0') and (answer(3)='1')and(foul(3)='0'))then
answer_success(3)<='1';
alamp<='1';
end if;
end if;
end if;
end process;
lemp_foul:process(stop_lamp,answer)is
begin
if(rest='1')then
answer_foul<="0000";
foul<="0000";
else
if(stop_lamp='1')then
if(answer(0)='1')and(alamp='0')then
answer_foul(0)<='1';
foul(0)<='1';
--end if;
elsif(answer(1)='1')and(alamp='0')then
answer_foul(1)<='1';
foul(1)<='1';
--end if;
elsif(answer(2)='1')and(alamp='0')then
answer_foul(2)<='1';
foul(2)<='1';
--end if;
elsif(answer(3)='1')and(alamp='0')then
answer_foul(3)<='1';
foul(3)<='1';
--end if;
end if;
end if;
end if;
end process;
end rtl;
process (clk,allow) is
后面怎么会有is