eda课程设计拔河游戏机

上传人:re****.1 文档编号:563823204 上传时间:2023-07-29 格式:DOC 页数:9 大小:159.50KB
返回 下载 相关 举报
eda课程设计拔河游戏机_第1页
第1页 / 共9页
eda课程设计拔河游戏机_第2页
第2页 / 共9页
eda课程设计拔河游戏机_第3页
第3页 / 共9页
eda课程设计拔河游戏机_第4页
第4页 / 共9页
eda课程设计拔河游戏机_第5页
第5页 / 共9页
点击查看更多>>
资源描述

《eda课程设计拔河游戏机》由会员分享,可在线阅读,更多相关《eda课程设计拔河游戏机(9页珍藏版)》请在金锄头文库上搜索。

1、实验要求拔河游戏机(1)、设计要求l 设计一个能进行拔河游戏的电路。l 电路使用15个(或9个)发光二极管表示拔河的“电子绳”,开机后只有中间一个发亮,此即拔河的中心点。l 游戏双方各持一个按钮,迅速地、不断地按动,产生脉冲,谁按得快,亮点就向谁的方向移动,每按一次,亮点移动一次。l 亮点移到任一方终端二极管时,这一方就获胜,此时双方按钮均无作用,输出保持,只有复位后才使亮点恢复到中心。l 由裁判下达比赛开始命令后,甲乙双方才能输入信号,否则,输入信号无效。l 用数码管显示获胜者的盘数,每次比赛结束自动给获胜方加分。 (2)、设计提示l 加/减计数器l 译码器l 得分计数显示电路2设计原理及总

2、体框图基本原理:由设计内容可知,需要一个十进制的计数器,用于对双方按钮的次数计数。当led灯移动到一端时,那边的选手得1分,通过比较模块比较两位选手的胜利的得分,并通过译码器显示在数码管上。设计要求用1MHz的频率,而设计用到的是100Hz、5Hz和1Hz的频率,所以要设计一个程序进行分频。显视控制部分设计要求在发光二极管上显示游戏状态,双方每按十次,亮点向先按十次移动一次,对脉冲进行计数,每十次移一位。需接入一个清零端,用于复位。将以上程序组装起来。当两位选手其中一位选手先得到3分时,比赛结束,音乐响起,所以有一个音乐模块。音乐music总体框图:分频器division防抖fangdou计数

3、count比赛compete译码decodePlayer1Player2图1 总体框图3 程序设计 总体设计电路图2 总体设计图 模块设计和相应模块程序a. 分频器library IEEE; use IEEE.std_logic_1164.all; use IEEE.std_logic_unsigned.all;entity division is port( clk:in std_logic; clk_100,clk_4,clk_1:out std_logic );end division;architecture division_body of division is signal co

4、unt1:integer range 0 to 4999; -signal count1:integer range 0 to 1; signal count2:integer range 0 to 124999; signal count3:integer range 0 to 49; -signal count3:integer range 0 to 1; signal clk1,clk2,clk3:std_logic; begin-得到100HZ的频率process(clk) beginif(clkevent and clk=1)then if(count1=4999)then coun

5、t1=0; clk1=not clk1; else count1=count1+1; end if; end if; end process;-得到4HZ的频率 process(clk) begin 图3 分频器if(clkevent and clk=1) then if(count2=124999) then count2=0; clk2=not clk2; else count2=count2+1; end if; end if; end process; -得到1HZ的频率process(clk1) begin if(clk1event and clk1=1) then if(count

6、3=49) then count3=0; clk3=not clk3; else count3=count3+1;end if; end if; end process;clk_100=clk1;clk_4=clk2; clk_1=clk3; end division_body; b. 防抖模块library IEEE; use IEEE.std_logic_1164.all; use IEEE.std_logic_unsigned.all; entity fangdou_player1 is port( clk_100:in std_logic; player1_b:in std_logic

7、; player1:out std_logic 图4 防抖1 ); end fangdou_player1; architecture fangdou_player1_body of fangdou_player1 is signal mp1,mp2:std_logic; begin process(clk_100) begin if(clk_100=0) then mp2=mp1; mp1=player1_b; end if; end process; player1=clk_100 and mp1 and (not mp2); end fangdou_player1_body;librar

8、y IEEE; use IEEE.std_logic_1164.all; use IEEE.std_logic_unsigned.all; entity fangdou_player2 is port( clk_100:in std_logic; player2_b:in std_logic; player2:out std_logic ); 图5 防抖2end fangdou_player2; architecture fangdou_player2_body of fangdou_player2 is signal mp1,mp2:std_logic; begin process(clk_

9、100) begin if(clk_100=0) then mp2=mp1; mp1=player2_b; end if; end process; player2=clk_100 and mp1 and (not mp2); end fangdou_player2_body;c. 计数器library IEEE; use IEEE.std_logic_1164.all; use IEEE.std_logic_unsigned.all; entity count is port( clk_1:in std_logic; switch:in std_logic; player1,player2:

10、in std_logic; 图6 计数器 sum1,sum2:out integer range 0 to 10 ); end count; architecture count_body of count is signal p1,p2:integer range 0 to 10 ; begin sum1=p1; sum2=p2; process(player1,player2,switch,clk_1) begin if(switch=1) then if(clk_1=0) then -p1=0; -p2=0; if(player1=1) then p1=p1+1; end if; if(

11、player2=1) then p2=p2+1; end if; else p1=0; p2=0; end if; else p1=0; p2=0; end if; end process; end count_body;d. 译码器library IEEE; use IEEE.std_logic_1164.all; 图7 译码器use IEEE.std_logic_unsigned.all; entity devode is port( clk_1:in std_logic; clk:in std_logic; nixie_state1,nixie_state2:in std_logic_v

12、ector(1 downto 0); leds_state:in std_logic_vector(2 downto 0);nixie1:out std_logic_vector(6 downto 0); nixie2:out std_logic_vector(6 downto 0); leds:out std_logic_vector(6 downto 0) ); end devode; architecture devode_body of devode is signal tmp_leds:std_logic_vector(6 downto 0); signal tmp_nixie1:std_logic_vector(6 downto 0); signal tmp_nixie2:std_logic_vector(6 downto 0); signal tmp_nixiea

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 商业/管理/HR > 商业计划书

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号