VHDL大作業(yè)-二人乒乓球游戲機(jī)設(shè)計(jì)_第1頁
VHDL大作業(yè)-二人乒乓球游戲機(jī)設(shè)計(jì)_第2頁
VHDL大作業(yè)-二人乒乓球游戲機(jī)設(shè)計(jì)_第3頁
VHDL大作業(yè)-二人乒乓球游戲機(jī)設(shè)計(jì)_第4頁
VHDL大作業(yè)-二人乒乓球游戲機(jī)設(shè)計(jì)_第5頁
已閱讀5頁,還剩27頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡介

VHDL數(shù)字系統(tǒng)設(shè)計(jì)與測試

VHDL二人乒乓球游戲機(jī)設(shè)計(jì)

學(xué)號(hào):

姓名:

一、設(shè)計(jì)課題的任務(wù)要求

兩人乒乓球游戲機(jī)是以8*8點(diǎn)陣作為場地,中間的6*6共36個(gè)點(diǎn)作

為球臺(tái),最外圍的一圈點(diǎn)作為球拍移動(dòng)的軌道,并通過數(shù)碼管顯示雙方的

局?jǐn)?shù)和比分。雙方個(gè)通過3個(gè)按鈕控制球拍的上下移動(dòng)及發(fā)球(場上無球

時(shí))。球接觸到球拍后會(huì)自動(dòng)改變方向和速度(在一定范圍內(nèi))。當(dāng)球在甲

方的半場移動(dòng)出球臺(tái)范圍后,乙方得分,然后重新發(fā)球。直到達(dá)到規(guī)定比

分后,比賽結(jié)束。

(1)以8*8點(diǎn)陣作為場地,中間的6*6共36個(gè)點(diǎn)作為球臺(tái),最外

圍的一圈點(diǎn)作為球拍移動(dòng)的軌道,通過兩個(gè)按鍵控制球拍的移

動(dòng);

(2)球的移動(dòng)速度:在x,y方向上均為0.2s/點(diǎn)?0.6s/點(diǎn)(可為0),

會(huì)在擊球時(shí)按一定規(guī)則自動(dòng)改變;

(3)通過按鈕移動(dòng)球拍,球拍不能移出自己的半場(8*4);

(4)球出界后,自動(dòng)判定得分,球從球場中消失,等待下一次發(fā)球;

(5)用數(shù)碼管顯示局?jǐn)?shù)和比分,參考正式比賽規(guī)則,采用7局4勝

制:當(dāng)一方得分超過11分,并超過對(duì)方兩分時(shí),本局比賽結(jié)

束,當(dāng)一方率先贏得4局時(shí),比賽結(jié)束,此時(shí)數(shù)碼管保持最終

比分。

(6)按下復(fù)位鍵,比分清零,雙方重新開始比賽;

(7)雙方按乒乓球比賽規(guī)則獲得發(fā)球權(quán),沒有發(fā)球權(quán)的一方,發(fā)球

開關(guān)無效。

二、系統(tǒng)設(shè)計(jì)

1、設(shè)計(jì)思路

用x,y兩坐標(biāo)表示8*8點(diǎn)的每個(gè)點(diǎn)。分別用一組信號(hào)表示球和兩球

拍的坐標(biāo),以及球的移動(dòng)速度。以一定周期(0.1s),改變球的坐標(biāo),以

達(dá)到移動(dòng)球的目的,用一組信號(hào)(xm、ym)記錄球經(jīng)過兒個(gè)周期(0.1s)

在想x或y方向上移動(dòng)一個(gè)點(diǎn),通過改變這兩個(gè)信號(hào)的大小,即可控制球

移動(dòng)的速度和方向。

球拍的移動(dòng)由按鈕控制,鑒于球拍只在最外圈移動(dòng),只需要上下兩個(gè)

按鈕即可。當(dāng)球拍在y方向上移動(dòng)到邊緣時(shí),會(huì)自動(dòng)轉(zhuǎn)為在x方向上移動(dòng)。

球拍長度為3個(gè)點(diǎn),只需記錄中間點(diǎn)的位置即可。當(dāng)球與球拍接觸時(shí)(球

的坐標(biāo)與球拍中心的坐標(biāo)在x,y兩個(gè)方向的差均不大于1),根據(jù)球與球

