1、乒乓球游戏机EDA课程设计完整版本1 设计目的 12 设计要求和任务 12.1设计任务 12.2设计要求 13 总体设计思路及原理描述 14 分层次方案设计及代码描述 2 4.1控制模块的设计 24.1.1 cornal模块分析 24.1.2 cornal模块VHDL程序描述 34.2送数据模块的设计 74.2.1 ch41a模块分析 74.2.2 ch41a模块VHDL程序描述 74.3产生数码管片选信号模块的设计 84.3.1 sel模块分析 84.3.2 sel模块VHDL程序描述 94.4 七段译码器模块的设计 104.4.1 disp模块分析 104.4.2 disp模块VHDL程序
2、描述 104.5 顶层原理图设计 115 各模块的时序仿真图 126 总结 147 参考文献 14乒乓游戏机1 设计目的掌握熟悉的使用Quartus II 9.1软件的原理图绘制,程序的编写,编译以及仿真。体会使用EDA综合过程中电路设计方法和设计思路的不同。掌握使用EDA工具设计乒乓游戏机的的设计思路和设计方法。2 设计要求和任务2.1设计任务设计一个乒乓球游戏机,该机模拟乒乓球比赛的基本过程和规则,并能自动裁判和几分。2.2设计要求 (1)甲乙双方各在不同的位置发球或击球。 (2)乒乓球的位置和移动方向由灯亮及依次点亮的方向决定,球移动的速度为0.1-0.5秒移动一位。 (3)11分为一局
3、,甲乙双方都应设置各自的几分牌,任何一方先记满11分,该方胜出。当记分牌清零后,重新开始。3 总体设计思路及原理描述由乒乓游戏机功能,用原理图作为顶层模块,再将底层划分成四个小模块来实现: (1)cornal模块:整个程序的核心,它实现了整个系统的全部逻辑功能; (2)ch41a模块:在数码的片选信号时,送出相应的数据; (3)sel模块:产生数码管的片选信号; (4)disp模块:7段译码器。 图3.1 结构层次图4 分层次方案设计及代码描述4.1控制模块的设计 4.1.1 cornal模块分析a发球一、在范围内 1、b没有接到球,a加1分,将灯光清零000 00 000 2、b接到了球,则
4、灯光为0 &【7位】二、在b方出界了 1、如果b没有接到球,则a加分 2、如果b接到了球,则灯光为0 &【7位】b发球一、在范围内 1、a没有接到球,b加1分,并将灯光清零000 00 000 2、a接到了球,则灯光计分为【7位】& 0二、在a方出界了 1、a没有接到球,则b加分 2、a接到了球,则灯光计分为【7位】& 0af,aj,bf,bj分别为a方发球键和接球键,b方发球键和接球键,shift表示球所在的位置。图4.1 conal模块原理图4.1.2 cornal模块VHDL程序描述Library ieee;Use ieee.std_logic_1164.all;Use ieee.std
5、_logic_unsigned.all;Entity cornal isPort(clr,af,aj,bf,bj,clk:in std_logic;Shift:out std_logic_vector(7 downto 0);Ah,al,bh,bl:out std_logic_vector(3 downto 0);Awin,bwin:out std_logic);End cornal;Architecture bahave of cornal isSignal amark,bmark:integer;Begin Process(clr,clk)Variable a,b:std_logic;Va
6、riable she:std_logic_vector(7 downto 0);Begin If clr=0 t hena:=0;b:=0;she:=”amark=0;bmark8 then if bj=0 then -b方过网击球 amark=amark+1; -a方加一分 a:=0; b:=0; she:=”; else she:=0&she(7 downto 1); -b方没有击球 end if;elsif she=0 then -球从b方出界 amark=amark+1; -a方加一分 a:=0; b:=0;else if bj=0 then -b方正常击球a:=0;b:=1;else
7、 she:=0&she(7 downto 1); -b方没有击球end if;end if;elsif a=0 and b=1then -b方发球 if she16 and she/=0 then if aj=0 then bmark=bmark+1; a:=0; b:=0; she:=”; else she:=she(6 downto 0)&0;end if;elsif she=0 thenbmark=bmark+1;a:=0;b:=0;elseif aj=0then a:=1; b:=0;else she:=she(6 downto 0)&0;end if;end if;end if;en
8、d if;shifttmp1 then if ala=”1001” thenala:=”0000”;aha:=aha+1;tmp1:=tmp1+1;else ala:=ala+1; tmp1:=tmp1+1;end if;elsif bmarktmp2 then if bla=”1001” thenbla:=”0000”;bha:=bha+1;tmp2:=tmp2+1;else bla:=bla+1; tmp2:=tmp2+1;end if;end if;end if;al=ala;bl=bla;ah=aha;bh=bha;awin=t1;bwinqqqq=d3;End case;End pr
9、ocess;End behave;4.3产生数码管片选信号模块的设计4.3.1 sel模块分析 图4.3 sel模块分析及原理图4.3.2 sel模块VHDL程序描述Library ieee;Use ieee.std_logic_1164.all;Use ieee.std_logic_unsigned.all;Entity sel is Port(clk:in std_logic;Sell:out std_logic_vector(2 downto 0);End sel;Architecture behave of sel isBegin Process(clk) Variable tmp:std_logic_vector(2 downto 0);Begin If clkevent and clk=1 then If tmp=”000” then Tmp:=”001”; Elsif tmp=”001” then Tmp:=”100”;Elsif Tmp=”100” then Tmp:=”101”;Elsif tmp=”101” then Tmp:=”000”;End if;End if;Sellqqqqq=”;
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1