Skip to content

Instantly share code, notes, and snippets.

@jpf91
Created May 23, 2025 11:21
Show Gist options
  • Save jpf91/31e596ab72b07921fb3f1c1265c0d495 to your computer and use it in GitHub Desktop.
Save jpf91/31e596ab72b07921fb3f1c1265c0d495 to your computer and use it in GitHub Desktop.
Simple counter in VHDL
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity Counter is
port (
clk: in std_logic;
rst: in std_logic;
count: out std_logic_vector(3 downto 0)
);
end;
architecture Behavioral of Counter is
signal value: unsigned(3 downto 0);
begin
process (clk)
begin
if (rising_edge(clk)) then
if (rst = '1') then
value <= x"0";
else
value <= value + x"1";
end if;
end if;
end process;
count <= std_logic_vector(value);
end;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment