You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.1 KiB

  1. -- This design should display incrementing binary numbers
  2. -- at LED1-LED8 of the GateMate FPGA Starter Kit.
  3. library ieee ;
  4. use ieee.std_logic_1164.all;
  5. use ieee.numeric_std.all;
  6. entity blink is
  7. port (
  8. clk_i : in std_logic; -- 10 MHz clock
  9. rst_n_i : in std_logic; -- SW3 button
  10. led_n_o : out std_logic_vector(7 downto 0) -- LED1..LED8
  11. );
  12. end entity blink;
  13. architecture rtl of blink is
  14. signal s_clk_cnt : unsigned(19 downto 0);
  15. signal s_clk_en : boolean;
  16. signal s_led : unsigned(led_n_o'range);
  17. begin
  18. process (clk_i, rst_n_i) is
  19. begin
  20. if (not rst_n_i) then
  21. s_clk_cnt <= (others => '0');
  22. elsif (rising_edge(clk_i)) then
  23. s_clk_cnt <= s_clk_cnt + 1;
  24. end if;
  25. end process;
  26. s_clk_en <= s_clk_cnt = (s_clk_cnt'range => '1');
  27. process (clk_i, rst_n_i) is
  28. begin
  29. if (not rst_n_i) then
  30. s_led <= (others => '0');
  31. elsif (rising_edge(clk_i)) then
  32. if (s_clk_en) then
  33. s_led <= s_led + 1;
  34. end if;
  35. end if;
  36. end process;
  37. led_n_o <= not std_logic_vector(s_led);
  38. end architecture;