數(shù)字鐘VHDL程序_第1頁
數(shù)字鐘VHDL程序_第2頁
數(shù)字鐘VHDL程序_第3頁
數(shù)字鐘VHDL程序_第4頁
數(shù)字鐘VHDL程序_第5頁
已閱讀5頁,還剩7頁未讀, 繼續(xù)免費閱讀

下載本文檔

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

文檔簡介

1、相品用.3大連理工大學(xué)本科實驗報告題目:數(shù)字鐘的VHDL計課程名稱:數(shù)字電路課程設(shè)計學(xué)院系:電子信息與電氣工程學(xué)部專業(yè):電子信息工程班級:學(xué)生姓名:學(xué)號:完成日期:成績:2021年12月15日數(shù)字鐘的VHDL設(shè)計1 .設(shè)計任務(wù)及要求:設(shè)計任務(wù):設(shè)計一臺能顯示時、分、秒的數(shù)字鐘.具體要求如下:(1)設(shè)計一個數(shù)字鐘,能夠顯示當(dāng)前時間,分別用6個數(shù)碼管顯示小時、分鐘、秒鐘的時間,秒針的計數(shù)頻率為1Hz,可由系統(tǒng)脈沖分頻得到.(2)在整點進行提示,可通過LED閃爍實現(xiàn),閃爍頻率及花型可自己設(shè)計.(3)能夠調(diào)整小時和分鐘的時間,調(diào)整的形式為通過按鍵進行累加.(4)具有鬧鐘功能,鬧鐘時間可以任意設(shè)定(設(shè)定

2、的形式同樣為通過按鍵累加),并且在設(shè)定的時間能夠進行提示,提示同樣可以由LED閃爍實現(xiàn)設(shè)計要求:(1)編寫設(shè)計報告,要求包括方案選擇、程序代碼清單、調(diào)試過程、測試結(jié)果及心得體會.2 .設(shè)計原理圖1數(shù)字鐘的系統(tǒng)框圖該系統(tǒng)由振蕩器、分頻器、“時、分、秒計數(shù)器、譯碼器及顯示器、校時電路、整點報時電路等組成.石英晶體振蕩器和分頻器產(chǎn)生整個系統(tǒng)的時基信號,它直接決定計時系統(tǒng)的精度.“秒計數(shù)器采用六十進制計數(shù)器,每累計60秒向“分計數(shù)器進位;“分計數(shù)器采用六十進制計數(shù)器,每累計60分向“時計數(shù)器進位;“時計數(shù)器采用二十四進制計數(shù)器,根據(jù)“24翻1規(guī)律計數(shù).時、分、秒計數(shù)器的輸出經(jīng)譯碼器送顯示器顯示.校時電

3、路用來當(dāng)計時出現(xiàn)誤差時對“時、分、秒進行校對調(diào)整.整點報時電路是根據(jù)計時系統(tǒng)的輸出狀態(tài)產(chǎn)生一脈沖信號,然后去觸發(fā)音頻發(fā)生器實現(xiàn)報時.3 .設(shè)計過程3.1. 設(shè)計思路時鐘脈沖信號作為數(shù)字鐘的時間基準(zhǔn),再經(jīng)分頻器輸出標(biāo)準(zhǔn)秒脈沖.秒計數(shù)器計滿60后向分計數(shù)器進位,分計數(shù)器計滿60后向小時計數(shù)器進位,小時計數(shù)器是計滿24后,系統(tǒng)自動復(fù)位重新開始計數(shù).計數(shù)器的輸出經(jīng)譯碼電路后送到顯示器顯示.可以用校時電路進行校時.整點報時電路在每小時的最后50秒開始報時間隔一秒報一次時直至下一小時開始.3.2. 數(shù)字鐘的設(shè)計方案數(shù)字鐘的設(shè)計包括編碼模塊、分頻模塊、秒計時模塊、分計時模塊、小時計時模塊、鬧鐘模塊和報時模塊

4、.該數(shù)字鐘可以實現(xiàn)3個功能:計時功能、報時功能、鬧鈴和設(shè)置時間功能.3.2.1. 編碼模塊編碼模塊主要是對時、分、秒的設(shè)置輸入.3.2.2. 分頻模塊在數(shù)字鐘的設(shè)計中,外部輸入時鐘信號clkl的頻率為50Mhz,其分頻后的頻率為clk,使其分頻結(jié)果為1hz,用來提供應(yīng)秒計時模塊、分計時模塊、小時計時模塊.3.2.3. 秒計時模塊將“秒計時脈沖clk接信號源單元的1HZ脈沖信號,此時秒顯示將從00計時到59,然后回到00,重新計時.在秒位進行計時的過程中.秒計時器是由一個60進制的計數(shù)器構(gòu)成的,具有置數(shù)和計數(shù)功能.其中reset為置數(shù)信號,當(dāng)reset為1時,秒計時器置數(shù).clk為驅(qū)動秒計時器的

