四路抢答器EDA2.docx

上传人:b****6 文档编号:15584259 上传时间:2023-07-05 格式:DOCX 页数:14 大小:253.04KB
下载 相关 举报
四路抢答器EDA2.docx_第1页
第1页 / 共14页
四路抢答器EDA2.docx_第2页
第2页 / 共14页
四路抢答器EDA2.docx_第3页
第3页 / 共14页
四路抢答器EDA2.docx_第4页
第4页 / 共14页
四路抢答器EDA2.docx_第5页
第5页 / 共14页
四路抢答器EDA2.docx_第6页
第6页 / 共14页
四路抢答器EDA2.docx_第7页
第7页 / 共14页
四路抢答器EDA2.docx_第8页
第8页 / 共14页
四路抢答器EDA2.docx_第9页
第9页 / 共14页
四路抢答器EDA2.docx_第10页
第10页 / 共14页
四路抢答器EDA2.docx_第11页
第11页 / 共14页
四路抢答器EDA2.docx_第12页
第12页 / 共14页
四路抢答器EDA2.docx_第13页
第13页 / 共14页
四路抢答器EDA2.docx_第14页
第14页 / 共14页
亲,该文档总共14页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

四路抢答器EDA2.docx

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

四路抢答器EDA2.docx

四路抢答器EDA2

DEA设计——四路抢答器

学院:

自动化

专业:

自动化

姓名:

小组成员:

指导老师:

二零一五年九月二十八日

1实验任务及要求1

2程序流程图2

3电路原理图3

4电路模块3

4.1KEY模块3

4.2KEEP模块4

4.3TIME模块5

4.4STATE模块6

4.5BEEP模块7

5下载程序8

5.1分配引脚8

5.2下载到实验箱8

6实验心得9

 

1实验任务及要求

1.设计用于竞赛抢答的四人抢答器

1)有多路抢答,抢答台数为4;

2)抢答开始后20秒倒计时,20秒后无人抢答显示超时并报警;

3)能显示抢答台号并显示犯规警报;

2.系统复位后进入抢答状态,当有一路抢答键按下,该路抢答信号将其他各路抢答信号封锁,同时铃声响起,直至该路按键松开,显示该路抢答台号。

3.用VHDL语言设计符合上述功能要求的四人抢答器,并用层次化设计方法设计该电路。

4.完成电路设计后,通过系统试验箱下载验证设计的正确性。

2程序流程图

图2.1程序流程图

3电路原理图

电路原理图如下:

图3.1电路原理图

电路说明:

1)抢答状态由一个数码管显示,“F”代表超时,“E”代表犯规,“0”代表正常。

2)倒计时由两个数码管显示,从“20”记到“00”。

3)还有一个数码管用来显示当前抢答号“1”,“2”,“3”,“4”。

4电路模块

在这次实验当中,我在小组里负责编写STATE模块的编写,因此着重介绍STATE模块的程序。

4.1KEY模块

图4.1EntityKEY

这一模块主要负责按键的输入部件,设计一个重置按钮,一个开始按钮,和4个抢答按钮。

代码:

见附录

4.2KEEP模块

图4.2EntityKEEP

代码:

见附录

4.3TIME模块

图4.3EntityTIME20

这一模块主要负责时钟的产生,通过分频实现计时。

代码:

见附录

模块仿真:

图4.4TIME20仿真图(1)

图4.5TIME20仿真图(2)

4.4STATE模块

图4.6EntitySTATE

STATE这一模块由我负责,因此着重介绍。

这一模块主要用来记录抢答器的状态,如果ifstart为0,ifsomeone为1,即说明计时没有开始,有人已经抢答。

这时会输出1110,提示“E”表示有人抢答。

如果ifstart为1,ifsomeone为1,这时输出0000,提示“0”,表示正常状态。

如果ifover为1,这时输出1111,提示“F”,表示超时。

具体程序如下。

代码:

Libraryieee;

Useieee.std_logic_1164.all;

Entitystateis

port(ifsomeone,ifstart,ifover:

instd_logic;

state:

outstd_logic_vector(3downto0));

Endstate;

Architecturearchofstateis

Begin

Process(ifstart,ifsomeone,ifover)

Begin

