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

下載本文檔

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

文檔簡介

大連理工大學本科實驗報告題目:數(shù)字鐘的VHDL設(shè)計課程名稱: 數(shù)字電路課程設(shè)計 學院(系): 電子信息與電氣工程學部 專 業(yè): 電子信息工程 班 級: 學生姓名: 學 號: 完成日期: 成 績: 2013 年 12 月 15 日數(shù)字鐘的VHDL設(shè)計1. 設(shè)計任務(wù)及要求:設(shè)計任務(wù):設(shè)計一臺能顯示時、分、秒的數(shù)字鐘。具體要求如下:(1)設(shè)計一個數(shù)字鐘,能夠顯示當前時間,分別用6個數(shù)碼管顯示小時、分鐘、秒鐘的時間,秒針的計數(shù)頻率為1Hz,可由系統(tǒng)脈沖分頻得到。(2)在整點進行提示,可通過LED閃爍實現(xiàn),閃爍頻率及花型可自己設(shè)計。(3)能夠調(diào)整小時和分鐘的時間,調(diào)整的形式為通過按鍵進行累加。(4)具有鬧鐘功能,鬧鐘時間可以任意設(shè)定(設(shè)定的形式同樣為通過按鍵累加),并且在設(shè)定的時間能夠進行提示,提示同樣可以由LED閃爍實現(xiàn)設(shè)計要求:(1) 編寫設(shè)計報告,要求包括方案選擇、程序代碼清單、調(diào)試過程、測試結(jié)果及心得體會。2. 設(shè)計原理時顯示器秒顯示器分顯示器時譯碼器秒譯碼器分譯碼器報時時計數(shù)器分計數(shù)器秒計數(shù)器校時電路 1HZ分頻器振蕩器圖1 數(shù)字鐘的系統(tǒng)框圖該系統(tǒng)由振蕩器、分頻器、“時、分、秒”計數(shù)器、譯碼器及顯示器、校時電路、整點報時電路等組成。石英晶體振蕩器和分頻器產(chǎn)生整個系統(tǒng)的時基信號,它直接決定計時系統(tǒng)的精度。“秒計數(shù)器”采用六十進制計數(shù)器,每累計60秒向“分計數(shù)器”進位;“分計數(shù)器”采用六十進制計數(shù)器,每累計60分向“時計數(shù)器”進位;“時計數(shù)器”采用二十四進制計數(shù)器,按照“24翻1”規(guī)律計數(shù)。“時、分、秒”計數(shù)器的輸出經(jīng)譯碼器送顯示器顯示。校時電路用來當計時出現(xiàn)誤差時對“時、分、秒”進行校對調(diào)整。整點報時電路是根據(jù)計時系統(tǒng)的輸出狀態(tài)產(chǎn)生一脈沖信號,然后去觸發(fā)音頻發(fā)生器實現(xiàn)報時。 3. 設(shè)計過程3.1. 設(shè)計思路時鐘脈沖信號作為數(shù)字鐘的時間基準,再經(jīng)分頻器輸出標準秒脈沖。秒計數(shù)器計滿60后向分計數(shù)器進位,分計數(shù)器計滿60后向小時計數(shù)器進位,小時計數(shù)器是計滿24后,系統(tǒng)自動復位重新開始計數(shù)。計數(shù)器的輸出經(jīng)譯碼電路后送到顯示器顯示。可以用校時電路進行校時。整點報時電路在每小時的最后50秒開始報時間隔一秒報一次時直至下一小時開始。3.2. 數(shù)字鐘的設(shè)計方案數(shù)字鐘的設(shè)計包括編碼模塊、分頻模塊、秒計時模塊、分計時模塊、小時計時模塊、鬧鐘模塊和報時模塊。該數(shù)字鐘可以實現(xiàn)3個功能:計時功能、報時功能、鬧鈴和設(shè)置時間功能。3.2.1. 編碼模塊編碼模塊主要是對時、分、秒的設(shè)置輸入。3.2.2. 分頻模塊在數(shù)字鐘的設(shè)計中,外部輸入時鐘信號clk1的頻率為50Mhz,其分頻后的頻率為clk,使其分頻結(jié)果為1hz,用來提供給秒計時模塊、分計時模塊、小時計時模塊。3.2.3. 秒計時模塊將“秒計時脈沖”clk接信號源單元的1HZ脈沖信號,此時秒顯示將從00計時到59,然后回到00,重新計時。在秒位進行計時的過程中。秒計時器是由一個60進制的計數(shù)器構(gòu)成的,具有置數(shù)和計數(shù)功能。其中reset為置數(shù)信號,當reset為1時,秒計時器置數(shù)。clk為驅(qū)動秒計時器的時鐘,sec2、sec1為秒計時器的高位和低位輸出。3.2.4. 分計時模塊分計時電路:將“分計時脈沖”clk接信號源單元的c1脈沖信號,此時分顯示將從00計時到59,然后回到00,重新計時。在分位進行計時的過程中。分計時器是由一個60進制的計數(shù)器構(gòu)成的,具有置數(shù)和計數(shù)功能。其中rese為置數(shù)信號,當reset為1時,分計時器置數(shù)。fen4、fen3為分計時器的高位和低位輸出。3.2.5. 小時計時模塊將“小時計時脈沖”clk接信號源單元的c2脈沖信號,此時小時顯示將從00計時到23,然后回到00,重新計時。時計時器是由一個24進制的計數(shù)器構(gòu)成的,具有置數(shù)和計數(shù)功能。其中的reset為置數(shù)信號,當reset為1時,時計時器置數(shù)。shi6、shi5為時計時器的高位和低位輸出。3.2.6. 報時模塊當分位到59時,秒位計到51秒、53秒、55秒、57秒、59秒時報時一次,而后小時位加1。3.2.7.VHDL 引腳分配圖4. 源程序4.1. 數(shù)字鐘整體程序整個程序分為六個部分,分別為分頻部分、校時部分、秒部分、分部分、小時部分和報時部分。4.2. VHDL程序及波形分析4.2.1. VHDL程序library ieee;-count60use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity count60 isport(clk:in std_logic; reset:in std_logic; set:in std_logic; inc:in std_logic; out1:out std_logic_vector(3 downto 0); out2:out std_logic_vector(3 downto 0); c:out std_logic; alight:out std_logic); end;architecture run2 of count60 issignal ts1,ts2,as1,as2:std_logic_vector( 3 downto 0):=0000;signal tclk,aclk: std_logic;beginprocess(inc,clk,set)-根據(jù)設(shè)置模式,處理inc上的脈沖信號beginif set=0 then -時間調(diào)整模式aclk=0;if clk=1 and inc=1 then -clk=1則tclk=0,通過挖洞方式添加一個脈沖tclk=0;elsif clk=0 and inc=1 then -clk=0,則tclk=1,產(chǎn)生一個高電平,添加一脈沖tclk=1;elsetclk=clk;end if;elsif set=1 then -鬧鈴調(diào)整模式tclk=clk;aclk=inc; -inc上的脈沖直接修改鬧鈴定時值end if;end process;process(tclk,reset) beginif(reset=0)then ts1=0000;ts2=0000; elsif(tclkevent and tclk=1)then if ts1=1001 then ts1=0000; if ts2=0101 then ts2=0000; else ts2=ts2+1; end if; else ts1=ts1+1;-計數(shù)過程 end if;end if;end process;-結(jié)束進程process(aclk,reset) beginif(reset=0)then as1=0000;as2=0000; elsif(aclkevent and aclk=1)then if as1=1001 then as1=0000; if as2=0101 then as2=0000; else as2=as2+1; end if; else as1=as1+1;-計數(shù)過程 end if;end if;end process;-結(jié)束進程process(ts1,ts2,as1,as2)- 顯示時間或鬧鈴定時值begin if set=0 then - 顯示時間out1=ts1;out2=ts2;else - 顯示定時值out1=as1;out2=as2;end if;end process;process(ts1,ts2,as1,as2) -判斷定時值與時間值相等,輸出鬧鈴觸發(fā)信號begin if (ts1=1001 and ts2=0101) then c=1; else c=0; end if;if ts1=as1 and ts2=as2 thenalight=1;elsealight=0;end if;end process;end run2;library ieee;-count24use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity count24 isport(clk:in std_logic; reset:in std_logic; set:in std_logic; inc:in std_logic; out1:out std_logic_vector(3 downto 0); out2:out std_logic_vector(3 downto 0); c:out std_logic;alight:out std_logic); end; architecture run1 of count24 issignal ts1,ts2,as1,as2:std_logic_vector( 3 downto 0):=0000;signal tclk,aclk: std_logic;beginprocess(inc,clk,set)-根據(jù)設(shè)置模式,處理inc上的脈沖信號beginif set=0 then -時間調(diào)整模式aclk=0;if clk=1 and inc=1 then -clk=1則tclk=0,通過挖洞方式添加一個脈沖tclk=0;elsif clk=0 and inc=1 then -clk=0,則tclk=1,產(chǎn)生一個高電平,添加一脈沖tclk=1;elsetclk=clk;end if;elsif set=1 then -鬧鈴調(diào)整模式tclk=clk;aclk=inc; -inc上的脈沖直接修改鬧鈴定時值end if;end process;process(tclk,reset) beginif(reset=0)then ts1=0000;ts2=0000; elsif(tclkevent and tclk=1)then if ts20010 then if(ts1=1001) then ts1=0000;ts2=ts2+1; else ts1=ts1+1; end if; elsif(ts2=0010) then if(ts1=0011) then ts1=0000;ts2=0000; -計數(shù)過程 else ts1=ts1+1; end if; end if;end if;end process;-結(jié)束進程process(aclk,reset) beginif(reset=0)then as1=0000;as2=0000; elsif(aclkevent and aclk=1)then if as20010 then if(as1=1001) then as1=0000;as2=as2+1; else as1=as1+1; end if; elsif(as2=0010) then if(as1=0011) then as1=0000;as2=0000; -計數(shù)過程 else as1=as1+1; end if; end if;end if;end process;-結(jié)束進程process(ts1,ts2,as1,as2)- 顯示時間或鬧鈴定時值begin if set=0 then - 顯示時間out1=ts1;out2=ts2;else - 顯示定時值out1=as1;out2=as2;end if;end process;process(ts1,ts2,as1,as2) -判斷定時值與時間值相等,輸出鬧鈴觸發(fā)信號begin if ts1=0010 and ts2=0011 then c=1; else c=0; end if;if ts1=as1 and ts2=as2 thenalight=1;elsealightqqqqqqqqqqqqqqqqqqqq=0010000;end case;end process;end;library ieee;-shizhonguse ieee.std_logic_1164.all;useieee.std_logic_unsigned.all;entity shizhong isport (clk:in std_logic;-PIN_N2 reset:in std_logic;-PIN_N25 set:in std_logic;-PIN_N26 inc1,inc2,inc3:in std_logic;-PIN_G26,PIN_N23,PIN_P23 shi6,shi5,fen4,fen3,miao2,miao1:out std_logic_vector(6 downto 0); alight,light1,light2:out std_logic);-鬧鈴end;architecture run of shizhong issignal sshi6,sshi5,sfen4,sfen3,smiao2,smiao1: std_logic_vector(3 downto 0);signal c1,c2,c3,clk1s,clk2ms,clk1ms:std_logic;signal alight1,alight2,alight3:std_logic;component count60port(clk:in std_logic; reset:in std_logic; set:in std_logic; inc:in std_logic; out1:out std_logic_vector(3 downto 0); out2:out std_logic_vector(3 downto 0); c:out std_logic; alight:out std_logic);end component;component count24port(clk:in std_logic; reset:in std_logic; set:in std_logic; inc:in std_logic; out1:out std_logic_vector(3 downto 0); out2:out std_logic_vector(3 downto 0); c:out std_logic;alight:out std_logic);end component;component xianshi port(clk:in std_logic_vector(3 downto 0); qq:out std_logic_vector(6 downto 0);end component;beginprocess(clk)variable count1:integer range 0 to 49999999;begin if(clkevent and clk=1)then count1:=count1+1;-在clk 的上升沿計數(shù) if count1=24999999 then clk1s=0; elsif count1=49999999 then clk1s=1; else count1:=0; end if; end if; end process;-產(chǎn)生周期為1s的時鐘信號process(clk)variable count2:integer range 0 to 99999;begin if(clkevent and clk=1)then count2:=count2+1;-在clk 的上升沿計數(shù) if count2=49999 then clk2ms=0; elsif count2=99999 then clk2ms=1; else count2:=0; end if;end if;end process; -產(chǎn)生周期為2ms的時鐘信號 500Hzprocess(clk)variable count3:integer range 0 to 49999;begin if(clkevent and clk=1)then count3:=count3+1;-在clk 的上升沿計數(shù) if count3=24999 then clk1ms=0; elsif count3=49999 then clk1ms=1; else count3:=0; end if;end if;end process;-產(chǎn)生周期為1ms的時鐘信號1000Hzprocess(alight1,alight2,alight3)beginif alight1=1 and alight2=1 and alight3=1then alight=1; else alight=0;end if;end process;process(sfen4,sfen3,smiao2,smiao1)beginif sfen4=0101 and sfen3=1001 thenif smiao2=0101 thenif smiao1=0001 thenlight1=clk2ms;elsif smiao1=0011 thenlight1=clk2ms;elsif smiao1=0101 thenlight1=clk2ms;elsif smiao1=0111

溫馨提示

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

評論

0/150

提交評論