【正文】
TIME is signal count:std_logic_vector(2 downto 0)。輸出 sel:out std_logic_vector(2 downto 0))。掃描時鐘 secm1,secm0,sec1,sec0,min1,min0,h1,h0:in std_logic_vector(3 downto 0)。 use 。 use 。 end hour_arc。 h0=t0。 end if。高位記數累加 end if。 else t0:=0000。高位 /低位同時為 0 時 t0:=0000。139。139。記數 begin if clk39。時高位 /低位 25 end HOUR。 entity HOUR is port(clk,en:in std_logic。 use 。 end MIN。 min0=t0。 end if。 end if。039。 else t1:=0000。 else t0:=0000。 t0:=1001。 then if t1=0101 and t0=1000 then co=39。 then if en=39。event and clk=39。 architecture MIN of MINUTE is begin process(clk) variable t1,t0:std_logic_vector(3 downto 0)。 24 co:out std_logic)。 entity MINUTE is port(clk,en:in std_logic。 use 。 end SEC。 sec0=t0。 end if。 end if。 co=39。 if t10101 then高位小于 5 時 t1:=t1+1。低位為 9 elsif t01001 then小于 9 時 t0:=t0+1。139。139。 elsif clk39。 then當 ckr 為 1 時,高低位均為 0 t1:=0000。計數 begin if clr=39。輸出 /進位信號 end SECOND。時鐘 /清零信號 sec1,sec0:out std_logic_vector(3 downto 0)。 use 。 秒模塊程序清單 library ieee。 end process。 secm1=t1。 end if。039。 else t1:=0000。 else t0:=0000。低位為 9 elsif t01001 then小于 9 時 t0:=t0+1。139。 end if。 then t0:=t0。 then 22 if stop=39。event and clk=39。 t0:=0000。139。 END IF。 DOUT2= NOT DOUT2。THEN IF COUNT2=0 AND COUNT210 THEN COUNT2:=COUNT2+1。EVENT AND CLK=39。計數 VARIABLE COUNT2 :INTEGER RANGE 0 TO 10 。 architecture SEC of MINSECONDb is signal clk1,DOUT2:std_logic。秒高位 /低位 co:out std_logic)。 entity MINSECONDb is port(clk,clrm,stop:in std_logic。 use 。 =============================================================================================================================================================================================================== 分頻 模塊 采用原理圖輸入方式實現 2 分頻與 1000 分頻,但這里并沒有用到 1000 分頻,因為后來考慮到精度問題,將千分頻用直接輸入了。 end process disp。s2=1111。m2=setm2。h2=seth2。s2=sec2。m2=min2。h2=hou2。039。 20 end if。 when others=dout=1000000。 when 1000=dout=1111111。 when 0110=dout=1111101。 when 0100=dout=1100110。 when 0010=dout=1011011。 case s2 is when 0000=dout=0111111。 end case。 when 0101=dout=1101101。 when 0011=dout=1001111。 when 0001=dout=0000110。 elsif sel=100 then selout=100。 when others=dout=1000000。 when 1000=dout=1111111。 when 0110=dout=1111101。 when 0100=dout=1100110。 when 0010=dout=1011011。 case m2 is when 0000=dout=0111111。 end case。 when 0101=dout=1101101。 when 0011=dout=1001111。 18 when 0001=dout=0000110。 elsif sel=010 then selout=010。 when others=dout=1000000。 when 1000=dout=1111111。 when 0110=dout=1111101。 when 0100=dout=1100110。 when 0010=dout=1011011。 case h2 is when 0000=dout=0111111。 end case。 when 0010=dout=1011011。 case h1 is when 0000=dout=0111111。 end process speaker。 end if。 else speak=39。139。 鬧鈴 speaker:process(clk1,hou1,hou2,min1,min2) begin if clk139。 end if。 and md2=01then setm2=setm2+1。 16 elsif md1=39。139。 setmin2:process(clk,md1,md2) begin if clk39。 end if。 elsif setm2=1001then setm1=setm1+1。139。 時間設置分鐘部分 setmin1:process(clk,setm2) begin if clk39。 end if。 and md2=00 then seth2=seth2+1。 elsif md1=39。139。 sethour2:process(clk,md1,md2,seth1) begin if clk39。 end if。 elsif seth2=1001 then seth1=seth1+1。139。 時間設置小時部分 sethour1:process(clk,seth2) begin if clk39。 end if。 else sec2=sec2+1。139。 秒個位 14 s220:process(clk) begin if clk39。end if。 end if。 then if (sec1=0101 and sec2=1001)then sec1=0000。event and clk=39。 end process m220。 end if。 and md2=00)then min2=min2+1。 else if (sec1=0101 and sec2=1001) or(md1=39。039。 then if min2=1001and (sec1=0101 and sec2=1001)then min2=0000。event and clk=39。 end process m110。 end if。 and md2=00)then min1=min1+1。 elsif (min2=1001and (sec1=0101 and sec2=1001)) or (min2=1001and md1=39。039。 then if (min1=0101 and min2=1001) and (sec1=0101 and sec2=1001) then min1=0000。event and clk=39。 end process h220。 end if。 and md2=01) then hou2=hou2+1。 elsif ((min1=0101 and min2=1001) and (sec1=0101 and sec2=1001))or (md1=39。md=39。039。 elsif hou2=1001and(min1=0101 and min2=1001) and (sec1=0101 and sec2=1001) then hou2=0000。139。 小時個位 h220:process(clk,min1,min2,sec1,sec2,md1,md2,hou1) begin if clk39。 end if。 and md2=01) then hou1=hou1+1。 elsif (hou2=1001and(min1=0101 and min2=1001) and (sec1=0101 and sec2=1001))or (hou2=1001and md1=39。039。 then if (hou1=0010 and hou2=0011)and(min1=0101 and min2=1001) and (sec1=0101 and sec2=1001) then hou1=0000。event and clk=39。 end process choice。 end if。 then if sel=101 then sel=000。event and clk1=39。 signal s2:std_logic_vector(3 downto 0)。 signal m2:std_logic_vector(3 downto 0)。 signal h2:std_logic_vector(3 downto 0)。 signal sec2:std_logic_vector(3 downto 0)。 signal setm2:std_logic_vector(3 downto 0)。 signal seth2:std_logic_vector(3 downto 0)。 signal min2:std_logic_vector(3 downto 0)。 signal hou2:std_logic_vector(3 downto 0)。 architecture one of szz is signal sel:std_logic_vector(2 downto 0)。 selout:out std_logic_vector(2 downto 0))。 speak:out std_logic。 md1:in std_logic。 entity szz is port(clk:in std_logic。 use 。 圖 8 校時電路 (六)調 試 畢滿清等 .電子技術實驗與課程設計 .北京 :機械工業(yè)出 版社 ,~132 這本書上很全 =============================================================================================================================================================================================================、 時鐘 vhdl vhdl 與數字電路設計 vhdl數字系統(tǒng)設計 vhdl 數