數(shù)字時(shí)鐘的VHDL設(shè)計(jì)_第1頁(yè)
數(shù)字時(shí)鐘的VHDL設(shè)計(jì)_第2頁(yè)
數(shù)字時(shí)鐘的VHDL設(shè)計(jì)_第3頁(yè)
數(shù)字時(shí)鐘的VHDL設(shè)計(jì)_第4頁(yè)
數(shù)字時(shí)鐘的VHDL設(shè)計(jì)_第5頁(yè)
已閱讀5頁(yè),還剩17頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

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

文檔簡(jiǎn)介

1、數(shù)字系統(tǒng)設(shè)計(jì)與硬件描述語(yǔ)言期末考試作業(yè)姓名:趙洋題目數(shù)字時(shí)鐘的VHDL設(shè)計(jì)學(xué)院:信息學(xué)院專業(yè):物聯(lián)網(wǎng)工程學(xué)號(hào):30112042862013-11-06選題設(shè)計(jì)描述1.功能介紹設(shè)計(jì)一臺(tái)能顯示時(shí)、分、秒的數(shù)字鐘。由時(shí)鐘信號(hào)經(jīng)分頻產(chǎn)生秒脈沖;計(jì)時(shí)計(jì)數(shù)器用24進(jìn)制計(jì)時(shí)電路;可手動(dòng)校時(shí),能分別進(jìn)行時(shí)、分的校正;具有整點(diǎn)報(bào)時(shí)功能。2.算法簡(jiǎn)介設(shè)計(jì)原理圖1數(shù)字鐘的系統(tǒng)框圖該系統(tǒng)由振蕩器、分頻器、“時(shí)、分、秒”計(jì)數(shù)器、譯碼器及顯示器、校時(shí)電路、 整點(diǎn)報(bào)時(shí)電路等組成。振蕩器和分頻器產(chǎn)生整個(gè)系統(tǒng)的時(shí)基信號(hào),它直接決定計(jì)時(shí)系統(tǒng) 的精度。“秒計(jì)數(shù)器”采用六十進(jìn)制計(jì)數(shù)器,每累計(jì) 60秒向“分計(jì)數(shù)器”進(jìn)位;“分計(jì)數(shù)器”采

2、用六十進(jìn)制計(jì)數(shù)器,每累計(jì) 60分向“時(shí)計(jì)數(shù)器”進(jìn)位;“時(shí)計(jì)數(shù)器”采用二十四進(jìn)制計(jì)數(shù)器,按照“ 24翻1 ”規(guī)律計(jì)數(shù)?!皶r(shí)、分、秒”計(jì)數(shù)器的輸出經(jīng)譯碼器送顯 示器顯示。校時(shí)電路用來(lái)當(dāng)計(jì)時(shí)出現(xiàn)誤差時(shí)對(duì)“時(shí)、分、秒”進(jìn)行校對(duì)調(diào)整。設(shè)計(jì)過(guò)程1.設(shè)計(jì)思路時(shí)鐘脈沖信號(hào)作為數(shù)字鐘的時(shí)間基準(zhǔn),再經(jīng)分頻器輸出標(biāo)準(zhǔn)秒脈沖。秒計(jì)數(shù)器計(jì)滿60后向分計(jì)數(shù)器進(jìn)位,分計(jì)數(shù)器計(jì)滿 60后向小時(shí)計(jì)數(shù)器進(jìn)位,小時(shí)計(jì)數(shù)器是計(jì)滿 24后,系統(tǒng)自動(dòng)復(fù)位重新開(kāi)始計(jì)數(shù)。計(jì)數(shù)器的輸出經(jīng)譯碼電路后送到顯示器顯示??梢杂?校時(shí)電路進(jìn)行校時(shí)。2.數(shù)字鐘的設(shè)計(jì)方案數(shù)字鐘的設(shè)計(jì)包括編碼模塊、分頻模塊、秒計(jì)時(shí)模塊、分計(jì)時(shí)模塊、小時(shí)計(jì)時(shí)模塊和報(bào)時(shí)模塊。該

3、數(shù)字鐘可以實(shí)現(xiàn) 3個(gè)功能:計(jì)時(shí)功能、報(bào)時(shí)功能和設(shè)置時(shí)間功能。2.1.編碼模塊編碼模塊主要是對(duì)時(shí)(sethour )、分(setmin )、秒(setsec)的設(shè)置輸入。22.分頻模塊在數(shù)字鐘的設(shè)計(jì)中,外部輸入時(shí)鐘信號(hào)clk1的頻率為8hz,其分頻后的頻率為elk,使其分頻結(jié)果為1hz,用來(lái)提供給秒計(jì)時(shí)模塊、分計(jì)時(shí)模塊、小時(shí)計(jì)時(shí)模塊。2.3.秒計(jì)時(shí)模塊將“秒計(jì)時(shí)脈沖” elk接信號(hào)源單元的1HZ脈沖信號(hào),此時(shí)秒顯示將從00計(jì)時(shí)到 59,然后回到00,重新計(jì)時(shí)。在秒位進(jìn)行計(jì)時(shí)的過(guò)程中。秒計(jì)時(shí)器是由一個(gè)60進(jìn)制的計(jì)數(shù)器構(gòu)成的,具有置數(shù)和計(jì)數(shù)功能。其中rst為置數(shù)信號(hào),當(dāng)rst為1時(shí),秒計(jì)時(shí)器置數(shù)。e

4、lk為驅(qū)動(dòng)秒計(jì)時(shí)器的時(shí)鐘,seci、sec0為秒 計(jì)時(shí)器的高位和低位輸出。2.4.分計(jì)時(shí)模塊分計(jì)時(shí)電路:將“分計(jì)時(shí)脈沖” elk接信號(hào)源單元的1HZ脈沖信號(hào),此時(shí)分顯示將從00計(jì)時(shí)到59,然后回到00,重新計(jì)時(shí)。在分位進(jìn)行計(jì)時(shí)的過(guò)程中。分計(jì)時(shí)器是由一個(gè)60進(jìn)制的計(jì)數(shù)器構(gòu)成的,具有置數(shù)和計(jì)數(shù)功能。其中rst為置數(shù)信號(hào),當(dāng)rst為1時(shí),分計(jì)時(shí)器置數(shù)。mini、min0為分計(jì)時(shí)器的高位和低位輸出。2.5.小時(shí)計(jì)時(shí)模塊將“小時(shí)計(jì)時(shí)脈沖” elk接信號(hào)源單元的1HZ脈沖信號(hào),此時(shí)小時(shí)顯示將從 00計(jì)時(shí)到24,然后回到00,重新計(jì)時(shí)。時(shí)計(jì)時(shí)器是由一個(gè)24進(jìn)制的計(jì)數(shù)器構(gòu)成的,具有置數(shù)和計(jì)數(shù)功能。其中的 rs

5、t為置數(shù)信號(hào),當(dāng)rst為1時(shí),時(shí)計(jì)時(shí)器置數(shù)。hri、hr0為時(shí)計(jì)時(shí)器的高位和低位輸出。3.2.6,報(bào)時(shí)模塊當(dāng)分位到59時(shí),秒位計(jì)到51秒、53秒、55秒、57秒、59秒時(shí)報(bào)時(shí)一次,而后 小時(shí)位加1。程序源代碼及說(shuō)明源程序數(shù)字鐘整體程序整個(gè)程序分為五個(gè)部分,分別為分頻部分、校時(shí)部分、秒部分、分部分、小時(shí)部分。VHDL程序如下:library IEEE;use lEEE.STD LOGIC 1164.ALL;use IEEE.STD LOGIC ARITH.ALL;use IEEE.STD_LOGIC_UNSIGNED.ALL;en tity clock_24 isPort (clk1:inSTD

6、_LOGIC;-時(shí)鐘rst : inSTD_LOGIC;-復(fù)位,高有效sethr:inSTD_LOGIC;-小時(shí)設(shè)置,增加1setmin :inSTD_LOGIC;-分鐘設(shè)置setsec:inSTD_LOGIC;-秒設(shè)置hrO:outSTD_LOGIC_VECTOR(3 dow nto 0);-小時(shí)個(gè)位hr1:outSTD_LOGIC_VECTOR(3 dow nto 0);-小時(shí)十位mi nO:outSTD_LOGIC_VECTOR(3 dow nto 0);-分鐘個(gè)位mi n1:outSTD_LOGIC_VECTOR(3 dow nto 0);-分鐘十位sec0:outSTD_LOGIC_

7、VECTOR(3 dow nto 0);-秒個(gè)位sec1:outSTD_LOGIC_VECTOR(3 dow nto 0);-秒十位sp eak:outSTD_LOGIC-報(bào)時(shí)輸出);end clock_24;architecture rtl of clock_24 is sig nal co_secO: STD_LOGIC;-秒個(gè)位計(jì)數(shù)溢出標(biāo)示signalco sec1: STD LOGIC;signalco_mi nO: STD_LOGIC;signalco_mi n1: STD_LOGIC;signalco_hr0: STD_LOGIC;sig nal cnt_sec0: STD_LOG

