aboutsummaryrefslogtreecommitdiff
path: root/src/cnt1sec.vhd
blob: 14fad687708c9f8d6d66c3ceb07eb0d300650b88 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;

entity cnt1sec is
  port (
    clk   : in std_ulogic;
    rst_n : in std_ulogic;
    en_o  : out std_ulogic);
end entity;

architecture rtl of cnt1sec is
  signal cnt, ncnt : unsigned(25 downto 0);
begin
  cnt <= (others => '0') when rst_n = '0' else ncnt when rising_edge(clk);
  ncnt <= to_unsigned(0,cnt'length) when cnt = 4 else
          cnt + 1;
  en_o <= '1' when cnt = 0 else '0';
end architecture rtl;