X-Git-Url: https://git.zerfleddert.de/cgi-bin/gitweb.cgi/raggedstone/blobdiff_plain/9b5ba4276eca69f6fd5a942317c2ae614ed2bad2..152884e67f2cea6ff9f5787eab6c72dcffe484e4:/heartbeat/source/heartbeat.vhd diff --git a/heartbeat/source/heartbeat.vhd b/heartbeat/source/heartbeat.vhd new file mode 100644 index 0000000..76f084d --- /dev/null +++ b/heartbeat/source/heartbeat.vhd @@ -0,0 +1,39 @@ +library ieee; + +use ieee.std_logic_1164.all; +use ieee.std_logic_unsigned.all; + +entity heartbeat is +generic ( + divider : integer := 33000000 +); + +port ( + clk_i : in std_logic; + nrst_i : in std_logic; + led_o : out std_logic +); + +end heartbeat; + +architecture rtl of heartbeat is +begin + +process(clk_i, nrst_i) +variable counter : std_logic_vector(31 downto 0); +variable state : std_logic := '0'; +begin + +if (clk_i'event AND clk_i = '1') then + if nrst_i = '0' then + counter := (others => '0'); + else + led_o <= state; + counter := counter + 1; + if counter = divider then + state := not state; + end if; + end if; +end if; +end process; +end architecture;