8、IC_VECTOR(3 dow nto 0);-秒個(gè)位計(jì)數(shù)器sig nal cnt_sec1: STD_LOGIC_VECTOR(3 dow nto 0);sig nal cnt_m in0: STD_LOGIC_VECTOR(3 dow nto 0);sig nal cnt_mi n1: STD_LOGIC_VECTOR(3 dow nto 0);sig nal cnt_hr0: STD_LOGIC_VECTOR(3 dow nto 0);sig nal cnt_hr1: STD_LOGIC_VECTOR(3 dow nto 0);sig nal state_hour:STD_LOGIC_V

9、ECTOR(1 dow nto0);-小時(shí)個(gè)位當(dāng)前狀態(tài),當(dāng)state_hour="00","01" 時(shí),cnt_hr0 計(jì)數(shù)從 0 到 9,當(dāng)state_hour="10"時(shí),cnt_hr0 計(jì)算從0到3.beg in coun ter_seco nd0:- 秒個(gè)位計(jì)數(shù)器p rocess(clk1,rst,setsec) beg inif(rst='1') the n-異步復(fù)位如果秒計(jì)數(shù)脈沖上升沿到來(lái)cn t_sec0<="0000"elsif(clk1'eve nt and clk1

10、-1')the n-if(setsec='1')the n-如果秒設(shè)置按下,則秒計(jì)數(shù)器增加1if(c nt_sec0>="1000") thencnt sec0<=cnt sec0-"1000"elsecnt sec0<=cnt sec0+"0010"end if;elseif(cnt_sec0="1001")then-如果 cnt_sec0 計(jì)數(shù)到 9,則將 cnt_sec0=0;cn t_sec0<="0000"else-否則將 cnt_sec

11、0 增加 1;cn t_sec0<=c nt_sec0+"0001"-否則計(jì)數(shù)器加 1end if;end if;if(cnt_sec0="1000") the n-產(chǎn)生進(jìn)位標(biāo)志co_secOv-1'elseco_sec0<='0'end if;end if;end p rocess coun ter_sec ondO;coun ter_sec on d1:- 秒十位計(jì)數(shù)器p rocess(clk1,rst) beg inif(rst='1') thencn t_sec1<="0000&

12、quot;elsif(clk1'eve nt and clk1-1')thenif(co_sec0-1')thenif(cnt_sec1="0101")then-如果溢出則置 0cn t_sec1<="0000"elsecnt sec1<=cnt sec1+"0001"-否則計(jì)數(shù)器加 1end if;end if;產(chǎn)生進(jìn)位標(biāo)志if(cnt_secO="1OOO" a nd cn t_sec仁"0101")the n-co_sec1v-1'elseco_

13、sec1<='0'end if;end if;end p rocess coun ter_sec ond1;coun ter_mi niute0:-分個(gè)位計(jì)數(shù)器p rocess(clk1,rst,setmi n) beg inif(rst='1') thencn t_mi n0 <="0000"elsif(clk1'eve nt and clk1='1')thenif(setmi n='1')the ncnt_mi n0v=cnt_mi n0+"0001"end if;c

14、n t_mi n0 <="0000"if (co_sec1-1')thenif(cnt_min0="1001")then-如果溢出則置 0elsecn t_mi n0 v=c nt_mi n13+"0001"-否則計(jì)數(shù)器加 1end if;end if;if(cnt_mi nO="1OO1" and cnt_secO="1OOO" a nd cn t_sec仁"0101")the n-生進(jìn)位標(biāo)志co_mi nO <='1'elseco_m

15、inOv='O'end if;end if;end p rocess coun ter_m ini uteO;coun ter_mi niute1:-分十位計(jì)數(shù)器p rocess(clk1,rst) beg inif(rst='1') thencn t_mi n1v="0000"elsif(clk1'eve nt and clk1-1')thencn t_mi n1v="0000"if(co_mi nO-1')thenif(c nt_mi n仁"O1O1")the n-如果溢出則

16、置0elsecn t_mi n1v=c nt_mi n1+"0001"-否則計(jì)數(shù)器加 1end if;end if;if(cnt_min仁"0101"and cnt_min0="1001"and cnt_sec0="1000" andcnt_sec1="0101")the n-產(chǎn)生進(jìn)位標(biāo)志co_mi n1v='1'elseco_m in 1<='0'end if;end if;end p rocess coun ter_m ini ute1;coun ter

17、_hourO:-小時(shí)個(gè)位計(jì)數(shù)器p rocess(clk1,rst,sethr) beg inif(rst='1') thencn t_hrOv="OOOO"state_hour<="00"elsif(clk1'eve nt and clk1='1')thenif(sethr='1')thencnt_hrO<=c nt_hrO+"OOO1"end if;case state hour iswhen "00"=>-如果當(dāng)前是00 , cnt_hr

18、0的計(jì)數(shù)范圍從09 if (co_mi n仁'1')thenif(cnt_hr0="1001")then- 如果溢出則置 0cn t_hr0v="0000"state_hourv="01"elsecnt hr0<=cnt hr0+"0001"-否則計(jì)數(shù)器加 1end if;end if;if(c nt_hr0="1001"and cn t_mi n仁"0101" a ndcn t_mi n0="1001"andcnt_sec0=&qu

19、ot;1000" and cnt_sec1="0101")thenco_hr0<='1'- 產(chǎn)生進(jìn)位標(biāo)志elseco_hr0<='0'end if;when "01"=>-如果當(dāng)前是01,cnt_hr0的計(jì)數(shù)范圍從09cn t_hr0<="0000"if (co_mi n仁'1')thenif(cnt_hr0="1001")then- 如果溢出則置 0state_hourv="10"elsecnt hr0<=

20、cnt hr0+"0001"-否則計(jì)數(shù)器加 1end if;end if;if(cn t_hr0="1001"and cn t_mi n仁"0101" a ndcn t_mi n0="1001" and cnt_sec0="1000" and cnt_sec1="0101")thenco_hr0<='1'elseco_hr0<='0'end if;when "10"=>-如果當(dāng)前是10 , cnt_hr0的

21、計(jì)數(shù)范圍從03 if (co_mi n仁'1')thenif(cnt_hr0="0011")then- 如果溢出則置 0cn t_hr0<="0000"state_hour<="00"elsecnt hr0<=cnt hr0+"0001"-否則計(jì)數(shù)器加 1end if;end if;cn t_mi n0="1001"andif(cn t_hrO="OO11"and cn t_mi n仁"0101" a ndcnt_secO

22、="1OOO" and cnt_sec仁"0101")thenco_hrOv='1'- 產(chǎn)生進(jìn)位標(biāo)志elseco_hrO<='O'end if;whe n others=>state_hour<="OO"end case;end if;end p rocess coun ter_hourO;cou nter_hour1:-小時(shí)十位計(jì)數(shù)器p rocess(clk1,rst) beg inif(rst='1') thencn t_hr1<="OOOO&quo

23、t;elsif(clk1'eve nt and clk1='1')thencn t_hr1<="OOOO"if(co_hrO='1')thenif(c nt_hr仁"OO1O")the n-如果溢出則置0elseent hr1<=cnt hr1+"0001"end if;end if;end if;end p roeess coun ter_hour1;-在*-59-5*的時(shí)候speak=1,否則等于0with(cnt_mi n仁"0101" and ent_mi n0="1001" and cn t_sec仁"0101") select sp eak<='1' whe n TRUE,'0' whe n others;-將計(jì)數(shù)器的值賦給相應(yīng)的輸出引腳 hr0<=c nt_hr0;hr1<=c nt_hr1;min0 v=c nt_min0;min 1<=c nt_mi n1;sec0<=c nt_sec0;sec1<=c nt_sec1;end rtl;仿真結(jié)果及分析整體仿真結(jié)果如下El 3? reIllijiw Q;3C-13-J3I庶卩He

溫馨提示

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

評(píng)論

0/150

提交評(píng)論