eda课程设计基于vhd语言的乒乓球游戏机设计大学论文.doc

上传人:scccc 文档编号:11499218 上传时间:2021-08-09 格式:DOC 页数:16 大小:21.20KB
返回 下载 相关 举报
eda课程设计基于vhd语言的乒乓球游戏机设计大学论文.doc_第1页
第1页 / 共16页
eda课程设计基于vhd语言的乒乓球游戏机设计大学论文.doc_第2页
第2页 / 共16页
eda课程设计基于vhd语言的乒乓球游戏机设计大学论文.doc_第3页
第3页 / 共16页
eda课程设计基于vhd语言的乒乓球游戏机设计大学论文.doc_第4页
第4页 / 共16页
eda课程设计基于vhd语言的乒乓球游戏机设计大学论文.doc_第5页
第5页 / 共16页
点击查看更多>>
资源描述

《eda课程设计基于vhd语言的乒乓球游戏机设计大学论文.doc》由会员分享,可在线阅读,更多相关《eda课程设计基于vhd语言的乒乓球游戏机设计大学论文.doc(16页珍藏版)》请在三一文库上搜索。

1、目 录 1 项目名称、内容与要求 04页 1.1 设计内容04页 1.2 具体要求04页 2 系统整体架构(Architecture Description) 04页 2.1 设计思路04页 2.2 系统原理(包含:框图等阐述与设计说明等内容)04页 3 系统设计 (含HDL或原理图输入设计)05页 3.1 HDL 代码05页 3.2 系统整体电路图(或RTL级电路图)12页 4 系统仿真(Simulation Waveform)13页 5 FPGA实现(FPGA Implementation) 14页 6 总结(Closing)16页 参考书目(Reference):16页 一、项目名称、内

