1. library ieee;
  2. use ieee.std_logic_1164.all;
  3. use ieee.numeric_std.all;
  4. entity round_constant is
  5. port
  6. (
  7. CLK : in std_logic;
  8. key_load: in std_logic;
  9. rcon: out std_logic_vector(31 downto 0)
  10. );
  11. attribute SIGIS : string;
  12. attribute SIGIS of CLK : signal is "Clk";
  13. end round_constant;
  14. architecture EXAMPLE of key_expansion is
  15. signal rcnt_next, rcnt: integer := 0;
  16. signal rcon : std_logic_vector(31 downto 0) := (OTHERS => '0');
  17. begin
  18. process(clk)
  19. begin
  20. if rising_edge(clk) then
  21. if(key_load = '1') then
  22. rcon <= x"01000000";
  23. rcnt <= 0;
  24. else
  25. rcnt <= rcnt_next;
  26. end if;
  27. end if;
  28. end process;
  29. rcnt_next <= rcnt + 1;
  30. process(rcnt_next)
  31. begin
  32. case(rcnt_next) is
  33. when 0 => rcon <= x"01_00_00_00";
  34. when 1 => rcon <= x"02_00_00_00";
  35. when 2 => rcon <= x"04_00_00_00";
  36. when 3 => rcon <= x"08_00_00_00";
  37. when 4 => rcon <= x"10_00_00_00";
  38. when 5 => rcon <= x"20_00_00_00";
  39. when 6 => rcon <= x"40_00_00_00";
  40. when 7 => rcon <= x"80_00_00_00";
  41. when 8 => rcon <= x"1b_00_00_00";
  42. when 9 => rcon <= x"36_00_00_00";
  43. when OTHERS => rcon <= x"00_00_00_00";
  44. end case;
  45. end process;
  46. end architecture EXAMPLE;

round_constant.vhd