1. library ieee;
  2. use ieee.std_logic_1164.all;
  3. use ieee.numeric_std.all;
  4. entity key_expansion_tb is
  5. end key_expansion_tb;
  6. architecture tb of key_expansion_tb is
  7. component key_expansion
  8. port (CLK : in std_logic;
  9. key_load : in std_logic;
  10. key : in std_logic_vector (127 downto 0);
  11. xkey0 : out std_logic_vector (31 downto 0);
  12. xkey1 : out std_logic_vector (31 downto 0);
  13. xkey2 : out std_logic_vector (31 downto 0);
  14. xkey3 : out std_logic_vector (31 downto 0));
  15. end component;
  16. -- Input
  17. signal CLK : std_logic;
  18. signal key_load : std_logic;
  19. signal key : std_logic_vector (127 downto 0) := x"10_11_12_13_14_15_16_17_18_19_1a_1b_1c_1d_1e_1f";
  20. -- Output
  21. signal xkey0 : std_logic_vector (31 downto 0);
  22. signal xkey1 : std_logic_vector (31 downto 0);
  23. signal xkey2 : std_logic_vector (31 downto 0);
  24. signal xkey3 : std_logic_vector (31 downto 0);
  25. constant TbPeriod : time := 10 ns; -- EDIT put right period here
  26. signal TbClock : std_logic := '0';
  27. begin
  28. dut : key_expansion
  29. port map (CLK => CLK,
  30. key_load => key_load,
  31. key => key,
  32. xkey0 => xkey0,
  33. xkey1 => xkey1,
  34. xkey2 => xkey2,
  35. xkey3 => xkey3);
  36. TbClock <= not TbClock after TbPeriod/2;
  37. -- EDIT: Check that CLK is really your main clock signal
  38. CLK <= TbClock;
  39. stimuli : process
  40. begin
  41. key_load <= '0';
  42. wait for 20 ns;
  43. key_load <= '1';
  44. wait for 10 ns;
  45. key_load <= '0';
  46. wait for 500 ns;
  47. --wait;
  48. report "End of Simulation" severity failure;
  49. --finish(2);
  50. end process;
  51. end tb;

key_expansion_tb.vhd