拍中心的相對(duì)位置,改變xm、ym,從而將球擊回。

當(dāng)球位于邊緣部分時(shí),自動(dòng)更新比分,并將球的坐標(biāo)更改為特殊值

(x=0),使球在臺(tái)面上消失。此時(shí)發(fā)球按鈕生效,按下發(fā)球按鈕后,會(huì)

將球的坐標(biāo)及球速按一定規(guī)則重置,球再次開始移動(dòng)。當(dāng)比分符合一定規(guī)

則時(shí)一,將自動(dòng)清零,并更新局?jǐn)?shù),有一方局?jǐn)?shù)為4時(shí),時(shí)分頻器不再提供

時(shí)鐘信號(hào)。所有功能停止,系統(tǒng)保持在最后狀態(tài),直到復(fù)位。

系統(tǒng)時(shí)鐘為50MHz,通過兩級(jí)分頻器分別產(chǎn)生1kHz和10Hz的時(shí)鐘

信號(hào)供各模塊使用。數(shù)碼管和8*8點(diǎn)鐘使用1kHz的時(shí)鐘信號(hào),以掃描方

式輸出,其中球拍和球臺(tái)與球在不同周期交替顯示,以簡化系統(tǒng)。1kHz

的時(shí)鐘信號(hào)同時(shí)用于按鍵防抖動(dòng)。10Hz時(shí)鐘信號(hào)用于球的坐標(biāo)更新以及

出界、擊球等狀態(tài)的判定。

2、總體框圖

3、分塊設(shè)計(jì)圖

4、流程圖

注:圖中梯形表示按鍵輸入

5、狀態(tài)轉(zhuǎn)移圖

三、波形仿真及波形分析

1、分頻器

本設(shè)計(jì)中用到1000Hz和10Hz的時(shí)鐘信號(hào),采用兩級(jí)分頻器,由50MHz

的主時(shí)鐘信號(hào)產(chǎn)生。

分頻器L輸入50MHz時(shí)鐘信號(hào),產(chǎn)生1000Hz時(shí)鐘信號(hào)(占空比為調(diào)

節(jié),為1/50000)

分頻器2:輸入1000Hz時(shí)鐘信號(hào)(分頻器1產(chǎn)生),產(chǎn)生10Hz時(shí)鐘信

號(hào)(占空比為調(diào)節(jié),為1/100)

2、球拍移動(dòng)

本模塊集成了按鍵防抖動(dòng)功能。

If為向上移動(dòng),ri為向下移動(dòng),reset重置;1、2表示兩名球員。球

拍(racket)的坐標(biāo)(rxl,ryl為球拍1的橫縱坐標(biāo),rx2,ry2為球拍2

的橫縱坐標(biāo))表示其位置。球拍在8*8場地的最外圈移動(dòng),卻不會(huì)超出各

自半場。Reset鍵按下時(shí),坐標(biāo)復(fù)位

JJlX010XOilX:.|JX011X010XJJ1

>000X01HXOHOI0IQ1X0”0XWOO

0J011OHOX0111Iiooo*01"xDUO70101x0100f

oiotxonoxoutxloroXoiTi<ouoXoioix018

3、球臺(tái)顯示

根據(jù)輸入的球坐標(biāo)(x,y)球拍坐標(biāo)(racketx,rackety)顯示球,球

臺(tái)和球拍。row,colg和coir為控制矩陣顯示的輸出,輸出為掃描方式。

特別要指出的是,所有坐標(biāo)的有效范圍均不超過為1-8(特別的x為0

不顯示球),而球拍只能在8*8矩陣的最外圍顯示。波形中超出此范圍的

賦值不予考慮。

QMaterTimeBar50Q0s?|?|PWter552mInterval547m?EM

A5099TIP-12m?上中-&M.097AS66.718ns69.34UQT4■窣m77甲N」

l?M

區(qū)i>,oel.1000_rLrLrLrLrLrLrLrLrLn_rLrLn_rLn_n_rLrLrLrLrLrLrLrLFLrLrLn

