counter6.vhd

来自「采用VHDL语言设计了一个打铃系统。该系统已经调试」· VHDL 代码 · 共 31 行

VHD
31
字号
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;

entity counter6 is
    Port ( set : in std_logic;
           clk : in std_logic;
           x : in std_logic_vector(3 downto 0);
           y : out std_logic_vector(3 downto 0);
           c : out std_logic);
end counter6;

architecture Behavioral of counter6 is

  begin
    process(set,clk,x)
      variable cnt:std_logic_vector(3 downto 0);
  begin
     if set='0' then 
          cnt:=x;
          y<=cnt;c<='0';
     elsif clk'event and clk='1' then
           if cnt="0101" then
                cnt:="0000";y<=cnt;c<='1';
           else cnt:=cnt+1;y<=cnt;c<='0';
           end if;
     end if;
  end process;
end Behavioral;

⌨️ 快捷键说明

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