【正文】
態(tài) if (hit2=’ 1’ ) or (hit4=39。state=waitserve。 end if。 state=ballmoveto2。) and (a=’ 1’ ) then i=2。i=0。139。 a=’ 1’ 。 state=ballmoveto2。 state=waitserve。 end if。記分譯碼器( mydecoder) :由于記分需要顯示出來,所以要使用七段譯碼器。 乒乓球游戲電路設(shè)計 7 use 。 5位二進制碼的輸入端口 bcdout1:out std_logic_vector(1 to 7)。 begin process(binaryin) begin tembinaryin=binaryin。bcdout2=0110000。bcdout2=1111001。bcdout2=1011011。bcdout2=1110000。bcdout2=1111011。bcdout2=0110000。bcdout2=1111001。bcdout2=1011011。bcdout2=1110000。bcdout2=1111011。bcdout2=0110000。 end process。 use 。 red1,red2,green1,green2:in std_logic。 score11,score12,score21,score22:out std_logic_vector(1 to 7))。 serve:in std_logic_vector( 1 to 2 )。 ponent mydecoder port(binaryin : in std_logic_vector(1 to 5)。 signal d,e:std_logic_vector(4 downto 0)。 end 。狀態(tài)機中的 i信號和 count1,count2信號的變化同時就可以影響到外圍的顯示部分 發(fā)光二極管和七段譯碼器,從而表示出當(dāng)時的乒乓球位置和雙方分數(shù)情況。從最后一行 state 值的變化,可以清楚分析狀態(tài)轉(zhuǎn)移。在不允許甲乙擊球的狀態(tài)下,即 state 處在狀態(tài) 5 時, hit1 或 hit3 輸入邏輯‘ 1’,表示甲或乙擊球了,所以丙丁得分。一方得分時,電路自動響鈴 3秒,這期間發(fā)球無效,等鈴聲停止后方能繼續(xù)比賽。在具體設(shè)計過程中還需要改進的是控制系統(tǒng)的糾錯功能。此外,也學(xué)會了使用 QuartusⅡ 軟件。在設(shè)計過程中。 entity ying is port(reset1,clk1:in std_logic。 Llight:out std_logic_vector(1 to 8)。 startbutton,hit1,hit2,hit3,hit4:in std_logic。 end ponent 。 end ponent。 u3 :mydecoder port map(binaryin=e,bcdout1=score21,bcdout2=score22)。 use 。 乒乓球游戲電路設(shè)計 15 count1,count2 : buffer std_logic_vector(1 to 5)。 signal state : pingponggame。139。a=0。139。 elsif startbutton=39。count2=00000。state=light8on。 if (hit2=39。) then i=0。 end if。) or (hit3=39。state=waitserve。139。 count2=count2+1。 else i=i1。) or (hit4=39。state=waitserve。 end if。139。 elsif (hit3=39。 a=0。 end if。 state=ballmoveto1。) and (b=1) then i=2。i=0。 end if。 end one。 use 。 end entity mydecoder。bcdout2=1111110。bcdout2=1101101。bcdout2=0110011。bcdout2=1011111。bcdout2=1111111。bcdout2=1111110。bcdout2=1101101。bcdout2=0110011。bcdout2=1011111。bcdout2=1111111。bcdout2=1111110。bcdout2=1111110。 。 end process。bcdout2=0110000。bcdout2=1111011。bcdout2=1110000。bcdout2=1011011。bcdout2=1111001。bcdout2=0110000。bcdout2=1111011。bcdout2=1110000。bcdout2=1011011。bcdout2=1111001。bcdout2=0110000。 begin process(binaryin) begin tembinaryin=binaryin。 5 位 二進制碼的輸入端口 bcdout1 : out std_logic_vector(1 to 7)。 use 。 end process。 end if。 b=0。 elsif (hit4=39。139。i=0。) and (a=1) then i=2。 state=ballmoveto2。139。 state=allow24hit。) then i=0。 when ballmoveto2= if (hit2=39。 elsif i=2 then i=1。139。 end if。) then i=0。 if (hit1=39。state=waitserve。) or (hit4=39。 end case。state=light1on。 then i=0。count1=00000。 elsif clk39。count1=00000。 signal i: integer range 0 to 8。 end pingponggame。 startbutton,hit1,hit2,hit3,hit4:in std_logic。 狀態(tài)機: ibrary ieee。 begin u1:pingponggame port map(count1=d,count2=e,hit1=red1,hit2=green1,hit3=red2,hit4=green2,clk=clk1, startbutton=lopen,serve=fire,reset=reset1,light=Llight)。 5 位二進制碼的輸入端口 bcdout1 : out std_logic_vector(1 to 7)。 light:out std_logic_vector(1 to 8)。 end ying。 lopen:in std_logic。 乒乓球游戲電路設(shè)計 14 參考資料 [1] 潘松著 .EDA 技術(shù)實用教程 (第二版 ). 北京:科學(xué)出版社 ,2021. [2] 劉艷 . EDA 技術(shù)在數(shù)字系統(tǒng)電路設(shè)計實驗中的應(yīng)用 [J]. 實驗室研究與探索 ,2021,21(3): 63264 [3] 徐穎 .Protel 99 SE EDA 技術(shù)及應(yīng)用 [M].西安: 機械工業(yè)出版社 .2021 [4] 楊恒,盧飛成 . FPGA/VHDL 快速工程實踐入門與提高 [M].北京航空航天大學(xué)出版社 .2021 [5]甘歷 .VHDL 應(yīng)用與開發(fā)實踐 [M].科學(xué)出版社 .200 [6] 侯伯亨 .VHDL 硬件描述語言與數(shù)字邏輯電路設(shè)計 [M].西安:西安電子科技大學(xué)出版社, 1999: 27. [7] 潭會生,張昌凡 .EDA 技術(shù)及應(yīng)用 [M].西安:西安電子科技大學(xué)出版社,2021 [8] 王振紅 .VHDL 數(shù)字電路設(shè)計與應(yīng)用實踐教程 [M].北京:機械工業(yè)出版社,2021 乒乓球游戲電路設(shè)計 15 附錄 復(fù)合語句: use 。但卻是我獨立自主的從設(shè)計電路到得出結(jié)論。 這次課程設(shè)計總的說來收獲很大。甲 乙和丙丁 雙方各設(shè)