counter.vhd

来自「脉冲发生器」· VHDL 代码 · 共 38 行

VHD
38
字号
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity counter is
port(
   clk:   in std_logic;
   enable:    in std_logic;
   load:  in std_logic;
   co:  out std_logic;
   data:    in std_logic_vector(7 downto 0);
   q:    buffer std_logic_vector(7 downto 0)
   );
end counter;
architecture counter_behave of counter is
signal pulse:   std_logic;
begin
process(clk,enable)
begin
  if load='1' then
    q<=data;
  else if rising_edge(clk) then
    if enable='1' then
      q<=q-1;
    else
      q<=q;
    end if;
    if q="00000000" then
     q<="00000000";
     pulse<='1';
    else
     pulse<='0';
    end if;
  end if;
  end if;
end process;
co<=pulse;
end counter_behave;

⌨️ 快捷键说明

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