EDA课程设计--乒乓球游戏机.doc_第1页
EDA课程设计--乒乓球游戏机.doc_第2页
EDA课程设计--乒乓球游戏机.doc_第3页
EDA课程设计--乒乓球游戏机.doc_第4页
EDA课程设计--乒乓球游戏机.doc_第5页
已阅读5页,还剩12页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

基于fpga的数字系统设计项目设计文档项目名称: 乒乓球比赛游戏机 姓 名: 院 系: 应用技术学院 专 业: 电子信息工程(应电应本) 学 号: 指导教师: 完成时间: 2012年 06月19日基于fpga的数字系统设计项目成绩评价表设计题目乒乓球比赛游戏机设计要求设计一个乒乓球比赛游戏机,能模拟比赛的基本过程和规则并能自动裁判和记分,具体要求如下: (1)使用乒乓球游戏机的双方在不同位置发球或击球; (2)乒乓球的位置和移动方向由灯亮和依次亮的方向决定。使用者根据球的位置发出相应的动作;(3)比赛用11分为一局来进行,双方设置各自的记分牌,任意一方先记满11分就获胜此局。当记分牌清零后,开始新的一局比赛;(4)比赛结束后音乐自动响起。设计过程用8个led排成一条直线,以中点为界,两边各代表参赛双方的位置,其中一只点亮的led指示球的当前位置,点亮的led依次从左到右,或从右到左,其移动的速度应能调节。“球”(点亮的那只led)运动到某方的最后一位时,参赛者应能果断地按下位于自己一方的按纽开关,即表示启动球拍击球,若击中,则球向相反方向运动;若未中,球掉出桌外,则对方得一分。设置自动记分电路,甲乙双方各用两位数码管进行记分显示,每计满11分为1局。甲乙双方各设一个发光二极管表示拥有发球权,每隔2次自动交换发球权,拥有发球权的一方发球才有效。项目设计成绩评价评价项目指 标满分评分工作量、工作态度和出勤率按期圆满的完成了规定的任务,难易程度和工作量符合教学要求,工作努力,遵守纪律,出勤率高,工作作风严谨,善于与他人合作。30课程设计质量项目设计系统架构合理,设计过程简练正确,分析问题思路清晰,结构严谨,文理通顺,撰写规范,图表完备正确。40创新工作中有创新意识,对前人工作有一些改进或有一定应用价值。15答辩能正确回答指导教师所提出的问题。15综合成绩等级指导教师: 年 月 日目 录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页5fpga实现(fpga implementation) 14页6 总结(closing)16页参考书目(reference):16页一、项目名称、内容与要求1.1项目名称乒乓球比赛游戏机1.2设计内容设计一个由甲乙双方参赛,二人乒乓球游戏机。用8个(或更多个)led排成一条直线,以中点为界,两边各代表参赛双方的位置,其中一只点亮的led指示球的当前位置,点亮的led依次从左到右,或从右到左,其移动的速度应能调节。当“球”(点亮的那只led)运动到某方的最后一位时,参赛者应能果断地按下位于自己一方的按纽开关,即表示启动球拍击球,若击中,则球向相反方向运动;若未中,球掉出桌外,则对方得一分。设置自动记分电路,甲乙双方各用两位数码管进行记分显示,每计满11分为1局。甲乙双方各设一个发光二极管表示拥有发球权,每隔2次自动交换发球权,拥有发球权的一方发球才有效。1.3具体要求(1)使用乒乓球游戏机的双方在不同位置发球或击球。(2)乒乓球的位置和移动方向由灯亮和依次亮的方向决定。使用者根据球的位置发出相应的动作。(3)比赛用11分为一局来进行,双方设置各自的记分牌,任意一方先记满21分就获胜此局。当记分牌清零后,开始新的一局比赛。(4)比赛结束后音乐自动响起。二、系统整体架构(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:in std_logic;startbutton:in std_logic; -开始游戏输入端口serve:in std_logic_vector(1 downto 0); -发球输入端口hit1,hit2:in std_logic; -甲和乙的击球输入端口light:out std_logic_vector(1 to 8); -控制8个发光二极管的输出端口music_begin:out std_logic;-控制音乐开始的输出端口counta,countb:out std_logic_vector(3 downto 0); -2个用于控制4个7段译码器的输出端口end compete;architecture one of compete istype 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,count4:std_logic_vector(3 downto 0):=0000; -内部计数器,是4位二进制变量beginprocess(clk_1) begin if(clk_1event and clk_1=1) then if count3=0001 or count4=0001 then music_begin=1;end if; if(reset=1)then music_begin=0; end if; end if; end process; process(clk_1) -状态机进程 -clk_1作为敏感信号触发进程begin -进程开始if reset=1 then -异步置位i=0;count1=0000;count2=0000;count3=0000;count4=0000;elsif clk_1event and clk_1=1 then -当处于时钟inclock上升沿时 if count1=1011 theni=0;count1=0000;count2=0000;count3=count3+1;elsif count2=1011 then i=0;count1=0000;count2=0000;count4=count4+1;elsif startbutton=0 theni=0;count1=0000;count2=0000;count3=0000;count4 -进程处于等待发球状态case serve iswhen 01= i=1;state i=8;statei i -进程处于第一盏灯亮状态i=2;if hit2=1 theni=0;count1=count1+1;state=waitserve; elsestate -进程处于第八盏灯亮状态i=7;if hit1=1 theni=0;count2=count2+1;state=waitserve;elsestate -进程处于球向乙移动状态if hit1=1 theni=0;count2=count2+1;state=waitserve;elsif i=2 then i=1;state=allow1hit;else i -进程处于球向乙移动状态if hit2=1theni=0;count1=count1+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;state -进程处于允许乙击球状态if hit2=1then i=7;state=ballmoveto1;else count1=count1+1;i=0;state=waitserve;end if;end case;end if;end if;end process;counta=count1;countb=count2; -进程处i信号控制发光二极管的亮暗light=10000000when(i=1) else01000000 when(i=2) else00100000 when(i=3) else00010000 when(i=4) else00001000 when(i=5) else00000100 when(i=6) else00000010 when(i=7) else00000001 when(i=8) else00000000; -其他情况所有发光二极管都暗end one;分频模块library ieee; use ieee.std_logic_1164.all;use ieee.std_logic_arith.all;use ieee.std_logic_unsigned.all;entity division16 isport( cp:in std_logic; clk_4:out std_logic );end division16;architecture division_body of division16 issignal count:std_logic_vector(3 downto 0);beginprocess(cp)beginif(cpevent and cp=1)then if(count=1111)thencount0);elsecount=count+1;end if;end if;end process;process(cp)beginif(cpevent and cp=1)then if(count=1111)thenclk_4=1;elseclk_4qqqqqqqqqqq=0000000; end case; 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) beginif(sel=1)then c=a;else c=b;end if;end 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;-955; 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:integer range 0 to 1000; signal carrier:std_logic; signal pat,pat1,pat2:std_logic;beginprocess(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; process(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 countercountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcount=m0; end case; end process; end music_body;3.2 系统整体电路图(或rtl级电路图)四、系统仿真(simulation waveform)功能仿真波形图时序仿真波形图 五、fpga实现(fpga implementation)将程序下载到eda2000实验箱然后按照设定的管脚在eda2000实验箱上连接好实物图输入脉冲,验证其功能六、总结(closing)经过一学期的学习,在陈强老师的教导下,我对在系统编程技术

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论