EDA课程设计拔河游戏机.docx

上传人:b****0 文档编号:9779752 上传时间:2023-05-21 格式:DOCX 页数:22 大小:114.61KB
下载 相关 举报
EDA课程设计拔河游戏机.docx_第1页
第1页 / 共22页
EDA课程设计拔河游戏机.docx_第2页
第2页 / 共22页
EDA课程设计拔河游戏机.docx_第3页
第3页 / 共22页
EDA课程设计拔河游戏机.docx_第4页
第4页 / 共22页
EDA课程设计拔河游戏机.docx_第5页
第5页 / 共22页
EDA课程设计拔河游戏机.docx_第6页
第6页 / 共22页
EDA课程设计拔河游戏机.docx_第7页
第7页 / 共22页
EDA课程设计拔河游戏机.docx_第8页
第8页 / 共22页
EDA课程设计拔河游戏机.docx_第9页
第9页 / 共22页
EDA课程设计拔河游戏机.docx_第10页
第10页 / 共22页
EDA课程设计拔河游戏机.docx_第11页
第11页 / 共22页
EDA课程设计拔河游戏机.docx_第12页
第12页 / 共22页
EDA课程设计拔河游戏机.docx_第13页
第13页 / 共22页
EDA课程设计拔河游戏机.docx_第14页
第14页 / 共22页
EDA课程设计拔河游戏机.docx_第15页
第15页 / 共22页
EDA课程设计拔河游戏机.docx_第16页
第16页 / 共22页
EDA课程设计拔河游戏机.docx_第17页
第17页 / 共22页
EDA课程设计拔河游戏机.docx_第18页
第18页 / 共22页
EDA课程设计拔河游戏机.docx_第19页
第19页 / 共22页
EDA课程设计拔河游戏机.docx_第20页
第20页 / 共22页
亲,该文档总共22页,到这儿已超出免费预览范围,如果喜欢就下载吧!
下载资源
资源描述

EDA课程设计拔河游戏机.docx

《EDA课程设计拔河游戏机.docx》由会员分享,可在线阅读,更多相关《EDA课程设计拔河游戏机.docx(22页珍藏版)》请在冰点文库上搜索。

EDA课程设计拔河游戏机.docx

EDA课程设计拔河游戏机

XXXXXX学院

课程设计

 

题目:

EDA拔河游戏机课程设计

 

作者:

XXX

专业:

自动化

班级:

XXX

学号:

XXXXX

指导教师:

XXX

2021年12月15日

要紧内容、大体要求、要紧参考资料等

要紧内容:

电子拔河游戏机是一种能容纳甲乙两边参赛游戏电路。

由一排发光二极管表示拔河的“电子绳”。

由甲乙两边通过按纽开关使发光二极管向一方的终点延伸,当延伸到某方的最后一个发光二极管时,那么该方获胜,持续竞赛多局以定输赢。

大体要求:

一、设计一个能进行拔河游戏的电路。

二、电路利用9个发光二极管,开机后只有中间一个发亮,此即拔河的中心点。

3、游戏两边各持一个按钮,迅速地、不断地按动,产生脉冲,谁按得快,亮点就向谁的方向移动,每按一次,亮点移动一次。

4、亮点移到任一方终端二极管时,这一方就获胜,现在两边按钮均无作用,输出维持,只有复位后才使亮点恢复到中心。

五、用数码管显示获胜者的盘数。

要紧参考资料:

[1]潘松著.EDA技术有效教程(第二版).北京:

科学出版社,2005.

[2]康华光主编.电子技术基础模拟部份.北京:

高教出版社,2006.

[3]阎石主编.数字电子技术基础.北京:

高教出版社,2003.

 

一、整体设计思想

1.大体原理

由设计内容可知,需要一个十进制的计数器,用于对两边按钮的次数计数,并通过译码器显示在数码管上。

