数字式竞赛抢答器VHDL.docx

上传人:b****1 文档编号:2307339 上传时间:2022-10-28 格式:DOCX 页数:17 大小:137.95KB
下载 相关 举报
数字式竞赛抢答器VHDL.docx_第1页
第1页 / 共17页
数字式竞赛抢答器VHDL.docx_第2页
第2页 / 共17页
数字式竞赛抢答器VHDL.docx_第3页
第3页 / 共17页
数字式竞赛抢答器VHDL.docx_第4页
第4页 / 共17页
数字式竞赛抢答器VHDL.docx_第5页
第5页 / 共17页
点击查看更多>>
下载资源
资源描述

数字式竞赛抢答器VHDL.docx

《数字式竞赛抢答器VHDL.docx》由会员分享,可在线阅读,更多相关《数字式竞赛抢答器VHDL.docx(17页珍藏版)》请在冰豆网上搜索。

数字式竞赛抢答器VHDL.docx

数字式竞赛抢答器VHDL

数字系统设计与硬件描述语言

期末考试作业

 

题目:

数字式竞赛抢答器设计

学院:

电子信息工程

专业:

电子信息工程

学号:

姓名:

 

一、选题设计描述

1.功能介绍

此设计用于竞赛的四人抢答,有如下的功能:

(1)具有多路抢答功能,台数设计为四;

(2)具有抢答器开始后30秒倒计时,30秒后无人抢答显示超时,并报警;

(3)能显示超前抢答犯规,并警报;

(4)能显示各组得分,大队加分,答错扣分;

当系统复位,主持人按下抢答开始按键,处于使能状态,抢答开始,某路抢答键按下时,该路信号将其他路信号锁存,同时抢答铃声响起,直至此路按键松开,显示该路组号。

2.算法简介

本设计采用分层设计思想,分为:

信号鉴别模块、计时模块、计分模块、BCD译码模块、分频器,还有顶层模块。

信号鉴别模块。

此模块主要实现抢答器的抢答功能,并能够分辨是正常抢答还是提前抢答,选取最先按下的一路信号,锁存其余信号,实现信号选取功能。

在此模块中,用到的信号为抢答信号a、b、c、d;抢答使能信号en;抢答结果信号states;警报时钟信号clk2;复位信号

rst;提前抢答信号fangui。

计时模块。

此模块主要实现抢答过程中的计时功能,在抢答开始后进行30秒的倒计时,且在30秒后显示无人抢答报警信号。

其中有抢答时钟信号clk;系统复位信号rst;抢答使能信号en;无人抢答警报信号warn;计时中止信号stop;计时十位个位信号tb,ta。

计分模块。

此模块主要实现给四个抢答器计分的功能,初始条件下,为每个抢答器信号预制5分,当某组抢答且回答正确时加一分,答错减一分,未获答题机会时保持不变。

其中设有时钟信号clk;复位信号rst;抢答使能信号en;抢答结果显示信号states;记分加减信号add(add=‘1’时为加,add=‘0’时为减);四个信号的得分显示信号a_out,b_out,c_out,d_out。

BCD译码模块。

此模块主要实现将抢答结果信号显示在bcd七段译码器上。

其中输入信号a;输出译码结果信号q。

分频器。

此模块主要实现时钟分频功能。

在开头对时钟信号进行一次千分频。

其中时钟输入信号clkin,输出信号clk。

顶层模块。

将前几个模块综合在一起,形成一个整体。

分频器输出作为其他模块所需的时钟信号,使整个系统正常运转。

二、程序源代码及说明

抢答信号鉴别模块的程序:

libraryieee;

useieee.std_logic_1164.all;

useieee.std_logic_unsigned.all;

entityqdjbis

port(clk2,en,rst:

instd_logic;

a,b,c,d:

instd_logic;

fangui:

outstd_logic;

states:

outstd_logic_vector(3downto0));

endqdjb;

architectureoneofqdjbis

signalsinor,fanguif,tmp:

std_logic;

signalcnt:

std_logic_vector(5downto0);

begin

sinor<=aorborcord;

p1:

process(a,rst,b,c,d,tmp)

begin

ifrst='1'then--复位信号有效,系统复位。

tmp<='1';states<="0000";

elsiftmp='1'then

ifa='1'then--判断哪路信号变化,进行选取

states<="0001";tmp<='0';--对states进行置数

