Browse Source

Refactoring; remove unused functions

master
T. Meissner 4 years ago
parent
commit
dce8396498
2 changed files with 17 additions and 25 deletions
  1. +7
    -7
      aes/rtl/vhdl/aes_enc.vhd
  2. +10
    -18
      aes/rtl/vhdl/aes_pkg.vhd

+ 7
- 7
aes/rtl/vhdl/aes_enc.vhd View File

@ -52,11 +52,11 @@ begin
IterG : if design_type = "ITER" generate IterG : if design_type = "ITER" generate
signal s_round : t_enc_rounds; signal s_round : t_enc_rounds;
begin begin
@ -79,7 +79,7 @@ begin
if (accept_o = '1' and valid_i = '1') then if (accept_o = '1' and valid_i = '1') then
accept_o <= '0'; accept_o <= '0';
v_state := set_state(data_i); v_state := set_state(data_i);
v_key := (key_i(0 to 31), key_i(32 to 63), key_i(64 to 95), key_i(96 to 127));
v_key := set_key(key_i);
s_round <= s_round + 1; s_round <= s_round + 1;
end if; end if;
@ -133,7 +133,7 @@ begin
cover {accept_o}; cover {accept_o};
assert always (accept_o -> s_round = 0); assert always (accept_o -> s_round = 0);
cover {valid_i and accept_o}; cover {valid_i and accept_o};
assert always (valid_i and accept_o -> next not accept_o); assert always (valid_i and accept_o -> next not accept_o);
@ -152,7 +152,7 @@ begin
end generate IterG; end generate IterG;
end architecture rtl; end architecture rtl;


+ 10
- 18
aes/rtl/vhdl/aes_pkg.vhd View File

@ -130,8 +130,6 @@ package aes_pkg is
constant c_rcon : t_rcon := (x"01", x"02", x"04", x"08", x"10", x"20", x"40", x"80", x"1B", x"36"); constant c_rcon : t_rcon := (x"01", x"02", x"04", x"08", x"10", x"20", x"40", x"80", x"1B", x"36");
type t_mode is (ENCRYPT, DECRYPT);
function bytesub (input : std_logic_vector(7 downto 0)) return std_logic_vector; function bytesub (input : std_logic_vector(7 downto 0)) return std_logic_vector;
function invbytesub (input : std_logic_vector(7 downto 0)) return std_logic_vector; function invbytesub (input : std_logic_vector(7 downto 0)) return std_logic_vector;
@ -145,8 +143,6 @@ package aes_pkg is
function mixcolumns (input : t_datatable2d) return t_datatable2d; function mixcolumns (input : t_datatable2d) return t_datatable2d;
function invmixcolumns (input : t_datatable2d) return t_datatable2d; function invmixcolumns (input : t_datatable2d) return t_datatable2d;
function sortdata (input : std_logic_vector(127 downto 0)) return t_datatable2d;
function gmul (a : std_logic_vector(7 downto 0); b : std_logic_vector(7 downto 0)) return std_logic_vector; function gmul (a : std_logic_vector(7 downto 0); b : std_logic_vector(7 downto 0)) return std_logic_vector;
function addroundkey (input : in t_datatable2d; key : in t_key) return t_datatable2d; function addroundkey (input : in t_datatable2d; key : in t_key) return t_datatable2d;
@ -161,6 +157,8 @@ package aes_pkg is
function get_state (input : in t_datatable2d) return std_logic_vector; function get_state (input : in t_datatable2d) return std_logic_vector;
function set_key (input : in std_logic_vector(0 to 127)) return t_key;
function to_string(input : t_datatable2d) return string; function to_string(input : t_datatable2d) return string;
@ -171,27 +169,15 @@ end package aes_pkg;
package body aes_pkg is package body aes_pkg is
function sortdata (input : std_logic_vector(127 downto 0)) return t_datatable2d is
variable v_datamatrix : t_datatable2d;
begin
for outdex in 0 to 3 loop
for index in 0 to 3 loop
v_datamatrix(index)(outdex) := input(outdex*32+(index+1)*7 downto outdex*32+index*8);
end loop;
end loop;
return v_datamatrix;
end function sortdata;
function bytesub (input : std_logic_vector(7 downto 0)) return std_logic_vector is function bytesub (input : std_logic_vector(7 downto 0)) return std_logic_vector is
begin begin
return(c_sbox(to_integer(unsigned(input(7 downto 4))))(to_integer(unsigned(input(3 downto 0)))));
return c_sbox(to_integer(unsigned(input(7 downto 4))))(to_integer(unsigned(input(3 downto 0))));
end function bytesub; end function bytesub;
function invbytesub (input : std_logic_vector(7 downto 0)) return std_logic_vector is function invbytesub (input : std_logic_vector(7 downto 0)) return std_logic_vector is
begin begin
return(c_sbox_invers(to_integer(unsigned(input(7 downto 4))))(to_integer(unsigned(input(3 downto 0)))));
return c_sbox_invers(to_integer(unsigned(input(7 downto 4))))(to_integer(unsigned(input(3 downto 0))));
end function invbytesub; end function invbytesub;
@ -384,6 +370,12 @@ package body aes_pkg is
end function get_state; end function get_state;
function set_key (input : in std_logic_vector(0 to 127)) return t_key is
begin
return (input(0 to 31), input(32 to 63), input(64 to 95), input(96 to 127));
end function set_key;
function to_string(input : t_datatable2d) return string is function to_string(input : t_datatable2d) return string is
begin begin
return '(' & to_hstring(input(0)(0)) & ',' & to_hstring(input(0)(1)) & ',' & to_hstring(input(0)(2)) & ',' & to_hstring(input(0)(3)) & ')' & LF & return '(' & to_hstring(input(0)(0)) & ',' & to_hstring(input(0)(1)) & ',' & to_hstring(input(0)(2)) & ',' & to_hstring(input(0)(3)) & ')' & LF &


Loading…
Cancel
Save