显视操纵部份设计要求在发光二极管上显示游戏状态,两边每按十次,亮点向先按十次移动一次,对脉冲进行计数,每十次移一名。

需接入一个清零端,用于复位。

将以上程序组装起来。

2.设计框图

图1.拔河机游戏机框图

二、设计步骤和调试进程

一、整体设计电路

整体电路图和仿真图如图(25)所示,由仿真图可知,此电路设计无误,能够实现按动A、B两个按键时,别离产生两个脉冲信号,经整形后别离加到可逆计数器上,可逆计数器输出的代码经译码器译码后驱动电平指示灯点亮并产生位移,当亮点移到任何一方终端后,由于操纵电路的作用,使这一状态被锁定,两边按键产生的输入脉冲不起作用。

如按动复位键C,亮点又回到中点位置,再次按C键那么竞赛又可从头开始。

图2.电路图

二、模块设计和相应模块程序

libraryIEEE;

usebaheis

port(

player1,player2:

instd_logic;--玩家1,2输入

clk_in:

instd_logic;--clk_in(1MHZ)

reset:

instd_logic;--重置键

row:

outstd_logic_vector(7downto0);

col:

outstd_logic_vector(7downto0);

led:

outstd_logic_vector(7downto0);--绳索

cats:

outstd_logic_vector(6downto0);--比分

q:

outstd_logic_vector(5downto0);--数码管操纵

mus:

outstd_logic);--蜂鸣输出

endbahe;

architecturebody_baheofbaheis

--计数模块

componentcount

port(

clk_1:

instd_logic;--1HZ输入

sw:

instd_logic;--状态开关

player1,player2:

instd_logic;--选手输入

sum1,sum2:

outstd_logic_vector(4downto0));--计数结果输出

endcomponent;

--比较模块

componentcmp

port(

clk_100:

instd_logic;--100hz

clk_1:

instd_logic;--1hz

sw:

outstd_logic;--状态开关输出

reset:

instd_logic;--重置

start:

instd_logic;--开始

sum1,sum2:

instd_logic_vector(4downto0);--计数结果输入

music_begin:

outstd_logic;--音乐

record1,record2:

outstd_logic_vector(1downto0);--比分输出

lights:

outstd_logic_vector(2downto0));--拔河绳索显示

endcomponent;

--音乐模块

componentmusic

port(

reset:

instd_logic;--重置

clk:

instd_logic;--1MHz

clk_5:

instd_logic;--5hz

music_begin:

instd_logic;--音乐开始

mus:

outstd_logic);

endcomponent;

--译码模块

componentdecode

port(

clk_in:

instd_logic;--1mHZ

record1,record2:

instd_logic_vector(1downto0);--比分输入

lights:

instd_logic_vector(2downto0);--拔河绳索输入

led:

outstd_logic_vector(7downto0);--输出到LED

q:

bufferstd_logic_vector(5downto0);--数码管操纵

cats:

outstd_logic_vector(6downto0)--数码管显示比分

);

endcomponent;

--倒计时模块

componentdaojishi

port(

clk_in,clk_1,reset:

instd_logic;

row:

outstd_logic_vector(7downto0);

col:

outstd_logic_vector(7downto0);

start:

outstd_logic

);

endcomponent;

--分频器输出

signalclk_100,clk_5,clk_1:

std_logic;--时钟信号

--计数器输出

signalsum1,sum2:

std_logic_vector(4downto0);--计数结果

--比较器输出

signalsw:

std_logic;--状态开关

signalrecord1,record2:

std_logic_vector(1downto0);--比分

signallights:

std_logic_vector(2downto0);--绳索

signalmusic_begin:

std_logic;

--解码器输出

signaltmp_led:

std_logic_vector(7downto0);--LED显示

signaltmp_q:

std_logic_vector(5downto0);--数码管操纵

signaltmp_cat:

std_logic_vector(6downto0);--数码管显示比分

--倒计时器输出

