- library ieee;
- use ieee.std_logic_1164.all;
- use ieee.numeric_std.all;
- entity round_constant is
- port
- (
- CLK : in std_logic;
- key_load: in std_logic;
- rcon: out std_logic_vector(31 downto 0)
- );
- attribute SIGIS : string;
- attribute SIGIS of CLK : signal is "Clk";
- end round_constant;
- architecture EXAMPLE of key_expansion is
- signal rcnt_next, rcnt: integer := 0;
- signal rcon : std_logic_vector(31 downto 0) := (OTHERS => '0');
- begin
- process(clk)
- begin
- if rising_edge(clk) then
- if(key_load = '1') then
- rcon <= x"01000000";
- rcnt <= 0;
- else
- rcnt <= rcnt_next;
- end if;
- end if;
- end process;
- rcnt_next <= rcnt + 1;
- process(rcnt_next)
- begin
- case(rcnt_next) is
- when 0 => rcon <= x"01_00_00_00";
- when 1 => rcon <= x"02_00_00_00";
- when 2 => rcon <= x"04_00_00_00";
- when 3 => rcon <= x"08_00_00_00";
- when 4 => rcon <= x"10_00_00_00";
- when 5 => rcon <= x"20_00_00_00";
- when 6 => rcon <= x"40_00_00_00";
- when 7 => rcon <= x"80_00_00_00";
- when 8 => rcon <= x"1b_00_00_00";
- when 9 => rcon <= x"36_00_00_00";
- when OTHERS => rcon <= x"00_00_00_00";
- end case;
- end process;
- end architecture EXAMPLE;
round_constant.vhd