if(ifstart'eventandifstart='1')then

state<="0000";

endif;

if(ifstart='0'andifsomeone='1')then

state<="1110";

elsif(ifover='1')then

state<="1111";

else

state<="0000";

endif;

EndProcess;

Endarch;

模块仿真:

图4.9STATE仿真图

4.5BEEP模块

图4.10EntityBEEP

这一模块负责,抢答器正常工作时,有人按下抢答按钮后的声音提示。

代码:

见附录

5下载程序

5.1分配引脚

图5.1分配引脚图

5.2下载到实验箱

经下载调试,抢答器的各项功能基本都能实现。

6实验心得

本次实验让我们基本学会了VHDL语言,让我们认识到EDA设计的强大之处。

为我们以后的学习和工作打下了良好的基础。

附录:

其他模块程序:

Key模块程序:

Libraryieee;

Useieee.std_logic_1164.all;

Entitykeyis

port(k1,k2,k3,k4,feedback:

instd_logic;

r1,r2,r3,r4,someone:

outstd_logic);

Endkey;

Architecturearchofkeyis

Begin

r1<=k1andfeedback;

r2<=k2andfeedback;

r3<=k3andfeedback;

r4<=k4andfeedback;

Process(k1,k2,k3,k4)

Begin

if((k1ork2ork3ork4)='1')then

someone<='1';

else

someone<='0';

endif;

endProcess;

Endarch;

Keep模块:

Libraryieee;

Useieee.std_logic_1164.all;

Entitykeepis

port(p1,p2,p3,p4,start:

instd_logic;

person:

outstd_logic_vector(3downto0);

keepout:

outstd_logic);

Endkeep;

Architecturearchofkeepis

Begin

Process(start,p1,p2,p3,p4)

Begin

if((p1orp2orp3orp4)='1')then

person(3)<=p4;

person

(2)<=p3;

person

(1)<=p2;

person(0)<=p1;

keepout<='0';

elsif(start'eventandstart='1')then

keepout<='1';

person<="0000";

endif;

EndProcess;

Endarch;

Time模块:

Libraryieee;

Useieee.std_logic_1164.all;

Entitytime20is

port(clk,start,stop:

instd_logic;

dig2,dig1:

outstd_logic_vector(3downto0);

over:

bufferstd_logic);

Endtime20;

Architecturearchoftime20is

signalok:

std_logic;

Begin

Process(clk,start,stop)

variabletmp1:

integerrange0to10;

variabletmp2:

integerrange0to2;

Begin

if(start='0')then

tmp2:

=2;

tmp1:

=0;

over<='0';

elsif((clk'eventandclk='1'))then

if((stop='1'andover='0'))then

if(tmp1=0andtmp2/=0)then

tmp1:

=9;

tmp2:

=tmp2-1;

else

tmp1:

=tmp1-1;

endif;

if(tmp2=0andtmp1=0)then

over<='1';

endif;

endif;

endif;

casetmp1is

when0=>dig1<="0000";

when1=>dig1<="0001";

when2=>dig1<="0010";

when3=>dig1<="0011";

when4=>dig1<="0100";

when5=>dig1<="0101";

when6=>dig1<="0110";

when7=>dig1<="0111";

when8=>dig1<="1000";

when9=>dig1<="1001";

whenothers=>null;

endcase;

casetmp2is

when0=>dig2<="0000";

when1=>dig2<="0001";

when2=>dig2<="0010";

whenothers=>null;

endcase;

EndProcess;

Endarch;

Beep模块:

Libraryieee;

Useieee.std_logic_1164.all;

Entitybeepis

port(someone,start,over:

instd_logic;

beep,beeplong:

outstd_logic);

Endbeep;

Architecturearchofbeepis

Begin

Process(start,someone,over)

Begin

if(start='0'andsomeone='1')then

beeplong<='1';

beep<='0';

elsif(start='1'andover='1')then

beeplong<='1';

beep<='0';

elsif(start='1'andsomeone='1'andover='0')then

beeplong<='0';

beep<='1';

elsif(start='1'andsomeone='0'andover='0')then

beeplong<='0';

beep<='0';

endif;

EndProcess;

Endarch;

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

当前位置:首页 > 经管营销 > 经济市场

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2