-- divider.vhd: 1.8432 MHz to 1 Hz clock divider -- Dan R. K. Ports -- 6.111 Lab 2, 2003/10/01 library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity divider is port ( clk, rst : in std_logic; longclk : out std_logic); end divider; architecture behavioral of divider is signal longclkstate : std_logic := '0'; signal count : std_logic_vector(24 downto 0); begin -- behavioral -- purpose: generate output pulse when counter reaches 1000000 -- type : sequential -- inputs : clk, rst -- outputs: longclk process (clk, rst) begin -- process if rst = '1' then -- asynchronous reset (active high) count <= (others => '0'); elsif clk'event and clk = '1' then -- rising clock edge count <= count + 1; if count = 1843199 then longclkstate <= '1'; elsif count = 1843200 then count <= (others => '0'); longclkstate <= '0'; end if; end if; end process; longclk <= longclkstate; end behavioral;