EDA課程設計萬年歷_第1頁
EDA課程設計萬年歷_第2頁
EDA課程設計萬年歷_第3頁
EDA課程設計萬年歷_第4頁
EDA課程設計萬年歷_第5頁
已閱讀5頁,還剩19頁未讀, 繼續(xù)免費閱讀

下載本文檔

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

文檔簡介

1、目錄一、設計任務和要求1二、總體框圖1三、選擇器件2四、功能模塊341日模塊34.2月模塊54.3年模塊74.4星期模塊84.5掃描模塊94.6數(shù)碼管模塊114.7三八譯碼器124.8分頻器模塊14五總體電路設計圖和硬件實現(xiàn)145.1程序仿真電路145.2硬件實現(xiàn)18六設計中存在的問題21七、深入研究21八、心得體會21簡易萬年歷的設計一、設計任務和要求1.用七個七段數(shù)碼管顯示年的低兩位,月,日和星期,并具有閏年判斷功能;2.可以手動調整年,月,日,星期;3.在quartus ii 6.0中編寫vhdl程序實現(xiàn)年,月,日星期各模塊的功能;4.編寫頂層程序將各模塊連接起來實現(xiàn)萬年歷調時功能。二、

2、總體框圖圖1 總體框圖上圖為總體設計框圖,主要有計數(shù)模塊、年月日模塊、分頻模塊和掃描譯碼顯示模塊組成。分頻模塊在外部時鐘信號的作用下實現(xiàn)分頻后將其分頻信號分別輸出給計數(shù)模塊和掃描模塊。在分頻信號(日脈沖)作用下計數(shù)模塊實現(xiàn)計數(shù)功能實現(xiàn)年月日計數(shù)功能,但其計數(shù)功能是在以bcd碼形式所記錄的。這就需要掃描電路去掃描計數(shù)模塊所輸出的時間在500hz脈沖下經(jīng)過譯碼器將其譯成共陰數(shù)碼管所對應的二進制數(shù)進行顯示,最終顯示的為年月日。外部時間控制信號可控制時間的校驗。三、選擇器件1、pc機一臺。2、cpld/fpga適配器板:標準配置epf10k10lc84-4接口板,下載接口是數(shù)字芯片的下載接口(digi

3、tal jtag),主要用于cpld/fpga芯片的數(shù)據(jù)下載。3、實驗箱:裝有七段數(shù)碼管及蜂鳴器等,七段數(shù)碼管真值表及字型如下表1 七段數(shù)碼管真值表輸入輸出字型dcba00001111110000101100000010110110100111111001010001100110101101101101101011111011111100001000111111110011111011七段數(shù)碼管字形如下:圖2 數(shù)碼管字型圖四、功能模塊41日模塊1.模塊圖圖3 日模塊圖2.仿真圖 圖4 日模塊仿真圖clk:輸入脈沖;pan:輸入月的判斷信號,0表示大月為31天,1表示小月30天,2表示平月為28

4、天,3表示閏月為29天;t1:日的個位;t2:日的十位;cout:進位信號,當pan=0的時候t2t1=31時產(chǎn)生進位,cout=1,當pan=1的時候t2t1=30時產(chǎn)生進位信號,cout=1,當pan=2的時候t2t1=28時產(chǎn)生進位,cout=1,當pan=3的時候t2t1=29時產(chǎn)生進位,cout=1。3.程序library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity tian is port(clk:in std_logic; pan: in std_logic_vector(1 do

5、wnto 0); t1,t2:out std_logic_vector(3 downto 0); cout:out std_logic); end;architecture one of tian issignal q1,q2:std_logic_vector(3 downto 0);signal ab:std_logic_vector(1 downto 0);begin process (clk,pan) begin if (clkevent and clk=1 )then 檢測時鐘上升沿 q1=q1+1; q1開始計數(shù) if (q1=9 )then q1=0000; q2=q2+1; q1

