數(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è),還剩9頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

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

文檔簡(jiǎn)介

1、-作者xxxx-日期xxxx數(shù)字時(shí)鐘的VHDL設(shè)計(jì)【精品文檔】數(shù)字系統(tǒng)設(shè)計(jì)與硬件描述語(yǔ)言期末考試作業(yè) 題目: 數(shù)字時(shí)鐘的VHDL設(shè)計(jì) 學(xué)院: 信息學(xué)院 專業(yè): 物聯(lián)網(wǎng)工程 學(xué)號(hào): 3011204286 姓名: 趙洋 2013-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ì)原理時(shí)顯示器秒顯示器分顯示器時(shí)譯碼器秒譯碼器分譯碼器報(bào)時(shí)時(shí)計(jì)數(shù)器分計(jì)數(shù)器秒計(jì)數(shù)器校時(shí)電路 1HZ分頻器振蕩器圖1 數(shù)字鐘的系統(tǒng)框圖該系統(tǒng)由振蕩器、分頻器、“時(shí)、分、秒

2、”計(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ù)器”采用六十進(jìn)制計(jì)數(shù)器,每累計(jì)60分向“時(shí)計(jì)數(shù)器”進(jìn)位;“時(shí)計(jì)數(shù)器”采用二十四進(jìn)制計(jì)數(shù)器,按照“24翻1”規(guī)律計(jì)數(shù)。“時(shí)、分、秒”計(jì)數(shù)器的輸出經(jīng)譯碼器送顯示器顯示。校時(shí)電路用來當(dāng)計(jì)時(shí)出現(xiàn)誤差時(shí)對(duì)“時(shí)、分、秒”進(jìn)行校對(duì)調(diào)整。 設(shè)計(jì)過程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)

3、復(fù)位重新開始計(jì)數(shù)。計(jì)數(shù)器的輸出經(jīng)譯碼電路后送到顯示器顯示??梢杂眯r(shí)電路進(jìn)行校時(shí)。2. 數(shù)字鐘的設(shè)計(jì)方案 數(shù)字鐘的設(shè)計(jì)包括編碼模塊、分頻模塊、秒計(jì)時(shí)模塊、分計(jì)時(shí)模塊、小時(shí)計(jì)時(shí)模塊和報(bào)時(shí)模塊。該數(shù)字鐘可以實(shí)現(xiàn)3個(gè)功能:計(jì)時(shí)功能、報(bào)時(shí)功能和設(shè)置時(shí)間功能。2.1. 編碼模塊編碼模塊主要是對(duì)時(shí)(sethour)、分(setmin)、秒(setsec)的設(shè)置輸入。2.2. 分頻模塊在數(shù)字鐘的設(shè)計(jì)中,外部輸入時(shí)鐘信號(hào)clk1的頻率為8hz,其分頻后的頻率為clk,使其分頻結(jié)果為1hz,用來提供給秒計(jì)時(shí)模塊、分計(jì)時(shí)模塊、小時(shí)計(jì)時(shí)模塊。2.3. 秒計(jì)時(shí)模塊將“秒計(jì)時(shí)脈沖”clk接信號(hào)源單元的1HZ脈沖信號(hào),此

4、時(shí)秒顯示將從00計(jì)時(shí)到59,然后回到00,重新計(jì)時(shí)。在秒位進(jìn)行計(jì)時(shí)的過程中。秒計(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ù)。clk為驅(qū)動(dòng)秒計(jì)時(shí)器的時(shí)鐘,sec1、sec0為秒計(jì)時(shí)器的高位和低位輸出。2.4. 分計(jì)時(shí)模塊分計(jì)時(shí)電路:將“分計(jì)時(shí)脈沖”clk接信號(hào)源單元的1HZ脈沖信號(hào),此時(shí)分顯示將從00計(jì)時(shí)到59,然后回到00,重新計(jì)時(shí)。在分位進(jìn)行計(jì)時(shí)的過程中。分計(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ù)。min1、min0為分計(jì)時(shí)器的高位和低位輸出。2.5. 小時(shí)計(jì)時(shí)

