diff options
author | Tristan Gingold <tgingold@free.fr> | 2020-08-04 06:38:24 +0200 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2020-09-27 09:57:18 +0200 |
commit | 987f573390666b057b2275ddda3c0f0ef70303c4 (patch) | |
tree | 26bf69b71429b7889d702581bd85ae68cb42930d /testsuite/ghdl-issues/issue1421a/aes_pkg.vhdl | |
parent | 8aae9102038582e702b5d68d30a48b3aefff6810 (diff) | |
download | ghdl-yosys-plugin-987f573390666b057b2275ddda3c0f0ef70303c4.tar.gz ghdl-yosys-plugin-987f573390666b057b2275ddda3c0f0ef70303c4.tar.bz2 ghdl-yosys-plugin-987f573390666b057b2275ddda3c0f0ef70303c4.zip |
testsuite: add a test for ghdl/ghdl#1421
Diffstat (limited to 'testsuite/ghdl-issues/issue1421a/aes_pkg.vhdl')
-rw-r--r-- | testsuite/ghdl-issues/issue1421a/aes_pkg.vhdl | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/testsuite/ghdl-issues/issue1421a/aes_pkg.vhdl b/testsuite/ghdl-issues/issue1421a/aes_pkg.vhdl new file mode 100644 index 0000000..8873d82 --- /dev/null +++ b/testsuite/ghdl-issues/issue1421a/aes_pkg.vhdl @@ -0,0 +1,40 @@ + +library ieee; + use ieee.std_logic_1164.all; + use ieee.numeric_std.all; + +package aes_pkg is + + type t_usig_1d is array(natural range <>) of unsigned(7 downto 0); + + type t_usig_2d is array(natural range <>, natural range <>) of unsigned(7 downto 0); + + constant C_STATE_ROWS : integer := 2; + constant C_STATE_COLS : integer := 2; + + subtype st_word is t_usig_1d(0 to C_STATE_COLS - 1); + subtype st_state is t_usig_2d(0 to C_STATE_ROWS - 1, 0 to C_STATE_COLS - 1); + subtype st_sbox is t_usig_1d(0 to 255); + + type t_key is array(natural range <>) of st_word; + + function mix_columns (a_in : st_state) return st_state; + +end package aes_pkg; + +package body aes_pkg is + + -- FIPS 197, 5.1.3 MixColumns() Transformation + + function mix_columns (a_in : st_state) return st_state is + variable a_out : st_state; + begin + for col in 0 to C_STATE_COLS - 1 loop + a_out(0, col) := a_in(0, col) xor + a_in(1, col); + a_out(1, col) := a_in(0, col) xor + a_in(1, col); + end loop; + return a_out; + end mix_columns; +end package body; |