抢答器.docx

上传人:b****2 文档编号:18235925 上传时间:2023-04-24 格式:DOCX 页数:14 大小:92.35KB
下载 相关 举报
抢答器.docx_第1页
第1页 / 共14页
抢答器.docx_第2页
第2页 / 共14页
抢答器.docx_第3页
第3页 / 共14页
抢答器.docx_第4页
第4页 / 共14页
抢答器.docx_第5页
第5页 / 共14页
点击查看更多>>
下载资源
资源描述

抢答器.docx

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

抢答器.docx

抢答器

可编程逻辑器件应用

 

项目名称:

抢答器

指导老师:

龚兰芳

姓名:

李诗华

学号:

080212215

班级:

08电子2班

 

目录

一、设计要求--------------------------------------------------------------------------------

二、设计方案--------------------------------------------------------------------------------

三、设计程序--------------------------------------------------------------------------------

四、管脚分配---------------------------------------------------------------------------------

五、硬件下载实现现象描述-----------------------------------------------------------

六、体会与收获-----------------------------------------------------------------------------

一、设计要求

1.具有第一抢答信号的鉴别和锁存功能。

在主持人发出抢答指令后,若有参赛者按抢答器按钮,则该组指示灯亮,显示器显示出抢答者的组别。

同时,电路处于自锁状态,使其他组的抢答器按钮不起作用。

2.具有计时功能。

在初始状态时,主持人可以设置答题时间的初始值。

在主持人对抢答组别进行确认,并给出倒计时计数开始信号以后,抢答者开始回答问题。

此时,显示器从初始值开始倒计时,计至0时停止计数,同时扬声器发出超时报警信号。

若参赛者在规定的时间内回答完问题,主持人可以给出计时停止信号,以免扬声器鸣叫。

二、设计方案

从要实现的功能来看,层次化的设计会更加容易实现,将设计分为三个部分,第一部分用来实现第一抢答信号的鉴别和锁存功能,在主持人发出抢答指令后,若有参赛者按抢答器按钮,则该组指示灯亮,显示器显示出抢答者的组别。

同时,电路处于自锁状态,使其他组的抢答器按钮不起作用,第二部分用来实现在初始状态时,主持人可以设置答题时间的初始值。

在主持人对抢答组别进行确认,并给出倒计时计数开始信号以后,抢答者开始回答问题。

此时,显示器从初始值开始倒计时,计至0时停止计数,同时扬声器发出超时报警信号。

若参赛者在规定的时间内回答完问题,主持人可以给出计时停止信号,以免扬声器鸣叫。

第三部分是译码部分将主持人的设置的倒计时数值用数码显示出来。

 

三、设计程序

第一部分:

抢答模块

-------库-------

libraryieee;

useieee.std_logic_1164.all;

useieee.std_logic_unsigned.all;

useieee.std_logic_arith.all;

-------实体---------

entityjnbis

port(clk,i:

instd_logic;

u,r,t,y:

instd_logic;

led3:

outstd_logic_vector(3downto0);

k:

outstd_logic_vector(2downto0);

o:

outstd_logic_vector(3downto0));

end;

 

--------结构体---------

architectureoneofjnbis

signaln:

integerrange0to1;

signalclk_1k,clk_100h:

std_logic;

signaldata:

std_logic_vector(3downto0);

signals:

std_logic_vector(6downto0);

signalh:

std_logic_vector(2downto0);

signalj:

std_logic_vector(3downto0);

begin

process(clk)

variablecnt1:

integerrange0to250;

variablecnt2:

integerrange0to100;

begin

ifclk'eventandclk='1'then

ifcnt1=250then

cnt1:

=0;

ifcnt2=100then

cnt2:

=0;

clk_1k<=notclk_1k;

else

cnt2:

=cnt2+1;

endif;

else

cnt1:

=cnt1+1;

endif;

endif;

endprocess;

process(clk_1k)

begin

ifi='1'then

ifn=0then

ifu='0'then

led3<="0001";

j<="0111";

n<=n+1;

elsifr='0'then

led3<="0010";

j<="1011";

n<=n+1;

elsift='0'then

led3<="0011";

j<="1101";

n<=n+1;

elsify='0'then

led3<="0100";

j<="1110";

n<=n+1;

endif;

endif;

else

h<="100";

n<=0;

led3<="0000";

j<="1111";

endif;

k<=h;

o<=j;

endprocess;

end;

 

第二部分:

数值输入模块

libraryieee;

useieee.std_logic_1164.all;

useieee.std_logic_unsigned.all;

useieee.std_logic_arith.all;

entityWERis