6、=9時,q2開始計數(shù)且q1清零 end if; -abif (q2=3 )and q1=1 then q2=0000;q1=0000;cout=1; 當pan=00時,如果q2=3,q1=1,q2清零,q1從1開始計數(shù)并輸出進位信號else coutif q2=3 and q1=0 then q2=0000;q1=0001;cout=1; 當pan=01時,如果q2=3,q1=0,q2清零,q1從1開始計數(shù)并輸出進位信號else coutif q2=2 and q1=8 then q2=0000;q1=0001;cout=1; 當pan=10時,如果q2=2,q1=9,q2清零,q1從1開始計

7、數(shù)并輸出進位信號elsif q2=2 and q1=9 then q2=0000;q1=0001;cout=1; 當pan=11時,如果q2=2,q1=8,q2清零,q1從1開始計數(shù)并輸出進位信號else coutnull;end case;end if;end process;t1=q1;t2=q2;end one;4.2月模塊1.模塊圖圖5 月模塊圖2.仿真圖圖6 月模塊仿真圖clk:輸入脈沖;pan:輸出月的判斷信號,1、3、5、7、8、10、12為大月輸出pan=00,4、6、9、11為小月輸出pan=01,閏年時2月為閏月輸出pan=11,否則輸出pan=10;y1:月的個位;y2:

8、月的十位;cout:進位信號,當y2y1等于12時輸出cout=1;run:輸入閏年信號,run=1時表示閏年,run=0時表示不是閏年。3.程序library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity yue is port(clk,run:in std_logic; cout:out std_logic; pan: out std_logic_vector(1 downto 0); y1,y2: out std_logic_vector(3 downto 0); end;architect

9、ure one of yue issignal q1,q2:std_logic_vector(3 downto 0);signal q3:std_logic_vector(7 downto 0);begin process (clk,run) begin if (clkevent and clk=1 )then 檢測時鐘上升沿 q1=q1+1; q1開始計數(shù) if (q1=9 )then q1=0000; q2=q2+1; q1=9時,q2開始計數(shù)且q1清零 end if; if q1=2 and q2=1 then q1=0001;q2=0000;cout=1; q1=2,q2=1時,q2清

10、零,q1從1開始計數(shù)并輸出進位信號 else cout=0; end if; end if; q3panif run=1 then pan=11;else panpanpanpanpanpanpanpanpanpanpanpan=00;end case;end process;y1=q1;y2=q2;end one;4.3年模塊1.模塊圖圖7 年模塊圖2.仿真圖圖8 年模塊仿真圖clk:輸入脈沖;n1:年的個位;n2:年的十位;run:閏年信號輸出,run=1時表示閏年,run=0時表示不是閏年,從n2n1=00開始,每4年輸出一個閏年信號run=1。3.程序library ieee;use

11、ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity nian is port(clk:in std_logic; n1,n2:out std_logic_vector(3 downto 0); run:out std_logic); end;architecture one of nian issignal q1,q2,q3:std_logic_vector(3 downto 0);begin process (clk,q1,q2) begin if (clkevent and clk=1 )then 檢測時鐘上升沿 q

12、1=q1+1; q3=q3+1; if (q1=9 )then q1=0000; q2=q2+1; q1=9時,q2開始計數(shù)且q1清零 end if; if q3=3 then q3=0000; run=1; else run=0; end if; if q2=9 and q1=9 then q1=0000; q2=0000; end if;end if; end process;n1=q1;n2=q2;end one;4.4星期模塊1模塊圖圖9 星期模塊圖2仿真圖圖10 星期模塊仿真圖clk:輸入脈沖;q1:從1到7變化;3程序library ieee;use ieee.std_logic_

13、1164.all;use ieee.std_logic_unsigned.all;entity xingqi is port(clk:in std_logic; q1:out std_logic_vector(3 downto 0);end xingqi;architecture one of xingqi is signal cq1:std_logic_vector(3 downto 0);beginprocess(clk) begin if clkevent and clk=1then 檢測時鐘上升沿 cq1=cq1+1; q1開始計數(shù) if cq1=7 then cq1=0001; en

14、d if; end if;end process; q1=cq1; end;4.5掃描模塊1.模塊圖圖11 掃描模塊該模塊的功能是對輸入信號依次進行掃描顯示,產(chǎn)生對數(shù)碼管的選擇信號。reset為復位信號低電平有效。時鐘信號clk1為1ns脈沖信號,依次掃描星期年月日輸出,但速度十分快,可以看作是同時輸出。daout輸出依次是星期年月日輸出,每位輸出都為bcd碼,sel為bcd碼。2.仿真圖圖12 掃描模塊仿真圖3.程序library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;use ieee.std_log

15、ic_arith.all;entity seltime is port( clk1,reset:in std_logic; nian1,nian2,yue1,yue2,tian1,tian2:in std_logic_vector(3 downto 0); xingqi:in std_logic_vector(3 downto 0); daout:out std_logic_vector(3 downto 0); sel:out std_logic_vector(2 downto 0);end seltime;architecture fun of seltime is - signal co

16、unt:std_logic_vector(2 downto 0);signal count:std_logic_vector(2 downto 0);begin sel=count; process(clk1,reset) begin if(reset=0)then 復位信號有效,輸出為零 count=110)then count=000; else countdaoutdaoutdaoutdaoutdaoutdaoutdaout=xingqi(3 downto 0); - daout(1 downto 0)=xingqi(3 downto 0); end case; end process;

17、end fun; 4.6數(shù)碼管模塊1.模塊圖圖13 數(shù)碼管模塊該模塊的功能是將輸入bcd碼數(shù)轉換為七段數(shù)碼管需要的數(shù)據(jù)。將num中的bcd碼編譯到共陰數(shù)碼管,顯示為具有年月日的簡易萬年歷。表2 數(shù)碼管真值表numled000011111100001011000000101101101001111110010100011001101011011011011010111110111111000010001111111100111110111010111011110110011111110010011101101011110111101001111111110001112.仿真圖圖14 數(shù)碼管模塊仿

18、真圖3.程序library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity deled is port(num:in std_logic_vector(3 downto 0); led:out std_logic_vector(6 downto 0);end deled;architecture fun of deled isbegin led=1111110when num=0000else 0110000when num=0001else 1101101when num=0010else 111

19、1001when num=0011else 0110011when num=0100else 1011011when num=0101else 1011111when num=0110else 1110000when num=0111else 1111111when num=1000else 1111011when num=1001else 1000111when num=1111;end fun;4.7三八譯碼器1.模塊圖圖15 三八譯碼器模塊圖該模塊的功能是將輸入bcd碼數(shù)轉換為七段數(shù)碼管需要的數(shù)據(jù),將seltime中的bcd碼編譯到共陰數(shù)碼管,顯示為具有年月日功能的簡易萬年歷。2.仿真圖

20、 圖16 三八譯碼器仿真圖表3 三八譯碼器真值表sel q011111110111111101211111011311110111411101111511011111610111111others111111113.程序library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity decode3_8 is port(sel:in std_logic_vector(2 downto 0); q:out std_logic_vector(7 downto 0) );end decode3_8;arch

21、itecture a of decode3_8 isbegin q=11111110when sel=0 else 11111101when sel=1 else 11111011when sel=2 else 11110111when sel=3 else 11101111when sel=4 else 11011111when sel=5 else 10111111when sel=6 else 11111111;end a;4.8分頻器模塊1.模塊圖圖17 分頻器模塊圖 該模塊實現(xiàn)的功能是分頻,clk_in 輸入一個100mhz的脈沖信號,經(jīng)過分頻器后得到一個1hz的秒脈沖的脈沖信號。其

22、中是為掃描模塊提供時鐘信號。2.程序:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity div_clk is port(clk_in:in std_logic; div_out:out std_logic);end div_clk;architecture a of div_clk issignal fre_n:integer range 0 to 10;signal clk_tmp:std_logic;begin div_out=9 then fre_n=0; clk_tmp=not

23、 clk_tmp; else fre_n=fre_n+1; end if; end if; end process;end a;五總體電路設計圖和硬件實現(xiàn)5.1程序仿真電路1.總電路圖圖18 總仿真電路圖100mhz脈沖作為天計數(shù)信號輸入使天計數(shù),通過pan判斷大小月及制計數(shù),滿進制后進位,進位信號作為月信號時鐘使月以十二進制計數(shù),滿十二后進位,進位信號作為年時鐘使年計數(shù)。同時100mhz脈沖還作為星期的計數(shù)信號,使星期以七進制循環(huán)。掃描電路有時間信號進來后在1000mhz時鐘下進行快速掃描,經(jīng)過譯碼器和七段數(shù)碼管顯示時間。2.仿真圖圖19 總體仿真圖在clk信號為10ns,clkdsp信號為

24、1ns,reset高電平1無效時,出現(xiàn)正確的年月日循環(huán),三八譯碼器可以正確編碼。3.管腳分配圖圖20 管腳分配圖4.總程序library ieee;use ieee.std_logic_1164.all;entity wannianli isport(clk:in std_logic;k1,k2:in std_logic;o1,o2,o3,o4,o5,o6,o7:out std_logic_vector(6 downto 0);d1,d2:out std_logic);end entity;architecture one of wannianli iscomponent tianport(c

25、lk:in std_logic;pan:in std_logic_vector(1 downto 0);t1,t2:out std_logic_vector(3 downto 0);cout:out std_logic);end component;component xingqi port(clk:in std_logic; q1:out std_logic_vector(3 downto 0);end component;component yueport(clk,run:in std_logic;cout:out std_logic;pan:out std_logic_vector(1

26、downto 0);y1,y2:out std_logic_vector(3 downto 0);end component;component nianport(clk:in std_logic;n1,n2:out std_logic_vector(3 downto 0);run:out std_logic);end component;component tiaoshiport(k1,k2:in std_logic;m1,m2:in std_logic;n1,n2:out std_logic;d1,d2:out std_logic);end component;component ledp

27、ort(ledi:in std_logic_vector(3 downto 0);ledo:out std_logic_vector(6 downto 0);end component;signal y1,y2,y3,y4,y5,y6,y7: std_logic_vector(3 downto 0);signal p: std_logic_vector(1 downto 0);signal c1,c2: std_logic;signal r: std_logic;signal ck1,ck2: std_logic;beginu1:tian port map(clk,p,y1,y2,c1);u2

28、:xingqi port map(clk,y7);u3: yue port map(ck1,r,c2,p,y3,y4);u4:nian port map(ck2,y5,y6,r);u5:tiaoshi port map(k1,k2,c1,c2,ck1,ck2,d1,d2);u6:led port map(y1,o1);u7:led port map(y2,o2);u8:led port map(y3,o3);u9:led port map(y4,o4);u10:led port map(y5,o5);u11:led port map(y6,o6);u12:led port map(y7,o7);end;5.2硬件實現(xiàn) 連線:用一根導線連clk與io3。經(jīng)硬件測試,啟動電源,數(shù)碼管有正確的數(shù)字顯示,即年月日、星期在實驗箱上按正確的進制計數(shù)。1.總電路圖:圖21 總電路圖2.實物圖圖22 02年8月22日 周一圖23 12年12月31日 周二六設計中存在的問題1.程序在編寫過程中不夠細心,出現(xiàn)errors,最終根據(jù)提示一一改正;2.各個模塊在單獨仿真時能出現(xiàn)正確

溫馨提示

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

評論

0/150

提交評論