_yi國r?dc?txl^TYnTYBnrociTO5nTnYgrxNYRTY^nTOcnnnsrYTiTYiHYEnTiryTgnMYFm5miHMYnnTTOgmsn

3Qr*dcetx2^D(EixgDCgiXEiXMXiiDO(nnxiiiDEnxEgxn5msmTTYisTxgDcgiy^TxgixEiyT§TXKxiigix【mxsiDwnvn

3rkdwtyl二

?15國r?ck?ty275Tj.瓦

T>20SX

*25國y【心X⑸「

少30國C?l(01111"?!皁ooooooo01111110W66665

杼393c?lroooocooo;而「oooooooooooooooo

0*48國rvtHYiniionXiiiuhnXiiKnimomiCTiSnnmoiininYluinio.XiinnoiXiiiuouXiinoiuYnioiniynoiiniQ5nnrr%niiiu

?ir?

4、數(shù)碼管輸出

數(shù)碼管采用掃描輸出,cat1-6(共陰極)分別對(duì)應(yīng),球員1的局?jǐn)?shù)

(inningsl),比分的十位、個(gè)位(scorell,scorelO),球員2比分的

十位、個(gè)位(score21,score20),局?jǐn)?shù)(innings位。app為數(shù)碼管輸出,

cat為共陰極,0電平選通。

5、球移動(dòng)

由于情況過多,顧不采用枚舉法,而通過仿真依次驗(yàn)證其功能。

發(fā)球后球在兩板的中間點(diǎn)間反彈.,速度逐漸上升(范圍0-5,到達(dá)5

后不再上升)racketx、y分別為板的橫縱坐標(biāo),xmo>ymo為兩方向上的

移動(dòng)速度,球的坐標(biāo)以xmo、ymo為速度,按一定周期改變。

xo、yo為球的橫縱坐標(biāo)。

球從板的邊緣反彈后,會(huì)改變y方向上的速度,達(dá)到最外圈(本例

(x=racketxl+l或racketx2-l,y=racketyl或y2),按乒乓球比賽規(guī)則,

發(fā)兩次球后交換發(fā)球權(quán)(此時(shí)另一方的發(fā)球鍵無效)

開局時(shí),只有playerl有發(fā)球權(quán)。

此為第三次發(fā)球,為player2發(fā)球。

16825ns?|?|Parief35.39>Interval36391Start

A

A*0▲」0TLn_n_njTrLnjLrLrLnjmnjTrmnjTnjrmrLn_n_nrLnjmn

S囹rack?txlTTT

3回ruk.tx2

1^10國rtdntylM

35Qrtck?ly2ITT

?20r?s?t

?21strvtl

222s?rv?2

外電23國xoXET⑸wI~T3T

“28By。X

砂33國mouT

Br?oToT

4川

6、計(jì)分模塊

當(dāng)球在球臺(tái)最外圍(x,y中有至少一個(gè)等于1或8)時(shí)判斷為出界,并自

動(dòng)更改比分,按乒乓球比賽規(guī)則,得分率先超過11分,切高于對(duì)方2分

時(shí),贏得一局。如始終無法超出對(duì)方2分,則率先得到21分者贏得本局。

贏得四局后比賽結(jié)束。系統(tǒng)停止在最后狀態(tài)(保持比分),知道按下reset

鍵后方重新運(yùn)行。scorelKscore21為十位,scorelO>score20為個(gè)位,

inningsl>2為局?jǐn)?shù)

取值范圍x為0到8,y為1到8o超過這個(gè)范圍的情況不予考慮。

贏得4局后系統(tǒng)停止,等待reset復(fù)位。

圖均為作者如此仿真操作后生成。

2、因本設(shè)計(jì)較為復(fù)雜,采用總體仿真難以設(shè)計(jì)全面的仿真條件(要考慮球在臺(tái)上的各種反

彈情況),同時(shí)也無法直觀地觀察實(shí)驗(yàn)結(jié)果以及檢查程序中出現(xiàn)的問題(輸出為數(shù)碼管以及

8*8點(diǎn)陣的坐標(biāo),并且為掃描輸出方式,不以觀察),故在各模塊仿真正確的情況下,不再進(jìn)

