




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
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页5FPGA实现(FPGA Implementation) 14页6 总结(Closing)16页参考书目(Reference):16页一、项目名称、内容与要求二、系统整体架构(Ar
2、chitecture 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
3、 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 std_logic_vector(3 downto 0); -
4、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,count5,count6:std_logic_vector(3 do
5、wnto 0):=0000; -内部计数器,是4位二进制变量beginprocess(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作为敏感信号触发进程begin -进程开始if reset=1 then -异步置位i=0;c
6、ount1=0;count2=0;count5=0;count6=0;elsif clk_1event and clk_1=1 then -当处于时钟inclock上升沿时 if count1=10 thencount1=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; elsif count2=1 and count6=1 theni=0;count1=0;cou
7、nt2=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 theni=0;count1=0;count2=0;count3=0;count4=0;count5=0;count6 -进程处于等待发球状态case serve iswhen 01= i=1;state i=8;statei i=0;sound -进程处于第一盏灯亮状态i=2;if hit2=1 or hit22=1 theni=0;count1
8、=count1+1;sound=”1”state=waitserve; elsestate -进程处于第八盏灯亮状态i=7;if hit1=1 or hit11=”1” theni=0;count2=count2+1;sound=”1”;state=waitserve;elsestate -进程处于球向甲移动状态if hit1=1 theni=0;count2=count2+1;sound=”1”;state=waitserve;elsif i=2 then i=1;state=allow1hit;else i -进程处于球向乙移动状态if hit2=1theni=0;count1=count
9、1+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;else count2=count2+1;i=0;sound=”1”;state -进程处于允许乙击球状态if hit2=1then i=7;state=ball
10、moveto1;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=count1;countb=count2;countc=count3;countd=count4;counte=count5;countf=count6; process(clk_1) if
11、(clk_1event and clk_1=1)then-进程处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 process; -其他情况所有发光二极管都暗end one;分频模块library IEEE; use
12、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(c
13、ount=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
14、);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
15、 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:=3
16、79;-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) th
17、en 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
18、_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 countercountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcoun
19、tcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcountcount=m0; end case; end process; end music_body;3.2 系统整体电路图(或RTL级电路图)四、系统仿真(Simulation Waveform)功能仿真波形图时序仿真波形图 五、FPGA实现(FPGA Implementa
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025年中国美术知识竞赛试题(附答案)
- 特殊药品相关知识考核试题及答案
- 国防知识竞赛题库(附答案)
- 德州初二结业考试试卷及答案
- 冲压操作安全培训资料课件
- 2025年皮肤病诊断治疗实践模拟考试答案及解析
- 冰墩墩课件教学课件
- 八女投江课件
- 生态保护区通信基站租赁与自然保护合作协议
- 智能家居产品展示中心场地租赁及市场推广合同
- 第七届全国“学宪法、讲宪法”知识竞赛试题及答案
- GB/T 10325-2012定形耐火制品验收抽样检验规则
- 平行平板的多光束干涉
- 《大众传播学研究方法导论(第二版)》课件第二章 研究基础
- 萃智创新方法理论考试题库(含答案)
- 生物材料检验-课件
- 小学生视力检测登记表
- 植物生物技术绪论
- 时空大数据课件
- 机器视觉课件
- 客舱广播词的基本知识
评论
0/150
提交评论