




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)
文檔簡介
1、精選文檔基于VHDL的多功能數(shù)字鐘設(shè)計報告021215班衛(wèi)時章02121451一、設(shè)計要求1、具有以二十四小時制計時、顯示、整點報時、時間設(shè)置和鬧鐘的功能。2、設(shè)計精度要求為1秒。二、設(shè)計環(huán)境:Quartus II 三、系統(tǒng)功能描述1、系統(tǒng)輸入:時鐘信號clk接受50MHz;系統(tǒng)狀態(tài)及較時、定時轉(zhuǎn)換的把握信號為k、set,校時復(fù)位信號為reset,均由按鍵信號產(chǎn)生。2、系統(tǒng)輸出:LED顯示輸出;蜂鳴器聲音信號輸出。3、多功能數(shù)字電子鐘系統(tǒng)功能的具體描述如下:(一)計時:正常工作狀態(tài)下,每日按24h計時制計時并顯示,蜂鳴器無聲,逢整點報時。(二)校時:在計時顯示狀態(tài)下,按下“k”鍵,進入“小時”
2、待校準狀態(tài),若此時按下“set”鍵,小時開頭校準;之后按下“k”鍵則進入“分”待校準狀態(tài);連續(xù)按下“k”鍵則進入“秒”待復(fù)零狀態(tài);再次按下“k”鍵數(shù)碼管顯示鬧鐘時間,并進入鬧鐘“小時”待校準狀態(tài);再次按下“k”鍵則進入鬧鐘“分”待校準狀態(tài);若再按下“k”鍵恢復(fù)到正常計時顯示狀態(tài)。若校時過程中按下“reset”鍵,則系統(tǒng)恢復(fù)到正常計數(shù)狀態(tài)。(1)“小時”校準狀態(tài):在“小時”校準狀態(tài)下,顯示“小時”的數(shù)碼管以2Hz閃爍,并按下“set”鍵時以2Hz的頻率遞增計數(shù)。(2)“分”校準狀態(tài):在“分”校準狀態(tài)下,顯示“分”的數(shù)碼管以2Hz閃爍,并按下“set”鍵時以2Hz的頻率遞增計數(shù)。(3)“秒”校準狀
3、態(tài):在“秒復(fù)零”狀態(tài)下,顯示“秒”的數(shù)碼管以2Hz閃爍,并以1Hz的頻率遞增計數(shù)。(4)鬧鐘“小時”校準狀態(tài):在鬧鐘“小時”校準狀態(tài)下,顯示“小時”的數(shù)碼管以2Hz閃爍,并按下“set”鍵時以2Hz的頻率遞增計數(shù)。(5)鬧鐘“分”校準狀態(tài):在鬧鐘“分”校準狀態(tài)下,顯示“分”的數(shù)碼管以2Hz閃爍,并按下“set”鍵時以2Hz的頻率遞增計數(shù)。(三)整點報時:蜂鳴器在“59”分鐘的第“51”、“53”、“55”、“57”秒發(fā)頻率為500Hz的低音,在“59”分鐘的第“59”秒發(fā)頻率為1000Hz的高音,結(jié)束時為整點。(四)顯示:接受掃描顯示方式驅(qū)動4個LED數(shù)碼管顯示小時、分,秒由兩組led燈以4位
4、BCD 碼顯示。(五)鬧鐘:鬧鐘定時時間到,蜂鳴器發(fā)出頻率為1000Hz的高音,持續(xù)時間為60秒。四、各個模塊分析說明1、分頻器模塊(freq.vhd)(1)模塊說明:輸入一個頻率為50MHz的CLK,利用計數(shù)器分出1KHz的q1KHz,500Hz的q500Hz,2Hz的q2Hz和1Hz的q1Hz。(2) 源程序:library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all;entity freq is port (CLK: in std_logic ; -輸入時鐘信號 q1KHz: buffer std_
5、logic; q500Hz: buffer std_logic; q2Hz: buffer std_logic; q1Hz: out std_logic);end freq; architecture bhv of freq is beginP1KHZ:process(CLK)variable cout:integer:=0;begin if CLK'event and CLK='1' then cout:=cout+1; -每來個時鐘上升沿時cout開頭計數(shù)if cout<=25000 then q1KHz<='0' -當cout<=
6、25000時,q1KHz輸出“0” elsif cout<50000 then q1KHz<='1' -當25000<cout<=50000時,q1KHz else cout:=0; -輸出“1”,完成1KHz頻率輸出end if; end if; end process;P500HZ:process(q1KHz) -q1KHz作為輸入信號,分出q500Hzvariable cout:integer:=0;beginif q1KHz'event and q1KHz='1' thencout:=cout+1;if cout=1 th
7、en q500Hz<='0' -二分頻 elsif cout=2 then cout:=0;q500Hz<='1'end if; end if; end process;P2HZ:process(q500Hz)variable cout:integer:=0;beginif q500Hz'event and q500Hz='1' thencout:=cout+1;if cout<=125 then q2Hz<='0' elsif cout<250 then q2Hz<='1
8、9; else cout:=0;end if; end if; end process;P1HZ:process(q2Hz)variable cout:integer:=0;beginif q2Hz'event and q2Hz='1' thencout:=cout+1;if cout=1 then q1Hz<='0' elsif cout=2 then cout:=0;q1Hz<='1'end if; end if; end process;end bhv;(3)模塊圖:2、把握器模塊(contral.vhd)(1)模塊說明
9、:輸入端口k,set鍵來把握6個狀態(tài),這六個狀態(tài)分別是:顯示計時時間狀態(tài),調(diào)計時的時、分、秒的3個狀態(tài),調(diào)鬧鈴的時、分的3個狀態(tài),reset鍵是復(fù)位鍵,用來回到顯示計時時間的狀態(tài)。(2) 波形仿真圖:(3) 模塊圖:3、 二選一模塊(mux21a.vhd)(1)源程序:library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all;entity mux21a isport(a,b,s:in bit; y:out bit);end entity mux21a;architecture one of mux21a
10、 isbegin process(a,b,s)beginif s='0' then y<=a; -若s=0,y輸出a,反之輸出b。else y<=b;end if;end process;end architecture one;(2)仿真波形圖:(3) 模塊圖:4、 計時模塊a. 秒計時(second.vhd)(1)仿真波形圖:(2)模塊圖:b.分計時(minute.vhd)(1)仿真波形圖:(2)模塊圖:c.小時計時(hour.vhd)(1)仿真波形圖:(2)模塊圖:d.鬧鐘分計時(cntm60b.vhd)(1)仿真波形圖:(2)模塊圖:e.鬧鐘小時計時(cnt
11、h24b.vhd)(1)仿真波形圖:(2)模塊圖:5、鬧鐘比較模塊(compare.vhd)(1)模塊說明:比較正常計數(shù)時間與鬧鐘定時時間是否相等,若相等,compout輸出“1”,反之輸出“0”。(2)仿真波形圖:(3)模塊圖:6、報時模塊(bell.vhd)(1)模塊說明:該模塊既實現(xiàn)了整點報時的功能,又實現(xiàn)了鬧鈴的功能,蜂鳴器通過所選頻率的不同,而發(fā)出不同的聲音。(2)仿真波形圖:(3)模塊圖:7、把握顯示模塊(show_con.vhd)(1)模塊說明:該模塊實現(xiàn)了數(shù)碼管既可以顯示正常時間,又可以顯示鬧鐘時間的功能;調(diào)時過程的定時閃爍功能也在此模塊中真正實現(xiàn)。(2)源程序:library
12、 ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity show_con is port(th1,tm1,ts1:in std_logic_vector(7 downto 4); th0,tm0,ts0:in std_logic_vector(3 downto 0); bh1,bm1:in std_logic_vector(7 downto 4); bh0,bm0:in std_logic_vector(3 downto 0); sec1,min1,h1: out std_logic_vector(7 d
13、ownto 4); sec0,min0,h0: out std_logic_vector(3 downto 0); q2Hz,flashs,flashh,flashm,sel_show:in std_logic);end show_con;architecture rtl of show_con isbeginprocess(th1,tm1,ts1,th0,tm0,ts0,bh1,bm1,bh0,bm0,q2Hz,flashs,flashh,flashm,sel_show) begin if sel_show='0'then if ( flashh='1'and
14、 q2Hz='1')then h1<="1111"h0<="1111" -顯示小時數(shù)碼管以2Hz閃爍 min1<=tm1;min0<=tm0; sec1<=ts1;sec0<=ts0; elsif (flashm='1'and q2Hz='1')then h1<=th1;h0<=th0; min1<="1111"min0<="1111" sec1<=ts1;sec0<=ts0; elsif (fl
15、ashs='1'and q2Hz='1')then h1<=th1;h0<=th0; min1<=tm1;min0<=tm0; sec1<="1111"sec0<="1111" else h1<=th1;h0<=th0; min1<=tm1;min0<=tm0; sec1<=ts1;sec0<=ts0; end if; elsif sel_show='1'then-若sel_show為“1”,數(shù)碼管顯示鬧鐘時間 if(flashh=
16、39;1' and q2Hz='1')then h1<="1111"h0<="1111" min1<=bm1;min0<=bm0; sec1<="0000"sec0<="0000" elsif ( flashm='1' and q2Hz='1')then h1<=bh1;h0<=bh0; min1<="1111"min0<="1111" sec1<=&qu
17、ot;0000"sec0<="0000" else h1<=bh1;h0<=bh0; min1<=bm1;min0<=bm0; sec1<="0000"sec0<="0000" end if ; end if; end process;end rtl;(3)模塊圖:8、動態(tài)掃描顯示模塊(scan_led.vhd)(1)模塊說明:由4組輸入信號和輸出信號進而實現(xiàn)了時鐘時、分的動態(tài)顯示。(2)源程序:library ieee;use ieee.std_logic_1164.all;use
18、 ieee.std_logic_unsigned.all;entity scan_led isport(clk1:in std_logic; h0:in std_logic_vector(3 downto 0); h1:in std_logic_vector(7 downto 4); min0:in std_logic_vector(3 downto 0); min1:in std_logic_vector(7 downto 4); ML:out std_logic_vector(7 downto 0); MH:out std_logic_vector(7 downto 0); HL:out
19、std_logic_vector(7 downto 0); HH:out std_logic_vector(7 downto 0) );end scan_led;architecture one of scan_led issignal cnt4:std_logic_vector(1 downto 0);signal a: std_logic_vector(3 downto 0) ;beginp1:process(clk1)begin if clk1'event and clk1 ='1' then cnt4<=cnt4+1; if cnt4=3 then cnt
20、4<="00" end if; end if;end process p1;p2:process(cnt4,h1,h0,min1,min0)begincase cnt4 is -把握數(shù)碼管位選when "00"=>case min0 is when "0000"=>ML<="11000000" when "0001"=>ML<="11111001" when "0010"=>ML<="1010010
21、0" when "0011"=>ML<="10110000" when "0100"=>ML<="10011001" when "0101"=>ML<="10010010" when "0110"=>ML<="10000010" when "0111"=>ML<="11111000" when "1000"=
22、>ML<="10000000" when "1001"=>ML<="10010000" when others=>NULL; end case;when "01"=>case min1 is when "0000"=>MH<="11000000" when "0001"=>MH<="11111001" when "0010"=>MH<="
23、;10100100" when "0011"=>MH<="10110000" when "0100"=>MH<="10011001" when "0101"=>MH<="10010010" when "0110"=>MH<="10000010" when "0111"=>MH<="11111000" when "100
24、0"=>MH<="10000000" when "1001"=>MH<="10010000" when others=>NULL; end case;when "10"=>case h0 is when "0000"=>HL<="11000000" when "0001"=>HL<="11111001" when "0010"=>HL<
25、="10100100" when "0011"=>HL<="10110000" when "0100"=>HL<="10011001" when "0101"=>HL<="10010010" when "0110"=>HL<="10000010" when "0111"=>HL<="11111000" when &qu
26、ot;1000"=>HL<="10000000" when "1001"=>HL<="10010000" when others=>NULL; end case;when "11"=>case h1 is when "0000"=>HH<="11000000" when "0001"=>HH<="11111001" when "0010"=>HH<="10100100" when "0011"=>HH<="10110000" when "0100"=>HH<="10011001"
溫馨提示
- 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)容負責。
- 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 合同之冷凍食品購銷合同
- 創(chuàng)新思維訓(xùn)練在小學(xué)數(shù)學(xué)思維提升教案
- 建筑勞務(wù)鋼筋工分包合同
- 2025年陽江貨運資格證模擬考試題庫
- 抽真空合同范文6篇
- 客服回訪合同模板7篇
- 2025年高中化學(xué)新教材同步 必修第一冊 第2章 第3節(jié) 第1課時 物質(zhì)的量 摩爾質(zhì)量
- 認識三角形(2)教學(xué)設(shè)計-2024-2025學(xué)年北師大版(2024)七年級數(shù)學(xué)下冊
- 中學(xué)生拒絕校園霸凌 從我做起班會教案
- 土地糾紛調(diào)解合同范本
- 《醫(yī)學(xué)心理學(xué)》教案
- 海綿城市建設(shè)技術(shù)標準 DG-TJ08-2298-2019
- 2024年2天津理工大學(xué)馬克思主義基本原理概論(期末考試題+答案)
- 跟著名著《小王子》學(xué)高考英語讀后續(xù)寫絕佳的續(xù)寫清單-高中英語作文復(fù)習專項
- 產(chǎn)教融合大學(xué)科技園建設(shè)項目實施方案
- 交通法律與交通事故處理培訓(xùn)課程與法律解析
- 廣西版四年級下冊美術(shù)教案
- 《換熱器及換熱原理》課件
- 兒童權(quán)利公約演示文稿課件
- UPVC排水管技術(shù)標準
- MSA-測量系統(tǒng)分析模板
評論
0/150
提交評論