counter104.vhd

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

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

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

architecture Behavioral of counter104 is

 begin
  process(set,clk,x,rd)
   variable cnt:std_logic_vector(3 downto 0);
 begin
    if rd='1' then cnt:="0000";y<="0000";c<='0';k<='0';
    elsif set='0' then 
            cnt:=x;
            y<=cnt;c<='0';k<='0';

    elsif clk'event and clk='1' then

           if cnt="1001" then
            cnt:="0000";y<=cnt;c<='1';k<='0';
           elsif cnt="0011" then cnt:=cnt+1;y<=cnt;c<='0';k<='1';
           else cnt:=cnt+1;y<=cnt;c<='0';k<='0';
           end if;
    end if;
 end process;
end Behavioral;

⌨️ 快捷键说明

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