5、時鐘,sec2、sec1為秒計時器的高位和低位輸出.3.2.4. 分計時模塊分計時電路:將“分計時脈沖clk接信號源單元的c1脈沖信號,此時分顯示將從00計時到59,然后回到00,重新計時.在分位進行計時的過程中.分計時器是由一個60進制的計數(shù)器構(gòu)成的,具有置數(shù)和計數(shù)功能.其中rese為置數(shù)信號,當(dāng)reset為1時,分計時器置數(shù).fen4、fen3為分計時器的高位和低位輸出.3.2.5. 小時計時模塊將“小時計日脈沖clk接信號源單元的c2脈沖信號,此時小時顯示將從00計時到23,然后回到00,重新計時.時計時器是由一個24進制的計數(shù)器構(gòu)成的,具有置數(shù)和計數(shù)功能.其中的reset為置數(shù)信號,當(dāng)

6、reset為1時,時計時器置數(shù).shi6、shi5為時計時器的高位和低位輸出.3.2.6. 報時模塊當(dāng)分位到59時,秒位計到51秒、53秒、55秒、57秒、59秒時報時一次,而后小時位:!?cb:5m-,一加日1,54;ns皿露*1DMd曰MF2jJ國*一也w*b*浜也一4大duk1MfcjajiL-arLEjK*Wr7-一RftHjnn*ip*waMlJJtrsy-iVPUJtLrriikJi1.rrLCfrfwiyUXILir?Q7-*Etl.5網(wǎng)tLl巾、1堂F.ihiraLuxltWJKlE44Tu&fJ1ibL-,;pnjnLTLi;AJh.*TQ咽*rFilJuw0P7UTLiat

7、fUhJ-j.iMliJjJUELn期W0E*JutafP0IJU-LITLIMult廿4*El.FMTUwlt03Tbk-LEjfyiKiii用-號k4 .源程序4.1. 數(shù)字鐘整體程序整個程序分為六個局部,分別為分頻局部、校時局部、秒局部、分局部、小時局部和報時局部.4.2. VHDL程序及波形分析4.2.1. VHDL程序libraryieee;-count60useieee.std_logic_1164.all;useieee.std_logic_unsigned.all;entitycount60isport(clk:instd_logic;reset:instd_logic;set

8、:instd_logic;inc:instd_logic;out1:outstd_logic_vector(3downto0);out2:outstd_logic_vector(3downto0);c:outstd_logic;alight:outstd_logic);end;architecturerun2ofcount60issignalts1,ts2,as1,as2:std_logic_vector(3downto0):=0000;signaltclk,aclk:std_logic;beginprocess(inc,clk,set)-根據(jù)設(shè)置模式,處理inc上的脈沖信號beginifse

9、t=0then-時間調(diào)整模式aclk=0;ifclk=1andinc=1then-clk=1那么tclk=0,通過挖洞方式添加一個脈沖tclk=0;elsifclk=0andinc=1then-clk=0,那么tclk=1,產(chǎn)生一個高電平,添力口一脈沖tclk=1;elsetclk=clk;endif;elsifset=1then-鬧鈴調(diào)整模式tclk=clk;aclk=inc;-inc上的脈沖直接修改鬧鈴定時值endif;endprocess;process(tclk,reset)beginif(reset=0)thents1=0000;ts2=0000;elsif(tclkeventand

10、tclk=1)thenifts1=1001thents1=0000;ifts2=0101thents2=0000;elsets2=ts2+1;endif;elsets1=ts1+1;-計數(shù)過程endif;endif;endprocess;-結(jié)束進程process(aclk,reset)beginif(reset=0)thenas1=0000;as2=0000;elsif(aclkeventandaclk=1)thenifas1=1001thenas1=0000;ifas2=0101thenas2=0000;elseas2=as2+1;endif;elseas1=as1+1;-計數(shù)過程endif

11、;endif;endprocess;-結(jié)束進程process(ts1,ts2,as1,as2)-顯示時間或鬧鈴定時值beginifset=0then-顯示時間out1=ts1;out2=ts2;else-顯示定時值out1=as1;out2=as2;endif;endprocess;process(ts1,ts2,as1,as2)-判斷定時值與時間值相等,輸出鬧鈴觸發(fā)信號beginif(ts1=1001andts2=0101)thenc=1;elsec=0;endif;ifts1=as1andts2=as2thenalight=1;elsealight=0;endif;endprocess;e

12、ndrun2;libraryieee;-count24useieee.std_logic_1164.all;useieee.std_logic_unsigned.all;entitycount24isport(clk:instd_logic;reset:instd_logic;set:instd_logic;inc:instd_logic;out1:outstd_logic_vector(3downto0);out2:outstd_logic_vector(3downto0);c:outstd_logic;alight:outstd_logic);end;architecturerunlofc

