--- ============================================================================
--
-- Design unit      :   aes_decryption
--
-- File Name        :   aes_decryption.vhd
--
-- Purpose          :   design file
--
--
-- Depends on       :
--
-- - Package(s)     :   -
--
-- - Module(s)      :   -
--
--
-- Dev. Platform    :   Xilinx ISE 8.1i SP3 / Win32 (W2k SP4)
--
-- - Simulator(s)   :   Modelsim XE III 6.0d
--
-- - Synthesis      :   Xilinx XST
--
-- - Place & Route  :   Xilinx PAR
--
--
-- Errors           :   None known
--
--
-- Limitations      :   None known
--
--
-- Notes            :   -
--
--
-- Author(s)        :   A. Freund (af) <a.freund@dsi-it.de>, 
--                      M.v.d.Wall (mvdw) <vdwall@dsi-it.de>
--                      Digitale Signalverabeitung & Informationstechnik GmbH,
--                      Bremen, Germany
--
-- ============================================================================
--
-- Revision List:
--
-- see SVN logs
--
-- ============================================================================
--
-- Naming conventions:
--
-- - coding style: record-signals for related purposes (Gaisler-style)
-- - active-low signals are indicated by appending "_n"
-- - constants are in UPPERCASE
-- - name parts are separated by "_"
--
-- ============================================================================

library ieee;
use ieee.std_logic_1164.all;

use work.aes_definitions.all;
use work.aes_common.all;
use work.aes_column_ops.all;
use work.aes_row_ops.all;



package aes_decryption is


	function inv_mix_columns(st : in aes_state_t) return aes_state_t;

	function inv_shift_rows(st : in aes_state_t) return aes_state_t;


end aes_decryption;


package body aes_decryption is


	function inv_mix_columns(st : in aes_state_t) return aes_state_t is
		type columns_t is array(0 to 3) of column_t;
		variable v_cols : columns_t;
		variable v_st : aes_state_t;
	begin
		for i in v_cols'range loop
			v_cols(i) := inv_mix_column(select_column(st, i));
			v_st := replace_column(v_st, v_cols(i), i);
		end loop;

		return v_st;
	end inv_mix_columns;




	function inv_shift_rows(st : in aes_state_t) return aes_state_t is
		type rows_t is array(0 to 3) of row_t;
		variable v_rows : rows_t;
		variable v_st : aes_state_t;
	begin
		for i in v_rows'range loop
			v_rows(i) := inv_shift_row(select_row(st, i), i);
			v_st := replace_row(v_st, v_rows(i), i);
		end loop;

		return v_st;
	end inv_shift_rows;






end aes_decryption;