2、容与要求 二、系统整体架构(Architecture Description) 2.1设计思路 根据系统设计的要求,乒乓球比赛游戏机的电路原理框图如下: 三、系统设计 (含HDL或原理图输入设计) 3.1 VHDL 代码 比赛模块 library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_arith.all; use ieee.std_logic_unsigned.all; -引用必要的库函数和包集合 entity compete is -实体名为pingpong port(reset:in std_logic; clk_1:i

3、n std_logic; startbutton:in std_logic; -开始游戏输入端口 serve:in std_logic_vector(1 downto 0); -发球输入端口 hit1,hit2,hit11,hit22:in std_logic; -甲和乙的击球输入端口 light:out std_logic_vector(1 to 8); sound:out std_logic;-控制8个发光二极管的输出端口 music_begin:out std_logic;-控制音乐开始的输出端口 counta,countb,countc,countd,counte,countf:out

4、 std_logic_vector(3 downto 0); -2个用于控制4个7段译码器的输出端口 end compete; architecture one of compete is type pingpong is (waitserve,light1on,ballmoveto2,allow2hit, light8on,ballmoveto1,allow1hit); -设置7个状态,为枚举数据类型,记为pingpong signal state:pingpong; signal i:integer range 0 to 8; signal count1,count2,count3,cou

5、nt4,count5,count6:std_logic_vector(3 downto 0):=0000; -内部计数器,是4位二进制变量 begin process(clk_1) begin if(clk_1event and clk_1=1) then if count1=1 and count5=1 or count2=1 and count6=1 then music_begin=1; end if; if(reset=1)then music_begin=0; end if; end if; end process; process(clk_1) -状态机进程 -clk_1作为敏感信

6、号触发进程 begin -进程开始 if reset=1 then -异步置位 i=0;count1=0;count2=0;count5=0;count6=0; elsif clk_1event and clk_1=1 then -当处于时钟inclock上升沿时 if count1=10 then count1=0;count5=1; elsif count1=1 and count5=1 then i=0;count1=0;count5=0;count3=count3+1;count2=0;count6=0; elsif count2=10 then count2=0;count6=1;

7、elsif count2=1 and count6=1 then i=0;count1=0;count2=0;count4=count4+1;count5=0;count6=0; elsif count3=4 or count4=4 then i=9;music_begin=1;startbutton=0; elsif startbutton=0 then i=0;count1=0;count2=0;count3=0;count4=0;count5=0;count6 -进程处于等待发球状态 case serve is when 01= i=1;state i=8;statei i=0;soun

8、d -进程处于第一盏灯亮状态 i=2; if hit2=1 or hit22=1 then i=0; count1=count1+1;sound=”1”state=waitserve; else state -进程处于第八盏灯亮状态 i=7; if hit1=1 or hit11=”1” then i=0; count2=count2+1;sound=”1”;state=waitserve; else state -进程处于球向甲移动状态 if hit1=1 then i=0; count2=count2+1;sound=”1”;state=waitserve; elsif i=2 then

9、i=1; state=allow1hit; else i -进程处于球向乙移动状态 if hit2=1then i=0; count1=count1+1; sound=”1”;state=waitserve; elsif i=7 then i=8; state=allow2hit; else i -进程处于允许甲击球状态 if hit1=1 then i=2; state=ballmoveto2; else count2=count2+1;i=0;sound=”1”; state=waitserve; end if; if hit11=1 then i=2; state=ballmoveto2

10、; else count2=count2+1;i=0;sound=”1”; state -进程处于允许乙击球状态 if hit2=1then i=7;state=ballmoveto1; else count1=count1+1;i=0;sound=”1”; state=waitserve; end if; if hit22=1then i=7;state=ballmoveto1; else count1=count1+1;i=0;sound=”1”; state=waitserve; end if; end case; end if; end if; end process; counta=

11、count1;countb=count2;countc=count3;countd=count4;counte=count5;countf=count6; process(clk_1) if (clk_1event and clk_1=1)then-进程处i信号控制发光二极管的亮暗 light=10000000when(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

12、when(i=7) else 00000001 when(i=8) else 00000000; End process; -其他情况所有发光二极管都暗 end one; 分频模块 library IEEE; use IEEE.std_logic_1164.all; use ieee.std_logic_arith.all; use IEEE.std_logic_unsigned.all; entity division16 is port( cp:in std_logic; clk_4:out std_logic ); end division16; architecture divisio

13、n_body of division16 is signal count:std_logic_vector(3 downto 0); begin process(cp) begin if(cpevent and cp=1)then if(count=1111)then count0); else count=count+1; end if; end if; end process; process(cp) begin if(cpevent and cp=1)then if(count=1111)then clk_4=1; else clk_4qqqqqqqqqqq=0000000; end c

14、ase; end process; end disp_arc; 数码管选择 LIBRARY IEEE; USE IEEE.STD_LOGIC_1164.ALL; ENTITY mux2 IS PORT(a,b: IN STD_LOGIC_VECTOR(6 downto 0); sel: IN STD_LOGIC; c:OUT STD_LOGIC_VECTOR(6 downto 0); END mux2; ARCHITECTURE example OF mux2 IS BEGIN PROCESS(sel) BEGIN IF(SEL=1)THEN c=a; ELSE c=b; END IF; EN

15、D PROCESS; END example; 音乐模块(两只老虎) library IEEE; use IEEE.std_logic_1164.all; use IEEE.std_logic_unsigned.all; entity music is port ( music_begin:in std_logic; clk_4:in std_logic; clk:in std_logic; music_out:out std_logic ); end music; architecture music_body of music is constant m1:integer:=637;-95

16、5; constant m2:integer:=587;-851; constant m3:integer:=505;-758; constant m4:integer:=468;-716; constant m5:integer:=425;-639; constant m6:integer:=379;-569; constant m7:integer:=330;-506; constant m0:integer:=0; signal counter:integer range 0 to 67; signal count:integer range 0 to 1000; signal sub:

17、integer range 0 to 1000; signal carrier:std_logic; signal pat,pat1,pat2:std_logic; begin process(clk) begin if(clkevent and clk=1)then if(carrier=1) then sub=count; else sub=sub-1; end if; end if; end process; process(sub) begin if(sub=0) then pat=1; else pat=0; end if; carrier=pat; end process; pro

18、cess(clk) begin if(clkevent and clk=1)then pat1=pat; end if; end process; process(pat1) begin if(pat1event and pat1=1) then pat2= not pat2; end if; music_out=pat2; end process; process(clk_4) begin if(clk_4event and clk_4=1) then if(music_begin=1) then counter=counter+1; else countercountcountcountc

19、ountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountc

20、ountcountcountcountcount=m0; end case; end process; end music_body; 3.2 系统整体电路图(或RTL级电路图) 四、系统仿真(Simulation Waveform) 功能仿真波形图 时序仿真波形图 五、 FPGA实现(FPGA Implementation) 将程序下载到EDA2000实验箱 然后按照设定的管脚在EDA2000实验箱上连接好实物图 输入脉冲,验证其功能 六、总结(Closing) 经过一学期的学习,在陈强老师的教导下,我对在系统编程技术这门课有了很深刻的理解,并能结合所学的知识设计了这次的乒乓球游戏机。由于实

21、验箱上脉冲端有限,于是我又想到了要设计一个分频器,我开始设计的是16分频和64分频,因为我需要一个4Hz和1Hz的脉冲信号,但是,这样做对整个电路而言没有任何效果,无论怎样都仿真不出波形,但是代码没错,单独仿真分频器也有波形输出。当我准备放弃时,我又抱着侥幸心理只设计一个16分频的分频器,我把分频器接入电路,然后仿真,结果仿真波形出来了。然后下载到实验箱验证时,结果甲乙两位选手的得分不能再同一排数码管上显示,后经过我冷静的分析,我想到了曾经做过的60进制计数器,于是我便加了个数码管选择器,这样甲乙二人的分数可以再同一排数码上显示了。 经过这次实训,我收获颇丰,学到了很多知识,特别是提高了综合分析应用的能力。我学会了如何去完成一个任务,懂得了享受过程。当遇到问题,冷静,想办法一点一点的排除障碍,到最后获取成功,一种自信心由然而生。实训是对每个人综合能力的检验。要想做好任何事,除了自己平时要有一定的功底外,我们还需要一定的实践动手能力,操作能力。此次实训,我深深体会到了积累知识的重要性。在短暂的实训过程中,让我深深的感觉到自己在实际运用中的知识的匮乏这时才真正领悟到“学无止境”的含义。

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

当前位置:首页 > 社会民生


经营许可证编号:宁ICP备18001539号-1