行整體仿真

四、源程序

-filename:table_tennis

—author:ShenKewei

-time:2011-10-10

libraryieee;

useieee.std_logic_l164.all;

entitytable_tennisis

port(

If1,lf2,ri1,ri2,serve1,serve2:instd_logic;

—1,2:twoplayer;If:moveleft;ri:moveright;hit:hittheball;

reset:instd」ogic;

row:outstd_logic_vector(7downto0);

colg,colr:outstd_logic_vector(0to7);—row,colg,coir:8*8output

cat:outstd_logic_vector(1to6);—digitronchioce

aap:outstd_logic_vector(0to7);—digitron

elk:instd_logic);

endtable_tennis;

architectureaoftable_tennisis

signalcl_1000:std_logic;—1000Hzclock

signalcl_10:std_logic;-10Hzclock

signalx:integerrange0to8;

signaly:integerrange1to8;-x,y:coordinate

signalxm:integerrange0to5;

signalym:integerrange0to5;—xm,ym:thelengthballmoveatonceinthedirection

signalxmd,ymd:integerrange0to1;—thedirectioninwhichtheballmoves

signalscore10,score11:integerrange0to9;

signalscore20,score21:integerrange0to9;-differentdigitalsofbothplayers'scores

signalinningsl,innings2:integerrange0to4;"players*innings

signalracketyl,rackety2:integerrange1to8;

signalracketx1:integerrange1to4;

signalracketx2:integerrange5to8;-rackets'coordinates

signalserve_flag1,serve_flag2:integerrange0to2;-flagoftherighttoserve

signalhit_flag1,hit_flag2:integerrange0to1;—righttohit

constantspeed:integer:=5;

proceduredig(signalnum:inintegerrange0to9;signaloutl:outstd_logic_vector(0to7))is—output

ofdigitaltubes

begin

casenumis

when0=>outl<="11111100n;

when1=>outl<=n01100000n;

when2=>outl〈二"11011010”;

when3=>outl<="11110010";

when4=>outl<=n01100110*1;

when5=>outl<="10110110";

when6=>outl<="00111110";

when7=>outl<="1100000”;

when8=>outl<=n11111110n;

when9=>outl<="11100110";

endcase;

endproceduredig;

begin

pl:process(clk)

—get1000Hzclock

variablecount1:integerrange1to50000;

begin

ifclk'eventandelk=Tthen

ifcount1=50000then

count1:=1;

cl_1000<=,r;

else

countl:=countl+l;

cl_1000<=0';

endif;

endif;

endprocessp1;

P2:process(cl_1000)

—get10Hzclock

variablecount2:integerrange1to100;

begin

ifcl_1000*eventandcl_1000=1'then

ifcount2=100then

cl_10<=T;

count2:=1;

else

cl_10<=O;

count2:=count2+l;

endif;

endif;

endprocessp2;

p3:process(cl_1000)

-8*8output

variablecount3:integerrange1to8;

variablecountf:std_logic;-flagofwhettoshow

begin

ifcl_1000'eventandcl_1000=,l'then

ifcountf='1*then—showthetableandracket

countf:=O;

ifcount3=8then

count3:=l;

else

count3:=count3+l;

endif;

casecount3is-scanning

when1=>row<=nl1111110";

when2=>row<=H111111010;

when3=>row<=M11111011";

when4=>row〈二"11110111”;

when5=>row<="11101111";

when6=>row〈二"11011111”;

when7=>row<=n101111H";

when8=>row<="01111111”;

endcase;

if(count3=lorcount3=8)then-upside/downside

colg<="00000000H;

ifracketyl=count3then

caseracketxlis

when1=>colr(1to3)<="100”;

when2=>colr(1to3)<="110n;

when3=>colr(1to3)<=H11ln;

when4=>colr(1to3)<="01ln;

endcase;

else

colr(lto3)<=H000";

endif;

ifrackety2=count3then

caseracketx2is

when5=>colr(4to6)<=,,110,';

when6=>colr(4to6)<="111”;

when7=>colr(4to6)<="011”;

when8=>colr(4to6)<="001";

endcase;

else

colr(4to6)<=H000n;

endif;

