--clockdiv.vhd ---------------------------------------------------- --divides down the system clock for slower clockrates ---------------------------------------------------- -- borrowed from traffic light example in EE552 class -- notes LIBRARY ieee; use ieee.std_logic_1164.all; use ieee.std_logic_arith.all; use ieee.std_logic_unsigned.all; ENTITY clkdiv IS -- default to .75H -- 25.175 MHz/ (2**24) /2 Generic (Divisor1: positive :=33554432 ; -- clock for sending Divisor2: positive :=33554432 ); -- clock for receiving PORT(fast_clock : IN STD_LOGIC; reset : IN STD_LOGIC; slow_clock1 : BUFFER STD_LOGIC; slow_clock2: BUFFER STD_LOGIC); END clkdiv; ARCHITECTURE behaviour OF clkdiv IS BEGIN clock_divider: process (fast_clock) is variable c1:natural range 0 to Divisor1; variable c2:natural range 0 to Divisor2; BEGIN if fast_clock'EVENT and fast_clock = '1' then IF reset ='1' THEN c1:= 0; c2:= 0; slow_clock1 <= '0'; ELSE c1 := (c1 + 1); c2 := (c2 +1); IF c1=Divisor1 THEN slow_clock1 <= not slow_clock1; c1 := 0; elsif c2 = Divisor2 then slow_clock2 <= not slow_clock2; c2:= 0; END IF; END IF; end if; END PROCESS clock_divider; END behaviour;