Created
May 23, 2025 11:21
-
-
Save jpf91/31e596ab72b07921fb3f1c1265c0d495 to your computer and use it in GitHub Desktop.
Simple counter in VHDL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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