




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、目錄一、設(shè)計(jì)任務(wù)和要求1二、總體框圖1三、選擇器件2四、功能模塊341日模塊34.2月模塊54.3年模塊74.4星期模塊84.5掃描模塊94.6數(shù)碼管模塊114.7三八譯碼器124.8分頻器模塊14五總體電路設(shè)計(jì)圖和硬件實(shí)現(xiàn)145.1程序仿真電路145.2硬件實(shí)現(xiàn)18六設(shè)計(jì)中存在的問題21七、深入研究21八、心得體會(huì)21簡(jiǎn)易萬年歷的設(shè)計(jì)一、設(shè)計(jì)任務(wù)和要求1.用七個(gè)七段數(shù)碼管顯示年的低兩位,月,日和星期,并具有閏年判斷功能;2.可以手動(dòng)調(diào)整年,月,日,星期;3.在quartus ii 6.0中編寫vhdl程序?qū)崿F(xiàn)年,月,日星期各模塊的功能;4.編寫頂層程序?qū)⒏髂K連接起來實(shí)現(xiàn)萬年歷調(diào)時(shí)功能。二、
2、總體框圖圖1 總體框圖上圖為總體設(shè)計(jì)框圖,主要有計(jì)數(shù)模塊、年月日模塊、分頻模塊和掃描譯碼顯示模塊組成。分頻模塊在外部時(shí)鐘信號(hào)的作用下實(shí)現(xiàn)分頻后將其分頻信號(hào)分別輸出給計(jì)數(shù)模塊和掃描模塊。在分頻信號(hào)(日脈沖)作用下計(jì)數(shù)模塊實(shí)現(xiàn)計(jì)數(shù)功能實(shí)現(xiàn)年月日計(jì)數(shù)功能,但其計(jì)數(shù)功能是在以bcd碼形式所記錄的。這就需要掃描電路去掃描計(jì)數(shù)模塊所輸出的時(shí)間在500hz脈沖下經(jīng)過譯碼器將其譯成共陰數(shù)碼管所對(duì)應(yīng)的二進(jìn)制數(shù)進(jìn)行顯示,最終顯示的為年月日。外部時(shí)間控制信號(hào)可控制時(shí)間的校驗(yàn)。三、選擇器件1、pc機(jī)一臺(tái)。2、cpld/fpga適配器板:標(biāo)準(zhǔn)配置epf10k10lc84-4接口板,下載接口是數(shù)字芯片的下載接口(digi
3、tal jtag),主要用于cpld/fpga芯片的數(shù)據(jù)下載。3、實(shí)驗(yàn)箱:裝有七段數(shù)碼管及蜂鳴器等,七段數(shù)碼管真值表及字型如下表1 七段數(shù)碼管真值表輸入輸出字型dcba00001111110000101100000010110110100111111001010001100110101101101101101011111011111100001000111111110011111011七段數(shù)碼管字形如下:圖2 數(shù)碼管字型圖四、功能模塊41日模塊1.模塊圖圖3 日模塊圖2.仿真圖 圖4 日模塊仿真圖clk:輸入脈沖;pan:輸入月的判斷信號(hào),0表示大月為31天,1表示小月30天,2表示平月為28
4、天,3表示閏月為29天;t1:日的個(gè)位;t2:日的十位;cout:進(jìn)位信號(hào),當(dāng)pan=0的時(shí)候t2t1=31時(shí)產(chǎn)生進(jìn)位,cout=1,當(dāng)pan=1的時(shí)候t2t1=30時(shí)產(chǎn)生進(jìn)位信號(hào),cout=1,當(dāng)pan=2的時(shí)候t2t1=28時(shí)產(chǎn)生進(jìn)位,cout=1,當(dāng)pan=3的時(shí)候t2t1=29時(shí)產(chǎn)生進(jì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 檢測(cè)時(shí)鐘上升沿 q1=q1+1; q1開始計(jì)數(shù) if (q1=9 )then q1=0000; q2=q2+1; q1
6、=9時(shí),q2開始計(jì)數(shù)且q1清零 end if; -abif (q2=3 )and q1=1 then q2=0000;q1=0000;cout=1; 當(dāng)pan=00時(shí),如果q2=3,q1=1,q2清零,q1從1開始計(jì)數(shù)并輸出進(jìn)位信號(hào)else coutif q2=3 and q1=0 then q2=0000;q1=0001;cout=1; 當(dāng)pan=01時(shí),如果q2=3,q1=0,q2清零,q1從1開始計(jì)數(shù)并輸出進(jìn)位信號(hào)else coutif q2=2 and q1=8 then q2=0000;q1=0001;cout=1; 當(dāng)pan=10時(shí),如果q2=2,q1=9,q2清零,q1從1開始計(jì)
7、數(shù)并輸出進(jìn)位信號(hào)elsif q2=2 and q1=9 then q2=0000;q1=0001;cout=1; 當(dāng)pan=11時(shí),如果q2=2,q1=8,q2清零,q1從1開始計(jì)數(shù)并輸出進(jìn)位信號(hào)else coutnull;end case;end if;end process;t1=q1;t2=q2;end one;4.2月模塊1.模塊圖圖5 月模塊圖2.仿真圖圖6 月模塊仿真圖clk:輸入脈沖;pan:輸出月的判斷信號(hào),1、3、5、7、8、10、12為大月輸出pan=00,4、6、9、11為小月輸出pan=01,閏年時(shí)2月為閏月輸出pan=11,否則輸出pan=10;y1:月的個(gè)位;y2:
8、月的十位;cout:進(jìn)位信號(hào),當(dāng)y2y1等于12時(shí)輸出cout=1;run:輸入閏年信號(hào),run=1時(shí)表示閏年,run=0時(shí)表示不是閏年。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 檢測(cè)時(shí)鐘上升沿 q1=q1+1; q1開始計(jì)數(shù) if (q1=9 )then q1=0000; q2=q2+1; q1=9時(shí),q2開始計(jì)數(shù)且q1清零 end if; if q1=2 and q2=1 then q1=0001;q2=0000;cout=1; q1=2,q2=1時(shí),q2清
10、零,q1從1開始計(jì)數(shù)并輸出進(jìn)位信號(hào) 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:年的個(gè)位;n2:年的十位;run:閏年信號(hào)輸出,run=1時(shí)表示閏年,run=0時(shí)表示不是閏年,從n2n1=00開始,每4年輸出一個(gè)閏年信號(hào)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 檢測(cè)時(shí)鐘上升沿 q
12、1=q1+1; q3=q3+1; if (q1=9 )then q1=0000; q2=q2+1; q1=9時(shí),q2開始計(jì)數(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 檢測(cè)時(shí)鐘上升沿 cq1=cq1+1; q1開始計(jì)數(shù) if cq1=7 then cq1=0001; en
14、d if; end if;end process; q1=cq1; end;4.5掃描模塊1.模塊圖圖11 掃描模塊該模塊的功能是對(duì)輸入信號(hào)依次進(jìn)行掃描顯示,產(chǎn)生對(duì)數(shù)碼管的選擇信號(hào)。reset為復(fù)位信號(hào)低電平有效。時(shí)鐘信號(hào)clk1為1ns脈沖信號(hào),依次掃描星期年月日輸出,但速度十分快,可以看作是同時(shí)輸出。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 復(fù)位信號(hào)有效,輸出為零 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ù)轉(zhuǎn)換為七段數(shù)碼管需要的數(shù)據(jù)。將num中的bcd碼編譯到共陰數(shù)碼管,顯示為具有年月日的簡(jiǎn)易萬年歷。表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ù)轉(zhuǎn)換為七段數(shù)碼管需要的數(shù)據(jù),將seltime中的bcd碼編譯到共陰數(shù)碼管,顯示為具有年月日功能的簡(jiǎn)易萬年歷。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 分頻器模塊圖 該模塊實(shí)現(xiàn)的功能是分頻,clk_in 輸入一個(gè)100mhz的脈沖信號(hào),經(jīng)過分頻器后得到一個(gè)1hz的秒脈沖的脈沖信號(hào)。其
22、中是為掃描模塊提供時(shí)鐘信號(hào)。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;五總體電路設(shè)計(jì)圖和硬件實(shí)現(xiàn)5.1程序仿真電路1.總電路圖圖18 總仿真電路圖100mhz脈沖作為天計(jì)數(shù)信號(hào)輸入使天計(jì)數(shù),通過pan判斷大小月及制計(jì)數(shù),滿進(jìn)制后進(jìn)位,進(jìn)位信號(hào)作為月信號(hào)時(shí)鐘使月以十二進(jìn)制計(jì)數(shù),滿十二后進(jìn)位,進(jìn)位信號(hào)作為年時(shí)鐘使年計(jì)數(shù)。同時(shí)100mhz脈沖還作為星期的計(jì)數(shù)信號(hào),使星期以七進(jìn)制循環(huán)。掃描電路有時(shí)間信號(hào)進(jìn)來后在1000mhz時(shí)鐘下進(jìn)行快速掃描,經(jīng)過譯碼器和七段數(shù)碼管顯示時(shí)間。2.仿真圖圖19 總體仿真圖在clk信號(hào)為10ns,clkdsp信號(hào)為
24、1ns,reset高電平1無效時(shí),出現(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硬件實(shí)現(xiàn) 連線:用一根導(dǎo)線連clk與io3。經(jīng)硬件測(cè)試,啟動(dòng)電源,數(shù)碼管有正確的數(shù)字顯示,即年月日、星期在實(shí)驗(yàn)箱上按正確的進(jìn)制計(jì)數(shù)。1.總電路圖:圖21 總電路圖2.實(shí)物圖圖22 02年8月22日 周一圖23 12年12月31日 周二六設(shè)計(jì)中存在的問題1.程序在編寫過程中不夠細(xì)心,出現(xiàn)errors,最終根據(jù)提示一一改正;2.各個(gè)模塊在單獨(dú)仿真時(shí)能出現(xiàn)正確
溫馨提示
- 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ì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 產(chǎn)業(yè)園區(qū)入駐合同協(xié)議
- 關(guān)于推進(jìn)跨部門合作項(xiàng)目的工作計(jì)劃
- 關(guān)于采購(gòu)流程的往來文書說明
- 商務(wù)會(huì)議溝通要點(diǎn)及會(huì)議紀(jì)要模板
- 健康管理平臺(tái)的構(gòu)建及運(yùn)營(yíng)規(guī)劃
- 機(jī)器人智能化生產(chǎn)線建設(shè)委托代理合同
- 交通物流調(diào)度管理系統(tǒng)建設(shè)方案
- 房屋預(yù)約買賣合同
- 木材原木購(gòu)銷合同
- 2025年版《認(rèn)識(shí)大熊貓》課件發(fā)布
- 中國(guó)計(jì)量大學(xué)《微機(jī)原理及其應(yīng)用》2021-2022學(xué)年第一學(xué)期期末試卷
- 中國(guó)技能大賽-第45屆世界技能大賽全國(guó)選拔賽“水處理技術(shù)”項(xiàng)目技術(shù)工作文件
- 混凝土工安全教育培訓(xùn)試題及答案
- 臨床家庭化產(chǎn)房開展經(jīng)驗(yàn)分享
- 安徽省六安市裕安區(qū)六安市獨(dú)山中學(xué)2024-2025學(xué)年高一上學(xué)期11月期中生物試題(含答案)
- 低血糖的護(hù)理查房
- GB/T 44718-2024城市軌道交通無障礙運(yùn)營(yíng)服務(wù)規(guī)范
- DB41T 2567-2023 消防技術(shù)服務(wù)機(jī)構(gòu)服務(wù)規(guī)范
- 2024年職工普法教育宣講培訓(xùn)課件
- 音樂鑒賞與實(shí)踐 第一單元第四課音樂的力量(下)
- 《外科護(hù)理學(xué)(第七版)》考試復(fù)習(xí)題庫(kù)-上(單選題)
評(píng)論
0/150
提交評(píng)論