【正文】
處于被動 20 地位,只是簡單的輸出一些狀態(tài)信號配合配置過程。 JTAG 接口是一個業(yè)界標準 ,主要用于芯片測試等功能 ,使用 IEEE Std 聯(lián)合邊界掃描接口引腳,支持 JAM STAPL 標準,可以使用 Altera 下載電纜或主控器來完成。 FPGA 在正常工作時,它的配置數(shù)據(jù)存儲在 SRAM 中,加電時須重新下載。在此實驗系統(tǒng)中,使用的是 AS 配置方式,加電時無需重新下載。在實用系統(tǒng)中,多數(shù)情況下必須由 FPGA 主動引導配置操作過程,這時 FPGA 將主動從外圍專用存儲芯片中獲得配置數(shù)據(jù),而此芯片中 FPGA 配置信息是用普通編程器將設計所得的 pof 格式的文件燒錄進去。 AS 編程模式下配置如圖 15所示 以及引腳分布圖( 如 圖 14) : 圖 14 引腳分布 圖 圖 15 AS 模式配置圖 21 本章主要 介紹整個系統(tǒng)的編譯、仿真、分配以及編程下載。通過對系統(tǒng)的仿真、編程下載,實現(xiàn)了系統(tǒng)的基本功能現(xiàn)象,達到了設計的要求。 5 結(jié)論 本文 乒乓球游戲機的設計是基于 FPGA 技術(shù)設計的乒乓球游戲機,利用FPGA 最小系統(tǒng)作為設計基礎,運用 QuartusII 軟件和 VHDL 硬件描述語言實現(xiàn)了乒乓球游戲機的功能。在設計時 用 EDA 實驗箱進行驗證,目標芯片是Altera 公司 CycloneII 系列的 EP2C5T144C8N 芯片 , 電路 由狀態(tài)機 /球臺控制器、記分牌譯碼顯示電路 、按鍵去抖 和乒乓球路徑顯示電路等模塊組成, 通過實驗箱模擬乒乓球 游戲機 。本次設計發(fā)揮了 FPGA 在智能化的應用,為FPGA 應用技術(shù)的研究和學習奠定了實踐基礎。通過本設計 實驗 ,對 EDA 技術(shù)有了更深入的認識與了解。 通過幾個月的努力,基本完成了畢業(yè)設計任務書所要求的內(nèi)容,而且在實驗箱上對大部分功能進行了仿真,取得了預期的結(jié)果,總之,通過自己的努力以及同學和老師的幫助,圓滿的完成了本次設計任務。 22 參考文獻 [1] 邊 計年 .用 VHDL 設計電子線路 [M].北京:清華出版社 , 2021: 2. [2] 黃任 .VHDL 入門?解惑?經(jīng)典實例?經(jīng)驗總結(jié) [M].北京:北京航天 大學出版社, 2021:35, 115. [3] 尹常永 .EDA 技術(shù) /電子設計實驗講義 [M].西安:西安電子科技大學出版社, 2021: 3. [4] 楊剛 .現(xiàn)代電子技術(shù) — VHDL 與數(shù)字系統(tǒng)設計 [M].北京:電子工業(yè)出版社, 2021: 6. [5] 甘歷 .VHDL 應用與開發(fā)實驗 [M].北京:科學出版社, 2021: 4. [6] 侯伯亨 .VHDL 硬件描述語言與數(shù)字邏輯電路設計 [M].西安:西安電子科技大學出版社, 1999: 27. [7] 潭會生,張昌凡 .EDA 技術(shù)及應用 [M].西安:西安電子科技大學出版社, 2021: 256. [8] 王振紅 .VHDL 數(shù)字電路設計與應用實踐教程 [M].北京:機械工業(yè)出版社, 2021: 35, 37. [9] 李宜達 .數(shù)字邏輯電路設計與實現(xiàn) [M].北京:科學出版社, 2021: 144. [10] 王振紅,張常年 .綜合電子設計與實 踐 [M].北京:清華大學出版社,2021: 122. [11] 杭州康芯電子有限公司 .EDA技術(shù)實用教程 [M].北京:科學出版社,2021: 17. [12] 朱正偉 .EDA 技術(shù)及應用 [M].北京:清華大學出版社, 2021: 2125. 23 致謝 本次 設計 是在 指導老師 吳強 的指導下完成的。在 設計 的過程中, 吳 老師給予了 我許多 指導, 是他帶我進入 VHDL 世界 ,僅僅幾次課讓我們認知了VHDL 的世界,這是我這次設計能成功的一些因素, 并提供了很多與該 設計 相關的重要信息,培養(yǎng)了我們對 該 設計的興趣,豐富了我們的知識 。這 都 將非常有利于我們今后的學習和工作。在此表示衷心的感謝! 另外,在設計過程中,我更深刻的了解到電子信息工程是一門很精深的課程,它 是一個硬件與軟件相通的課程,要想很好的學好它,還必須投入更多時間與熱情。也了解到很多內(nèi)容不是光看可不就能學到的,必須高強度的提高動手能力, 多去嘗試。這些都對我以后的學習有很大的幫助。還有,班上同學同樣給與我不少幫助,這里一并表示感謝。 24 附件 1:硬件實物圖 25 附件 2:源程序代碼 library ieee。 use 。 use 。 use 。 entity game is 實體部分 port(reset: in std_logic。 reset 是記分牌清零信號 clk: in std_logic。 start: in std_logic。 Start 控制游戲是否開始 serve: in std_logic_vector(0 to 1)。 發(fā)球信號 hit1,hit2: in std_logic。 擊球鍵 light: out std_logic_vector(0 to 6)。 發(fā)光二極管的輸出信號 tmp: buffer std_logic。 tmp,tmg為輸入輸出類型,作為分頻后的信號,供給數(shù)碼管掃描和發(fā)光二極管點亮使用 tmg: buffer std_logic。 score11,score12,score21,score22: out std_logic_vector(0 to 6))。 end game。 architecture one of game is 構(gòu)造體部分 type pingpong is (waitserve,light1on,ballmoveto2,allow2hit,light7on, ballmoveto1,allow1hit)。 狀態(tài)機的七個狀態(tài) signal state:pingpong。 signal i:integer range 0 to 7。 代表 8 個二極管的發(fā)光狀態(tài) signal count1,count2:std_logic_vector(0 to 3):=0000。 signal ht : std_logic。 signal dt : std_logic。 signal count:integer range 0 to 25000000。 signal couny:integer range 0 to 5000000。 ponent qdd is 調(diào)用按鍵去抖 port( clk1,set:in std_logic。 din: in std_logic。 dout : out std_logic)。 end ponent qdd。 ponent myd is 調(diào)用數(shù)碼管 顯示 port(bin: in std_logic_vector(0 to 3)。 out1: out std_logic_vector(0 to 6)。 out2: out std_logic_vector(0 to 6))。 end ponent myd。 begin 26 p1:process(count,clk) 50000000 分頻,發(fā)光二極管分頻 begin if clk39。event and clk=39。139。 then count=count+1。 if count=25000000 then tmp=39。139。 count=0。 else tmp=39。039。 end if。 end if。 end Process。 p2:process(couny) 數(shù)碼管分頻 begin if clk39。event and clk=39。139。 then couny=couny+1。 if couny=5000000 then tmg=39。139。 couny=0。 else tmg=39。039。 end if。 end if。 end Process。 p3:process(tmp) 狀態(tài)機部分 begin if reset=39。139。 then 按下復位鍵,比賽開始 i=0。count1=0000。count2=0000。 記分器清零 elsif tmp39。event and tmp=39。139。then 每到來一個時鐘上升沿 if count1=1011 or count2=1011then 如果 1 或 2 比分是 11, i變?yōu)?0 i=0。count1=0000。count2=0000。 elsif start=39。039。 then i=0。count1=0000。count2=0000。 else case state is when waitserve = 等待狀態(tài)下 進程處于等待發(fā)球狀態(tài) case serve is when 00 = i=0。 when 10 = i=1。state=light1on。 若有 1 發(fā)球,則狀態(tài)變?yōu)?“l(fā)ight1on”狀態(tài) ,二極管第一個燈點亮 when 01 = i=7。state=light7on。 若 2 發(fā)球,則狀態(tài)變?yōu)?“l(fā)ight7on”狀態(tài), 27 二極管第八個燈點亮 when 11 = i=0。 when others = i=0。 end case。 when light1on = i=2。 light1on 狀態(tài)下 進程處于第一盞燈亮狀態(tài) if hit2=39。139。 then i=0。 count1=count1+1。state=waitserve。 else state=ballmoveto2。 end if。 when light7on = i=6。 light7on 狀態(tài)下 進程處于第八盞燈亮狀態(tài) if hit1=39。139。 then i=0。 count2=count2+1。state=waitserve。 else state=ballmoveto1。 end if。 when ballmoveto1 = 進程處于球向 2 移動狀態(tài) if hit1=39。139。 then i=0。 count2=count2+1。state=waitserve。 elsif i=2 then i=1。 state=allow1hit。 else i=i1。 end if。 when ballmoveto2 = 進程處于球向 1 移動狀態(tài) if hit2=39。139。 then i=0。 count1=count1+1。state=waitserve。 elsif i=6 then i=7。 state=allow2hit。 else i=i+1。 end if。 when allow1hit = 進程處于允許 1 擊球狀態(tài) if hit1=39。139。 then i=2。state=ballmoveto2。 else count2=count2+1。i=0。 state=waitserve。 end if。 when allow2hit = 進程處于允許 2 擊球狀態(tài) if hit2=39。139。 then i=6。state=ballmoveto1。 else count1=count1+1。i=0。 state=waitserve。 28 end if。 end case。 end if。 end if。 end process。 light=1000000 when (i=1) else 將 i的值翻譯為二極管顯示情況 0100000 when (i=2) else 0010000 when (i=3) else 0001000 when (i=4) else 0000100 when (i=5) else 0000010 when (i=6) else 0000001