-- ============================================================================
--
-- Design unit      :   cbc_mode_iface (interfaces of CBC-mode en-/decryption
--                      modules)
--
-- File Name        :   cbc_mode_iface.vhd
--
-- Purpose          :   The package collects type declarations for all non-
--                      trivial interfaces of used entities. Record types
--                      are used extensively to group related signals (e.g.
--                      data / control & status, physical attachment etc.).
--
--
-- Depends on       :
--
--  - Package(s)    :   aes_definitions, tech_iface, engine_iface
--
--  - 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            :   Version for implementation using 32-bit datapath
--
--
-- Author(s)        :   A. Freund (af) <a.freund@dsi-it.de>
--                      Digitale Signalverabeitung & Informationstechnik GmbH,
--                      Bremen, Germany
--
--
-- ============================================================================
--
-- Revision List:
-- Version      Author(s)       Date        Changes
--
-- v0.00        af              2007-01-31  initial version
--
-- 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.tech_iface.all;
use work.engine_iface.all;


package cbc_mode_iface is


--
-- CBC-mode encryption interface definition
--


	-- data/control input signals
	type cbc_mode_encryption_in_type is record
		start	:	std_logic;			-- start encryption
		load_iv	:	std_logic;			-- load IV
		din		:	part_data_t;		-- IV / data to be encrypted (plaintext)
		key_id	:	key_id_t;			-- key id to use
	end record;

	-- data/status outputs signals
	type cbc_mode_encryption_out_type is record
		dout	:	part_data_t;		-- encrypted data (ciphertext)
		busy 	:	std_logic;			-- busy, encrypion in progress
		valid	:	std_logic;			-- ciphertext is valid
	end record;


--
-- CBC-mode decryption interface definition
--


	-- data/control input signals
	type cbc_mode_decryption_in_type is record
		start	:	std_logic;			-- start decryption
		load_iv	:	std_logic;			-- load IV
		din		:	part_data_t;		-- IV / data to be decrypted (ciphertext)
		key_id	:	key_id_t;			-- key id to use
	end record;

	-- data/status outputs signals
	type cbc_mode_decryption_out_type is record
		dout	:	part_data_t;		-- decrypted data (plaintext)
		busy 	:	std_logic;			-- busy, decrypion in progress
		valid	:	std_logic;			-- plaintext is valid
	end record;


--
--
-- Component declarations
--
--


	-- AES CBC-mode encryption
	component cbc_mode_encryption is
		port (
			rst		: 	in	std_logic;						-- reset
			clk		:	in	std_logic;						-- clock
			mode_i	:	in	cbc_mode_encryption_in_type;	-- see package cbc_mode_iface
			mode_o	:	out	cbc_mode_encryption_out_type;	-- see package cbc_mode_iface
			enc_i	:	in	encryption_engine_out_type;		-- see package engine_iface
			enc_o	:	out	encryption_engine_in_type		-- see package engine_iface
		);
	end component;



	-- AES CBC-mode decryption
	component cbc_mode_decryption is
		port (
			rst		: 	in	std_logic;						-- reset
			clk		:	in	std_logic;						-- clock
			mode_i	:	in	cbc_mode_decryption_in_type;	-- see package cbc_mode_iface
			mode_o	:	out	cbc_mode_decryption_out_type;	-- see package cbc_mode_iface
			dec_i	:	in	decryption_engine_out_type;		-- see package engine_iface
			dec_o	:	out	decryption_engine_in_type		-- see package engine_iface
		);
	end component;


end cbc_mode_iface;
