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.

49 lines
1.1 KiB

  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 120 ns;
  19. s_clk <= not s_clk after 50 ns;
  20. -- Let's test one complete rotate of LED output
  21. TestP : process is
  22. variable v_led_n : std_logic_vector(s_led_n'range) := x"FE";
  23. begin
  24. wait until s_rst_n;
  25. wait until rising_edge(s_clk);
  26. for i in 0 to 7 loop
  27. report "LED: " & to_hstring(s_led_n);
  28. assert s_led_n = v_led_n
  29. report "LED error, got 0x" & to_hstring(s_led_n) & ", expected 0x" & to_hstring(v_led_n)
  30. severity failure;
  31. wait until s_led_n'event;
  32. v_led_n := v_led_n(6 downto 0) & v_led_n(7);
  33. end loop;
  34. report "Simulation finished :-)";
  35. stop(0);
  36. end process;
  37. end architecture;