VHDL數(shù)字時鐘實驗報告1_第1頁
VHDL數(shù)字時鐘實驗報告1_第2頁
VHDL數(shù)字時鐘實驗報告1_第3頁
VHDL數(shù)字時鐘實驗報告1_第4頁
已閱讀5頁,還剩8頁未讀 繼續(xù)免費閱讀

下載本文檔

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

文檔簡介

1、vhdl數(shù)字時鐘實驗報告vhdl數(shù)字時鐘設(shè)計一、實驗?zāi)康模哼M一步練習(xí)vhdl語言設(shè)計工程的建立與仿真的步驟和方法、熟悉vhdl語言基本設(shè)計實體的編寫方法。同時,在已有知識的基礎(chǔ)上,簡單綜合編寫程序,仿制簡單器械。二、實驗環(huán)境:pc個人計算機、windows xp操作系統(tǒng)、quartus ii集成開發(fā)環(huán)境軟件。三、設(shè)計要求:運用vhdl語言編寫一個數(shù)字鐘,具體要求:1. 具有時、分、秒計數(shù)的十進制數(shù)字顯示功能,以24小時循環(huán)計時。2. 具有手動調(diào)節(jié)小時,分鐘的功能。3. 具有鬧鐘的功能,能夠在設(shè)定的鬧鐘時間發(fā)出鬧鈴聲。四、實驗步驟:1. 定義輸入輸出信號量port(clk:in std_logi

2、c; -時鐘speak:out std_logic; -鈴dout:out std_logic_vector(7 downto 0); -晶體管顯示setclk:in std_logic_vector(2 downto 0); -操作按鈕d1,d2,d3,d4,d5,d6: out std_logic); -六個晶體管2. 定義結(jié)構(gòu)體中的信號量signal sel:std_logic_vector(2 downto 0);signal hou1:std_logic_vector(3 downto 0); -時分秒的個位和十位signal hou2:std_logic_vector(3 down

3、to 0);signal min1:std_logic_vector(3 downto 0);signal min2:std_logic_vector(3 downto 0);signal seth1:std_logic_vector(3 downto 0);signal seth2:std_logic_vector(3 downto 0);signal setm1:std_logic_vector(3 downto 0);signal setm2:std_logic_vector(3 downto 0);signal sec1:std_logic_vector(3 downto 0);sig

4、nal sec2:std_logic_vector(3 downto 0);signal h1:std_logic_vector(3 downto 0);signal h2:std_logic_vector(3 downto 0);signal m1:std_logic_vector(3 downto 0); signal m2:std_logic_vector(3 downto 0); signal s1:std_logic_vector(3 downto 0);signal s2:std_logic_vector(3 downto 0);signal sph1,sph2,spm1,spm2

5、,sps1,sps2:std_logic_vector(3 downto 0);signal count_sec:std_logic_vector(9 downto 0);signal sec_co :std_logic;signal co1,co2,co3,co4:std_logic; -進位signal switch :std_logic_vector(1 downto 0); -表示狀態(tài)3. 分頻模塊用來定義秒count_sec用來計時鐘個數(shù),當count_sec=11時,及得到1hz信號。代碼如下: process (clk) is -define a secondbeginif(cl

6、kevent and clk=1)thenif(count_sec=11)thencount_secsec_coelsecount_secsec_coend if;end if;end process;4時鐘正常走時模塊該模塊使用6個進程實現(xiàn),分別為秒個位計時、秒十位計時、分個位計時、分十位計時、時個位計時、時十位計時。process(sec_co) is -秒個位beginif switch=00 then -正常狀態(tài)if sec_co=1 thenif sec2=1001 thensec2co1elsesec2co1end if;end if;elsif switch=01 then -調(diào)

7、時狀態(tài)sec2end if;end process;-process (co1) is -秒十位beginif switch=00 then if co1event and co1=1 then if (sec1=0101)thensec1co2elsesec1co2end if;end if;elsif switch=01 thensec1end if;end process;-process (co1,co2) is -分鐘個位beginif switch=00 thenif co2event and co2=1 thenif min2=1001 thenmin2co3elsemin2co

8、3end if;end if;elsif switch=01 thenmin2end if;end process;- process (co3) is -分鐘十位beginif switch=00 thenif co3=1 thenif min1=0101 thenmin1co4elsemin1co4end if;end if;elsif switch=01 thenmin1end if; end process; -process(co4) -小時beginif switch=00 thenif co4=1 thenif (hou1=0010) then -小時十位為2時,個位滿3進一if

