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.

73 lines
1.6 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_neorv32_aes is
  6. end entity tb_neorv32_aes;
  7. architecture sim of tb_neorv32_aes is
  8. constant c_baudrate : natural := 9600;
  9. constant c_period_ns : time := 1000000000 / c_baudrate * ns;
  10. procedure uart_send ( data : in std_logic_vector(7 downto 0);
  11. signal tx : out std_logic) is
  12. begin
  13. report "UART send: 0x" & to_hstring(data);
  14. tx <= '0';
  15. wait for c_period_ns;
  16. for i in 0 to 7 loop
  17. tx <= data(i);
  18. wait for c_period_ns;
  19. end loop;
  20. tx <= '1';
  21. wait for c_period_ns;
  22. end procedure;
  23. procedure uart_recv ( data : out std_logic_vector(7 downto 0);
  24. signal rx : in std_logic) is
  25. begin
  26. wait until not rx;
  27. wait for c_period_ns; -- Skip start bit
  28. wait for c_period_ns/2;
  29. for i in 0 to 7 loop
  30. data(i) := rx;
  31. wait for c_period_ns;
  32. end loop;
  33. report "UART recv: 0x" & to_hstring(data);
  34. end procedure;
  35. signal s_clk : std_logic := '1';
  36. signal s_rst_n : std_logic := '0';
  37. signal s_len_n : std_logic_vector(7 downto 0);
  38. signal s_debug : std_logic_vector(15 downto 0);
  39. begin
  40. dut : entity work.neorv32_aes
  41. port map (
  42. clk_i => s_clk,
  43. rst_n_i => s_rst_n,
  44. --
  45. led_n_o => s_len_n,
  46. --uart_tx_o => s_uart_tx
  47. --uart_rx_i => s_uart_rx
  48. debug_o => s_debug
  49. );
  50. s_rst_n <= '1' after 120 ns;
  51. s_clk <= not s_clk after 50 ns;
  52. process is
  53. begin
  54. wait for 2 ms;
  55. stop(0);
  56. end process;
  57. end architecture;