port(rst,clk,tsr,en:

instd_logic;

p:

outstd_logic;

c,d:

instd_logic_vector(3downto0);

duon:

outstd_logic_vector(5downto0);

led3:

instd_logic_vector(3downto0);

cout:

outstd_logic_vector(6downto0));

end;

architectureoneofWERis

signalt,r:

integerrange0to1;

signalw:

integerrange0to6;

signalclk_1k:

std_logic;

signalclk_100h:

std_logic;

signalcnt6:

integerrange0to3;

signaldata:

std_logic_vector(3downto0);

signaldout:

std_logic_vector(5downto0);

signals:

std_logic_vector(6downto0);

signalled1,led2:

std_logic_vector(3downto0);

begin

process(clk)

variablecnt1:

integerrange0to250;

variablecnt2:

integerrange0to100;

begin

ifclk'eventandclk='1'then

ifcnt1=250then

cnt1:

=0;

ifcnt2=100then

cnt2:

=0;

clk_1k<=notclk_1k;

else

cnt2:

=cnt2+1;

endif;

else

cnt1:

=cnt1+1;

endif;

endif;

endprocess;

process(clk)

variablecnt1:

integerrange0to5000;

variablecnt2:

integerrange0to5000;

begin

ifclk'eventandclk='1'then

ifcnt1=5000then

cnt1:

=0;

ifcnt2=5000then

cnt2:

=0;

clk_100h<=notclk_100h;

else

cnt2:

=cnt2+1;

endif;

else

cnt1:

=cnt1+1;

endif;

endif;

endprocess;

process(clk_1k)

begin

ifclk_1k'eventandclk_1k='1'then

ifcnt6=33then

cnt6<=0;

else

cnt6<=cnt6+1;

endif;

endif;

endprocess;

process(cnt6)

begin

casecnt6is

when0=>dout<="111110";

when1=>dout<="111101";

when2=>dout<="111011";

whenothers=>null;

endcase;

endprocess;

process(dout)

begin

casedoutis

when"111110"=>data<=led1;

when"111101"=>data<=led2;

when"111011"=>data<=led3;

whenothers=>null;

endcase;

endprocess;

process(clk_100h)

begin

iftsr='0'then

led1<="0000";

led2<="0000";

t<=0;

else

ifrst='0'then

t<=1;

p<='0';

led2<=c;led1<=d;

elsifclk_100h'eventandclk_100h='1'andt=1then

ifen='1'then

if(led1<="0000")then

led1<="1001";

led2<=led2-1;

if(led2<="0000")then

led1<="0000";

led2<="0000";

ifw<=5then

p<='1';

w<=w+1;

else

p<='0';

endif;

else

p<='0';

endif;

else

led1<=led1-1;

endif;

else

t<=t-1;

endif;

endif;

endif;

endprocess;

process(data)

begin

casedatais

when"0000"=>s<="0111111";--0

when"0001"=>s<="0000110";--1

when"0010"=>s<="1011011";--2

when"0011"=>s<="1001111";--3

when"0100"=>s<="1100110";--4

when"0101"=>s<="1101101";--5

when"0110"=>s<="1111101";--6

when"0111"=>s<="0000111";--7

when"1000"=>s<="1111111";--8

when"1001"=>s<="1101111";--9

whenothers=>null;

endcase;

endprocess;

duon<=dout;

cout<=s;

end;

第三部分:

译码模块

libraryieee;

useieee.std_logic_1164.all;

useieee.std_logic_unsigned.all;

useieee.std_logic_arith.all;

entityyimais

port(h:

instd_logic_vector(6downto0);

a,b,c,d,e,f,g:

outstd_logic);

end;

architectureoneofyimais

begin

g<=h(6);

f<=h(5);

e<=h(4);

d<=h(3);

c<=h

(2);

b<=h

(1);

a<=h(0);

endone;

总体框图:

四、管脚分配

 

五.硬件下载实现现象描述

和预想的效果一样。

当主持人按下复位开关时,四个按键开关生效。

选手开始抢答。

抢答完后,显示管显示选手的号数。

这时主持人可以设置答题时间的初始值此时,显示器从初始值开始倒计时,计至0时停止计数,同时扬声器发出超时报警信号。

若参赛者在规定的时间内回答完问题,主持人可以用开关给出计时停止信号,以免扬声器鸣叫。

六、体会与收获

这次实验虽然要实现的功能比较多,看起来仿佛也比较复杂,但是我们用了层次化来设计程序以后,才发现其实也不是很复杂,把程序分成三个模块来设计,设计起来明显降低了难度。

只是在连接总体框上需要我们熟悉数电的知识,不过在翻阅资料后,问题都一一解决了。

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

当前位置:首页 > 外语学习 > 日语学习

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

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