EDA课程设计乒乓球游戏机vhd语言lWord文档格式.docx

上传人:b****5 文档编号:20390684 上传时间:2023-01-22 格式:DOCX 页数:16 大小:3.62MB
下载 相关 举报
EDA课程设计乒乓球游戏机vhd语言lWord文档格式.docx_第1页
第1页 / 共16页
EDA课程设计乒乓球游戏机vhd语言lWord文档格式.docx_第2页
第2页 / 共16页
EDA课程设计乒乓球游戏机vhd语言lWord文档格式.docx_第3页
第3页 / 共16页
EDA课程设计乒乓球游戏机vhd语言lWord文档格式.docx_第4页
第4页 / 共16页
EDA课程设计乒乓球游戏机vhd语言lWord文档格式.docx_第5页
第5页 / 共16页
点击查看更多>>
下载资源
资源描述

EDA课程设计乒乓球游戏机vhd语言lWord文档格式.docx

《EDA课程设计乒乓球游戏机vhd语言lWord文档格式.docx》由会员分享,可在线阅读,更多相关《EDA课程设计乒乓球游戏机vhd语言lWord文档格式.docx(16页珍藏版)》请在冰豆网上搜索。

EDA课程设计乒乓球游戏机vhd语言lWord文档格式.docx

music_begin:

--控制音乐开始的输出端口

counta,countb,countc,countd,counte,countf:

outstd_logic_vector(3downto0));

--2个用于控制4个7段译码器的输出端口

endcompete;

architectureoneofcompeteis

typepingpongis(waitserve,light1on,ballmoveto2,allow2hit,

light8on,ballmoveto1,allow1hit);

---设置7个状态,为枚举数据类型,记为pingpong

signalstate:

pingpong;

signali:

integerrange0to8;

signalcount1,count2,count3,count4,count5,count6:

std_logic_vector(3downto0):

="

0000"

;

---内部计数器,是4位二进制变量

begin

process(clk_1)

begin

if(clk_1'

eventandclk_1='

1'

)then

ifcount1=1andcount5=1orcount2=1andcount6=1then

music_begin<

='

endif;

if(reset='

)then

0'

endif;

endprocess;

process(clk_1)--状态机进程

--clk_1作为敏感信号触发进程

begin--进程开始

ifreset='

then--异步置位

i<

=0;

count1<

count2<

count5<

count6<

elsifclk_1'

then--当处于时钟inclock上升沿时

ifcount1=10then

count1<

=1;

elsifcount1=1andcount5=1then

i<

count3<

=count3+1;

elsifcount2=10then

count2<

elsifcount2=1andcount6=1then

count4<

=count4+1;

elsifcount3=4orcount4=4then

=9;

music_begin<

startbutton=’0’;

elsifstartbutton='

then

else--以下case语句是程序中最关键的状态机部分

casestateis

whenwaitserve=>

--进程处于等待发球状态

caseserveis

when"

01"

=>

state<

=light1on;

10"

=8;

=light8on;

11"

i<

when“00”=>

sound<

=”0”;

endcase;

whenlight1on=>

--进程处于第一盏灯亮状态

i<

=2;

ifhit2='

orhit22=’1’then

i<

count1<

=count1+1;

=”1”state<

=waitserve;

else

state<

=ballmoveto2;

endif;

whenlight8on=>

--进程处于第八盏灯亮状态

=7;

ifhit1='

orhit11=”1”then

count2<

=count2+1;

=”1”;

=ballmoveto1;

whenballmoveto1=>

--进程处于球向甲移动状态

elsifi=2theni<

=allow1hit;

elsei<

=i-1;

whenballmoveto2=>

--进程处于球向乙移动状态

then

sound<

elsifi=7theni<

=allow2hit;

=i+1;

whenallow1hit=>

--进程处于允许甲击球状态

theni<

elsecount2<

ifhit11='

whenallow2hit=>

--进程处于允许乙击球状态

theni<

elsecount1<

ifhit22='

endcase;

endprocess;

counta<

=count1;

countb<

=count2;

countc<

=count3;

countd<

=count4;

counte<

=count5;

countf<

=count6;

if(clk_1'

)then--进程处i信号控制发光二极管的亮暗

light<

10000000"

when(i=1)else

"

01000000"

when(i=2)else

00100000"

when(i=3)else

00010000"

when(i=4)else

00001000"

when(i=5)else

00000100"

when(i=6)else

00000010"

when(i=7)else

00000001"

when(i=8)else

00000000"

Endprocess;

--其他情况所有发光二极管都暗

endone;

分频模块

libraryIEEE;

useIEEE.std_logic_1164.all;

useIEEE.std_logic_unsigned.all;

entitydivision16is

port(cp:

clk_4:

outstd_logic);

enddivision16;

architecturedivision_bodyofdivision16is

signalcount:

std_logic_vector(3downto0);

process(cp)

