【正文】
圖 21 秒計(jì)數(shù)器實(shí)體圖 7 library ieee。 秒計(jì)數(shù)器 use 。 use 。 entity miao is port(clk,rest:in std_logic。 時(shí)鐘、復(fù)位 miao_diwei,miao_gaowei:out std_logic_vector(3 downto 0)。 miao_out:out std_logic)。 秒進(jìn)位輸出 end miao。 architecture one of miao is signal miao_bian1,miao_bian2:std_logic_vector(3 downto 0)。 定義兩個(gè)信號(hào) begin process(clk,rest) begin if rest=39。039。then miao_bian1=0000。 低位 miao_bian2=0000。 高位 elsif clk39。event and clk=39。139。 then 上升沿 8 if miao_bian1=1001then 秒低位到 9 時(shí)清零 miao_bian1=0000。 if miao_bian2=0101then 秒高位到 5 時(shí)清零 miao_bian2=0000。 else miao_bian2=miao_bian2+1。 秒高位沒(méi)到 5 時(shí)加 1 end if。 else miao_bian1=miao_bian1+1。 秒低位沒(méi)到 9 時(shí)加 1 end if。 if miao_bian1=1001 and miao_bian2=0101then 秒位到 59 時(shí)進(jìn)位分低位 miao_out=39。139。 else miao_out=39。039。 end if。 end if。 9 end process。 miao_diwei=miao_bian1。 秒低位輸出 miao_gaowei=miao_bian2。 秒高位輸出 end one。 秒的仿真波形如圖 22 圖 22 秒的仿真波形 分計(jì)數(shù)器模塊 圖 31 分計(jì)數(shù)器實(shí)體圖 10 library ieee。 原理同秒計(jì)數(shù)器的一樣 use 。 use 。 entity fen is port(clk,rest:in std_logic。 fen_diwei,fen_gaowei:out std_logic_vector(3 downto 0)。 fen_out:out std_logic)。 end fen。 architecture two of fen is signal fen_bian1,fen_bian2:std_logic_vector(3 downto 0)。 begin process(clk,rest) begin if rest=39。039。then fen_bian1=0000。 fen_bian2=0000。 elsif clk39。event and clk=39。139。