13、ount24issignalts1,ts2,as1,as2:std_logic_vector(3downto0):=0000;signaltclk,aclk:std_logic;beginprocess(inc,clk,set)-根據(jù)設(shè)置模式,處理inc上的脈沖信號beginifset=0then-時間調(diào)整模式aclk=0;ifclk=1andinc=1then-clk=1那么tclk=0,通過挖洞方式添加一個脈沖tclk=0;elsifclk=0andinc=1then-clk=0,那么tclk=1,產(chǎn)生一個高電平,添力口一脈沖tclk=1;elsetclk=clk;endif;elsifs

14、et=1then-鬧鈴調(diào)整模式tclk=clk;aclk=inc;-inc上的脈沖直接修改鬧鈴定時值endif;endprocess;process(tclk,reset)beginif(reset=0)thents1=0000;ts2=0000;elsif(tclkeventandtclk=1)thenifts20010thenif(ts1=1001)thents1=0000;ts2=ts2+1;elsets1=ts1+1;endif;elsif(ts2=0010)thenif(ts1=0011)thents1=0000;ts2=0000;-計數(shù)過程elsets1=ts1+1;endif;e

15、ndif;endif;endprocess;-結(jié)束進程process(aclk,reset)beginif(reset=0)thenas1=0000;as2=0000;elsif(aclkeventandaclk=1)thenifas20010thenif(as1=1001)thenas1=0000;as2=as2+1;elseas1=as1+1;endif;elsif(as2=0010)thenif(as1=0011)thenas1=0000;as2=0000;-計數(shù)過程elseas1=as1+1;endif;endif;endif;endprocess;-結(jié)束進程process(ts1,t

16、s2,as1,as2)-顯示時間或鬧鈴定時值beginifset=0then-顯示時間out1=ts1;out2=ts2;else-顯示定時值out1=as1;out2=as2;endif;endprocess;process(ts1,ts2,as1,as2)-判斷定時值與時間值相等,輸出鬧鈴觸發(fā)信號beginifts1=0010andts2=0011thenc=1;elsec=0;endif;ifts1=as1andts2=as2thenalight=1;elsealightqqqqqqqqqqqqqqqqqqqq=0010000;endcase;endprocess;end;library

17、ieee;-shizhonguseieee.std_logic_1164.all;useieee.std_logic_unsigned.all;entityshizhongisport(clk:instd_logic;-PIN_N2reset:instd_logic;-PIN_N25set:instd_logic;-PIN_N26inc1,inc2,inc3:instd_logic;-PIN_G26,PIN_N23,PIN_P23shi6,shi5,fen4,fen3,miao2,miao1:outstd_logic_vector(6downto0);alight,light1,light2:

18、outstd_logic);-鬧鈴end;architecturerunofshizhongissignalsshi6,sshi5,sfen4,sfen3,smiao2,smiao1:std_logic_vector(3downto0);signalc1,c2,c3,clk1s,clk2ms,clk1ms:std_logic;signalalight1,alight2,alight3:std_logic;componentcount60port(clk:instd_logic;reset:instd_logic;set:instd_logic;inc:instd_logic;out1:outs

19、td_logic_vector(3downto0);out2:outstd_logic_vector(3downto0);c:outstd_logic;alight:outstd_logic);endcomponent;componentcount24port(clk:instd_logic;reset:instd_logic;set:instd_logic;inc:instd_logic;out1:outstd_logic_vector(3downto0);out2:outstd_logic_vector(3downto0);c:outstd_logic;alight:outstd_logi

20、c);endcomponent;componentxianshiport(clk:instd_logic_vector(3downto0);qq:outstd_logic_vector(6downto0);endcomponent;beginprocess(clk)variablecount1:integerrange0to49999999;beginif(clkeventandclk=1)thencount1:=count1+1;-在clk的上升沿計數(shù)ifcount1=24999999thenclk1s=0;elsifcount1=49999999thenclk1s=1;elsecount1

21、:=0;endif;endif;endprocess;-產(chǎn)生周期為1s的時鐘信號process(clk)variablecount2:integerrange0to99999;beginif(clkeventandclk=1)thencount2:=count2+1;-在clk的上升沿計數(shù)ifcount2=49999thenclk2ms=0;elsifcount2=99999thenclk2ms=1;elsecount2:=0;endif;endif;endprocess;-產(chǎn)生周期為2ms的時鐘信號500Hzprocess(clk)variablecount3:integerrange0to49999;beginif(clkeventandclk=1)thencount3:=count3+1;-在clk的上升沿計數(shù)ifcount3=24999thenclk1ms=0;elsifcount3=49999thenclk1ms=1;elsecount3:=0;endif;endif;endprocess;-產(chǎn)生周期為1ms的時鐘信號1000Hzprocess(alight1,alight2,alight3)beginifalight1=1andalight2=1andalight3=1thenalig

溫馨提示

  • 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)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

最新文檔

評論

0/150

提交評論