Code · 1 file

Sample VHDL File

VHDL hardware description: a generic counter with synchronous reset. Every language sample implements the same small program so you can compare them side by side.

VHDL · 920 B

Sample VHDL file

An idiomatic VHDL example — the same customer program (or, for hardware languages, a small counter design) we offer in every language.

CC0 · free for any use · Verified by an independent tool · Report a problem

counter.vhd — first linesVHDL
-- Sample VHDL — samplefiles.com
-- An up-counter with synchronous reset, enable and an overflow flag.
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;

entity counter is
  generic (WIDTH : positive := 8);
  port (
    clk      : in  std_logic;
    rst      : in  std_logic;
    en       : in  std_logic;
    count    : out unsigned(WIDTH - 1 downto 0);
    overflow : out std_logic
  );
end entity counter;

architecture rtl of counter is
  constant MAX_VALUE : unsigned(WIDTH - 1 downto 0) := (others => '1');
  signal value : unsigned(WIDTH - 1 downto 0) := (others => '0');
begin
  process (clk)
  begin
    if rising_edge(clk) then
      if rst = '1' then

File details

Size
920 B (920 bytes)
MIME type
text/x-vhdl
SHA-256
c86eebac5f76dbc355f1c4b9a71e194786c11cecf0b46d4d79a5c80e69d72393
MD5
d80688ae8ec0396b67e40510fe538ed9

Download from the command line

curl -L -o counter.vhd https://files.samplefiles.com/code/vhd/counter.vhd

Or check the download in your browser with the checksum calculator.