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