signaltmp_start:

std_logic;

begin

cats<=tmp_cat;

q<=tmp_q;

led<=tmp_led;

div:

divisionportmap(clk_in=>clk_in,clk_100=>clk_100,clk_5=>clk_5,clk_1=>clk_1);

cnt:

countportmap(

clk_1=>clk_1,sw=>sw,player1=>player1,player2=>player2,

sum1=>sum1,sum2=>sum2);

com:

cmpportmap(

clk_100=>clk_100,clk_1=>clk_1,sw=>sw,reset=>reset,

start=>tmp_start,sum1=>sum1,sum2=>sum2,music_begin=>music_begin,

record1=>record1,record2=>record2,lights=>lights);

dec:

decodeportmap(

clk_in=>clk_in,record1=>record1,record2=>record2,

lights=>lights,led=>tmp_led,q=>tmp_q,cats=>tmp_cat);

mu:

musicportmap(

reset=>reset,clk=>clk_in,clk_5=>clk_5,

music_begin=>music_begin,mus=>mus);

dao:

daojishiportmap(

clk_in=>clk_in,clk_1=>clk_1,reset=>reset,

start=>tmp_start,col=>col,row=>row);

endbody_bahe;

模块

libraryIEEE;

usecmpis

port(clk_100:

instd_logic;--100HZ输入

clk_1:

instd_logic;--1HZ输入

reset:

instd_logic;--重置

start:

instd_logic;--开始

sum1,sum2:

instd_logic_vector(4downto0);--计数输入

record1,record2:

outstd_logic_vector(1downto0);--比分输出

music_begin:

outstd_logic;--音乐开始

sw:

outstd_logic;--状态输出

lights:

outstd_logic_vector(2downto0));--绳子状态

endcmp;

architecturebody_cmpofcmpis

signaltmp_record1:

std_logic_vector(1downto0);--比分

signaltmp_record2:

std_logic_vector(1downto0);

signaltmp:

std_logic_vector(2downto0);--绳子状态

signaltmp_sta:

std_logic;--状态

signals1,s2:

std_logic_vector(4downto0);--计数

begin

record1<=tmp_record1;

record2<=tmp_record2;

lights<=tmp;

sw<=tmp_sta;

process(clk_100)--判断比赛状态

begin

if(start='1')then

