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.

45 lines
962 B

  1. library ieee ;
  2. use ieee.std_logic_1164.all;
  3. use ieee.numeric_std.all;
  4. use std.env.all;
  5. entity tb_blink is
  6. end entity tb_blink;
  7. architecture sim of tb_blink is
  8. signal s_clk : std_logic := '1';
  9. signal s_rst_n : std_logic := '0';
  10. signal s_led_n : std_logic_vector(7 downto 0);
  11. begin
  12. dut : entity work.blink
  13. port map (
  14. clk_i => s_clk,
  15. rst_n_i => s_rst_n,
  16. led_n_o => s_led_n
  17. );
  18. s_rst_n <= '1' after 1.2 us;
  19. s_clk <= not s_clk after 500 ns;
  20. -- Let's test the first 8 values of LED output
  21. process is
  22. begin
  23. wait until s_rst_n;
  24. wait until rising_edge(s_clk);
  25. for i in 0 to 7 loop
  26. report "LED: " & to_hstring(not s_led_n);
  27. assert to_integer(unsigned(not s_led_n)) = i
  28. report "LED error, got 0x" & to_hstring(s_led_n) & ", expected 0x" & to_hstring(to_unsigned(255-i, 8))
  29. severity failure;
  30. wait until s_led_n'event;
  31. end loop;
  32. stop(0);
  33. end process;
  34. end architecture;