5、模塊將“小時(shí)計(jì)時(shí)脈沖”clk接信號(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ù)功能。其中的rst為置數(shù)信號(hào),當(dāng)rst為1時(shí),時(shí)計(jì)時(shí)器置數(shù)。hr1、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。二、 程序源代碼及說明源程序數(shù)字鐘整體程序整個(gè)程序分為五個(gè)部分,分別為分頻部分、校時(shí)部分、秒部分、分部分、小時(shí)部分。VHDL程序如下:library IEEE;use IEEE.STD_LOGIC_1164.ALL;u

6、se IEEE.STD_LOGIC_ARITH.ALL;use IEEE.STD_LOGIC_UNSIGNED.ALL;entity clock_24 isPort ( clk1: in STD_LOGIC;-時(shí)鐘rst: in STD_LOGIC;-復(fù)位,高有效sethr: in STD_LOGIC;-小時(shí)設(shè)置,增加1setmin: in STD_LOGIC;-分鐘設(shè)置setsec: in STD_LOGIC;-秒設(shè)置hr0 : out STD_LOGIC_VECTOR(3 downto 0);-小時(shí)個(gè)位hr1 : out STD_LOGIC_VECTOR(3 downto 0);-小時(shí)十位

7、min0 : out STD_LOGIC_VECTOR(3 downto 0);-分鐘個(gè)位min1 : out STD_LOGIC_VECTOR(3 downto 0);-分鐘十位sec0 : out STD_LOGIC_VECTOR(3 downto 0);-秒個(gè)位 sec1 : out STD_LOGIC_VECTOR(3 downto 0);-秒十位speak: out STD_LOGIC-報(bào)時(shí)輸出 );end clock_24;architecture rtl of clock_24 issignal co_sec0: STD_LOGIC;-秒個(gè)位計(jì)數(shù)溢出標(biāo)示signal co_sec

8、1: STD_LOGIC;signal co_min0: STD_LOGIC;signal co_min1: STD_LOGIC;signal co_hr0: STD_LOGIC;signal cnt_sec0: STD_LOGIC_VECTOR(3 downto 0);-秒個(gè)位計(jì)數(shù)器signal cnt_sec1: STD_LOGIC_VECTOR(3 downto 0);signal cnt_min0: STD_LOGIC_VECTOR(3 downto 0);signal cnt_min1: STD_LOGIC_VECTOR(3 downto 0);signal cnt_hr0: STD

9、_LOGIC_VECTOR(3 downto 0);signal cnt_hr1: STD_LOGIC_VECTOR(3 downto 0);signal state_hour:STD_LOGIC_VECTOR(1 downto 0);-小時(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.begincounter_second0:-秒個(gè)位計(jì)數(shù)器process(clk1,rst,setsec)beginif(rst=1) then-異步復(fù)位cnt_sec0=1000) thencnt_sec0=cnt_s

10、ec0-1000;elsecnt_sec0=cnt_sec0+0010;end if;elseif(cnt_sec0=1001)then-如果cnt_sec0計(jì)數(shù)到9,則將cnt_sec0=0;cnt_sec0=0000;else-否則將cnt_sec0增加1;cnt_sec0=cnt_sec0+0001;-否則計(jì)數(shù)器加1end if;end if;if(cnt_sec0=1000) then-產(chǎn)生進(jìn)位標(biāo)志co_sec0=1;elseco_sec0=0;end if;end if;end process counter_second0;counter_second1:-秒十位計(jì)數(shù)器proces

11、s(clk1,rst)beginif(rst=1) thencnt_sec1=0000;elsif(clk1event and clk1=1)thenif(co_sec0=1)thenif(cnt_sec1=0101)then-如果溢出則置0cnt_sec1=0000;elsecnt_sec1=cnt_sec1+0001;-否則計(jì)數(shù)器加1end if;end if;if(cnt_sec0=1000 and cnt_sec1=0101)then-產(chǎn)生進(jìn)位標(biāo)志co_sec1=1;elseco_sec1=0;end if;end if;end process counter_second1;coun

12、ter_miniute0:-分個(gè)位計(jì)數(shù)器process(clk1,rst,setmin)beginif(rst=1) thencnt_min0=0000;elsif(clk1event and clk1=1)thenif(setmin=1)thencnt_min0=cnt_min0+0001;end if;if (co_sec1=1)thenif(cnt_min0=1001)then-如果溢出則置0cnt_min0=0000;elsecnt_min0=cnt_min0+0001;-否則計(jì)數(shù)器加1end if;end if;if(cnt_min0=1001 and cnt_sec0=1000 a

13、nd cnt_sec1=0101)then-產(chǎn)生進(jìn)位標(biāo)志co_min0=1;elseco_min0=0;end if;end if;end process counter_miniute0;counter_miniute1:-分十位計(jì)數(shù)器process(clk1,rst)beginif(rst=1) thencnt_min1=0000;elsif(clk1event and clk1=1)thenif(co_min0=1)thenif(cnt_min1=0101)then-如果溢出則置0cnt_min1=0000;elsecnt_min1=cnt_min1+0001;-否則計(jì)數(shù)器加1end i

