⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 count24.vhd

📁 很好的多功能数字钟的HDL代码不可多得的哦
💻 VHD
字号:
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity count24 is
  port(cout:out std_logic;
        en:in std_logic;
       ten,one:out std_logic_vector(3 downto 0);
       clk,clr:in std_logic);
end count24;
architecture a of count24 is
   signal cin:std_logic;
begin 
process(clk,clr)
  variable cnt0:std_logic_vector(3 downto 0);
begin
 if clr='1'then
 cnt0:="0000";
 elsif clk'event and clk='1'then
   if (en='1')then
   if cnt0="0011"then
      cin<='1' ;
      cnt0:="0000";
   else cnt0:=cnt0+1; cin<='0';
    end if;
  end if;
end if;
  one<=cnt0;
 end process;
process (clk,clr,cin)
  variable cnt1: std_logic_vector(3 downto 0);
begin
 if clr='1'then
   cnt1:="0000";
 elsif clk'event and clk='1'then
    if cin='1'then
      if cnt1="0010"then
        cnt1:="0000";cout<='1';
       else cnt1:=cnt1+1; cout<='0';
     end if;
    end if;
   else cnt1:=cnt1;
  end if;
ten<=cnt1;
end process;
end a;
      

⌨️ 快捷键说明

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