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.

87 lines
1.9 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. library gatemate;
  7. use gatemate.components.all;
  8. entity blink is
  9. port (
  10. clk_i : in std_logic; -- 10 MHz clock
  11. rst_n_i : in std_logic; -- SW3 button
  12. led_n_o : out std_logic_vector(7 downto 0) -- LED1..LED8
  13. );
  14. end entity blink;
  15. architecture rtl of blink is
  16. signal s_pll_clk : std_logic;
  17. signal s_pll_lock : std_logic;
  18. signal s_clk_cnt : unsigned(19 downto 0);
  19. signal s_clk_en : boolean;
  20. signal s_rst_n : std_logic;
  21. signal s_cfg_end : std_logic;
  22. signal s_led : unsigned(led_n_o'range);
  23. begin
  24. pll : CC_PLL
  25. generic map (
  26. REF_CLK => "10",
  27. OUT_CLK => "1",
  28. PERF_MD => "SPEED"
  29. )
  30. port map (
  31. CLK_REF => clk_i,
  32. CLK_FEEDBACK => '0',
  33. USR_CLK_REF => '0',
  34. USR_LOCKED_STDY_RST => not rst_n_i,
  35. USR_PLL_LOCKED_STDY => open,
  36. USR_PLL_LOCKED => s_pll_lock,
  37. CLK270 => open,
  38. CLK180 => open,
  39. CLK0 => s_pll_clk,
  40. CLK90 => open,
  41. CLK_REF_OUT => open
  42. );
  43. cfg_end_inst : CC_CFG_END
  44. port map (
  45. CFG_END => s_cfg_end
  46. );
  47. s_rst_n <= rst_n_i and s_pll_lock and s_cfg_end;
  48. process (s_pll_clk, s_rst_n) is
  49. begin
  50. if (not s_rst_n) then
  51. s_clk_cnt <= (others => '0');
  52. elsif (rising_edge(clk_i)) then
  53. s_clk_cnt <= s_clk_cnt + 1;
  54. end if;
  55. end process;
  56. s_clk_en <= s_clk_cnt = (s_clk_cnt'range => '1');
  57. process (s_pll_clk, s_rst_n) is
  58. begin
  59. if (not s_rst_n) then
  60. s_led <= (others => '0');
  61. elsif (rising_edge(clk_i)) then
  62. if (s_clk_en) then
  63. s_led <= s_led + 1;
  64. end if;
  65. end if;
  66. end process;
  67. led_n_o <= not std_logic_vector(s_led);
  68. end architecture;