




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)
文檔簡介
1、EDA電子鐘設計一、設計目的1.掌握VHDL語言的基本運用。2.掌握復雜系統(tǒng)的EDA設計方法。3.學習多層次、多模塊系統(tǒng)設計。4.了解數(shù)字鐘的工作原理,利用VHDL語言實現(xiàn)數(shù)字鐘。5.掌握Quartus的簡單操作并會使用EDA實驗箱。6.掌握各芯片的邏輯功能及使用方法。二、系統(tǒng)總體設計我們設計的是多功能數(shù)字鐘,共有5個系統(tǒng)模塊組成,分別是:液晶顯示屏、調(diào)時控制開關(guān)(用的是撥碼開關(guān))、LED顯示狀態(tài)燈及蜂鳴器報時系統(tǒng)和時鐘頻率系統(tǒng)。我們設計的是以24小時制顯示,數(shù)碼管掃描顯示時、分、秒;能夠正常計時和調(diào)時、調(diào)分等校時功能;經(jīng)過我們設計的數(shù)字鐘具有蜂鳴器整點報時的功能,還具備設置鬧鐘功能。EP1C
2、12Q240C8按鍵開關(guān)時鐘信號LED顯示圖2.1 多功能數(shù)字鐘模擬系統(tǒng)基本組成框圖三、詳細設計3.1數(shù)字鐘的基本工作原理3.1.1時基T 產(chǎn)生電路數(shù)字鐘以其顯示時間的直觀性、走時準確性作為一種計時工具,數(shù)字鐘的基本組成部分離不開計數(shù)器,在控制邏輯電路的控制下完成預定的各項功能。由晶振產(chǎn)生的頻率非常穩(wěn)定的脈沖,經(jīng)整形、穩(wěn)定電路后,產(chǎn)生一個頻率為1Hz的、非常穩(wěn)定的計數(shù)時鐘脈沖。3.1.2調(diào)時、調(diào)分信號的產(chǎn)生由計數(shù)器的計數(shù)過程可知,正常計數(shù)時,當秒計數(shù)器(60進制)計數(shù)到59 時,再來一個脈沖,則秒計數(shù)器清零,重新開始新一輪的計數(shù),而進位則作為分計數(shù)器的計數(shù)脈沖,使分計數(shù)器計數(shù)加1。現(xiàn)在我們把電
3、路稍做變動:把秒計數(shù)器的進位脈沖和一個頻率為2Hz的脈沖信號同時接到一個2選1數(shù)據(jù)選擇器的兩個數(shù)據(jù)輸入端,而位選信號則接一個脈沖按鍵開關(guān),當按鍵開關(guān)不按下去時(即為0),則數(shù)據(jù)選擇器將秒計數(shù)器的進位脈沖送到分計數(shù)器,此時,數(shù)字鐘正常工作;當按鍵開關(guān)按下去時(即為1),則數(shù)據(jù)選擇器將另外一個2Hz 的信號作為分計數(shù)器的計數(shù)脈沖,使其計數(shù)頻率加快,當達到正確時間時,松開按鍵開關(guān),從而達到調(diào)時的目的。調(diào)節(jié)小時的時間也一樣的實現(xiàn)。3.1.3計數(shù)顯示電路計數(shù)部分:由兩個60進制計數(shù)器和一個24 進制計數(shù)器組成,其中60 進制計數(shù)器可用6 進制計數(shù)器和10 進制計數(shù)器構(gòu)成;24 進制的小時計數(shù)同樣可用6
4、進制計數(shù)器和10 進制計數(shù)器得到:當計數(shù)器計數(shù)到24 時,“2”和“4”同時進行清零,則可實現(xiàn)24 進制計數(shù)。3.2設計思路根據(jù)系統(tǒng)設計要求,系統(tǒng)設計采用自底向上的設計方法,由時鐘分頻部分、計時部分、按鍵部分調(diào)時部分和顯示部分五個部分組成。這些模塊都放在一個頂層文件中。3.2.1時鐘計數(shù)首先下載程序進行復位清零操作,電子鐘從00:00:00計時開始。sethour可以調(diào)整時鐘的小時部分, setmin可以調(diào)整分鐘,步進為1。由于電子鐘的最小計時單位是1s,因此提供給系統(tǒng)的內(nèi)部的時鐘頻率應該大于1Hz,這里取100Hz。CLK端連接外部10Hz的時鐘輸入信號clk。對clk進行計數(shù),當clk=1
5、0時,秒加1,當秒加到60時,分加1;當分加到60時,時加1;當時加到24時,全部清0,從新計時。用6位數(shù)碼管分別顯示“時”、“分”、“秒”,通過OUTPUT( 6 DOWNTO 0 )上的信號來點亮指定的LED七段顯示數(shù)碼管。3.2.2時間設置手動調(diào)節(jié)分鐘、小時,可以對所設計的時鐘任意調(diào)時間,這樣使數(shù)字鐘真正具有使用功能。我們可以通過實驗板上的鍵7和鍵4進行任意的調(diào)整,因為我們用的時鐘信號均是1HZ的,所以每LED燈變化一次就來一個脈沖,即計數(shù)一次。根據(jù)系統(tǒng)設計要求,系統(tǒng)設計采用自頂向下設計方法,由時鐘分頻部分、計時部分、按鍵部分調(diào)時部分和顯示部分五個部分組成。這些模塊都放在一個頂層文件中。
6、1)通過對md1按鍵高低電平的控制可以進入時鐘的另一個調(diào)時模式,調(diào)試模式和計時模式是分開互不影響的。然后再通過對md21和md22對時鐘進行時間設定。等到計時到達設置時間時,實現(xiàn)打鈴功能。2)用6位數(shù)碼管分別顯示“時”、“分”、“秒”,通過DOUT( 6 DOWNTO 0 )上的信號來點亮指定的LED七段顯示數(shù)碼管。3)由于電子鐘的最小計時單位是1s,因此提供給系統(tǒng)的內(nèi)部的時鐘頻率應該大于1Hz,這里取100Hz。CLK端連接外部10Hz的時鐘輸入信號clk。對clk進行計數(shù),當clk=10時,秒加1,當秒加到60時,分加1;當分加到60時,時加1;當時加到24時,全部清0,從新計時。4)首先
7、下載程序進行復位清零操作,電子鐘從00:00:00計時開始。md21可以調(diào)整時鐘的小時部分, md22可以調(diào)整分鐘,步進為1。頂層設計分析:對于電子鐘的設計,這里將采用自底向上的設計方法進行設計,因此首先需要進行電子鐘的底層設計。本節(jié)將首先介紹電子鐘的系統(tǒng)結(jié)構(gòu)和模塊劃分,然后設計出頂層VHDL設計程序。源程序:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity szz is-端口定義port(clk:in std_logic; clk1:in std_logic; md1:in std_
8、logic; md2:in std_logic_vector(1 downto 0); ledout1:out std_logic; ledout2:out std_logic; speak:out std_logic; dout:out std_logic_vector(6 downto 0); selout:out std_logic_vector(2 downto 0); end szz;architecture one of szz issignal sel:std_logic_vector(2 downto 0);signal hou1:std_logic_vector(3 down
9、to 0);signal hou2:std_logic_vector(3 downto 0);signal min1:std_logic_vector(3 downto 0);signal min2:std_logic_vector(3 downto 0);signal seth1:std_logic_vector(3 downto 0);signal seth2:std_logic_vector(3 downto 0);signal setm1:std_logic_vector(3 downto 0);signal setm2:std_logic_vector(3 downto 0);sig
10、nal sec1:std_logic_vector(3 downto 0);signal sec2:std_logic_vector(3 downto 0);signal h1:std_logic_vector(3 downto 0);signal h2:std_logic_vector(3 downto 0);signal m1:std_logic_vector(3 downto 0);signal m2:std_logic_vector(3 downto 0);signal s1:std_logic_vector(3 downto 0);signal s2:std_logic_vector
11、(3 downto 0);begin-模6計數(shù)choice:process(clk1)beginif clk1'event and clk1='1' thenif sel="101" thensel<="000"elsesel<=sel+1;end if;end if;end process choice;-小時十位h110:process(clk,hou2,min1,min2,sec1,sec2,md1,md2)beginif clk'event and clk='1' thenif (hou
12、1="0010" and hou2="0011")and(min1="0101" and min2="1001") and (sec1="0101" and sec2="1001") thenhou1<="0000"elsif hou1="0010"and hou2="0011"and md1='0' and md2="01" then-當時間為23點且處于校時狀態(tài)時hou1
13、<="0000"elsif (hou2="1001"and(min1="0101" and min2="1001") and (sec1="0101" and sec2="1001")or (hou2="1001"and md1='0' and md2="01") thenhou1<=hou1+1;end if;end if;end process h110;-小時個位h220:process(clk,min
14、1,min2,sec1,sec2,md1,md2,hou1)beginif clk'event and clk='1' thenif (hou1="0010" and hou2="0011")and(min1="0101" and min2="1001") and (sec1="0101" and sec2="1001") thenhou2<="0000"elsif hou2="1001"and(min1=
15、"0101" and min2="1001") and (sec1="0101" and sec2="1001") thenhou2<="0000"elsif (hou2="1001"and md1='0' and md2="01")or (hou1="0010"and hou2="0011") thenhou2<="0000"-md<='1'el
16、sif (min1="0101" and min2="1001") and (sec1="0101" and sec2="1001")or (md1='0' and md2="01") thenhou2<=hou2+1;-speak<=clk;end if;end if;end process h220;-分鐘十位m110:process(clk,min2,sec1,sec2,md1,md2)beginif clk'event and clk='1
17、39; thenif (min1="0101" and min2="1001") and (sec1="0101" and sec2="1001") then min1<="0000"elsif min1="0101"and min2="1001"and (md1='0' and md2="00")thenmin1<="0000"elsif (min2="1001"an
18、d (sec1="0101" and sec2="1001") or (min2="1001"and md1='0' and md2="00")thenmin1<=min1+1;end if;end if;-end if;end process m110;-分鐘個位m220:process(clk,sec1,sec2,md1,md2)beginif clk'event and clk='1' thenif min2="1001"and (sec1=&
19、quot;0101" and sec2="1001")thenmin2<="0000"elsif min2="1001"and (md1='0' and md2="00")thenmin2<="0000"else if (sec1="0101" and sec2="1001") or(md1='0' and md2="00")thenmin2<=min2+1;end if;en
20、d if;end if;end process m220;-秒十位s110:process(clk)beginif clk'event and clk='1' thenif (sec1="0101" and sec2="1001")thensec1<="0000"else if sec2="1001"thensec1<=sec1+1;end if;end if;end if;end process s110;-秒個位s220:process(clk)beginif clk'
21、;event and clk='1' thenif sec2="1001" thensec2<="0000"else sec2<=sec2+1;end if;end if;end process s220;-時間設置小時部分sethour1:process(clk,seth2)beginif clk'event and clk='1' thenif seth1="0010"and seth2="0011" thenseth1<="0000"
22、;elsif seth2="1001" thenseth1<=seth1+1;end if;end if;end process sethour1;-sethour2:process(clk,md1,md2,seth1)beginif clk'event and clk='1' thenif (seth1="0010"and seth2="0011")or seth2="1001"thenseth2<="0000"elsif md1='1' a
23、nd md2="00" thenseth2<=seth2+1;end if;end if;end process sethour2;-時間設置分鐘部分setmin1:process(clk,setm2)beginif clk'event and clk='1' thenif setm1="0101"and setm2="1001"thensetm1<="0000"elsif setm2="1001"thensetm1<=setm1+1;end if;en
24、d if;end process setmin1;-setmin2:process(clk,md1,md2)beginif clk'event and clk='1'thenif setm2="1001"thensetm2<="0000"elsif md1='1' and md2="01"thensetm2<=setm2+1;end if;end if;end process setmin2;-鬧鈴speaker:process(clk1,hou1,hou2,min1,min2)be
25、ginif clk1'event and clk1='1'then-鬧鐘判斷,一分鐘響鈴if seth1=hou1 and seth2=hou2 and setm1=min1 and setm2=min2 thenspeak<=clk; ledout1<=clk;else speak<='0'ledout1<='0'-整點報時,3秒鐘響鈴if "0000"=min1 and "0000"=min2 and sec1="0000" thenif sec2=&
26、quot;0000" or sec2="0001" or sec2="0010" thenspeak<='1'ledout2<=clk;else speak<='0'ledout2<='0'end if;end if;end if;end if;end process speaker;-譯碼顯示部分disp:process(sel,md1,hou1,hou2,min1,min2,sec1,sec2,seth1,seth2,setm1,setm2)beginif sel=&q
27、uot;101" thenselout<="101"case h1 iswhen "0000"=>dout<="0111111"when "0001"=>dout<="0000110"when "0010"=>dout<="1011011"when others =>dout<="1000000"end case;elsif sel="100" then
28、selout<="100"case h2 iswhen "0000"=>dout<="0111111"when "0001"=>dout<="0000110"when "0010"=>dout<="1011011"when "0011"=>dout<="1001111"when "0100"=>dout<="1100110
29、"when "0101"=>dout<="1101101"when "0110"=>dout<="1111101"when "0111"=>dout<="0000111"when "1000"=>dout<="1111111"when "1001"=>dout<="1101111"when others=>dout<
30、="1000000"end case;elsif sel="011" thenselout<="011"case m1 iswhen "0000"=>dout<="0111111"when "0001"=>dout<="0000110"when "0010"=>dout<="1011011"when "0011"=>dout<="10
31、01111"when "0100"=>dout<="1100110"when "0101"=>dout<="1101101"when others=>dout<="1000000"end case;elsif sel="010" thenselout<="010"case m2 iswhen "0000"=>dout<="0111111"when &qu
32、ot;0001"=>dout<="0000110"when "0010"=>dout<="1011011"when "0011"=>dout<="1001111"when "0100"=>dout<="1100110"when "0101"=>dout<="1101101"when "0110"=>dout<=&qu
33、ot;1111101"when "0111"=>dout<="0000111"when "1000"=>dout<="1111111"when "1001"=>dout<="1101111"when others=>dout<="1000000"end case;elsif sel="001" thenselout<="001"case s1 iswhe
34、n "0000"=>dout<="0111111"when "0001"=>dout<="0000110"when "0010"=>dout<="1011011"when "0011"=>dout<="1001111"when "0100"=>dout<="1100110"when "0101"=>dout<
35、;="1101101"when others=>dout<="1000000"end case;elsif sel="000" thenselout<="000"case s2 iswhen "0000"=>dout<="0111111"when "0001"=>dout<="0000110"when "0010"=>dout<="1011011&quo
36、t;when "0011"=>dout<="1001111"when "0100"=>dout<="1100110"when "0101"=>dout<="1101101"when "0110"=>dout<="1111101"when "0111"=>dout<="0000111"when "1000"=>do
37、ut<="1111111"when "1001"=>dout<="1101111"when others=>dout<="1000000"end case;end if;if md1='0' then-計時時間顯示和設置模式h1<=hou1;h2<=hou2;m1<=min1;m2<=min2;s1<=sec1;s2<=sec2;else -鬧鈴時間現(xiàn)實和設置模式h1<=seth1;h2<=seth2;m1<=setm1;m2<=setm2;s1<="1111"s2<="1111"end if;end process disp;end one;四、仿真分析各端口的功能為:clk,clk1端:時鐘信號輸入端。dout0.6:數(shù)碼管選擇端。Selout2.0:七段碼譯碼器掃描接口輸入端。md1,md1.0:三個輸入端。ledout1,ledout2:顯示燈。speak:蜂鳴器。圖4.1 波形仿真圖實驗連線:clk接時鐘信號CLK0,clk1接時鐘信號C
溫馨提示
- 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. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 跨國企業(yè)在綠色能源項目的投資策略探討
- 云服務與本地系統(tǒng)集成規(guī)范
- 中國傳媒大學《建筑師職業(yè)基礎(chǔ)》2023-2024學年第二學期期末試卷
- 2025年郴州市蘇仙區(qū)數(shù)學四年級第二學期期末經(jīng)典模擬試題含解析
- 2024-2025學年新疆阿克蘇地區(qū)阿瓦提縣數(shù)學三下期末學業(yè)質(zhì)量監(jiān)測模擬試題含解析
- 湖北醫(yī)藥學院藥護學院《環(huán)境影響評價》2023-2024學年第二學期期末試卷
- 2024-2025學年江蘇省宿遷市泗陽縣倉集鎮(zhèn)中心小學三下數(shù)學期末聯(lián)考試題含解析
- 2024-2025學年撫順市望花區(qū)數(shù)學四年級第二學期期末學業(yè)水平測試模擬試題含解析
- 濱州學院《景觀建筑與外部環(huán)境設計》2023-2024學年第二學期期末試卷
- 貴州文化旅游職業(yè)學院《醫(yī)學生物學》2023-2024學年第二學期期末試卷
- 社會保障卡辦理委托書
- 微積分(第三版)課件:多元函數(shù)微積分
- 2024年青海公務員考試行測真題及答案
- 山東職業(yè)學院單招《英語》考試復習題庫(含答案)
- 興隆街辦拆遷規(guī)劃方案
- 四年級上冊數(shù)學計算題練習300題及答案
- 《開學第一課:一年級新生入學班會》課件
- 右側(cè)腹股溝疝教學查房
- 人工智能與自動駕駛技術(shù)
- 城市排水系統(tǒng)雨污分流改造
- 數(shù)據(jù)安全法 培訓課件
評論
0/150
提交評論