四人抢答器设计报告

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

四人抢答器设计报告
一、设计任务及要求
1、设计用于竞赛的四人抢答器
(1)有多路抢答器,台数为四;
(2)具有抢答开始后20秒倒计时,20秒倒计时后无人抢答显示超时,并报警;
(3)能显示超前抢答台号并显示犯规报警;
2、系统复位后进入抢答状态,当有一路抢答键按下时,该路抢答信号将其余各路抢答封锁,同时铃声响起,直至该路按键放松,显示牌显示该路抢答台号;
3、用VHDL语言设计符合上述功能要求的四人抢答器,并用层次设计方法设计该电路;
4、完成电路全部设计后,通过系统实验箱下载验证设计课题的正确性。

二、四人抢答器框图及设计说明
系统复位后,反馈信号为一个高电平,K1、K2、K3、K4输入有效。

当抢答开始后,在第一位按键后,保持电路低电平,同时送显示电路,让其保存按
键的台号并输出,同时反馈给抢答台,使所有抢答台输入无效,计时电路停止;当在规定的时间内无人抢答时,倒计时电路输出超时信号;当主持人开始说话未说完有人抢先按键时,显示犯规信号。

当选手回答正确时加分,回答错误时减分。

由主持人控制加减分数。

三、设计思路:根据设计框图和设计要求,本次实验可以采用模块化设计方法来实现智力竞赛四人抢答器。

将抢答器划分为抢答鉴别保持模块,倒计时模块,记分模块和判断显示模块。

再利用元件例化语句将这四个模块组成总的抢答器的设计电路。

选用模式五进行程序的下载。

四、VHDL语言设计与分析
1、鉴别模块
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity jianbie is
port(nu1,nu2,nu3,nu4:in std_logic;
clk,en,rst:in std_logic;
warn:out std_logic;
back:buffer std_logic;
s:out std_logic_vector(3 downto 0));
end jianbie;
architecture jianbiebeh of jianbie is
signal num,warnd:std_logic;
signal cnt:std_logic_vector(2 downto 0);
begin
num<=nu1 or nu2 or nu3 or nu4;
p1:process(rst, nu1,nu2,nu3,nu4,back) --判断抢答信号
begin
if rst='1' then back<='1';s<="0000";
elsif back='1' then
if nu1='1' then s<="0001";back<='0'; --一号台抢答,输出S为1 elsif nu2='1' then s<="0010";back<='0'; --二号台抢答,输出S为2
elsif nu3='1' then s<="0011";back<='0'; --三号台抢答,输出S为3 elsif nu4='1' then s<="0100";back<='0'; --四号台抢答,输出S为4 else back<='1'; s<="0000"; --无人抢答,输出S为0
end if ;
end if;
end process p1;
p2:process(clk,en,back,rst,cnt)
begin
if rst='1' then cnt<="000";warnd<='0';
elsif clk'event and clk='1' then
if en='0' and back='0' then
if cnt<"111" then warnd<=not warnd; cnt<=cnt+1;
else warnd<='0';
end if; end if;
end if;
end process p2;
warn<=warnd;
end jianbiebeh;
鉴别保持模块由两个进程组成,进程一主要用于鉴别强大信号,进程二用于鉴别是否为超前抢答,若是超前抢答,则输出报警信号。

其中鉴别保持模块的波形如下:
如图所示,抢答开始前需要一个RST信号,其由主持人控制。

当RST为高电平时则抢答开始。

输出S显示为抢答台号,当主持人还没有复位就有选手抢答,则输出一个WARN的高电平信号。

2、计时模块
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity jishibaojing is
port(clk,rst,agree,stop:in std_logic;
warn:buffer std_logic;
cone:buffer std_logic_vector(3 downto 0);
cten:buffer std_logic_vector(3 downto 0));
end jishibaojing;
architecture jishibeh of jishibaojing is
signal cc:std_logic;
begin
p1:process(warn,clk,rst,agree,stop,cone) --个位计时
begin
if rst='1' then cone<="0000";
elsif stop='0' then cten<="0000";
elsif clk'event and clk='1' then cc<='0';
if agree='1' and warn='0' then cone<=cone-1;
if cone="0000" then cone<="1001";cc<='1'; end if;
end if;
end if;
end process p1;
p2:process(cc,rst,agree,stop,cten) --十位计时
begin
if rst='1' then cten<="0010";
elsif stop='0' then cten<="0010";
elsif cc'event and cc='1' then
if agree='1' and warn='0' then cten<=cten-1; end if;
end if;
end process p2;
p3:process(rst,cone,cten) --若20S内无人抢答,则报警
begin
warn<=’1’when(data="0000")
else ‘0’;
end process p3;
end jishibeh;
计时模块由三个进程组成:进程一为二十秒倒计时的个位计时;进程二为二十秒倒计时的十位计时;进程三为二十秒倒计时计数完毕无人抢答,发出报警信号。

计时模块的波形如下:
如图所示,计时由二十开始,一直记到零零结束。

其中如果有抢答信号则重新从二十开始计数,为选手的答题倒计时时间。

如果二十秒之内无人抢答,则报警信号出现一个高电平。

