【正文】
ksv* 3t n GK 8! z8 9Am YWp azad Nu KNamp。 qY pEh 5p Dx2 zV ku m amp。 ks v*3t n G K8! z89 Am YW paza dN u K Namp。 q Yp Eh5 pD x2z Vkum amp。 ks v*3t nG K8! z89 Am YWpaz ad Nu K Namp。 q Yp Eh5 pD x2z Vk um amp。 U E9a Q Gn 8xp $R amp。 6a* C Z7 H$d q8 Kqqf H VZ Feds w Sy XTy amp。 end st。 end if。 when others =dataout=0000。 when0100=dataout=r1。 when0110=dataout=y1。 when1000=dataout=n1。 else 40 case count is when1010=dataout=n3。 when others =dataout=0000。 when0100=dataout=m1。 when0110=dataout=f1。 then case count is when1010=dataout=s1。 if conv=39。 end if。 then if count=1010 then count=0000。event and disclk=39。 begin wsel=count。 end seltime。 dataout:out std_logic_vector(3 downto 0)。 entity seltime is port(disclk,conv:in std_logic。 use 。 : library ieee。 end process。 c=n2。 a=n0。 end if。 else nsel=39。) then nsel=39。 and n1(0)=39。 and n0(1)=39。)or(n0(0)=39。 and n1(0)=39。 and n0(1)=39。 if (n0(0)=39。 else n3:=0010。 n1:=n11。 n2:=n21。 elsif n0=0000 and n1=0000 then n0:=1001。 n2:=1001。 elsif n0=0000 and n1=0000 and n2=0000 then n0:=1001。 n2:=1001。 elsif n0=0000 and n1=0000 and n2=0000 and n3=0000 then n0:=1001。139。 end if。 if n3=1010 then n3:=0000。 n3:=n3+1。 end if。 if n1=1010 then n1:=0000。 elsif n0=1001 then n0:=0000。139。139。139。 elsif clk39。 n2:=0000。 then n0:=0000。 begin if res=39。 end nian。 a,b,c,d:out std_logic_vector(3 downto 0)。 use 。 use 。 end SEC。 b=y1。 end if。 else eryue=39。 if y0=0010 and y1=0000 then eryue=39。039。139。 end if。 end if。 else y0:=1001。 y1:=0001。139。 end if。 else y0:=0000。 ca=39。139。 y1:=0000。139。139。039。139。 elsif clk39。 ca=39。 then y0:=0000。 begin if res=39。 end yue。 a,b:out std_logic_vector(3 downto 0)。 use 。 35 附錄 1. 月計(jì)數(shù)模塊的程序: library ieee。在此我向曾經(jīng)幫助和關(guān)心我的老師和同學(xué)致以誠摯的感謝。 在這次畢業(yè)設(shè)計(jì)中,我的專業(yè)知識(shí)水平也取得一定的進(jìn)步。在理論上,老師耐心講解電路原理圖的繪制,以及元器件的性能;在實(shí)際操作中,從系統(tǒng)的設(shè)計(jì)到最終系統(tǒng)的調(diào)試 , 老 師都給予了諸多幫助, 使我得到不少的提高, 這是在這次設(shè)計(jì)中我所得到的最寶貴的財(cái)富。 和志強(qiáng)和張瑞平 老師認(rèn)真負(fù)責(zé)的工作態(tài)度,嚴(yán)謹(jǐn)?shù)闹螌W(xué)精神和深厚的理論水平都使我 受 益匪淺。設(shè)計(jì)的過程變的相對簡單,容易修改等優(yōu)點(diǎn),相信隨著電子技術(shù)的發(fā)展,數(shù)字鐘的功能會(huì)更加多樣化,滿足人們的各種需要。這樣可以節(jié)省按鍵資源,以供更多的功能的使用。 研究展望 本設(shè)計(jì)中雖然有控制鍵對時(shí)鐘進(jìn)行控制,但是用到的按鍵太多,在實(shí)際應(yīng)用上存在不足。檢查程序后得知,月的進(jìn)位 信號(hào)在月為 12 后變一直有效,其它模塊也存在這種情況,改動(dòng)程序后各個(gè)模塊工作正常。 59 時(shí)變 0 時(shí),分計(jì)數(shù)模塊滯后計(jì)數(shù),考慮的器件的延時(shí),將程序中秒的進(jìn)位信號(hào)提前 1 秒。總的來說,通過這次的設(shè)計(jì)實(shí)驗(yàn)更進(jìn)一步地增強(qiáng)了實(shí)驗(yàn)的動(dòng)手能力,對數(shù)字鐘的工作原理也有了更加透徹的理解。再加上器件對信號(hào)的延時(shí)等問題,實(shí)際下載到實(shí)驗(yàn)箱上后會(huì)出現(xiàn)一系列的問題,因此仿真圖和電路連接圖還是有一定區(qū)別的。并能根據(jù)仿真結(jié)果分析設(shè)計(jì)的存在的問題和缺陷,從而進(jìn)行程序的調(diào)試和完善。 在此次的數(shù)字鐘設(shè)計(jì)過程中,更進(jìn)一步地熟悉有關(guān)數(shù)字電路的知識(shí)和具體應(yīng)用。由于所用到的數(shù)碼管為兩組,故位選電路用到兩片 7448 模塊。計(jì)數(shù)器實(shí)現(xiàn)了對時(shí)間的累計(jì)并以 8421BCD 碼的形式輸送到 動(dòng)態(tài)掃描模塊,再由其輸出的端送到 7448, 將 BCD 碼轉(zhuǎn)換為七段碼,再由數(shù)碼管顯示出來。其 VHDL 程序描述見附錄。由分頻模塊提供;端口 CONV 顯示轉(zhuǎn)換信號(hào),當(dāng)其為高電平時(shí),數(shù)碼管顯示時(shí)、分和秒。 動(dòng)態(tài)掃描邏輯框圖如圖 418 所示。只要保證每一位顯示的時(shí)間間隔不要太大,利用人眼的視覺暫留的現(xiàn)象,就可以造成各位數(shù)據(jù)同時(shí)顯示的假象。所謂動(dòng)態(tài)掃描顯示方式是在顯示某一位 LED 顯示塊的數(shù)據(jù)的時(shí)候,讓其它位不顯示,然后在顯示下一位的數(shù)據(jù),同時(shí)關(guān)閉其他顯示塊。 表 42 閏年表 00 04 08 12 16 20 24 28 32 36 40 44 48 52 56 60 64 68 72 76 80 84 88 92 96 30 其仿真時(shí)序圖如圖 417 所示,滿足設(shè)計(jì)的要求。由于年份都帶有 20,所以省略,用年份數(shù)來表示。其 VHDL 描述見附錄。年計(jì)數(shù)模塊的輸出 NSEL端口接日模塊的 sel[0]。仿真圖中有毛刺出現(xiàn),但并不會(huì)對本模塊的計(jì)數(shù)產(chǎn)生影響,滿足本設(shè)計(jì)的需要。其 VHDL 程序描述見附錄。 圖 413 日計(jì)數(shù)仿真時(shí)序圖 月計(jì)數(shù)和年計(jì)數(shù)模塊 414 所示。第二個(gè)進(jìn)程主要實(shí)現(xiàn)計(jì)數(shù)和加減控制。 程序中第一個(gè)進(jìn)程主要是對日的長短的設(shè)置, sr0 和 sr1 分別是日的低位和高位的信號(hào),它們的值由輸入 sel[2..0]決定。 28 end process。 a=r0。 end if。 r1:=r11。 elsif r00000 then r0:=r01。 then if r0=0001 and r1=0000 then r0:=sr0。 elsif rdec=39。 r1:=r1+1。039。 elsif r01001 then r0:=r0+1。 ca=39。 then if r0=sr0 and r1=sr1 then r0:=0001。 or enl=39。 if radd=39。 then ca=39。event and clk=39。039。 r1:=0000。139。 process(enl,clk,res) variable r0,r1:std_logic_vector(3 downto 0)。 end if。 27 if sel=101 then sr0=1000。 sr1=0010。 end if。 if sel=011 then sr0=0000。 sr1=0011。 architecture SEC of ri is signal sr0,sr1:std_logic_vector(3 downto 0)。 ca:out std_logic)。 sel:in std_logic_vector(2 downto 0)。 use 。 圖 412 日計(jì)數(shù)模塊邏輯框圖 日計(jì)數(shù)模塊的核心程序如下: library ieee。年中 0 表示閏年, 1 表示平年;月中 0 表示 10 和 12 月, 1 表示其它月份;二月中 1 表示 2 月, 0 表示其它月份。分計(jì)數(shù)和時(shí)計(jì)數(shù)模塊的設(shè)計(jì)原理與秒模塊的類似。 25 end SEC。 b=m1。 end if。 end if。 else m0:=1001。 m1:=0101。139。 end if。039。 m1:=0000。 m1:=m1+1。 if m01001 then m0:=m0+1。139。139。139。039。139。 elsif clk39。 ca=39。 then m0:=0000。 begin if res=39。 end miao。 a,b:out std_logic_vector(3 downto 0)。 use 。秒計(jì)數(shù)模塊的程序如下: library ieee。 圖 49 鍵盤接口連接框圖 23 計(jì)數(shù)模塊設(shè)計(jì)與實(shí)現(xiàn) 秒計(jì)數(shù)模塊 秒計(jì)數(shù)模塊邏輯框圖如圖 410 所示。 程序中采用 case 語句進(jìn)行按鍵編碼,也可以用 elsif 語句實(shí)現(xiàn)此段程序設(shè)計(jì)。 end process。 end case。 when 01111011=key_code=1110。 when 01111110=key_code=1100。 when 10111011=key_code=1010。 when 10111110=key_code=1000。 when 11011011=key_code=0110。 22 when 11011110=key_code=0100。 when 11101011=key_code=0010。)then case scan_code is when 11101110=key_code=0000。event and clky=39。 end jmzh。 scan_code:in std_logic_vector(7 downto 0)。 use 。 use 。模塊主要完成從鍵掃描碼到按鍵編碼的轉(zhuǎn)換。 最后一個(gè)進(jìn)程就是給鍵碼信號(hào)賦值的過程。