summaryrefslogtreecommitdiff
path: root/VHDL/counter.vhdl
blob: 8d1d52ef811f49072596d8ad154829240790e799 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
library ieee ;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;

entity counter is 
port(  clk:  in std_logic_vector(0 downto 0);
  reset:  in std_logic_vector(0 downto 0);
  count:  out std_logic_vector(3 downto 0)
);
end counter;

architecture behav of counter is         
  signal pre_count: unsigned(3 downto 0);
  
  begin
    process(clk,reset)
    begin
      if reset = "1" then
        pre_count <= "0000";
      elsif (clk= "1" and clk'event) then
          pre_count <= pre_count +1;
      end if;	
    end process; 
 
    count <= std_logic_vector(pre_count);
end behav;