else

colr(lto6)<=n000000M;

colg(0to7)<="011111101^;

endif;

if((racketyl=count3andracketxl<=2)or((rackety1-count3=1orrackety1-count3=-1)and

racketxl=l))then-racketofplayer1

colr(0)<='r;

else

colr(0)<='0';

endif;

if((rackety2=count3andracketx2>=7)or((rackety2-count3=1orrackety2-count3=-1)and

racketx2=8))then—racketofplayer2

coir⑺<=T;

else

coir⑺<='0';

endif;

elsifcountf='0,then—showtheball

countf:=r;

ify/=count3then

colr<="00000000n;

else

casexis

when0=>coir<=n00000000u;

when1=>coir<="10000000u;

when2=>coir<='^01000000,^;

when3=>coir<=H00100000,';

when4=>coir<=H00010000u;

when5=>coir<=,'00001000H;

when6=>coir<=H00000100";

when7=>coir<="00000010n;

when8=>coir<="00000001

endcase;

endif;

endif;

endif;

endprocessp3;

p4:process(cl_10)

—movetheball

-ifballmoveoutofthetable,renewthescoreandinnings

variablecountx,county:integerrange0tospeed;-counters

begin

ifcl_lO'eventandcl_10=rand((inningsl/=4andinnings2/=4)orreset=r)then

ifx/=0then

ifxm/=0then

ifcountx+xm=6then—theballmovesatxm*0.1seconds

casexmdis

when0=>x<=x-l;

when1=>x<=x+l;

endcase;

countx:=0;

else

countx:=countx+l;

endif;

elsecountx:=0;

endif;

ifym/=Othen

ifcounty+ym=6then—theballmovesatym*0.1seconds

caseymdis

when0=>y<=y-1;

when1=>y<=y+l;

endcase;

county:=0;

else

county:=county+1;

endif;

elsecounty:=0;

endif;

endif;

ifx=0andserve1=*Tthen—servetheball

ifserve_flagl/=Othen

x<=racketx1+1;y<=rackety1;—puttheball

hit_flag1<=0;hit_flag2<=1;-giverighttohit

xmd<=1;xm<=1;ym<=0;—resetthespeed

serve_flag1<=serve_flag1-1;

ifserve_flag1=1then

serve_flag2<=2;

endif;

endif;

endif;

ifx=0andserve2=rthen

ifserve_flag2/=0then

x<=racketx2-l;y<=rackety2;

hit_flag1<=1;hit_flag2<=0;

xmd<=0;xm<=1;ym<=0;

serve_flag2<=serve_flag2-l;

ifserve_flag2=lthen

serve_flagl<=2;

endif;

endif;

endif;

-renewthexm,ym

—(hittheball)

ifhit_flagl=landxmd=Othen-plarer1hasrighttohitandballmovetohim

ifrackety1>=2andrackety1<=7andx=2then—ballmovesintotheracket

ifracketyl=ythen

xmd<=l;—ballmovesbackwardsinthedirectionofx

hit_flagl<=O;

hit_flag2<=l;—changetherighttohit

ifxm/=speedthen

xm<=xm+l;—renewthespeed

endif;

ifym/=speedandym/=0then

ym<=ym+1;

endif;

elsifracketyl-y=lthen

xmd<=1;

hit_flagl<=0;

hit_flag2<=l;

ifym=0then

ym<=1;ymd<=0;

else

caseymdis

when1=>ym<=ym-1;

when0=>ifym/=speedthenym<=ym+1;endif;

endcase;

endif;

elsifracketyl-y=-lthen

xmd<=1;

hit_flagl<=0;

hit_flag2<=l;

ifym=0then

ym<=1;ymd<=1;

else

caseymdis

when0=>ym<=ym-l;

when1=>ifym/=speedthenym<=ym+1;endif;

endcase;

endif;

endif;

elsif(racketyl-y=lorracketyl-y=-l)and(rackety1=1orrackety1=8)andym/=0then

ifracketxl-x=-lthen

xmd<=l;

ymd<=l-ymd;

hit_flagl<=O;

hit_flag2<=l;

ifxm/=speedthen

xm<=xm+1;

endif;