14、f;end if;if(cnt_min1=0101 and cnt_min0=1001 and cnt_sec0=1000 and cnt_sec1=0101)then-產(chǎn)生進(jìn)位標(biāo)志co_min1=1;elseco_min1=0;end if;end if;end process counter_miniute1;counter_hour0:-小時(shí)個(gè)位計(jì)數(shù)器process(clk1,rst,sethr)beginif(rst=1) thencnt_hr0=0000;state_hour=00;elsif(clk1event and clk1=1)thenif(sethr=1)thencnt_h

15、r0-如果當(dāng)前是00,cnt_hr0的計(jì)數(shù)范圍從09if (co_min1=1)thenif(cnt_hr0=1001)then-如果溢出則置0cnt_hr0=0000;state_hour=01;elsecnt_hr0=cnt_hr0+0001;-否則計(jì)數(shù)器加1end if;end if;if(cnt_hr0=1001 and cnt_min1=0101 and cnt_min0=1001 and cnt_sec0=1000 and cnt_sec1=0101)thenco_hr0=1;-產(chǎn)生進(jìn)位標(biāo)志elseco_hr0-如果當(dāng)前是01,cnt_hr0的計(jì)數(shù)范圍從09if (co_min1=

16、1)thenif(cnt_hr0=1001)then-如果溢出則置0cnt_hr0=0000;state_hour=10;elsecnt_hr0=cnt_hr0+0001;-否則計(jì)數(shù)器加1end if;end if;if(cnt_hr0=1001 and cnt_min1=0101 and cnt_min0=1001 and cnt_sec0=1000 and cnt_sec1=0101)thenco_hr0=1;elseco_hr0-如果當(dāng)前是10,cnt_hr0的計(jì)數(shù)范圍從03if (co_min1=1)thenif(cnt_hr0=0011)then-如果溢出則置0cnt_hr0=000

17、0;state_hour=00;elsecnt_hr0=cnt_hr0+0001;-否則計(jì)數(shù)器加1end if;end if;if(cnt_hr0=0011 and cnt_min1=0101 and cnt_min0=1001 and cnt_sec0=1000 and cnt_sec1=0101)thenco_hr0=1;-產(chǎn)生進(jìn)位標(biāo)志elseco_hr0state_hour=00;end case;end if;end process counter_hour0;counter_hour1:-小時(shí)十位計(jì)數(shù)器process(clk1,rst)beginif(rst=1) thencnt_h

18、r1=0000;elsif(clk1event and clk1=1)thenif(co_hr0=1)thenif(cnt_hr1=0010)then-如果溢出則置0cnt_hr1=0000;elsecnt_hr1=cnt_hr1+0001;end if;end if;end if;end process counter_hour1;-在*-59-5*的時(shí)候speak=1,否則等于0with (cnt_min1=0101 and cnt_min0=1001 and cnt_sec1=0101) selectspeak=1 when TRUE,0 when others;-將計(jì)數(shù)器的值賦給相應(yīng)的輸出引腳hr0=cnt_hr0;hr1=cnt_hr1;min0=cnt_min0;min1=cnt_min1;sec0=cnt_sec0;sec1=cnt_sec1;end rtl;三、 仿真結(jié)果及分析整體仿真結(jié)果如下因整體不清晰,做了局部仿真截圖如下由上調(diào)試過程可知,該數(shù)字鐘實(shí)現(xiàn)了計(jì)時(shí)、重置時(shí)間和整點(diǎn)報(bào)時(shí)的功能。在給數(shù)字鐘重置時(shí)間后,數(shù)字鐘便開始從所置的時(shí)間計(jì)時(shí),到達(dá)59秒時(shí),秒計(jì)時(shí)器回到0秒,并且給分鐘加1;當(dāng)?shù)?/p>

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝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ù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 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)論