设计输入(VHDL)
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity counter is
Port ( rst: in std_logic;
clk : in std_logic;
clkout : out std_logic_vector(3 downto 0)
);
end counter; architecture Behavioral of counter is
signal temp: std_logic_vector(31 downto 0);
begin
process (clk)
begin
if rst='0' then
temp <= (others=>'0');
clkout <= (others=>'0');
elsif clk='0' and clk'event then
temp <= temp + 1;
clkout <= temp(3 downto 0);
end if;
end process;