数字电路课程设计《梁祝》乐曲 数字时钟 乒乓球游戏机 串并乘法(4)

2019-03-29 17:10

process(bclk,net) begin

if(net='1')then serclk<='0'; couclk<='0';

elsif(bclk'event and bclk='1')then if(serve='1')then serclk<='1'; Else if(ball='1')then serclk<='1'; Else serclk<='0'; couclk<='1'; end if; end if; end if; end process;

end architecture behave;

——乒乓球过中点时,couclr,serclk复位

——球拍接球时 ——系统处于发球状态时 ——发球成功 ——系统处于接球状态 ——乒乓球恰好落在接球点上 ——接球成功

——乒乓球没落在接球点上 ——接球失败

乒乓球前进方向产生模块(MWAY.VHD)

library ieee;

use ieee.std_logic_1164.all; entity mway is

port(servea:in std_logic; serveb:in std_logic; way:out std_logic); end entity mway;

architecture behave of mway is begin

process(servea,serveb) begin

if(servea='1')then way<='1'; elsif(serveb='1')then way<='0'; end if; end process;

end architecture behave;

——左选手发球信号 ——右选手发球信号

——乒乓球灯前进方向信号

——左选手发球 ——方向向右 ——右选手发球 ——方向向左

失球提示(SOUND.VHD)

library ieee;

use ieee.std_logic_1164.all; entity sound is

port(clk:in std_logic; sig:in std_logic; en:in std_logic; sout:out std_logic); end entity sound;

architecture behave of sound is begin

sout<=clk and(not sig)and en end architecture behave;

——发声时钟 ——正确接球信号 ——球拍接球脉冲 ——提示声输出,接小喇叭

——球拍接球,没接到时,发出提示音

十进制计数器用作失败低位计数(COUT10.VHD)

library ieee;

use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity cout10 is

port(clk,clr:in std_logic; cout:out std_logic;

qout:out std_logic_vector(3 downto 0)); end entity cout10;

architecture behave of cout10 is

signal qqout:std_logic_vector(3 downto 0); begin

process(clr,clk) begin

if(clr='1')then

qqout<=\ cout<='0';

elsif(clk'event and clk='1')then if(qqout>\ qqout<=\ cout<='1'; else

qqout<=qqout+'1'; cout<='0'; end if; end if;

qout<=qqout; end process;

end architecture behave;

四进制计数器用作失败球高位计数(COUT4.VHD)

library ieee;

use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all;

entity cout4 is

port(clk,clr:in std_logic; cout:out std_logic;

qout:out std_logic_vector(3 downto 0)); end cout4;

architecture behave of cout4 is

signal qqout:std_logic_vector(3 downto 0); begin

process(clr,clk) begin

if(clr='1')then qqout<=\cout<='0';

elsif(clk'event and clk='1')then if(qqout>\qqout<=\cout<='1'; else

qqout<=qqout+'1'; cout<='0'; end if; end if;

qout<=qqout; end process; end behave;

乒乓球游戏顶层文件(PINGPANG.VHD)

library ieee;

use ieee.std_logic_1164.all; entity pingpang is

port(bain,bbin,clr,clk,souclk:in std_logic;

ballout:out std_logic_vector(7 downto 0);

countah,countal:out std_logic_vector(3 downto 0); countbh,countbl:out std_logic_vector(3 downto 0); lamp,speaker:out std_logic); end entity pingpang;

architecture behave of pingpang is component sound

port(clk,sig,en:in std_logic; sout:out std_logic); end component; component ballctrl

port(clr,bain,bbin,serclka,serclkb,clk:in std_logic; bdout,serve,serclk,ballclr,ballen:out std_logic);

end component; component ballpath

port(clk,clr,way,en:in std_logic;

ballout:out std_logic_vector(7 downto 0)); end component; component catcher

port(ball,net,bclk,serve:in std_logic; couclk,serclk:out std_logic); end component; component cout10

port(clk,clr:in std_logic; cout:out std_logic;

qout:out std_logic_vector(3 downto 0)); end component; component cout4

port(clk,clr:in std_logic; cout:out std_logic;

qout:out std_logic_vector(3 downto 0)); end component; component mway

port(servea,serveb:in std_logic; way:out std_logic); end component; signal net,couclkah,

couclkal,couclkbh,

couclkbl,cah,cbh:std_logic; signal serve,serclka,serclkb, serclk,ballclr,bdout, way,ballen:std_logic;

signal bbll:std_logic_vector(7 downto 0); begin

net<=bbll(4); ballout<=bbll; lamp<=clk;

uah:cout4 port map(couclkah,clr,cah,countah); ual:cout10 port map(couclkal,clr,couclkah,countal); ubh:cout4 port map(couclkbh,clr,cbh,countbh); ubl:cout10 port map(couclkbl,clr,couclkbh,countbl);

ubda:catcher port map(bbll(0),net,bain,serve,couclkal,serclka); ubdb:catcher port map(bbll(7),net,bbin,serve,couclkbl,serclkb); ucpu:ballctrl

port map(clr,bain,bbin,serclka,serclkb,clk,bdout,serve,serclk,ballclr,ballen); uway:mway port map(serclka,serclkb,way);

uball:ballpath port map(clk,ballclr,way,ballen,bbll);

usound:sound port map(souclk,ballen,bdout,speaker); end architecture behave;

三:系统以及各个模块的仿真波形

乒乓球前进方向产生模块仿真波形

失球提示模块仿真波形

乒乓球游戏顶层文件仿真波形

四、系统调试运行结果说明与分析

实验箱选择模式5。CLK接入信号,一排发光管交替发光知识乒乓球的行进路径,当发光管亮到最后一个的瞬间,若检测到对应的表示球拍的键的信号,立即将“球”反向运行:如果没有检测到该键信号,将给出出错音,同时为对方加分,并将计分显示出来。

五:结论与体会

在实际的操作中,由于各种因素,游戏时并不十分的流畅,但程序可以实现

预期的功能。实验还是成功的,当然没有老师的帮助做起来还是很有难度的。

(四)通用串并乘法器

一:系统功能概述

① 串并乘法器,即指输入既有串行数据,也有并行数据。通常,串行数据作为被乘数,并行数据作为乘数,乘积串行输出。


数字电路课程设计《梁祝》乐曲 数字时钟 乒乓球游戏机 串并乘法(4).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:等差数列教案

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: