VHDL语言设计四人抢答器(三种设计方案)

本文为大家带来三种四人抢答器的vhdl语言设计方案介绍。
vhdl语言设计四人抢答器方案一 设计要求 l、设计用于竞赛的四人抢答器,功能如下:
(1)有多路抢答器,台数为四,能显示抢答台号;
(2)具有抢答开始后20秒倒计时,20秒倒计时后无人抢答显示超时,并报警;
(3)能显示超前抢答台号并显示犯规警报;
2、系统复位后进入抢答状态,当有一路抢答键按下时,该路抢答信号将其余各路抢答封锁,同时铃声响,直至该路按键松开,显示牌显示该路抢答台号。
3、用vhdl语言设计符合上述功能要求的四人抢答器,并用层次设计方法设计该电路。
电路工作原理 简易逻辑数字抢答器由主体电路与扩展电路组成。优先编码电路、锁存器、译码电路将参赛队的输入信号在显示器上输出;用控制电路和主持人开关启动报警电路,以上两部分组成主体电路。通过定时电路和译码电路将秒脉冲产生的信号在显示器上输出实现计时功能,构成扩展电路。
电路主要由脉冲产生电路、锁存电路、编码及译码显示电路、倒计时电路和音响产生电路组成。当有选手抢答时,首先锁存,阻止其他选手抢答,然后编码,再经译码器将数字显示在显示器上同时产生音响。主持人宣布开始抢答时,倒计时电路启动由20计到0,如有选手抢答,倒计时停止,如20秒后无人抢答,则会显示报警。
源程序 libraryieee;
useieee.std_logic_1164.all;
useieee.std_logic_unsigned.all;
entityqdqis
port(clr,clk,clk0,en,a,b,c,d:instd_logic;
dps:outstd_logic_vector(3downto0);
count:outstd_logic_vector(7downto0);
speaker:outstd_logic);
end;
architectureoneofqdqis
signaldps1:std_logic_vector(3downto0);
signalcount1:std_logic_vector(7downto0);
signaltmp1,tmp2,tmp3:std_logic;
begin
p1:process(clr,en,tmp1,tmp2)
begin
ifclr=‘1’then
tmp1<=‘0’;tmp2<=‘0’;
dps1<=“0000”;
elsifen=‘1’then
iftmp1=‘0’then
ifa=‘1’then
tmp1<=‘1’;
dps1<=“0001”;
endif;
ifb=‘1’thentmp1<=‘1’;
dps1<=“0010”;
endif;
ifc=‘1’thentmp1<=‘1’;
dps1<=“0011”;
endif;
ifd=‘1’thentmp1<=‘1’;
dps1<=“0100”;
endif;
endif;
elsifen=‘0’then
iftmp2=‘0’then
ifa=‘1’then
tmp2<=‘1’;
dps1<=“0001”;
endif;
ifb=‘1’then
tmp2<=‘1’;
dps1<=“0010”;
endif;
ifc=‘1’then
tmp2<=‘1’;
dps1<=“0011”;
endif;
ifd=‘1’then
tmp2<=‘1’;
dps1<=“0100”;
endif;
endif;
endif;
endprocess;
p2:process(clr,clk,tmp1,tmp3)
begin
ifclk‘eventandclk=’1‘then
ifclr=’1‘thencount1<=“00100000”;
tmp3<=’0‘;
elsifen=’1‘andtmp1=’0‘andtmp3=’0‘then
ifcount1=“00000000”then
tmp3<=’1‘;
elsifcount1(3downto0)=“0000”then
count1(3downto0)<=“1001”;
count1(7downto4)<=count1(7downto4)-’1‘;
elsecount1(3downto0)<=count1(3downto0)-’1‘;
endif;
endif;
endif;
endprocess;
count<=count1;
dps<=dps1;
speaker<=((tmp3oraorborcord)andclk0);
end;
仿真波形 (一)无人抢答的仿真波形
由上图可知,当en=0时此时主持人并没有提出开始抢答的信号.en=1,开始抢答的时候20秒倒计时,时间到而无人抢答。(count=“00000000”),则speaker报警,按下清零开关(clr=1),重新开始20秒倒计时进行下一轮
(二)有人抢答的仿真波形
由上图可知,clr=1,系统进入初始状态,即count=“00100000”,dps=“0000”;en=0时,此时主持人并没有提出开始抢答的信号是不允许抢答的,若有人抢答(b=1),则speaker报警,且数码管显示组别(dps=“0010”)显示出犯规的组别;en=1时,开始正常抢答而且count开始20秒倒计时,在15秒时(count=“00010101”)有人抢答(a=1),倒计时暂停同时锁存器工作将其他组别的信号锁存后面的信号将视为无效,数码管显示组别(dps=“0001”),且speaker报警。
vhdl语言设计四人抢答器方案二 设计任务及要求:
(1)设计用于竞赛抢答的四人抢答器;
①有多路抢答,抢答台数为8;
②具有抢答开始后20秒倒计时,20秒倒计时后无人抢答显示超时,并报警;
③能显示超前抢答台号并显示犯规警报;
(2)系统复位后进入抢答状态,当有一路抢答按键按下,该路抢答信号将其余各路抢答信号封锁,同时铃声想起,直至该路按键松开,显示牌显示该路抢答台号;
(3)用vhdl语言设计符合上述功能要求的四人抢答器,并用层次化设计方法设计该电路;
设计思路 设计制作一个竞赛抢答器,每组受控于一个抢答开关,分别为s1,s2,s3,s4,低电平表示抢答有效;设置主持人控制键k,用于控制整个系统清0和抢答有效控制,按下复位键时,k=0,系统清零;抬起复位键时,k=1,抢答开始;系统具有第一抢答信号鉴别和锁存功能。在主持人将系统复位并使抢答有效开始后,第一抢答者按下抢答按钮,对应的输入引脚接低电位0,电路应记忆下第一抢答者的组别,并封锁其他各组的按钮,即其他任何一组按键都不会使电路响应;系统以两种方式指示第一抢答者:其一是通过译码程序显示其组别号;其二是在第一抢答者产生时,蜂鸣器警示;设置违规电路单元,当抢答者在主持人按下复位清零按钮之前就已经按下抢答按钮时,则给出违规信号为高电平。对应组别的红色信号灯亮;当20秒倒计时后无人抢答显示超时,并报警。
vhdl程序实现 1、正常抢答程序 此模块包括正常抢答第一信号鉴别和显示抢答台号,并发生声音提示。其中s1,s2,s3,s4为抢答按钮,当对应的按钮信号为0时表示有抢答信号;k为主持人按钮,按下复位键k时, k=0,系统清零;抬起复位键时,k=1,抢答开始;g为报警信号。其vhdl源程序如下:
library ieee;
use ieee.std_logic_1164.all;
use ieee. std_logic_arith.all;
use ieee. std_logic_unsigned.all;
--------------------------------------------------------------------
entity qiangda is
port( s1,s2,s3,s4 : in std_logic; --输入:表示4个人,为0表示有抢答
k : in std_logic; --主持人抢答开始键
g : out std_logic; --报警信号
ledag : out std_logic_vector (6 downto 0);
dout : out std_logic_vector(3 downto 0) ); --抢答结果显示
end qiangda;
--------------------------------------------------------------------
architecture behave of qiangda is
signal enable_flag : std_logic;--允许抢答控制变量,为1表示允许抢答
signal s : std_logic_vector(3 downto 0);
signal d : std_logic_vector(3 downto 0);
begin
process(s1,s2,s3,s4,k) --允许抢答控制
begin
s<=s1&s2&s3&s4;
if (k=‘1’) then
enable_flag<=‘1’;
elsif(s/=“1111”) then
enable_flag<=‘0’;
end if;
end process;
process(s1,s2,s3,s4,k) --抢答结果显示
begin
if(k=‘0’) then
d<=“0000”;
elsif (enable_flag=‘1’) then
if(s1=‘0’) then
d(0)<=‘1’;
g<=‘0’;
elsif(s2=‘0’) then
d(1)<=‘1’;
g<=‘0’;
elsif(s3=‘0’) then
d(2)<=‘1’;
g<=‘0’;
elsif(s4=‘0’) then
d(3)<=‘1’;
g<=‘0’;
end if;
doutledagledagledagledagledagledag<=“0000000”;
end case;
end process;
end behave;
2、抢答倒计时程序 此模块为抢答20s倒计时程序,在主持人按下按钮k后此模块即开始工作,在20s倒计时完后会有声音提示,g为声音报警信号。
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity count is
port (clk, enable_flag: in std_logic;
h,l: out std_logic_vector (3 downto 0);
g:out std_logic); --声音报警
end count;
architecture count_arc of count is
begin
process (clk, enable_flag)
variable hh, ll: std_logic_vector (3 downto 0);
begin
if clk‘event and clk=’1‘then
if enable_flag=’1‘then
if ll=0 and hh=0 then
g<=’1‘;
elsif ll=0 then
ll: =“1001”;
hh: =hh-1;
else
ll: =ll-1;
end if;
else
g<=’0‘;
hh: =“1001”;
ll: =“1001”;
end if;
end if;
h<=hh;
l<=ll;
end process;
end count_arc;
3、超前犯规抢答程序 此模块为违规电路。当抢答者在主持人复位系统之前就已按下抢答按钮,即当reset=0时,有抢答信号出现,则y=11表示某组违规,当reset = 1时,显示违规组别。其中k为主持人按钮,s1,s2,s3,s4为抢答按钮,r1,r2,r3,r4为对应组别犯规红色显示灯。其vhdl源程序如下:
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity wg is
port(k: in std_logic;
s1, s2, s3, s4: in std_logic;
r1, r2, r3, r4: out std_logic; --红色灯指示超前抢答台号
y: out std_logic_vector (1 downto 0) );
end wg;
architecture a of wg is
signal temp1: std_logic;
signal temp2: std_logic_vector (1 downto 0);
begin
temp1<=s1 or s2 or s3 or s4 ;
temp2yyyy<=“00”;
end case;
if(k<=‘0’) then
if(s1=‘0’) then
r1<=‘0’;
elsif(s2=‘0’) then
r2<=‘0’;
elsif(s3=‘0’) then
r3<=‘0’;
elsif(s4=‘0’) then
r4<=‘0’;
end if;
end if;
end process;
vhdl语言设计四人抢答器方案三 问题描述 设计一个4人参加的智力竞赛抢答计时器。电路具有回答问题时间控制功能。要求回答问题时间小于等于100妙(显示为0~99),时间显示采用倒计时方式。当达到限定时间时,发出声响以示警告;当有某一参赛者首先按下抢答开关时,相应显示灯亮并伴有声响,此时抢答器不再接受其他输入信号。
功能要求 1、用feng模块将选手按下按键信号输出高电平给锁存模块lockb,进行锁存的同时发出aim信号实现声音提示,并使count模块进行答题时间的倒计时,在计满100妙后送出声音提示;
2、用ch41a模块将抢答结果转换为二进制数;
3、用sel模块产生数码管片选信号;
4、用ch42a模块将对应数码管片选信号,送出需要的显示信号;
5、用七段译码器dispa模块进行译码。
各模块vhdl源代码 1、抢答鉴别模块feng的vhdl源程序 --feng.vhd
library ieee;
use ieee.std_logic_1164.all;
entity feng is
port(cp,clr:in std_logic;
q :out std_logic);
end feng;
architecture feng_arc of feng is
begin
process(cp,clr)
begin
if clr=‘0’then
q<=‘0’;
elsif cp‘event and cp=’0‘then
q<=’1‘;
end if;
end process;
end feng_arc;
2、片选信号产生模块sel的vhdl源程序 --sel.vhd
library ieee;
use ieee.std_logic_1164.all;
entity sel is
port(clk:in std_logic;
a:out integer range 0 to 7);
end sel;
architecture sel_arc of sel is 片选信号产生模块sel
begin
process(clk)
variable aa:integer range 0 to 7;
begin
if clk’event and clk=‘1’then
aa:=aa+1;
end if;
a<=aa;
end process;
end sel_arc;
3、锁存器模块lockb的vhdl源程序 -lockb.vhd
library ieee;
use ieee.std_logic_1164.all;
entity lockb is
port(d1,d2,d3,d4:in std_logic;
clk,clr:in std_logic;
q1,q2,q3,q4,alm:out std_logic);
end lockb;
architecture lock_arc of lockb is
begin
process(clk)
begin
if clr=‘0’then
q1<=‘0’;
q2<=‘0’;
q3<=‘0’;
q4<=‘0’;
alm<=‘0’; 模块lockb
elsif clk‘event and clk=’1‘then
q1<=d1;
q2<=d2;
q3<=d3;
q4<=d4;
almqqqqqqqqq<=“1111”;
end case;
end process;
end ch31_arc;
6、倒计时模块count的vhdl源程序 倒计时模块count如图16-7所示,该模块实现答题时间的倒计时,在计满100s后送出声音提示。
--count.vhd
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity count is
port(clk,en:in std_logic; 倒计时 模块count
h,l:out std_logic_vector(3 downto 0);
sound:out std_logic);
end count;
architecture count_arc of count is
begin
process(clk,en)
variable hh,ll:std_logic_vector(3 downto 0);
begin
if clk’event and clk=‘1’then
if en=‘1’then
if ll=0 and hh=0 then
sound<=‘1’;
elsif ll=0 then
ll:=“1001”;
hh:=hh-1;
else
ll:=ll-1;
end if;
else
sound<=‘0’;
hh:=“1001”;
ll:=“1001”;
end if;
end if;
h<=hh;
lqqqqqqqqqqq<=“0000000”;
end case;
end process;
end disp_arc;

磁场中电流的作用力 电线上相互承载电流的力
砷化镓概念股有哪些? 砷化镓概念股一览
晶华微携全新产品亮相2023慕尼黑上海电子展
20+论坛活动开启2016中国(成都)电子展智慧分享模式
超声波工艺对晶振造成的损伤
VHDL语言设计四人抢答器(三种设计方案)
防水智能穿戴设备,融入IP67级疏水e-ptfe膜材料
区块链能为物联网做哪些改变
基于空间矢量调制的三相矩阵式变换器
概伦电子积极探索国内EDA人才培养的新模式
如何在嵌入式系统中使用音频编解码器更轻松地优化音频性能?
对于云服务器它自身的安全性能怎么样
关于互动远程教育分析和介绍
物通博联水文监测网关实现SL651多种报文数据传输
IGBT可靠性与寿命评估研究
苹果6.5/6.1英寸iPhone真机模型疑似曝光,都采用刘海全面屏
什么是非均匀数据重采样?哪种非均匀数据重采样方法更适合你?
三星CMOS 影像传感器猛追Sony,与Sony的产量差距将大幅缩小
时钟缓冲器单芯片解决方案的主要技术特点
小米线下掘金,还差这三板斧