设计数字式竞赛抢答器,用VHDL语言描述,用QuartusII工具编译和综合
1个回答
展开全部
7位抢答器设计:
LIBRARY IEEE;
USE IEEE.Std_logic_1164.ALL;
ENTITY Responder IS -- 实体声明
PORT(Start:IN Std_logic; -- 端口声明
Key:IN Std_logic_Vector(7 DOWNTO 1);
Led:OUT Std_logic_Vector(7 DOWNTO 1));
END Responder;
ARCHITECTURE behave OF Responder IS -- 结构体声明
SIGNAL mask_off:Std_logic; -- 信号声明
BEGIN
P1:PROCESS(Start,Key) -- 进程语句
BEGIN
IF Start = '0' THEN -- 行为描述
mask_off <= ‘0’; -- 起始信号Start复位mask_off信号
ELSIF (Key = "1111110" OR Key = "1111101" OR Key = "1111011" OR
Key = "1110111" OR Key = "1101111" OR Key = "1011111" OR
Key = "0111111") THEN
mask_off <= ‘1’; -- 某一按键按下则令mask_off信号出现上升沿
END IF;
END PROCESS;
P2:PROCESS(Start,mask_off) -- 进程语句
BEGIN
IF Start = '0' THEN -- 行为描述
Led <=(OTHERS => ‘0’); -- 7D触发器异步复位
ELSIF Rising_Edge (mask_off) THEN -- 出现mask_off信号上升沿
Led <= NOT Key; -- 7D触发器锁存Key(7)~Key(1)
END IF;
END PROCESS;
END behave;
如果上面的描述中包含有全角符号的话,你将其改成半角符号即可。
LIBRARY IEEE;
USE IEEE.Std_logic_1164.ALL;
ENTITY Responder IS -- 实体声明
PORT(Start:IN Std_logic; -- 端口声明
Key:IN Std_logic_Vector(7 DOWNTO 1);
Led:OUT Std_logic_Vector(7 DOWNTO 1));
END Responder;
ARCHITECTURE behave OF Responder IS -- 结构体声明
SIGNAL mask_off:Std_logic; -- 信号声明
BEGIN
P1:PROCESS(Start,Key) -- 进程语句
BEGIN
IF Start = '0' THEN -- 行为描述
mask_off <= ‘0’; -- 起始信号Start复位mask_off信号
ELSIF (Key = "1111110" OR Key = "1111101" OR Key = "1111011" OR
Key = "1110111" OR Key = "1101111" OR Key = "1011111" OR
Key = "0111111") THEN
mask_off <= ‘1’; -- 某一按键按下则令mask_off信号出现上升沿
END IF;
END PROCESS;
P2:PROCESS(Start,mask_off) -- 进程语句
BEGIN
IF Start = '0' THEN -- 行为描述
Led <=(OTHERS => ‘0’); -- 7D触发器异步复位
ELSIF Rising_Edge (mask_off) THEN -- 出现mask_off信号上升沿
Led <= NOT Key; -- 7D触发器锁存Key(7)~Key(1)
END IF;
END PROCESS;
END behave;
如果上面的描述中包含有全角符号的话,你将其改成半角符号即可。
追问
谢谢,我还想问一下抢答器中如何嵌入计时功能
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询