ifym/=speedthen

ym<=ym+1;

endif;

elsifracketxl=xthen

xmd<=l;

ymd<=l-ymd;

hit_flagl<=O;

hit_flag2<=l;

xm<=xm-l;

elsifracketx1-x=-2then

xmd<=l;

ymd<=1-ymd;

hit_flagl<=O;

hit_flag2<=1;

ifxm/=speedthen

xm<=xm+l;

endif;

endif;

elsifx=2andracketx1=1and(rackety1=1andy=2)andym=0then

xmd<=l;

ymd<=1;

hit_flagl<=O;

hit_flag2<=1;

ym<=l;

elsifx=2andracketx1=1and(y=7andrackety1=8)andym=0then

xmd<=1;

ymd<=0;

hit_flagl<=0;

hit_flag2<=l;

ym<=l;

endif;

endif;

ifhit_flag2=landxmd=lthen-plarer2hasrighttohitandballmovetohim

ifrackety2>=2andrackety2<=7andx=7then

ifrackety2=ythen

xmd<=0;

hit_flagl<=l;

hit_fiag2<=0;

ifxm/=speedthen

xm<=xm+l;

endif;

ifym/=speedandym/=0then

ym<=ym+l;

endif;

elsifrackety2-y=1then

xmd<=0;

hit_flagl<=l;

hit_flag2<=0;

ifym=0then

ym<=1;ymd<=0;

else

caseymdis

when1=>ym<=ym-1;

when0=>ifym/=speedthenym<=ym+1;endif;

endcase;

endif;

elsifrackety2-y=-1then

xmd<=0;

hit_flagl<=l;

hit_flag2<=0;

ifym=0then

ym<=1;ymd<=1;

else

caseymdis

when0=>ym<=ym-l;

when1=>ifym/=speedthenym<=ym+1;endif;

endcase;

endif;

endif;

elsif(rackety2-y=lorrackety2-y=-1)and(rackety2=1orrackety2=8)andym/=0then

ifracketx2-x=1then

xmd<=0;

ymd<=l-ymd;

hit_flagl<=l;

hit_flag2<=0;

ifxm/=speedthen

xm<=xm+l;

endif;

ifym/=speedthen

ym<=ym+l;

endif;

elsifracketx2-x=2then

xmd<=0;

ymd<=l-ymd;

hit_flagl<=l;

hit_flag2<=0;

ifxm/=speedthen

xm<=xm+l;

endif;

elsifracketx2=xthen

xmd<=0;

ymd<=l-ymd;

hit_flagl<=l;

hit_flag2<=0;

xm<=xm-l;

endif;

elsifx=7andracketx2=8and(rackety2=1andy=2)andym=0then

xmd<=0;

ymd<=1;

hit_flagl<=l;

hit_flag2<=0;

ym<=1;

elsifx=7andracketx2=8and(y=7andrackety2=8)andym=0then

xmd<=0;

ymd<=0;

hit_flagl<=l;

hit_flag2<=0;

ym<=l;

endif;

endif;

ifx=lthen-outofthetable

x<=0;--themarkoftime-out

ifscore20=9then

score21<=score21+1;

score20<=0;

else

score20<=score20+1;

endif;

elsifx=8then

x<=0;

ifscore10=9then

score11<=score11+1;

score10<=0;

else

score10<=score10+1;

endif;

elsif(y=lory=8)andx/=0then

x<=0;

ifx<=4then

ifscore20=9then

score21<=score21+1;

score20<=0;

else

score20<=score20+1;

endif;

else

ifscore10=9then

score11<=score11+1;

score10<=0;

else

score10<=score10+1;

endif;

endif;

endif;

ifscore11=2or(scorell=landscore10=1andscore21=0)or(score11=1andscore21=land

score10-score20=2)then—getoneinning

ifinnings1+innings2=0orinnings1+innings2=2orinningsI+innings2=4orinnings1+innings2=6

then-resettherighttoserve

serve_flag2<=2;

serve_flagl<=0;

else

serve_flagl<=2;

serve_flag2<=0;

endif;

innings1<=innings1+1;

score11<=0;

score10<=0;

score21<=0;

score20<=0;

