counter24.vhd

来自「VHDL的数字电子钟程序」· VHDL 代码 · 共 33 行

VHD
33
字号
------------------------------shijian-----------------------
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_arith;
entity counter24 is 
port(clk: in std_logic;
      en: in std_logic;
      co: out std_logic;
      high: out std_logic_vector(3 downto 0);
      low:  out std_logic_vector(3 downto 0));
end counter24;
architecture a of counter24 is
signal high1,low1:std_logic_vector(3 downto 0);
begin
 process(clk,en)
  begin 
    if(en='1')then low1<="0000";
                   high1<="0000";
     elsif(clk'event and clk='1')then 
      if(high1="0010" and low1="0011")then high1<="0000";
                                           low1<="0000";
                                           co<='1';
        elsif(low1="1001")then  low1<="0000";
                               high1<=high1+1;
          else low1<=low1+1;co<='0';
       end if;
    end if;
    high<=high1; low<=low1;
  end process;   
end a;

⌨️ 快捷键说明

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