数字式竞赛抢答器vhdl

上传人:小** 文档编号:89519033 上传时间:2019-05-26 格式:DOC 页数:15 大小:194KB
返回 下载 相关 举报
数字式竞赛抢答器vhdl_第1页
第1页 / 共15页
数字式竞赛抢答器vhdl_第2页
第2页 / 共15页
数字式竞赛抢答器vhdl_第3页
第3页 / 共15页
数字式竞赛抢答器vhdl_第4页
第4页 / 共15页
数字式竞赛抢答器vhdl_第5页
第5页 / 共15页
点击查看更多>>
资源描述

《数字式竞赛抢答器vhdl》由会员分享,可在线阅读,更多相关《数字式竞赛抢答器vhdl(15页珍藏版)》请在金锄头文库上搜索。

1、数字系统设计与硬件描述语言期末考试作业题目: 数字式竞赛抢答器设计 学院: 电子信息工程 专业: 电子信息工程 学号: 姓名: 一、 选题设计描述1. 功能介绍此设计用于竞赛的四人抢答,有如下的功能:(1) 具有多路抢答功能,台数设计为四;(2) 具有抢答器开始后30秒倒计时,30秒后无人抢答显示超时,并报警;(3) 能显示超前抢答犯规,并警报;(4) 能显示各组得分,大队加分,答错扣分;当系统复位,主持人按下抢答开始按键,处于使能状态,抢答开始,某路抢答键按下时,该路信号将其他路信号锁存,同时抢答铃声响起,直至此路按键松开,显示该路组号。2. 算法简介本设计采用分层设计思想,分为:信号鉴别模

2、块、计时模块、计分模块、BCD译码模块、分频器,还有顶层模块。信号鉴别模块。此模块主要实现抢答器的抢答功能,并能够分辨是正常抢答还是提前抢答,选取最先按下的一路信号,锁存其余信号,实现信号选取功能。在此模块中,用到的信号为抢答信号a、b、c、d;抢答使能信号en;抢答结果信号states;警报时钟信号clk2;复位信号rst;提前抢答信号fangui。计时模块。此模块主要实现抢答过程中的计时功能,在抢答开始后进行30秒的倒计时,且在30秒后显示无人抢答报警信号。其中有抢答时钟信号clk;系统复位信号rst;抢答使能信号en;无人抢答警报信号warn;计时中止信号stop;计时十位个位信号tb,

3、ta。计分模块。此模块主要实现给四个抢答器计分的功能,初始条件下,为每个抢答器信号预制5分,当某组抢答且回答正确时加一分,答错减一分,未获答题机会时保持不变。其中设有时钟信号clk;复位信号rst;抢答使能信号en;抢答结果显示信号states;记分加减信号add(add1时为加,add0时为减);四个信号的得分显示信号a_out,b_out,c_out,d_out。BCD译码模块。此模块主要实现将抢答结果信号显示在bcd七段译码器上。其中输入信号a;输出译码结果信号q。分频器。此模块主要实现时钟分频功能。在开头对时钟信号进行一次千分频。其中时钟输入信号clkin,输出信号clk。顶层模块。将

4、前几个模块综合在一起,形成一个整体。分频器输出作为其他模块所需的时钟信号,使整个系统正常运转。二、 程序源代码及说明抢答信号鉴别模块的程序:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity qdjb is port(clk2,en,rst:in std_logic; a,b,c,d:in std_logic; fangui:out std_logic; states:out std_logic_vector(3 downto 0);end qdjb;architecture one o

5、f qdjb issignal sinor,fanguif,tmp:std_logic;signal cnt:std_logic_vector(5 downto 0);beginsinor=a or b or c or d;p1:process(a,rst,b,c,d,tmp) begin if rst=1 then -复位信号有效,系统复位。 tmp=1;states=0000; elsif tmp=1 then if a=1 then -判断哪路信号变化,进行选取 states=0001;tmp=0; -对states进行置数 elsif b=1 then states=0010;tmp=

6、0; elsif c=1 then states=0011;tmp=0; elsif d=1 then states=0100;tmp=0; else tmp=1;states=0000; end if ; end if;end process p1; p2:process(clk2,en,rst,cnt) -判断是否提前抢答并报警 begin if rst=1 then cnt=000000;fanguif=0; -初始化提前抢答犯规信号 elsif clk2event and clk2=1 then if en=0 and sinor=1 then if cnt111111 then fa

7、nguif=not fanguif;cnt=cnt+1; else fanguif=0; end if; end if; end if;end process p2;fangui=fanguif;end one;计时模块的程序:library ieee; use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity js is port(clk,rst,en,stop:in std_logic; warn:buffer std_logic; ta,tb:buffer std_logic_vector(3 downto 0)

8、;end js;architecture one of js issignal co:std_logic;beginp1:process(clk,rst,en,stop,ta) -个位计时信号进行0到9循环计数 begin if rst=1 or stop=1 then ta=0000; elsif clkevent and clk=1 then co=0; if en=1 then if ta=0000 then ta=1001;co=1; else ta=ta-1; end if; end if; end if;end process p1;p2:process(co,rst,en,sto

9、p,tb) -十位计时信号0到3变化 begin if rst=1 or stop=1 then tb=0011; elsif coevent and co=1 then if en=1 then if tb=0000 then tb=0011; else tb=tb-1; end if; end if; end if;end process p2;p3:process(rst,ta,tb) -计时时间到达,报警 begin if rst=1 then warn=0; elsif ta=0000 and tb=0000 then warn=1; else warn=0; end if;end

10、process p3;end one;计分模块的程序:library ieee; use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity jf is port(clk,rst,en,add:in std_logic; states:in std_logic_vector(3 downto 0); a_out,b_out,c_out,d_out:buffer std_logic_vector(3 downto 0);end jf;architecture one of jf is beginp1:process(clk

11、,rst,add,states,a_out,b_out,c_out,d_out) begin if (rst=1) then a_out=0101;b_out=0101;c_out=0101;d_out if add=1 then -add信号为高时,加1分 if a_out=1111 then -最多15分 a_out=0000; else a_out=a_out+1; end if; elsif add=0 then -add信号为0,减1分 if a_out=0000 then a_out=0000; else a_out if add=1 then if b_out=1111 then b_out=0000; else b_out=b_out+1; end if; elsif add=0 then if b_out=0000 then

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 商业/管理/HR > 管理学资料

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号