elsifscore21=2or(score21=landscore20=landscore11=0)or(score11=1andscore21=land

score20-score10=2)then

ifinnings1+innings2=0orinnings1+innings2=2orinnings1+innings2=4orinnings1+innings2=6

then

serve_flag2<=2;

serve_flagl<=0;

else

serve_flagl<=2;

serve_flag2<=0;

endif;

innings2<=innings2+1;

score11<=0;

score10<=0;

score21<=0;

score20<=0;

endif;

ifreset=*rthen-reset

score11<=0;

score10<=0;

score21<=0;

score20<=0;

inningsl<=0;

innings2<=0;

x<=0;

serve_flagl<=2;

serve_flag2<=0;

endif;

endif;

endprocessp4;

p5:process(cl_1000)

-movetherackets

variablectu_l,ctul,ctu_2,ctu2,ctd_l,ctdl,ctd_2,ctd2:integerrange0to1000;—counteragainstthe

jitter

begin

ifcLIOOO'eventandcl_1000=,rthen

ifthen-againstthejitter

ifctu1=1000then

ctul:=0;

else

ctul:=ctul+l;

endif;

elsifctu1>50then

ifctu_l=1000then

ctu_l:=0;

else

ctu_l:=ctu_l+l;

endif;

else

ctul:=0;

ctu_l:=0;

endif;

ifctu1>50andctu_l>50then-deicdetheinputofbutton

ifrackety1/=8andracketx1=1then—movetheracket

rackety1<=rackety1+1;

elsifrackety1=8andracketxl/=4then

racketx1<=racketx1+1;

elsifrackety1=1then

racketx1<=racketx1-1;

endif;

ctul:=0;

ctu_l:=0;

endif;

iflf2='lrthen

ifctu2=1000then

ctu2:=0;

else

ctu2:=ctu2+l;

endif;

elsifctu2>50then

ifctu_2=1000then

ctu_2:=0;

else

ctu_2:=ctu_2+l;

endif;

else

ctu2:=0;

ctu_2:=0;

endif;

ifctu2>50andctu_2>50then

ifrackety2/=8andracketx2=8then

rackety2<=rackety2+1;

elsifracketx2/=5andrackety2=8then

racketx2<=racketx2-1;

elsifrackety2=1then

racketx2<=racketx2+1;

endif;

ctu2:=0;

ctu_2:=0;

endif;

ifril='rthen

ifctd1=1000then

ctdl:=0;

else

ctdl:=ctdl+l;

endif;

elsifctd1>50then

ifctd_l=1000then

ctd_l:=0;

else

ctd_l:=ctd_l+l;

endif;

else

ctdl:=0;

ctd_l:=0;

endif;

ifctdl>50andctd_l>50then

ifrackety1/=1andracketxl=lthen

rackety1<=rackety1-1;

elsifrackety1=1andracketxl/=4then

racketx1<=racketx1+1;

elsifrackety1=8then

racketx1<=racketx1-1;

endif;

ctdl:=O;

ctd_l:=O;

endif;

ifri2=Tthen

ifctd2=1000then

ctd2:=0;

else

ctd2:=ctd2+l;

endif;

elsifctd2>50then

ifctd_2=1000then

ctd_2:=0;

else

ctd_2:=ctd_2+l;

endif;

else

ctd2:=0;

ctd_2:=0;

endif;

ifctd2>50andctd_2>50then

ifrackety2/=landracketx2=8then

rackety2<=rackety2-1;

elsifrackety2=landracketx2/=5then

racketx2<=racketx2-1;

elsifrackety2=8then

racketx2<=racketx2+1;

endif;

ctd2:=0;

ctd_2:=0;

endif;

ifreset=Tthen

racketx1<=1;

racketx2<=8;

rackety1<=4;

rackety2<=5;

endif;

endif;

endprocessp5;

p6:process(cl_1000)

-digitron

variablecount?:integerrange1to6;

begin

ifcl_1000'eventandcl_1000=*rthen

ifcount7=6then-scanning

count7:=1;

else

count7:=count7+1;

endif;

casecount?is

when1=>cat<=ul11110";dig(inningsl,aap);—output

when2=>cat<='*111

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論