【正文】
end process。 thenQ1=keyin。s2=1111。 when 1000=dout=01111111。 when 0001=dout=00000110。 end case。3 when 0100=dout=11100110。 end if。event and clk1=39。 end if。end process h110。speak=clk。 elsif (min2=1001and (sec1=0101 and sec2=1001)) or (min2=1001and cj=011 and cj=100)then min1=min1+1。event and clk1=39。 if cj=001 then sec2=0000。 end if。 counf=counf+1。小時的個位 signal min1:std_logic_vector(3 downto 0)。 use 。當(dāng)分計時器min為0時,alarm輸出一個高電平,持續(xù)直到分計時器min的值為1。其中計時模塊有4部分構(gòu)成:秒計時器(second1)、分計時器(minute1)、時計時器(hour1)和星期計時器(day1)。數(shù)字鐘是一種用數(shù)字電路技術(shù)實(shí)現(xiàn)時、分、秒計時的裝置,與機(jī)械式時鐘相比具有更高的準(zhǔn)確性和直觀性,且無機(jī)械裝置,具有更更長的使用壽命,因此得到了廣泛的使用。方案二:采用AT89C52單片機(jī)、數(shù)碼管設(shè)計數(shù)字鐘 方案二電路圖本方案采用AT89C52單片機(jī),單片機(jī)的P1口接數(shù)碼管顯示電路,P0口接鍵控制數(shù)碼管的顯示,RESET接入復(fù)位和晶振電路。清0端(reset)前面一小段(200ns)為低電平,后面均為高電平;設(shè)置min的值,使其分別為……58分、59分、00分、01分、02分、03分……,保存波形圖,進(jìn)行仿真,產(chǎn)生如下波形:見由上述波形可以清楚的看到:alarm在0分時輸出高電平,并且持續(xù)至1min不為0。附件程序: library ieee。 signal sel:std_logic_vector(2 downto 0)。秒的十位 signal s2:std_logic_vector(3 downto 0)。1000HZ counf=0。 else sec2=sec2+1。 秒十位復(fù)位 end if。139。md=39。 end if。139。 end if。 else speak=39。0 when 0001=dout=10000110。 when 0100=dout=01100110。 end case。 when 0101=dout=11101101。 m1=setm1。quout:process(CP_5ms,keyin)beginif CP_5ms39。elsekeyout=39。 end if。end if。yanshi:process(clk)variable fp:integer range 0 to 29999。 end case。 when 0100=dout=01100110。 when 0001=dout=10000110。6 when 0111=dout=10000111。 end if。 elsif cj=101 then setm2=setm2+1。 end if。139。 if cj=001 then hou2=0000。end if。 elsif min2=1001and (cj=011 and cj=100)then min2=0000。秒十位s110:process(clk1,cj) begin if clk139。位掃描choice:process(clkk)位選 掃描 begin if rising_edge(clkk)then if sel=111 then sel=000。1Hz count=0。秒的十位 signal sec2:std_logic_vector(3 downto 0)。 speak:out std_logic。特別是當(dāng)每一個子模塊編寫調(diào)試成功時,心里特別的開心。1)、分頻器模塊 其實(shí)是一個計數(shù)器,外加信號頻率為12MHZ時,在內(nèi)部定義了一個信號從0到11999999的整數(shù)型計數(shù)信號count1,當(dāng)內(nèi)部信號計數(shù)為11999999時,count1計數(shù)為0,產(chǎn)生進(jìn)位信號CLK1為1,當(dāng)內(nèi)部信號計數(shù)為11999時,countf計數(shù)為0,產(chǎn)生進(jìn)位信號CLK1為1,.2) 、秒計數(shù)模塊 內(nèi)部定義時鐘其余時刻均為為秒計時器(second1)是由一個60進(jìn)制的計數(shù)器構(gòu)成的,具有清0、置數(shù)和計數(shù)功能。1.1.2要求(1)基本要求①計時功能:這是數(shù)字鐘的基本功能,每隔一秒鐘計時一次,并在顯示屏上顯示當(dāng)前時間。時間計數(shù)電路由秒個位和秒十位計數(shù)器、分個位和分十位計數(shù)器及時個位和時十位計數(shù)器電路構(gòu)成,其中秒個位和秒十位計數(shù)器、分個位和分十位計數(shù)器為60進(jìn)制計數(shù)器,而根據(jù)設(shè)計要求,時個位和時十位計數(shù)器為12進(jìn)制計數(shù)器。其中reset為清0信號,當(dāng)reset為0時,時計時器清0;set 為置數(shù)信號,當(dāng)set為0時,時計時器置數(shù),置h1的值。 附:參考文獻(xiàn)黃仁欣主編《EDA技術(shù)實(shí)訓(xùn)教程》,清華大學(xué)出版社,2006年第2版。 SIGNAL Q1,Q2,Q3: STD_LOGIC。小時的個位 signal m1:std_logic_vector(3 downto 0)。 end if。139。 end if。 end process m220。 then if (hou1=0010 and hou2=0011)and(min1=0101 and min2=1001) and (sec1=0101 and sec2=1001) then hou2=0000。 elsif hou1=0010and hou2=0011and cj=110 then當(dāng)時間為23點(diǎn)且處于校時狀態(tài)時 hou1=0000。end pr