hour.vhd

来自「利用一块芯片完成除时钟源、按键、扬声器和显示器(数码管)之外的所有数字电路功能。」· VHDL 代码 · 共 54 行

VHD
54
字号
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity hour is
port(clk,clr,set1,set0:in std_logic;
     co:buffer std_logic;
     ge,shi:buffer std_logic_vector(3 downto 0));
end;
architecture hour_1 of hour is
begin 
process(clk,clr)
begin
if clr='0' then
	ge<="0000";
	shi<="0000";
    co<='0';
 elsif clk'event and clk='0' then 

  if set1='0' then
    if shi="1001" then
       shi<="0000";
     else shi<=shi+'1';
    end if;
  elsif set0='0' then
    if ge="1001" then
       ge<="0000";
     else ge<=ge+'1';
    end if;


  elsif ge="0100" and shi="0010" then
     co<='0';
     ge<="0000";
	 shi<="0000";
    elsif ge="0010" and shi="0001" then
      co<='1';
      ge<=ge+'1';
      elsif ge="1001" then
        shi<=shi +'1';
        ge<="0000";
      else ge<=ge+'1';
   end if;
end if;

end process;
end;

      
 

 


⌨️ 快捷键说明

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