counter2.vhd

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

VHD
31
字号
-------------------------------fenpinqi----------------------------------
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_arith;
entity counter2 is 
port(clk: in std_logic;
      en: in std_logic;
      output: out std_logic);
end counter2;
architecture a of counter2 is
signal temp:std_logic_vector(3 downto 0);
begin
p1:process(clk)
  begin
    if(temp="0001")then output<='0';
     else output<='1';
     end if;
  end process;
 p2:process(clk,en)
  begin 
     if(en='1')then temp<="0000";
     elsif(clk'event and clk='1')then 
      if(temp="0001")then temp<="0000";
       else temp<=temp+1;
      end if; 
     end if;
   end process;   
end a;

⌨️ 快捷键说明

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