if(clk_100'eventandclk_100='1')then

tmp_sta<='1';

endif;

endif;

if(clk_100'eventandclk_100='1')then--任意比分到3,比赛结束,开始播放音乐

if(tmp_record1="11"ortmp_record2="11")then

tmp_sta<='0';

music_begin<='1';

endif;

if(tmp="001"ortmp="111")then--绳子到头,进入等待状态

tmp_sta<='0';

endif;

if(reset='1')then--复位,状态归零

tmp_sta<='0';

music_begin<='0';

endif;

endif;

endprocess;

s1<=sum1;

s2<=sum2;

process(clk_1,reset)--控制绳子移位

begin

if(reset='1')then

tmp<="100";--绳子初始状态为100

tmp_record1<="00";

tmp_record2<="00";

else

if(clk_1'eventandclk_1='1')then

if(tmp_sta='1')then

if(s1>s2)thentmp<=tmp-'1';--绳子左移

elsif(s1=s2)thentmp<=tmp;--绳子保持原状

elsetmp<=tmp+'1';--绳子右移

endif;

else

if(tmp="001")then--绳子到左尽头,左计分器加1

tmp_record1<=tmp_record1+'1';

tmp<="100";

elsif(tmp="111")then--绳子到右尽头,右记分器加1,

tmp_record2<=tmp_record2+'1';

tmp<="100";

endif;

endif;

endif;

endif;

endprocess;

endbody_cmp;

3.COUT模块

usecountis

libraryIEEE;

port(clk_1:

instd_logic;--1HZ输入

sw:

instd_logic;--状态判断输入

player1,player2:

instd_logic;--选手输入

sum1,sum2:

outstd_logic_vector(4downto0));--计数输出

endcount;

architecturebody_countofcountis

signalp1,p2:

std_logic_vector(4downto0);--计数输出

begin

sum1<=p1;

sum2<=p2;

process(player1,player2,sw,clk_1)

begin

if(sw='1')then--处于比赛状态

if(clk_1='0')then

if(player1'eventandplayer1='1')then

p1<=p1+'1';

endif;

if(player2'eventandplayer2='1')then

p2<=p2+'1';

endif;

else

p1<="00000";

p2<="00000";

endif;--比赛状态结束

elsep1<="00000";

p2<="00000";

endif;

endprocess;

endbody_count;

4.daojishi模块

libraryIEEE;

usedaojishiis

port(clk_1,clk_in,reset:

instd_logic;

row:

outstd_logic_vector(7downto0);

col:

outstd_logic_vector(7downto0);

start:

outstd_logic);

enddaojishi;

architecturebody_daojishiofdaojishiis

typestateis(s0,s1,s2,s3,s4,s5,s6,s7,s8,s9,s10);

signalpresent_state:

state:

=s10;

signalnum:

std_logic_vector(2downto0):

="000";

begin

p3:

process(clk_in)

begin

ifclk_in'eventandclk_in='1'then

ifnum="101"thennum<="000";

elsenum<=num+1;

casepresent_stateis

whens9=>

casenumis

when"000"=>col<="";row<="";

when"001"=>col<="";row<="01110100";

when"010"=>col<="";row<="01010100";

when"011"=>col<="";row<="01010100";

when"100"=>col<="";row<="01111100";

whenothers=>col<="00000000";row<="00000000";

endcase;

whens8=>

casenumis

when"000"=>col<="";row<="";

when"001"=>col<="";row<="01111100";

when"010"=>col<="";row<="01010100";

when"011"=>col<="";row<="01010100";

when"100"=>col<="";row<="01111100";

whenothers=>col<="00000000";row<="00000000";

endcase;

whens7=>

casenumis

when"000"=>col<="";row<="";

when"001"=>col<="";row<="01000000";

when"010"=>col<="";row<="01000000";

when"011"=>col<="";row<="01000000";

when"100"=>col<="";row<="01111100";

whenothers=>col<="00000000";row<="00000000";

endcase;

whens6=>

casenumis

when"000"=>col<="";row<="";

when"001"=>col<="";row<="01111100";

when"010"=>col<="";row<="01010100";

when"011"=>col<="";row<="01010100";

when"100"=>col<="";row<="01011100";

whenothers=>col<="00000000";row<="00000000";

endcase;

whens5=>

casenumis

when"000"=>col<="";row<="";

when"001"=>col<="";row<="01110100";

when"010"=>col<="";row<="01010100";

when"011"=>col<="";row<="01010100";

when"100"=>col<="";row<="01011100";

whenothers=>col<="00000000";row<="00000000";

endcase;

whens4=>

casenumis

when"000"=>col<="";row<="";

when"001"=>col<="";row<="01110000";

when"010"=>col<="";row<="00010000";

when"011"=>col<="";row<="00010000";

when"100"=>col<="";row<="01111100";

whenothers=>col<="00000000";row<="00000000";

endcase;

whens3=>

casenumis

when"000"=>col<="";row<="";

when"001"=>col<="";row<="01010100";

when"010"=>col<="";row<="01010100";

when"011"=>col<="";row<="01010100";

when"100"=>col<="";row<="01111100";

whenothers=>col<="00000000";row<="00000000";

endcase;

whens2=>

casenumis

when"000"=>col<="";row<="";

when"001"=>col<="";row<="01011100";

when"010"=>col<="";row<="01010100";

when"011"=>col<="";row<="01010100";

when"100"=>col<="";row<=

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 表格模板 > 表格类模板

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2