hour.vhd

来自「VHDL编写的数字钟」· VHDL 代码 · 共 67 行

VHD
67
字号
-----------------------------------------------------
--author:  Suntion Tang  Weixuan Yuan
--date:    2008-5-15 to  5-20
--modify:  By suntion Tang
-----------------------------------------------------


library ieee;
use ieee.std_logic_1164.all; 
use ieee.std_logic_unsigned.all;
entity hour is
    port (clk : in std_logic;                     
          h_overflow: out std_logic;                                     
          h_dspl : out std_logic_vector(3 downto 0);  
          h_dsph : out std_logic_vector(3 downto 0) );          
   end ;
architecture behav of hour is 
    signal sec1: std_logic_vector(3 downto 0); 
    signal sec2 : std_logic_vector(3 downto 0); 
begin
---------------------------------------------hour high bit

s1:process(clk,sec1,sec2)

begin

if clk'event and clk='1' then

if (sec1="0010" and sec2="0011")then

sec1<="0000";

else if sec2="1001"then

sec1<=sec1+1;

end if;

end if;
end if;
         if (sec1="0010" and sec2="0011") then h_overflow<='1';
           else h_overflow<='0';
         end if;
  h_dsph<=sec1;

end process s1;

--------------------------------------------hour low bit

s2:process(clk,sec2,sec1)

begin

if clk'event and clk='1' then

if (sec2="1001" or (sec1="0010" and sec2="0011")) then sec2<="0000" ;


else sec2<=sec2+1;

end if;
end if;
  h_dspl<=sec2;
end process s2;

end;

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?