elsifb='1'then

states<="0010";tmp<='0';

elsifc='1'then

states<="0011";tmp<='0';

elsifd='1'then

states<="0100";tmp<='0';

elsetmp<='1';states<="0000";

endif;

endif;

endprocessp1;

p2:

process(clk2,en,rst,cnt)--判断是否提前抢答并报警

begin

ifrst='1'then

cnt<="000000";fanguif<='0';--初始化提前抢答犯规信号

elsifclk2'eventandclk2='1'then

ifen='0'andsinor='1'then

ifcnt<"111111"then

fanguif<=notfanguif;cnt<=cnt+1;

elsefanguif<='0';

endif;

endif;

endif;

endprocessp2;

fangui<=fanguif;

endone;

计时模块的程序:

libraryieee;

useieee.std_logic_1164.all;

useieee.std_logic_unsigned.all;

entityjsis

port(clk,rst,en,stop:

instd_logic;

warn:

bufferstd_logic;

ta,tb:

bufferstd_logic_vector(3downto0));

endjs;

architectureoneofjsis

signalco:

std_logic;

begin

p1:

process(clk,rst,en,stop,ta)--个位计时信号进行0到9循环计数

begin

ifrst='1'orstop='1'then

ta<="0000";

elsifclk'eventandclk='1'then

co<='0';

ifen='1'then

ifta="0000"then

ta<="1001";co<='1';

elseta<=ta-1;

endif;

endif;

endif;

endprocessp1;

p2:

process(co,rst,en,stop,tb)--十位计时信号0到3变化

begin

ifrst='1'orstop='1'then

tb<="0011";

elsifco'eventandco='1'then

ifen='1'then

iftb="0000"thentb<="0011";

elsetb<=tb-1;

endif;

endif;

endif;

endprocessp2;

p3:

process(rst,ta,tb)--计时时间到达,报警

begin

ifrst='1'then

warn<='0';

elsifta="0000"andtb="0000"then

warn<='1';

elsewarn<='0';

endif;

endprocessp3;

endone;

计分模块的程序:

libraryieee;

useieee.std_logic_1164.all;

useieee.std_logic_unsigned.all;

entityjfis

port(clk,rst,en,add:

instd_logic;

states:

instd_logic_vector(3downto0);

a_out,b_out,c_out,d_out:

bufferstd_logic_vector(3downto0));

endjf;

architectureoneofjfis

begin

p1:

process(clk,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<="0101";--初始化置5分

elsifen='1'then

ifclk'eventandclk='1'then

casestatesis

when"0001"=>

ifadd='1'then--add信号为高时,加1分

ifa_out="1111"then--最多15分

a_out<="0000";

elsea_out<=a_out+1;

endif;

elsifadd='0'then--add信号为0,减1分

ifa_out="0000"then

a_out<="0000";

elsea_out<=a_out-1;

endif;

endif;

when"0010"=>

ifadd='1'then

ifb_out="1111"then

b_out<="0000";

elseb_out<=b_out+1;

endif;

elsifadd='0'then

ifb_out="0000"then

b_out<="0000";

elseb_out<=b_out-1;

endif;

endif;

when"0011"=>

ifadd='1'then

ifc_out="1111"then

c_out<="0000";

elsec_out<=c_out+1;

endif;

elsifadd='0'then

ifc_out="0000"then

c_out<="0000";

elsec_out<=c_out-1;

endif;

endif;

when"0100"=>

ifadd='1'then

ifd_out="1111"then

d_out<="0000";

elsed_out<=d_out+1;

endif;

elsifadd='0'then

ifd_out="0000"then

d_out<="0000";

elsed_out<=d_out-1;

endif;

endif;

whenothers=>

a_out<=a_out;b_out<=b_out;c_out<=c_out;d_out<=d_out;

endcase;

endif;

endif;

endprocessp1;

endone;

抢答器顶层模块程序:

libraryieee;

useieee.std_logic_1164.all;

useieee.std_logic_unsigned.all;

entityqiangdais

port(clkin,clk2,en,a,b,c,d,add,stop,rst:

instd_logic;

fangui,alarm:

outstd_logic;

ta,tb:

bufferstd_logic_vector(3downto0);

states:

bufferstd_logic_vector(3downto0);

statesout:

outstd_logic_vector(0to

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > PPT模板 > 自然景观

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1