完整word版乒乓球游戏机EDA课程设计完整版本Word文件下载.docx
《完整word版乒乓球游戏机EDA课程设计完整版本Word文件下载.docx》由会员分享,可在线阅读,更多相关《完整word版乒乓球游戏机EDA课程设计完整版本Word文件下载.docx(17页珍藏版)》请在冰点文库上搜索。
1、b没有接到球,a加1分,将灯光清零00000000
2、b接到了球,则灯光为0&
【7位】
二、在b方出界了
1、如果b没有接到球,则a加分
2、如果b接到了球,则灯光为0&【7位】
b发球
1、a没有接到球,b加1分,并将灯光清零00000000
2、a接到了球,则灯光计分为【7位】&0
二、在a方出界了
1、a没有接到球,则b加分
2、a接到了球,则灯光计分为【7位】&0
af,aj,bf,bj分别为a方发球键和接球键,b方发球键和接球键,shift表示球所在的位置。
图4.1conal模块原理图
4.1.2cornal模块VHDL程序描述
Libraryieee;
Useieee。
std_logic_1164.all;
Useieee.std_logic_unsigned.all;
Entitycornalis
Port(clr,af,aj,bf,bj,clk:
instd_logic;
Shift:
outstd_logic_vector(7downto0);
Ah,al,bh,bl:
outstd_logic_vector(3downto0);
Awin,bwin:
outstd_logic);
Endcornal;
Architecturebahaveofcornalis
Signalamark,bmark:
integer;
Begin
Process(clr,clk)
Variablea,b:
std_logic;
Variableshe:
std_logic_vector(7downto0);
Ifclr=’0'
then
a:
=’0'
;
b:
;
she:
="
00000000"
amark<
=0;
bmark〈=0;
elsifclk’eventandclk='
1’then
ifa='
0’andb='
0'
andaf=’0'
then--a方发球
a:
=’1’;
she;
=”10000000”;
elsifa=’0'
andb=’0’thenbf=’0’then--b方发球
b:
=’1’;
=”00000001”;
elsifa=’1’andb=’0’then——a方发球后
ifshe〉8then
ifbj=’0’then-—b方过网击球
amark〈=amark+1;
——a方加一分
=’0’;
b:
she:
=”00000000”;
else
she:
=’0’&
she(7downto1);
—-b方没有击球
endif;
elsifshe=0then—-球从b方出界
amark<
=amark+1;
—-a方加一分
a:
='
0’;
else
ifbj=’0’then——b方正常击球
a:
1’;
she(7downto1);
——b方没有击球
endif;
endif;
elsifa=’0’andb='
1’then——b方发球
ifshe〈16andshe/=0then
ifaj='
0’then
bmark<
=bmark+1;
=’0’;
=she(6downto0)&’0'
elsifshe=0then
bmark〈=bmark+1;
b:
ifaj=’0'
then
=’1'
=she(6downto0)&
’0’;
shift<
=she;
endprocess;
process(clk,clr,amark,bmark)
variableaha,ala,bha,bla:
std_logic_vector(3downto0);
variabletmp1,tmp2:
variablet1,t2:
std_logic;
begin
ifclr=’0'
then——清零
aha:
=”0000”;
ala:
=”0000”;
bha:
0000"
bla:
tmp1:
=0;
tmp2:
t1:
t2:
elsifclk’eventandclk=’1’then
ifaha=”0001”andala=”0001”then-—a方得分达到11分,则保持
=”0001"
=”0001”;
t1:
elsifbha=”0001”andbla=”0001"
then——b方得分达到11分,则保持
bha:
=”0001”;
bla:
elsifamark〉tmp1then
ifala=”1001”then
ala:
=”0000"
aha:
=aha+1;
tmp1:
=tmp1+1;
ala:
=ala+1;
tmp1:
=tmp1+1;
elsifbmark〉tmp2then
ifbla=”1001”then
bla:
bha:
=bha+1;
tmp2:
=tmp2+1;
=bla+1;
=tmp2+1;
al〈=ala;
bl<
=bla;
ah<
=aha;
bh〈=bha;
awin〈=t1;
bwin〈=t2;
endprocess;
endbehave;
2送数据模块的设计
4.2.1ch41a模块分析
图4.2ch41a模块分析及原理图
2ch41a模块VHDL程序描述
LibraryIEEE;
UseIEEE.std_logic_1164.all;
Entitych41ais
Port(sel:
instd_logic_vector(2downto0);
D0,d1,d2,d3:
instd_logic_vector(3downto0);
Q:
outstd_logic_vector(3downto0));
Endch41a;
Architecturebehaveofch41ais
Begin
Process(sel)
Caseselis
When"
100”=〉q<
=d0;
When”101”=〉q<
=d1;
When”000"
=>
q〈=d2;
Whenothers=>
q〈=d3;
Endcase;
Endprocess;
Endbehave;
4.3产生数码管片选信号模块的设计
3。
1sel模块分析
图4。
3sel模块分析及原理图
4.3.2sel模块VHDL程序描述
Libraryieee;
Useieee.std_logic_1164.all;
std_logic_unsigned.all;
Entityselis
Port(clk:
Sell:
outstd_logic_vector(2downto0));
Endsel;
Architecturebehaveofselis
Process(clk)
Variabletmp:
std_logic_vector(2downto0);
Ifclk’eventandclk=’1’then
Iftmp=”000”then
Tmp:
001”;
Elsiftmp=”001”then
Tmp:
=”100”;
ElsifTmp=”100"
then
101”;
Elsiftmp=”101”then
=”000"
Endif;
Endif;
Sell<
=tmp;
4.4七段译码器模块的设计
4.1disp模块分析
图4。
4disp模块分析及原理
4.2disp模块VHDL程序描述
Useieee.std_logic_1164。
all;
Entitydispis
Port(d:
instd_logic_vector(3downto0);
Q:
outstd_logic_vector(6downto0));
Enddisp;
Architecturebehaveofdispis
Process(d)
Begin
Casedis
When”0000"
q<
0111111”;
When”0001”=>
q〈=”0000110”;
When”0010"
=〉q〈=”1011011”;
When”0011”=〉q<
1001111”;
When”0100”=〉q<
=”1100110”;
When”0101”=>
=”1101101"
When”0110”=〉q<
1111101”;
When”0111”=>
=”0100111”;
When”1000”=〉q<
=”1111111”;
Whenothers=〉q<
=”1101111”;
Endcase;
Endprocess;
Endbehave;
5顶层原理图设计
图4.5顶层模块原理图
5各模块的时序仿真图
图5.1为A方两次发球,B方没有接到球,A方得到2分的仿真波形图
图5。
1仿真波形图
图5.2所示为A方发球,B方提前击球的情况,此时,A方得一分。
图中还显示了A方发球,B方在规定的时刻没有接到球的情况,此时,A方又得一分。
2仿真波形图
3所示为A方发球,在恰当的时候B方接到球,当球回到A方时,A方又接到球,但B方再也没有接到球的仿真波形。
图5.3仿真波形图
图5.4所示为A方得分增加到11分的情况,此时awin输出高电平,输出分数保持不变.当清零信号按下时,得分清为零,awin输出恢复低电平,又可以开始新的一局比赛.
图5.4仿真波形图
6总结
当知道我做的这个设计是乒乓游戏机的时候,我完全没有了头绪,不知道这到底会是一个怎样的设计,后来经过在网上参考了许许多多的资料,才知道这到底是怎么一回事,过了一个假期,许多软件上的操作都忘记了许多,当开始课程设计的时候,才发现原来安装好了的软件试用期到了,然后又得重装软件,重装又不成功,反复弄了几次才成功,总是急出一身的汗。
当软件安装好之后,开始将设计的VHDL程序输入到里面编译,最后设计顶层程序的时候,一直出现错误,是说不能使用两个脉冲时钟,于是又重新学画了原理图的设计,才最终成功.
通过这次设计,进一步加深了对EDA的了解,让我对它有了更加浓厚的兴趣。
特别是当每一个子模块编写调试成功时,心里特别的开心。
但是在编写顶层文件的程序时,遇到了不少问题,特别是各元件之间的连接,以及信号的定义,总是有错误,在细心的检查下,终于找出了错误和警告,排除困难后,程序编译就通过了,心里终于舒了一口气.
这次课程设计使我懂得了理论与实际相结合是很重要的,只有理论知识是远远不够的,只有把所学的理论知识与实践相结合起来,从理论中得出结论,才能真正为社会服务,从而提高自己的实际动手能力和独立思考的能力。
在设计的过程中遇到问题,可以说得是困难重重,这毕竟第一次做的,难免会遇到过各种各样的问题,同时在设计的过程中发现了自己的不足之处,对以前所学过的知识理解得不够深刻,掌握得不够牢固。
7参考文献
[1]邹彦主编。
EDA技术与数字系统设计。
电子工业出版社。
2012
[2]朱正伟主编。
EDA技术及应用.清华大学出版社.2005
[3]黄智伟等主编.FPGA系统设计与实践.电子工业出版社。
2004
[4张亦华等主编.数字逻辑设计实验技术与EDA工具。
北京邮电大学出版社.2003
[5]谭会生等主编.EDA技术及应用。
西安电子科技大学出版社.2001