For a timer of 20 seconds.
I wrote the following code, however the code still gives me the OUTPUT as always high.
The clock used is 50 MHz ( 20 ns ) and therefore I seek to count till 10^9 to obtain 20 seconds.
Below is the code -
---------------------------------------
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.numeric_std.all;
entity timer is
port ( clk : in std_logic ; q : buffer bit );
end entity;
architecture Behavioral of timer is
begin
process(clk)
variable cnt, cnt1: integer range 0 to 10**9 := 0 ;
constant int: integer := (10**6)+1 ;
begin
if rising_edge(clk) then cnt := (cnt + 1)mod int;
if cnt = 10**6 then cnt1 := (cnt1 + 1) mod 1001;
end if;
end if;
if cnt1 = 1000 then q <= '1' ;
end if ;
end process;
end behavioral;
Please help.