if(cp'

eventandcp='

if(count="

1111"

)then

count<

=(others=>

'

);

else

=count+1;

endif;

clk_4<

enddivision_body;

译码器部分

entitydispis

port(d:

instd_logic_vector(3downto0);

q:

outstd_logic_vector(6downto0));

enddisp;

architecturedisp_arcofdispis

begin

process(d)

casedis

when"

q<

0111111"

0001"

0000110"

0010"

1011011"

0011"

1001111"

0100"

1100110"

0101"

1101101"

0110"

1111101"

0111"

0100111"

1000"

1111111"

1001"

1101111"

whenothers=>

0000000"

endcase;

enddisp_arc;

数码管选择

LIBRARYIEEE;

USEIEEE.STD_LOGIC_1164.ALL;

ENTITYmux2IS

PORT(a,b:

INSTD_LOGIC_VECTOR(6downto0);

sel:

INSTD_LOGIC;

c:

OUTSTD_LOGIC_VECTOR(6downto0));

ENDmux2;

ARCHITECTUREexampleOFmux2IS

BEGIN

PROCESS(sel)

IF(SEL='

)THEN

c<

=a;

ELSE

=b;

ENDIF;

ENDPROCESS;

ENDexample;

音乐模块(两只老虎)

entitymusicis

port(music_begin:

clk:

music_out:

endmusic;

architecturemusic_bodyofmusicis

constantm1:

integer:

=637;

--955;

constantm2:

=587;

--851;

constantm3:

=505;

--758;

constantm4:

=468;

--716;

constantm5:

=425;

--639;

constantm6:

=379;

--569;

constantm7:

=330;

--506;

constantm0:

signalcounter:

integerrange0to67;

signalcount:

integerrange0to1000;

signalsub:

signalcarrier:

std_logic;

signalpat,pat1,pat2:

process(clk)

if(clk'

eventandclk='

if(carrier='

sub<

=count;

else

=sub-1;

process(sub)

if(sub=0)then

pat<

else

carrier<

=pat;

pat1<

process(pat1)

if(pat1'

eventandpat1='

pat2<

=notpat2;

music_out<

=pat2;

process(clk_4)

if(clk_4'

eventandclk_4='

if(music_begin='

counter<

=counter+1;

process(counter)

casecounteris

when0=>

=m0;

when1=>

=m1;

when2=>

when3=>

=m2;

when4=>

when5=>

=m3;

when6=>

when7=>

when8=>

when9=>

when10=>

when11=>

when12=>

when13=>

when14=>

when15=>

when16=>

when17=>

when18=>

=m4;

when19=>

=m4;

when20=>

=m5;

when21=>

when22=>

when23=>

when24=>

when25=>

when26=>

when27=>

when28=>

when29=>

when30=>

when31=>

when32=>

when33=>

=m6;

when34=>

when35=>

when36=>

when37=>

when38=>

when39=>

when40=>

when41=>

when42=>

when43=>

when44=>

when45=>

when46=>

when47=>

when48=>

when49=>

when50=>

when51=>

when52=>

when53=>

when54=>

when55=>

when56=>

when57=>

when58=>

when59=>

when60=>

when61=>

when62=>

when63=>

when64=>

when65=>

when66=>

when67=>

endcase;

endmusic_body;

3.2系统整体电路图(或RTL级电路图)

四、系统仿真(SimulationWaveform)

功能仿真波形图

时序仿真波形图

五、FPGA实现(FPGAImplementation)

将程序下载到EDA2000实验箱

然后按照设定的管脚在EDA2000实验箱上连接好实物图

输入脉冲,验证其功能

六、总结(Closing)

经过一学期的学习,在陈强老师的教导下,我对在系统编程技术这门课有了很深刻的理解,并能结合所学的知识设计了这次的乒乓球游戏机。

由于实验箱上脉冲端有限,于是我又想到了要设计一个分频器,我开始设计的是16分频和64分频,因为我需要一个4Hz和1Hz的脉冲信号,但是,这样做对整个电路而言没有任何效果,无论怎样都仿真不出波形,但是代码没错,单独仿真分频器也有波形输出。

当我准备放弃时,我又抱着侥幸心理只设计一个16分频的分频器,我把分频器接入电路,然后仿真,结果仿真波形出来了。

然后下载到实验箱验证时,结果甲乙两位选手的得分不能再同一排数码管上显示,后经过我冷静的分析,我想到了曾经做过的60进制计数器,于是我便加了个数码管选择器,这样甲乙二人的分数可以再同一排数码上显示了。

经过这次实训,我收获颇丰,学到了很多知识,特别是提高了综合分析应用的能力。

我学会了如何去完成一个任务,懂得了享受过程。

当遇到问题,冷静,想办法一点一点的排除障碍,到最后获取成功,一种自信心由然而生。

实训是对每个人综合能力的检验。

要想做好任何事,除了自己平时要有一定的功底外,我们还需要一定的实践动手能力,操作能力。

此次实训,我深深体会到了积累知识的重要性。

在短暂的实训过程中,让我深深的感觉到自己在实际运用中的知识的匮乏这时才真正领悟到“学无止境”的含义。

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

当前位置:首页 > 高中教育 > 数学

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

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