EDA中用VHDL语言设计五人抢答器
要求:1.电路设置有5个抢答按钮A~E,开始抢答控制按钮Start,以及复位按钮RST2.抢答前或复位时数码管显示为“0”,抢答完成后则显示抢答者的编号“1”~“5”(哪...
要求:1.电路设置有5个抢答按钮A~E,开始抢答控制按钮Start,以及复位按钮RST
2.抢答前或复位时数码管显示为“0”,抢答完成后则显示抢答者的编号“1”~“5”
(哪位知道怎么写的大哥帮我写哈程序啊~~谢谢了) 展开
2.抢答前或复位时数码管显示为“0”,抢答完成后则显示抢答者的编号“1”~“5”
(哪位知道怎么写的大哥帮我写哈程序啊~~谢谢了) 展开
1个回答
2013-06-26
展开全部
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_ARITH.all;
use ieee.std_logic_UNSIGNED.all;
ENTITY BIAOJUE IS
PORT(
FF:IN STD_LOGIC_VECTOR(1 TO 5);
QQ:OUT BIT;
QALL:OUT STD_LOGIC_VECTOR(3 DOWNTO 1);
SHIJIAN:BUFFER STD_LOGIC_VECTOR(3 DOWNTO 0);
FUWEI,KAISHI,CLK:IN STD_LOGIC);
END BIAOJUE;
ARCHITECTURE FUNG OF BIAOJUE IS
BEGIN
PROCESS(FF,CLK,KAISHI,FUWEI)
VARIABLE SUO:BOOLEAN;
VARIABLE SUM:STD_LOGIC_VECTOR(1 TO 3);
BEGIN
IF (FUWEI='0') THEN
QQ<='0';
SHIJIAN<="1010";
SUO:=FALSE;
SUM:="000";
QALL<="000";
ELSIF (CLK'EVENT AND CLK='1') THEN
IF (KAISHI='1') THEN
IF (NOT SUO) THEN
IF SHIJIAN="0000" THEN
SUO:=TRUE;
FOR N IN 1 TO 5 LOOP
SUM:=FF(N)+SUM;
END LOOP;
ELSE
SHIJIAN<=SHIJIAN-1;
END IF;
END IF;
QALL<=SUM;
IF (SUM >= 3) THEN
QQ<='1';
ELSE
QQ<='0';
END IF;
END IF;
END IF;
END PROCESS;
END FUNG;
use ieee.std_logic_1164.all;
use ieee.std_logic_ARITH.all;
use ieee.std_logic_UNSIGNED.all;
ENTITY BIAOJUE IS
PORT(
FF:IN STD_LOGIC_VECTOR(1 TO 5);
QQ:OUT BIT;
QALL:OUT STD_LOGIC_VECTOR(3 DOWNTO 1);
SHIJIAN:BUFFER STD_LOGIC_VECTOR(3 DOWNTO 0);
FUWEI,KAISHI,CLK:IN STD_LOGIC);
END BIAOJUE;
ARCHITECTURE FUNG OF BIAOJUE IS
BEGIN
PROCESS(FF,CLK,KAISHI,FUWEI)
VARIABLE SUO:BOOLEAN;
VARIABLE SUM:STD_LOGIC_VECTOR(1 TO 3);
BEGIN
IF (FUWEI='0') THEN
QQ<='0';
SHIJIAN<="1010";
SUO:=FALSE;
SUM:="000";
QALL<="000";
ELSIF (CLK'EVENT AND CLK='1') THEN
IF (KAISHI='1') THEN
IF (NOT SUO) THEN
IF SHIJIAN="0000" THEN
SUO:=TRUE;
FOR N IN 1 TO 5 LOOP
SUM:=FF(N)+SUM;
END LOOP;
ELSE
SHIJIAN<=SHIJIAN-1;
END IF;
END IF;
QALL<=SUM;
IF (SUM >= 3) THEN
QQ<='1';
ELSE
QQ<='0';
END IF;
END IF;
END IF;
END PROCESS;
END FUNG;
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询