9、(hou2=0011)thenhou2hou1elsehou2end if;else -小時十位為0或1,個位滿9進一if(hou2=1001)thenhou2hou1elsehou2end if;end if;end if;elsif switch=01 thenhou1hou2end if;end process;5調(diào)時模塊該進程用來控制時鐘狀態(tài),switch為“00”時正常顯示時間,為“01”時是進行調(diào)時,為“10”時是設(shè)置鬧鐘時間。代碼如下:process (setclk(0) isbeginif(setclk(0)event and setclk(0)=1)thenif(switch

10、=10)thenswitchelseswitchend if;end if;end process;process (setclk(2),switch,setclk(1) isbegin -setclk(1)為1調(diào)分if(switch=01 and setclk(1)=1)thenif(setclk(2)event and setclk(2)=1)then if(setm2=1001)then setm2if(setm1=0101)thensetm1elsesetm1end if;elsesetm2end if;end if;end if;end process;process (setclk

11、(2),switch,setclk(1) isbegin -setclk(1)為0調(diào)時if(switch=01 and setclk(1)=0)thenif(setclk(2)event and setclk(2)=1)thenif(seth1=0010)thenif(seth2=0011)thenseth1seth2elseseth2end if;elseif(seth2=1001)thenseth1seth2elseseth2end if;end if;end if;end if;end process;6鬧鐘模塊該模塊由3個小模塊組成,分別為設(shè)置鬧鐘時間、判斷鬧鐘時間是否到達以及鬧鈴聲音

12、模塊。(1)設(shè)置鬧鐘時間模塊該進程用于設(shè)置鬧鐘時間。信號量switch為10時,表示設(shè)置鬧鐘時間;if(switch=10)then -調(diào)鬧鐘時,顯示鬧鐘設(shè)置時間if sel=000 thend1case sph1 is when 0000=doutwhen 0001=doutwhen 0010=doutwhen others=doutend case; elsif sel=001 thend2case sph2 iswhen 0000=doutwhen 0001=doutwhen 0010=doutwhen 0011=doutwhen 0100=doutwhen 0101=doutwhen

13、0110=doutwhen 0111=doutwhen 1000=doutwhen 1001=doutwhen others=doutend case;elsif sel=010 thend3case spm1 iswhen 0000=doutwhen 0001=doutwhen 0010=doutwhen 0011=doutwhen 0100=doutwhen 0101=doutwhen others=doutend case;elsif sel=011 thend4case spm2 iswhen 0000=doutwhen 0001=doutwhen 0010=doutwhen 0011

14、=doutwhen 0100=doutwhen 0101=doutwhen 0110=doutwhen 0111=doutwhen 1000=doutwhen 1001=doutwhen others=doutend case; elsif sel=100 then d5case sps1 iswhen 0000=doutwhen 0001=doutwhen 0010=doutwhen 0011=doutwhen 0100=doutwhen 0101=doutwhen others=doutend case;elsif sel=101 thend6case sps2 iswhen 0000=d

15、outwhen 0001=doutwhen 0010=doutwhen 0011=doutwhen 0100=doutwhen 0101=doutwhen 0110=doutwhen 0111=doutwhen 1000=doutwhen 1001=doutwhen others=doutend case;end if;(2)鬧鈴聲音模塊通過分頻產(chǎn)生蜂鳴,即發(fā)出鬧鈴聲音。process (switch) is -鬧鈴begin -設(shè)置鬧鈴時秒歸零if switch=10 thensps1sps2end if;end process;process (switch,setclk(2),setcl

16、k(1) isbeginif(switch=10 and setclk(1)=1)thenif(setclk(2)event and setclk(2)=1)then if(spm2=1001)thenspm2if(spm1=0101)thenspm1 else spm1end if;elsespm2end if;end if;end if;end process;process (switch,setclk(2),setclk(1) isbeginif(switch=10 and setclk(1)=0)thenif(setclk(2)event and setclk(2)=1)thenif

17、(sph1=0010)thenif(sph2=0011)thensph1sph2elsesph2end if;elseif(sph2=1001)thensph2sph1elsesph2end if;end if;end if;end if;end process;process (clk,sph1,sph2,spm1,spm2,hou1,hou2,min1,min2) is beginif(sph1=hou1 and sph2=hou2 and spm1=min1 and spm2=min2)thenspeakelsespeakend if;end process;7數(shù)碼管顯示模塊(1)選擇時

18、間顯示process(key1,key2,change)beginif(key1=0)and(key2=0)then sec_0sec_1min_0min_1hour_1hour_0elsif(key1=1)and(key2=0)then sec_0sec_1min_0min_1hour_0hour_1elsif(key1=0)and(key2=1)then sec_0sec_1min_0min_1hour_0hour_1end if; end process;(2)數(shù)碼管時間顯示if sel=000 thend1case h1 iswhen 0000=doutwhen 0001=doutwh

19、en 0010=doutwhen others=doutend case;elsif sel=001 thend2case h2 iswhen 0000=doutwhen 0001=doutwhen 0010=doutwhen 0011=doutwhen 0100=doutwhen 0101=doutwhen 0110=doutwhen 0111=doutwhen 1000=doutwhen 1001=doutwhen others=doutend case; elsif sel=010 then d3case m1 iswhen 0000=doutwhen 0001=doutwhen 001

20、0=doutwhen 0011=doutwhen 0100=doutwhen 0101=doutwhen others=doutend case;elsif sel=011 thend4case m2 iswhen 0000=doutwhen 0001=doutwhen 0010=doutwhen 0011=doutwhen 0100=doutwhen 0101=doutwhen 0110=doutwhen 0111=doutwhen 1000=doutwhen 1001=doutwhen others=doutend case;elsif sel=100 thend5case s1 iswh

21、en 0000=doutwhen 0001=doutwhen 0010=doutwhen 0011=doutwhen 0100=doutwhen 0101=doutwhen others=doutend case;elsif sel=101 thend6case s2 iswhen 0000=doutwhen 0001=doutwhen 0010=doutwhen 0011=doutwhen 0100=doutwhen 0101=dout when 0110=doutwhen 0111=doutwhen 1000=doutwhen 1001=doutwhen others=doutend case; end if;五、實驗結(jié)果分析總結(jié):該程序基本實現(xiàn)了數(shù)字時鐘的基本功能,能夠正常走時,并且可以校正時間,還可以進行鬧鐘設(shè)置。通過這次vhdl課程設(shè)計,我學(xué)到了很多,對于原本掌握的不好的數(shù)字邏輯相關(guān)知識,在課程設(shè)計具體實踐中有了很深刻的認識,在對于quartus ii的操作上也有很大的提高,增加了操作的熟練程度,現(xiàn)在我已經(jīng)有

溫馨提示

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

最新文檔

評論

0/150

提交評論