3、记分模块
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity fenshu is
port(clk,rst,plus_s,sub_s:in std_logic;
s:in std_logic_vector(3 downto 0);
a1,a2,a3,a4:buffer std_logic_vector(3 downto 0));
end fenshu;
architecture fenshubeh of fenshu is
begin
process(clk,rst,plus_s,sub_s,s,a1,a2,a3,a4)
begin
if clk'event and clk='1' then
if rst='1' then a1<=a2<=a3<=a4<=’0’; --开始时,分数均为零
elsif s ="0001" then --选手一抢答
if plus_s='1' then --加分
if a1="1111" then a1<="0000"; else a1<=a1+1; end if;
elsif sub_s='1' then
if a1="0000" then a1<="0000"; else a1<=a1-1; end if;
end if;
elsif s= "0010" then --二号选手抢答
if plus_s='1' then
if a2="1111" then a2<="0000"; else a2<=a2+1; end if;
elsif sub_s='1' then
if a2="0000" then a2<="0000"; else a2<=a2-1; end if;
end if;
elsif s="0011" then -- 三号选手抢答
if plus_s='1' then
if a3="1111" then a3<="0000";else a3<=a3+1;end if;
elsif sub_s='1' then
if a3="0000" then a3<="0000"; else a3<=a3-1; end if;
end if;
elsif s= "0100" then --四号选手抢答
if plus_s='1' then
if a4="1111" then a4<="0000";else a4<=a4+1; end if;
elsif sub_s='1' then
if a4="0000" then a4<="0000"; else a4<=a4-1; end if;
end if;
end if;
end if;
end process;
end fenshubeh;
计分模块仅有一个进程组成。

若一号选手抢答,则开始给一号台计分,其余也是如此。

当分数记为“1111”时,再加分则为“0000”;当分数记为“0000”时再减分时仍然为“0000”。

其中记分模块的波形如下:
4、模块
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity segment is
port (sg_en:in std_logic;
sg_in:in std_logic_vector(3 downto 0);
sg:out std_logic_vector(6 downto 0));
end segment;
architecture one of segment is
begin
process(sg_en)
begin
if sg_en='0' then
if sg_in<=”0001”then sg<=”0000110”;
if sg_in<=”0010”then sg<=”1011011”;
if sg_in<=”0100”then sg<=”1001111”;
if sg_in<=”1000”then sg<=”1100110”;
end if;
end if;
end process;
end one;
模块四连接数码管,当选控信号选择1,则一号数码管显示;选控信号选择2,则二号数码管显示;选控信号选择3,则三号数码管显示;选控信号选择4,则四号数码管显示;
5、抢答器总模块
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity q_da is
port(clk,en,k1,k2,k3,k4,rst,plus,sub:in std_logic;
ring,warn:out std_logic;
cone,cten:buffer std_logic_vector(3 downto 0);
a1,a2,a3,a4:out std_logic_vector(3 downto 0);
s:buffer std_logic_vector(3 downto 0));
end q_da;
architecture bhv of q_da is
component jianbie is --鉴别模块
port(clk,en,rst:in std_logic;
warn:out std_logic;
back:buffer std_logic;
nu1,nu2,nu3,nu4:in std_logic;
s:out std_logic_vector(3 downto 0));
end component;
component jishibaojing is --计时模块
port(clk,rst,agree,stop:in std_logic;
warn:out std_logic;
cone:buffer std_logic_vector(3 downto 0);
cten:buffer std_logic_vector(3 downto 0));
end component;
component fenshu is --计分模块
port(clk,rst,plus_s,sub_s:in std_logic;
s:in std_logic_vector(3 downto 0);
a1,a2,a3,a4:buffer std_logic_vector(3 downto 0));
end component;
signal back_in,warn_out,warn1:std_logic:='0';
signal sf,cnt:std_logic_vector(3 downto 0);
begin
s<=sf;
process(warn1,clk,rst,back_in)
begin
if rst='1' then --初始状态
cnt<="0000";warn_out<='0';
elsif clk'event and clk='1' then
if warn1='1' and back_in='1' then
if cnt<"1010" then warn_out<=not warn_out; cnt<=cnt+1;
else warn_out<='0';
end if;
end if ;
end if;
end process;
warn<=warn_out;
u1:stay port map(clk,en,rst,ring,back_in,k1,k2,k3,k4,sf);
u2:jishibaojing port map(clk,rst,en,back_in,warn1,cone,cten);
u3:jf port map(clk,rst,plus,sub,sf,a1,a2,a3,a4);
end bhv;
将上述四个模块进行元件例化,采用顺序语句组合在一起,其总的波形如下图所示:
波形分析如下:由主持人控制系统复位信号、抢答开始信号和加分减分信号。

开始时系统复位。

抢答信号低电平无效、时间信号预置为二十秒。

允许抢答后,当有一路信号优先抢答时,开始重新二十秒倒计时并将其它信号封闭。

五、实验中出现的问题及解决办法
(1)实验中经常出现编译未通过的现象,经检查核对程序,发现有时是因为漏掉分号,或者if语句不完全,漏掉end if等的原因。

(2)仿真中会出现仿真波形与设计需要波形不符,检查后发现多数时候因为对功能描述语句使用有误,后者描述语句的顺序使用错误导致。

(3)将程序下载至实验板上时,扬声器不能发声。

将其输出该接至显示灯时,显示正常。

判定为扬声器的频率选择有误。

六、实验总结
通过本次课程设计,加深了对VHDL语言及其运用的理解。

VHDL语言是一门灵活的电子设计语言。

EDA是通过这种硬件描述语言,在PLD开发软件上进行电子系统的设计。

了解了电子系统设计的整个流程。

在我们以后的学习和工作中,我相信一定有很大的作用。

七、参考文献:
(1)江国强,《EDA技术与应用(第2版)》,电子工业出版社,2007
(2)王勇,《电子设计自动化实验指导书》,河南科技大学电子信息工程学院,2007
(3)谭会生、瞿遂春,《EDA技术综合应用实例与分析》,西安电子科技大学出版社,2004
(4)高有堂,《EDA技术及应用实践》,清华大学出版社,2006
(5)邹彦、庄严、邹宁、王宇鸿,《EDA计术与数字系统设计》,电子工业出版社,2007
(6)曹昕燕、周凤臣等,《EDA技术实验与课程设计》,清华大学出版社,2006。

相关文档
最新文档