-- ============================================================================
--
-- Design unit      :   cbc_128_encryption_core_tb (vefification testbench for
--                      CBC-128 encryption core)
--
-- File Name        :   cbc_128_encryption_core_tb.vhd
--
-- Purpose          :   The testbench uses test vectors to stimulate the encryption
--                      core with given test data and verify output data and
--                      behaviour of the core
--
--
-- Depends on       :
--
--  - Package(s)    :   tech_iface, key_schedule_iface, engine_iface,
--                      cbc_mode_iface, cbc_core_iface
--
--  - Module(s)     :   cbc_128_encryption_core, sbox_loader
--
--
-- 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 ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;

use std.textio.all;


use work.tech_iface.all;
use work.key_schedule_iface.all;
use work.engine_iface.all;
use work.cbc_mode_iface.all;
use work.cbc_core_iface.all;


entity cbc_128_encryption_core_tb is
end cbc_128_encryption_core_tb;


architecture stimuli of cbc_128_encryption_core_tb is


	-- put a message on stdout
	procedure puts(msg : string) is
		variable line_out_data : line;
	begin
		write(line_out_data, string'(msg));
		writeline(output, line_out_data);
	end procedure;


	component sbox_loader is
		port (
			rst		: 	in	std_logic;					-- reset
			clk		:	in	std_logic;					-- clock
			load_o	:	out	sbox_stage_load_in_type		-- see package tech_iface
		);
	end component;


	-- type definition for test vectors
	type test_vector_type_t is record
		cycles	:	integer;						-- number of clock cycles this test vector should be applied
		mode_i	:	cbc_mode_encryption_in_type;	-- stimulus for mode_i input (data to be encrypted etc.)
		key_i	:	key_schedule_128_in_type;		-- stimulus for key_i input (key to be expanded etc.)
		sep		:	character;
		mode_o	:	cbc_mode_encryption_out_type;	-- expected value for mode_o output (encrypted data etc.)
		key_o	:	key_schedule_128_out_type;		-- expected value for key_o output (key scheduling progress etc.)
	end record;


	constant KEY_ID : key_id_t := CONV_STD_LOGIC_VECTOR(1, key_id_t'length);



	type test_vectors_type_t is array(natural range <>) of test_vector_type_t;

	constant TEST_VECTORS : test_vectors_type_t := (

		-- (tv #1) idle
		(
			cycles		=>	1,
			mode_i		=>	(
								start		=>	'0',
								load_iv		=>	'0',
								din			=>	(others => '-'),
								key_id		=>	(others => '-')
							),
			key_i		=>	(
								load_key	=>	'0',
								key_id		=>	(others => '-'),
								key			=>	(others => '-')
							),
			sep			=>	'=',
			mode_o 		=>	(
								busy		=>	'0',
								valid		=>	'0',
								dout		=>	(others => '-')
							),
			key_o 		=>	(busy => '0')
		),

--
-- load / expand key
--

		-- key = X"2b7e151628aed2a6abf7158809cf4f3c"
		-- (tv #2) load key (part #0)
		(
			cycles		=>	1,
			mode_i		=>	(
								start		=>	'0',
								load_iv		=>	'0',
								din			=>	(others => '-'),
								key_id		=>	(others => '-')
							),
			key_i		=>	(
								load_key	=>	'1',
								key_id		=>	KEY_ID,
								key			=>	X"2b7e1516"
							),
			sep			=>	'=',
			mode_o 		=>	(
								busy		=>	'0',
								valid		=>	'0',
								dout		=>	(others => '-')
							),
			key_o 		=>	(busy => '0')
		),

		-- (tv #3) load key (part #1)
		(
			cycles		=>	1,
			mode_i		=>	(
								start		=>	'0',
								load_iv		=>	'0',
								din			=>	(others => '-'),
								key_id		=>	(others => '-')
							),
			key_i		=>	(
								load_key	=>	'0',
								key_id		=>	(others => '-'),
								key			=>	X"28aed2a6"
							),
			sep			=>	'=',
			mode_o 		=>	(
								busy		=>	'0',
								valid		=>	'0',
								dout		=>	(others => '-')
							),
			key_o 		=>	(busy => '1')
		),

		-- (tv #4) load key (part #2)
		(
			cycles		=>	1,
			mode_i		=>	(
								start		=>	'0',
								load_iv		=>	'0',
								din			=>	(others => '-'),
								key_id		=>	(others => '-')
							),
			key_i		=>	(
								load_key	=>	'0',
								key_id		=>	(others => '-'),
								key			=>	X"abf71588"
							),
			sep			=>	'=',
			mode_o 		=>	(
								busy		=>	'0',
								valid		=>	'0',
								dout		=>	(others => '-')
							),
			key_o 		=>	(busy => '1')
		),

		-- (tv #5) load key (part #3)
		(
			cycles		=>	1,
			mode_i		=>	(
								start		=>	'0',
								load_iv		=>	'0',
								din			=>	(others => '-'),
								key_id		=>	(others => '-')
							),
			key_i		=>	(
								load_key	=>	'0',
								key_id		=>	(others => '-'),
								key			=>	X"09cf4f3c"
							),
			sep			=>	'=',
			mode_o 		=>	(
								busy		=>	'0',
								valid		=>	'0',
								dout		=>	(others => '-')
							),
			key_o 		=>	(busy => '1')
		),

		-- (tv #6) wait while key is expanded
		(
			cycles		=>	41,
			mode_i		=>	(
								start		=>	'0',
								load_iv		=>	'0',
								din			=>	(others => '-'),
								key_id		=>	(others => '-')
							),
			key_i		=>	(
								load_key	=>	'0',
								key_id		=>	(others => '-'),
								key			=>	(others => '-')
							),
			sep			=>	'=',
			mode_o 		=>	(
								busy		=>	'0',
								valid		=>	'0',
								dout		=>	(others => '-')
							),
			key_o 		=>	(busy => '1')
		),

--
-- load IV
--

		-- IV = X"000102030405060708090a0b0c0d0e0f"
		-- (tv #7) load IV part 0
		(
			cycles		=>	1,
			mode_i		=>	(
								start		=>	'0',
								load_iv		=>	'1',
								din			=>	X"00010203",
								key_id		=>	KEY_ID
							),
			key_i		=>	(
								load_key	=>	'0',
								key_id		=>	(others => '-'),
								key			=>	(others => '-')
							),
			sep			=>	'=',
			mode_o 		=>	(
								busy		=>	'0',
								valid		=>	'0',
								dout		=>	(others => '-')
							),
			key_o 		=>	(busy => '0')
		),


		-- (tv #8) load IV part 1
		(
			cycles		=>	1,
			mode_i		=>	(
								start		=>	'0',
								load_iv		=>	'0',
								din			=>	X"04050607",
								key_id		=>	(others => '-')
							),
			key_i		=>	(
								load_key	=>	'0',
								key_id		=>	(others => '-'),
								key			=>	(others => '-')
							),
			sep			=>	'=',
			mode_o 		=>	(
								busy		=>	'1',
								valid		=>	'0',
								dout		=>	(others => '-')
							),
			key_o 		=>	(busy => '0')
		),

		-- (tv #9) load IV part 2
		(
			cycles		=>	1,
			mode_i		=>	(
								start		=>	'0',
								load_iv		=>	'0',
								din			=>	X"08090a0b",
								key_id		=>	(others => '-')
							),
			key_i		=>	(
								load_key	=>	'0',
								key_id		=>	(others => '-'),
								key			=>	(others => '-')
							),
			sep			=>	'=',
			mode_o 		=>	(
								busy		=>	'1',
								valid		=>	'0',
								dout		=>	(others => '-')
							),
			key_o 		=>	(busy => '0')
		),


		-- (tv #10) load IV part 3
		(
			cycles		=>	1,
			mode_i		=>	(
								start		=>	'0',
								load_iv		=>	'0',
								din			=>	X"0c0d0e0f",
								key_id		=>	(others => '-')
							),
			key_i		=>	(
								load_key	=>	'0',
								key_id		=>	(others => '-'),
								key			=>	(others => '-')
							),
			sep			=>	'=',
			mode_o 		=>	(
								busy		=>	'1',
								valid		=>	'0',
								dout		=>	(others => '-')
							),
			key_o 		=>	(busy => '0')
		),

--
-- encrypt data
--

		-- plaintext = X"6bc1bee22e409f96e93d7e117393172a"
		-- (tv #11) start encryption / load plaintext part 0
		(
			cycles		=>	1,
			mode_i		=>	(
								start		=>	'1',
								load_iv		=>	'0',
								din			=>	X"6bc1bee2",
								key_id		=>	(others => '-')
							),
			key_i		=>	(
								load_key	=>	'0',
								key_id		=>	(others => '-'),
								key			=>	(others => '-')
							),
			sep			=>	'=',
			mode_o 		=>	(
								busy		=>	'0',
								valid		=>	'0',
								dout		=>	(others => '-')
							),
			key_o 		=>	(busy => '0')
		),


		-- (tv #12) load plaintext part 1
		(
			cycles		=>	1,
			mode_i		=>	(
								start		=>	'0',
								load_iv		=>	'0',
								din			=>	X"2e409f96",
								key_id		=>	(others => '-')
							),
			key_i		=>	(
								load_key	=>	'0',
								key_id		=>	(others => '-'),
								key			=>	(others => '-')
							),
			sep			=>	'=',
			mode_o 		=>	(
								busy		=>	'1',
								valid		=>	'0',
								dout		=>	(others => '-')
							),
			key_o 		=>	(busy => '0')
		),

		-- (tv #13) load plaintext part 2
		(
			cycles		=>	1,
			mode_i		=>	(
								start		=>	'0',
								load_iv		=>	'0',
								din			=>	X"e93d7e11",
								key_id		=>	(others => '-')
							),
			key_i		=>	(
								load_key	=>	'0',
								key_id		=>	(others => '-'),
								key			=>	(others => '-')
							),
			sep			=>	'=',
			mode_o 		=>	(
								busy		=>	'1',
								valid		=>	'0',
								dout		=>	(others => '-')
							),
			key_o 		=>	(busy => '0')
		),


		-- (tv #14) load plaintext part 3
		(
			cycles		=>	1,
			mode_i		=>	(
								start		=>	'0',
								load_iv		=>	'0',
								din			=>	X"7393172a",
								key_id		=>	(others => '-')
							),
			key_i		=>	(
								load_key	=>	'0',
								key_id		=>	(others => '-'),
								key			=>	(others => '-')
							),
			sep			=>	'=',
			mode_o 		=>	(
								busy		=>	'1',
								valid		=>	'0',
								dout		=>	(others => '-')
							),
			key_o 		=>	(busy => '0')
		),

		-- (tv #15) wait while busy
		(
			cycles		=>	47,
			mode_i		=>	(
								start		=>	'0',
								load_iv		=>	'0',
								din			=>	(others => '-'),
								key_id		=>	(others => '-')
							),
			key_i		=>	(
								load_key	=>	'0',
								key_id		=>	(others => '-'),
								key			=>	(others => '-')
							),
			sep			=>	'=',
			mode_o 		=>	(
								busy		=>	'1',
								valid		=>	'0',
								dout		=>	(others => '-')
							),
			key_o 		=>	(busy => '0')
		),

--
-- verify ciphertext
--

		-- ciphertext = X"7649abac8119b246cee98e9b12e9197d"
		-- (tv #16) verify ciphertext part 0
		(
			cycles		=>	1,
			mode_i		=>	(
								start		=>	'0',
								load_iv		=>	'0',
								din			=>	(others => '-'),
								key_id		=>	(others => '-')
							),
			key_i		=>	(
								load_key	=>	'0',
								key_id		=>	(others => '-'),
								key			=>	(others => '-')
							),
			sep			=>	'=',
			mode_o 		=>	(
								busy		=>	'1',
								valid		=>	'1',
								dout		=>	X"7649abac"
							),
			key_o 		=>	(busy => '0')
		),

		-- (tv #17) verify ciphertext part 1
		(
			cycles		=>	1,
			mode_i		=>	(
								start		=>	'0',
								load_iv		=>	'0',
								din			=>	(others => '-'),
								key_id		=>	(others => '-')
							),
			key_i		=>	(
								load_key	=>	'0',
								key_id		=>	(others => '-'),
								key			=>	(others => '-')
							),
			sep			=>	'=',
			mode_o 		=>	(
								busy		=>	'1',
								valid		=>	'1',
								dout		=>	X"8119b246"
							),
			key_o 		=>	(busy => '0')
		),

		-- (tv #18) verify ciphertext part 2
		(
			cycles		=>	1,
			mode_i		=>	(
								start		=>	'0',
								load_iv		=>	'0',
								din			=>	(others => '-'),
								key_id		=>	(others => '-')
							),
			key_i		=>	(
								load_key	=>	'0',
								key_id		=>	(others => '-'),
								key			=>	(others => '-')
							),
			sep			=>	'=',
			mode_o 		=>	(
								busy		=>	'1',
								valid		=>	'1',
								dout		=>	X"cee98e9b"
							),
			key_o 		=>	(busy => '0')
		),

		-- (tv #19) verify ciphertext part 3
		(
			cycles		=>	1,
			mode_i		=>	(
								start		=>	'0',
								load_iv		=>	'0',
								din			=>	(others => '-'),
								key_id		=>	(others => '-')
							),
			key_i		=>	(
								load_key	=>	'0',
								key_id		=>	(others => '-'),
								key			=>	(others => '-')
							),
			sep			=>	'=',
			mode_o 		=>	(
								busy		=>	'1',
								valid		=>	'1',
								dout		=>	X"12e9197d"
							),
			key_o 		=>	(busy => '0')
		),

--
-- encrypt data
--

		-- plaintext = X"ae2d8a571e03ac9c9eb76fac45af8e51"
		-- (tv #20) start encryption / load plaintext part 0
		(
			cycles		=>	1,
			mode_i		=>	(
								start		=>	'1',
								load_iv		=>	'0',
								din			=>	X"ae2d8a57",
								key_id		=>	(others => '-')
							),
			key_i		=>	(
								load_key	=>	'0',
								key_id		=>	(others => '-'),
								key			=>	(others => '-')
							),
			sep			=>	'=',
			mode_o 		=>	(
								busy		=>	'0',
								valid		=>	'0',
								dout		=>	(others => '-')
							),
			key_o 		=>	(busy => '0')
		),


		-- (tv #21) load plaintext part 1
		(
			cycles		=>	1,
			mode_i		=>	(
								start		=>	'0',
								load_iv		=>	'0',
								din			=>	X"1e03ac9c",
								key_id		=>	(others => '-')
							),
			key_i		=>	(
								load_key	=>	'0',
								key_id		=>	(others => '-'),
								key			=>	(others => '-')
							),
			sep			=>	'=',
			mode_o 		=>	(
								busy		=>	'1',
								valid		=>	'0',
								dout		=>	(others => '-')
							),
			key_o 		=>	(busy => '0')
		),

		-- (tv #22) load plaintext part 2
		(
			cycles		=>	1,
			mode_i		=>	(
								start		=>	'0',
								load_iv		=>	'0',
								din			=>	X"9eb76fac",
								key_id		=>	(others => '-')
							),
			key_i		=>	(
								load_key	=>	'0',
								key_id		=>	(others => '-'),
								key			=>	(others => '-')
							),
			sep			=>	'=',
			mode_o 		=>	(
								busy		=>	'1',
								valid		=>	'0',
								dout		=>	(others => '-')
							),
			key_o 		=>	(busy => '0')
		),


		-- (tv #23) load plaintext part 3
		(
			cycles		=>	1,
			mode_i		=>	(
								start		=>	'0',
								load_iv		=>	'0',
								din			=>	X"45af8e51",
								key_id		=>	(others => '-')
							),
			key_i		=>	(
								load_key	=>	'0',
								key_id		=>	(others => '-'),
								key			=>	(others => '-')
							),
			sep			=>	'=',
			mode_o 		=>	(
								busy		=>	'1',
								valid		=>	'0',
								dout		=>	(others => '-')
							),
			key_o 		=>	(busy => '0')
		),

		-- (tv #24) wait while busy
		(
			cycles		=>	47,
			mode_i		=>	(
								start		=>	'0',
								load_iv		=>	'0',
								din			=>	(others => '-'),
								key_id		=>	(others => '-')
							),
			key_i		=>	(
								load_key	=>	'0',
								key_id		=>	(others => '-'),
								key			=>	(others => '-')
							),
			sep			=>	'=',
			mode_o 		=>	(
								busy		=>	'1',
								valid		=>	'0',
								dout		=>	(others => '-')
							),
			key_o 		=>	(busy => '0')
		),

--
-- verify ciphertext
--

		-- ciphertext = X"5086cb9b507219ee95db113a917678b2"
		-- (tv #25) verify ciphertext part 0
		(
			cycles		=>	1,
			mode_i		=>	(
								start		=>	'0',
								load_iv		=>	'0',
								din			=>	(others => '-'),
								key_id		=>	(others => '-')
							),
			key_i		=>	(
								load_key	=>	'0',
								key_id		=>	(others => '-'),
								key			=>	(others => '-')
							),
			sep			=>	'=',
			mode_o 		=>	(
								busy		=>	'1',
								valid		=>	'1',
								dout		=>	X"5086cb9b"
							),
			key_o 		=>	(busy => '0')
		),

		-- (tv #26) verify ciphertext part 1
		(
			cycles		=>	1,
			mode_i		=>	(
								start		=>	'0',
								load_iv		=>	'0',
								din			=>	(others => '-'),
								key_id		=>	(others => '-')
							),
			key_i		=>	(
								load_key	=>	'0',
								key_id		=>	(others => '-'),
								key			=>	(others => '-')
							),
			sep			=>	'=',
			mode_o 		=>	(
								busy		=>	'1',
								valid		=>	'1',
								dout		=>	X"507219ee"
							),
			key_o 		=>	(busy => '0')
		),

		-- (tv #27) verify ciphertext part 2
		(
			cycles		=>	1,
			mode_i		=>	(
								start		=>	'0',
								load_iv		=>	'0',
								din			=>	(others => '-'),
								key_id		=>	(others => '-')
							),
			key_i		=>	(
								load_key	=>	'0',
								key_id		=>	(others => '-'),
								key			=>	(others => '-')
							),
			sep			=>	'=',
			mode_o 		=>	(
								busy		=>	'1',
								valid		=>	'1',
								dout		=>	X"95db113a"
							),
			key_o 		=>	(busy => '0')
		),

		-- (tv #28) verify ciphertext part 3
		(
			cycles		=>	1,
			mode_i		=>	(
								start		=>	'0',
								load_iv		=>	'0',
								din			=>	(others => '-'),
								key_id		=>	(others => '-')
							),
			key_i		=>	(
								load_key	=>	'0',
								key_id		=>	(others => '-'),
								key			=>	(others => '-')
							),
			sep			=>	'=',
			mode_o 		=>	(
								busy		=>	'1',
								valid		=>	'1',
								dout		=>	X"917678b2"
							),
			key_o 		=>	(busy => '0')
		),

--
-- encrypt data
--

		-- plaintext = X"30c81c46a35ce411e5fbc1191a0a52ef"
		-- (tv #29) start encryption / load plaintext part 0
		(
			cycles		=>	1,
			mode_i		=>	(
								start		=>	'1',
								load_iv		=>	'0',
								din			=>	X"30c81c46",
								key_id		=>	(others => '-')
							),
			key_i		=>	(
								load_key	=>	'0',
								key_id		=>	(others => '-'),
								key			=>	(others => '-')
							),
			sep			=>	'=',
			mode_o 		=>	(
								busy		=>	'0',
								valid		=>	'0',
								dout		=>	(others => '-')
							),
			key_o 		=>	(busy => '0')
		),


		-- (tv #30) load plaintext part 1
		(
			cycles		=>	1,
			mode_i		=>	(
								start		=>	'0',
								load_iv		=>	'0',
								din			=>	X"a35ce411",
								key_id		=>	(others => '-')
							),
			key_i		=>	(
								load_key	=>	'0',
								key_id		=>	(others => '-'),
								key			=>	(others => '-')
							),
			sep			=>	'=',
			mode_o 		=>	(
								busy		=>	'1',
								valid		=>	'0',
								dout		=>	(others => '-')
							),
			key_o 		=>	(busy => '0')
		),

		-- (tv #31) load plaintext part 2
		(
			cycles		=>	1,
			mode_i		=>	(
								start		=>	'0',
								load_iv		=>	'0',
								din			=>	X"e5fbc119",
								key_id		=>	(others => '-')
							),
			key_i		=>	(
								load_key	=>	'0',
								key_id		=>	(others => '-'),
								key			=>	(others => '-')
							),
			sep			=>	'=',
			mode_o 		=>	(
								busy		=>	'1',
								valid		=>	'0',
								dout		=>	(others => '-')
							),
			key_o 		=>	(busy => '0')
		),


		-- (tv #32) load plaintext part 3
		(
			cycles		=>	1,
			mode_i		=>	(
								start		=>	'0',
								load_iv		=>	'0',
								din			=>	X"1a0a52ef",
								key_id		=>	(others => '-')
							),
			key_i		=>	(
								load_key	=>	'0',
								key_id		=>	(others => '-'),
								key			=>	(others => '-')
							),
			sep			=>	'=',
			mode_o 		=>	(
								busy		=>	'1',
								valid		=>	'0',
								dout		=>	(others => '-')
							),
			key_o 		=>	(busy => '0')
		),

		-- (tv #33) wait while busy
		(
			cycles		=>	47,
			mode_i		=>	(
								start		=>	'0',
								load_iv		=>	'0',
								din			=>	(others => '-'),
								key_id		=>	(others => '-')
							),
			key_i		=>	(
								load_key	=>	'0',
								key_id		=>	(others => '-'),
								key			=>	(others => '-')
							),
			sep			=>	'=',
			mode_o 		=>	(
								busy		=>	'1',
								valid		=>	'0',
								dout		=>	(others => '-')
							),
			key_o 		=>	(busy => '0')
		),

--
-- verify ciphertext
--

		-- ciphertext = X"73bed6b8e3c1743b7116e69e22229516"
		-- (tv #34) verify ciphertext part 0
		(
			cycles		=>	1,
			mode_i		=>	(
								start		=>	'0',
								load_iv		=>	'0',
								din			=>	(others => '-'),
								key_id		=>	(others => '-')
							),
			key_i		=>	(
								load_key	=>	'0',
								key_id		=>	(others => '-'),
								key			=>	(others => '-')
							),
			sep			=>	'=',
			mode_o 		=>	(
								busy		=>	'1',
								valid		=>	'1',
								dout		=>	X"73bed6b8"
							),
			key_o 		=>	(busy => '0')
		),

		-- (tv #35) verify ciphertext part 1
		(
			cycles		=>	1,
			mode_i		=>	(
								start		=>	'0',
								load_iv		=>	'0',
								din			=>	(others => '-'),
								key_id		=>	(others => '-')
							),
			key_i		=>	(
								load_key	=>	'0',
								key_id		=>	(others => '-'),
								key			=>	(others => '-')
							),
			sep			=>	'=',
			mode_o 		=>	(
								busy		=>	'1',
								valid		=>	'1',
								dout		=>	X"e3c1743b"
							),
			key_o 		=>	(busy => '0')
		),

		-- (tv #36) verify ciphertext part 2
		(
			cycles		=>	1,
			mode_i		=>	(
								start		=>	'0',
								load_iv		=>	'0',
								din			=>	(others => '-'),
								key_id		=>	(others => '-')
							),
			key_i		=>	(
								load_key	=>	'0',
								key_id		=>	(others => '-'),
								key			=>	(others => '-')
							),
			sep			=>	'=',
			mode_o 		=>	(
								busy		=>	'1',
								valid		=>	'1',
								dout		=>	X"7116e69e"
							),
			key_o 		=>	(busy => '0')
		),

		-- (tv #37) verify ciphertext part 3
		(
			cycles		=>	1,
			mode_i		=>	(
								start		=>	'0',
								load_iv		=>	'0',
								din			=>	(others => '-'),
								key_id		=>	(others => '-')
							),
			key_i		=>	(
								load_key	=>	'0',
								key_id		=>	(others => '-'),
								key			=>	(others => '-')
							),
			sep			=>	'=',
			mode_o 		=>	(
								busy		=>	'1',
								valid		=>	'1',
								dout		=>	X"22229516"
							),
			key_o 		=>	(busy => '0')
		),

--
-- encrypt data
--

		-- plaintext = X"f69f2445df4f9b17ad2b417be66c3710"
		-- (tv #38) start encryption / load plaintext part 0
		(
			cycles		=>	1,
			mode_i		=>	(
								start		=>	'1',
								load_iv		=>	'0',
								din			=>	X"f69f2445",
								key_id		=>	(others => '-')
							),
			key_i		=>	(
								load_key	=>	'0',
								key_id		=>	(others => '-'),
								key			=>	(others => '-')
							),
			sep			=>	'=',
			mode_o 		=>	(
								busy		=>	'0',
								valid		=>	'0',
								dout		=>	(others => '-')
							),
			key_o 		=>	(busy => '0')
		),


		-- (tv #39) load plaintext part 1
		(
			cycles		=>	1,
			mode_i		=>	(
								start		=>	'0',
								load_iv		=>	'0',
								din			=>	X"df4f9b17",
								key_id		=>	(others => '-')
							),
			key_i		=>	(
								load_key	=>	'0',
								key_id		=>	(others => '-'),
								key			=>	(others => '-')
							),
			sep			=>	'=',
			mode_o 		=>	(
								busy		=>	'1',
								valid		=>	'0',
								dout		=>	(others => '-')
							),
			key_o 		=>	(busy => '0')
		),

		-- (tv #40) load plaintext part 2
		(
			cycles		=>	1,
			mode_i		=>	(
								start		=>	'0',
								load_iv		=>	'0',
								din			=>	X"ad2b417b",
								key_id		=>	(others => '-')
							),
			key_i		=>	(
								load_key	=>	'0',
								key_id		=>	(others => '-'),
								key			=>	(others => '-')
							),
			sep			=>	'=',
			mode_o 		=>	(
								busy		=>	'1',
								valid		=>	'0',
								dout		=>	(others => '-')
							),
			key_o 		=>	(busy => '0')
		),


		-- (tv #41) load plaintext part 3
		(
			cycles		=>	1,
			mode_i		=>	(
								start		=>	'0',
								load_iv		=>	'0',
								din			=>	X"e66c3710",
								key_id		=>	(others => '-')
							),
			key_i		=>	(
								load_key	=>	'0',
								key_id		=>	(others => '-'),
								key			=>	(others => '-')
							),
			sep			=>	'=',
			mode_o 		=>	(
								busy		=>	'1',
								valid		=>	'0',
								dout		=>	(others => '-')
							),
			key_o 		=>	(busy => '0')
		),

		-- (tv #42) wait while busy
		(
			cycles		=>	47,
			mode_i		=>	(
								start		=>	'0',
								load_iv		=>	'0',
								din			=>	(others => '-'),
								key_id		=>	(others => '-')
							),
			key_i		=>	(
								load_key	=>	'0',
								key_id		=>	(others => '-'),
								key			=>	(others => '-')
							),
			sep			=>	'=',
			mode_o 		=>	(
								busy		=>	'1',
								valid		=>	'0',
								dout		=>	(others => '-')
							),
			key_o 		=>	(busy => '0')
		),

--
-- verify ciphertext
--

		-- ciphertext = X"3ff1caa1681fac09120eca307586e1a7"
		-- (tv #43) verify ciphertext part 0
		(
			cycles		=>	1,
			mode_i		=>	(
								start		=>	'0',
								load_iv		=>	'0',
								din			=>	(others => '-'),
								key_id		=>	(others => '-')
							),
			key_i		=>	(
								load_key	=>	'0',
								key_id		=>	(others => '-'),
								key			=>	(others => '-')
							),
			sep			=>	'=',
			mode_o 		=>	(
								busy		=>	'1',
								valid		=>	'1',
								dout		=>	X"3ff1caa1"
							),
			key_o 		=>	(busy => '0')
		),

		-- (tv #44) verify ciphertext part 1
		(
			cycles		=>	1,
			mode_i		=>	(
								start		=>	'0',
								load_iv		=>	'0',
								din			=>	(others => '-'),
								key_id		=>	(others => '-')
							),
			key_i		=>	(
								load_key	=>	'0',
								key_id		=>	(others => '-'),
								key			=>	(others => '-')
							),
			sep			=>	'=',
			mode_o 		=>	(
								busy		=>	'1',
								valid		=>	'1',
								dout		=>	X"681fac09"
							),
			key_o 		=>	(busy => '0')
		),

		-- (tv #45) verify ciphertext part 2
		(
			cycles		=>	1,
			mode_i		=>	(
								start		=>	'0',
								load_iv		=>	'0',
								din			=>	(others => '-'),
								key_id		=>	(others => '-')
							),
			key_i		=>	(
								load_key	=>	'0',
								key_id		=>	(others => '-'),
								key			=>	(others => '-')
							),
			sep			=>	'=',
			mode_o 		=>	(
								busy		=>	'1',
								valid		=>	'1',
								dout		=>	X"120eca30"
							),
			key_o 		=>	(busy => '0')
		),

		-- (tv #46) verify ciphertext part 3
		(
			cycles		=>	1,
			mode_i		=>	(
								start		=>	'0',
								load_iv		=>	'0',
								din			=>	(others => '-'),
								key_id		=>	(others => '-')
							),
			key_i		=>	(
								load_key	=>	'0',
								key_id		=>	(others => '-'),
								key			=>	(others => '-')
							),
			sep			=>	'=',
			mode_o 		=>	(
								busy		=>	'1',
								valid		=>	'1',
								dout		=>	X"7586e1a7"
							),
			key_o 		=>	(busy => '0')
		),

--
-- load IV
--

		-- IV = X"000102030405060708090a0b0c0d0e0f"
		-- (tv #47) load IV part 0
		(
			cycles		=>	1,
			mode_i		=>	(
								start		=>	'0',
								load_iv		=>	'1',
								din			=>	X"00010203",
								key_id		=>	KEY_ID
							),
			key_i		=>	(
								load_key	=>	'0',
								key_id		=>	(others => '-'),
								key			=>	(others => '-')
							),
			sep			=>	'=',
			mode_o 		=>	(
								busy		=>	'0',
								valid		=>	'0',
								dout		=>	(others => '-')
							),
			key_o 		=>	(busy => '0')
		),


		-- (tv #48) load IV part 1
		(
			cycles		=>	1,
			mode_i		=>	(
								start		=>	'0',
								load_iv		=>	'0',
								din			=>	X"04050607",
								key_id		=>	(others => '-')
							),
			key_i		=>	(
								load_key	=>	'0',
								key_id		=>	(others => '-'),
								key			=>	(others => '-')
							),
			sep			=>	'=',
			mode_o 		=>	(
								busy		=>	'1',
								valid		=>	'0',
								dout		=>	(others => '-')
							),
			key_o 		=>	(busy => '0')
		),

		-- (tv #49) load IV part 2
		(
			cycles		=>	1,
			mode_i		=>	(
								start		=>	'0',
								load_iv		=>	'0',
								din			=>	X"08090a0b",
								key_id		=>	(others => '-')
							),
			key_i		=>	(
								load_key	=>	'0',
								key_id		=>	(others => '-'),
								key			=>	(others => '-')
							),
			sep			=>	'=',
			mode_o 		=>	(
								busy		=>	'1',
								valid		=>	'0',
								dout		=>	(others => '-')
							),
			key_o 		=>	(busy => '0')
		),


		-- (tv #50) load IV part 3
		(
			cycles		=>	1,
			mode_i		=>	(
								start		=>	'0',
								load_iv		=>	'0',
								din			=>	X"0c0d0e0f",
								key_id		=>	(others => '-')
							),
			key_i		=>	(
								load_key	=>	'0',
								key_id		=>	(others => '-'),
								key			=>	(others => '-')
							),
			sep			=>	'=',
			mode_o 		=>	(
								busy		=>	'1',
								valid		=>	'0',
								dout		=>	(others => '-')
							),
			key_o 		=>	(busy => '0')
		),

--
-- encrypt data
--

		-- plaintext = X"6bc1bee22e409f96e93d7e117393172a"
		-- (tv #51) start encryption / load plaintext part 0
		(
			cycles		=>	1,
			mode_i		=>	(
								start		=>	'1',
								load_iv		=>	'0',
								din			=>	X"6bc1bee2",
								key_id		=>	(others => '-')
							),
			key_i		=>	(
								load_key	=>	'0',
								key_id		=>	(others => '-'),
								key			=>	(others => '-')
							),
			sep			=>	'=',
			mode_o 		=>	(
								busy		=>	'0',
								valid		=>	'0',
								dout		=>	(others => '-')
							),
			key_o 		=>	(busy => '0')
		),


		-- (tv #52) load plaintext part 1
		(
			cycles		=>	1,
			mode_i		=>	(
								start		=>	'0',
								load_iv		=>	'0',
								din			=>	X"2e409f96",
								key_id		=>	(others => '-')
							),
			key_i		=>	(
								load_key	=>	'0',
								key_id		=>	(others => '-'),
								key			=>	(others => '-')
							),
			sep			=>	'=',
			mode_o 		=>	(
								busy		=>	'1',
								valid		=>	'0',
								dout		=>	(others => '-')
							),
			key_o 		=>	(busy => '0')
		),

		-- (tv #53) load plaintext part 2
		(
			cycles		=>	1,
			mode_i		=>	(
								start		=>	'0',
								load_iv		=>	'0',
								din			=>	X"e93d7e11",
								key_id		=>	(others => '-')
							),
			key_i		=>	(
								load_key	=>	'0',
								key_id		=>	(others => '-'),
								key			=>	(others => '-')
							),
			sep			=>	'=',
			mode_o 		=>	(
								busy		=>	'1',
								valid		=>	'0',
								dout		=>	(others => '-')
							),
			key_o 		=>	(busy => '0')
		),


		-- (tv #54) load plaintext part 3
		(
			cycles		=>	1,
			mode_i		=>	(
								start		=>	'0',
								load_iv		=>	'0',
								din			=>	X"7393172a",
								key_id		=>	(others => '-')
							),
			key_i		=>	(
								load_key	=>	'0',
								key_id		=>	(others => '-'),
								key			=>	(others => '-')
							),
			sep			=>	'=',
			mode_o 		=>	(
								busy		=>	'1',
								valid		=>	'0',
								dout		=>	(others => '-')
							),
			key_o 		=>	(busy => '0')
		),

		-- (tv #55) wait while busy
		(
			cycles		=>	47,
			mode_i		=>	(
								start		=>	'0',
								load_iv		=>	'0',
								din			=>	(others => '-'),
								key_id		=>	(others => '-')
							),
			key_i		=>	(
								load_key	=>	'0',
								key_id		=>	(others => '-'),
								key			=>	(others => '-')
							),
			sep			=>	'=',
			mode_o 		=>	(
								busy		=>	'1',
								valid		=>	'0',
								dout		=>	(others => '-')
							),
			key_o 		=>	(busy => '0')
		),

--
-- verify ciphertext
--

		-- ciphertext = X"7649abac8119b246cee98e9b12e9197d"
		-- (tv #56) verify ciphertext part 0
		(
			cycles		=>	1,
			mode_i		=>	(
								start		=>	'0',
								load_iv		=>	'0',
								din			=>	(others => '-'),
								key_id		=>	(others => '-')
							),
			key_i		=>	(
								load_key	=>	'0',
								key_id		=>	(others => '-'),
								key			=>	(others => '-')
							),
			sep			=>	'=',
			mode_o 		=>	(
								busy		=>	'1',
								valid		=>	'1',
								dout		=>	X"7649abac"
							),
			key_o 		=>	(busy => '0')
		),

		-- (tv #57) verify ciphertext part 1
		(
			cycles		=>	1,
			mode_i		=>	(
								start		=>	'0',
								load_iv		=>	'0',
								din			=>	(others => '-'),
								key_id		=>	(others => '-')
							),
			key_i		=>	(
								load_key	=>	'0',
								key_id		=>	(others => '-'),
								key			=>	(others => '-')
							),
			sep			=>	'=',
			mode_o 		=>	(
								busy		=>	'1',
								valid		=>	'1',
								dout		=>	X"8119b246"
							),
			key_o 		=>	(busy => '0')
		),

		-- (tv #58) verify ciphertext part 2
		(
			cycles		=>	1,
			mode_i		=>	(
								start		=>	'0',
								load_iv		=>	'0',
								din			=>	(others => '-'),
								key_id		=>	(others => '-')
							),
			key_i		=>	(
								load_key	=>	'0',
								key_id		=>	(others => '-'),
								key			=>	(others => '-')
							),
			sep			=>	'=',
			mode_o 		=>	(
								busy		=>	'1',
								valid		=>	'1',
								dout		=>	X"cee98e9b"
							),
			key_o 		=>	(busy => '0')
		),

		-- (tv #59) verify ciphertext part 3
		(
			cycles		=>	1,
			mode_i		=>	(
								start		=>	'0',
								load_iv		=>	'0',
								din			=>	(others => '-'),
								key_id		=>	(others => '-')
							),
			key_i		=>	(
								load_key	=>	'0',
								key_id		=>	(others => '-'),
								key			=>	(others => '-')
							),
			sep			=>	'=',
			mode_o 		=>	(
								busy		=>	'1',
								valid		=>	'1',
								dout		=>	X"12e9197d"
							),
			key_o 		=>	(busy => '0')
		),

--
-- encrypt data
--

		-- plaintext = X"ae2d8a571e03ac9c9eb76fac45af8e51"
		-- (tv #60) start encryption / load plaintext part 0
		(
			cycles		=>	1,
			mode_i		=>	(
								start		=>	'1',
								load_iv		=>	'0',
								din			=>	X"ae2d8a57",
								key_id		=>	(others => '-')
							),
			key_i		=>	(
								load_key	=>	'0',
								key_id		=>	(others => '-'),
								key			=>	(others => '-')
							),
			sep			=>	'=',
			mode_o 		=>	(
								busy		=>	'0',
								valid		=>	'0',
								dout		=>	(others => '-')
							),
			key_o 		=>	(busy => '0')
		),


		-- (tv #61) load plaintext part 1
		(
			cycles		=>	1,
			mode_i		=>	(
								start		=>	'0',
								load_iv		=>	'0',
								din			=>	X"1e03ac9c",
								key_id		=>	(others => '-')
							),
			key_i		=>	(
								load_key	=>	'0',
								key_id		=>	(others => '-'),
								key			=>	(others => '-')
							),
			sep			=>	'=',
			mode_o 		=>	(
								busy		=>	'1',
								valid		=>	'0',
								dout		=>	(others => '-')
							),
			key_o 		=>	(busy => '0')
		),

		-- (tv #62) load plaintext part 2
		(
			cycles		=>	1,
			mode_i		=>	(
								start		=>	'0',
								load_iv		=>	'0',
								din			=>	X"9eb76fac",
								key_id		=>	(others => '-')
							),
			key_i		=>	(
								load_key	=>	'0',
								key_id		=>	(others => '-'),
								key			=>	(others => '-')
							),
			sep			=>	'=',
			mode_o 		=>	(
								busy		=>	'1',
								valid		=>	'0',
								dout		=>	(others => '-')
							),
			key_o 		=>	(busy => '0')
		),


		-- (tv #63) load plaintext part 3
		(
			cycles		=>	1,
			mode_i		=>	(
								start		=>	'0',
								load_iv		=>	'0',
								din			=>	X"45af8e51",
								key_id		=>	(others => '-')
							),
			key_i		=>	(
								load_key	=>	'0',
								key_id		=>	(others => '-'),
								key			=>	(others => '-')
							),
			sep			=>	'=',
			mode_o 		=>	(
								busy		=>	'1',
								valid		=>	'0',
								dout		=>	(others => '-')
							),
			key_o 		=>	(busy => '0')
		),

		-- (tv #64) wait while busy
		(
			cycles		=>	47,
			mode_i		=>	(
								start		=>	'0',
								load_iv		=>	'0',
								din			=>	(others => '-'),
								key_id		=>	(others => '-')
							),
			key_i		=>	(
								load_key	=>	'0',
								key_id		=>	(others => '-'),
								key			=>	(others => '-')
							),
			sep			=>	'=',
			mode_o 		=>	(
								busy		=>	'1',
								valid		=>	'0',
								dout		=>	(others => '-')
							),
			key_o 		=>	(busy => '0')
		),

--
-- verify ciphertext
--

		-- ciphertext = X"5086cb9b507219ee95db113a917678b2"
		-- (tv #65) verify ciphertext part 0
		(
			cycles		=>	1,
			mode_i		=>	(
								start		=>	'0',
								load_iv		=>	'0',
								din			=>	(others => '-'),
								key_id		=>	(others => '-')
							),
			key_i		=>	(
								load_key	=>	'0',
								key_id		=>	(others => '-'),
								key			=>	(others => '-')
							),
			sep			=>	'=',
			mode_o 		=>	(
								busy		=>	'1',
								valid		=>	'1',
								dout		=>	X"5086cb9b"
							),
			key_o 		=>	(busy => '0')
		),

		-- (tv #66) verify ciphertext part 1
		(
			cycles		=>	1,
			mode_i		=>	(
								start		=>	'0',
								load_iv		=>	'0',
								din			=>	(others => '-'),
								key_id		=>	(others => '-')
							),
			key_i		=>	(
								load_key	=>	'0',
								key_id		=>	(others => '-'),
								key			=>	(others => '-')
							),
			sep			=>	'=',
			mode_o 		=>	(
								busy		=>	'1',
								valid		=>	'1',
								dout		=>	X"507219ee"
							),
			key_o 		=>	(busy => '0')
		),

		-- (tv #67) verify ciphertext part 2
		(
			cycles		=>	1,
			mode_i		=>	(
								start		=>	'0',
								load_iv		=>	'0',
								din			=>	(others => '-'),
								key_id		=>	(others => '-')
							),
			key_i		=>	(
								load_key	=>	'0',
								key_id		=>	(others => '-'),
								key			=>	(others => '-')
							),
			sep			=>	'=',
			mode_o 		=>	(
								busy		=>	'1',
								valid		=>	'1',
								dout		=>	X"95db113a"
							),
			key_o 		=>	(busy => '0')
		),

		-- (tv #68) verify ciphertext part 3
		(
			cycles		=>	1,
			mode_i		=>	(
								start		=>	'0',
								load_iv		=>	'0',
								din			=>	(others => '-'),
								key_id		=>	(others => '-')
							),
			key_i		=>	(
								load_key	=>	'0',
								key_id		=>	(others => '-'),
								key			=>	(others => '-')
							),
			sep			=>	'=',
			mode_o 		=>	(
								busy		=>	'1',
								valid		=>	'1',
								dout		=>	X"917678b2"
							),
			key_o 		=>	(busy => '0')
		),

--
-- encrypt data
--

		-- plaintext = X"30c81c46a35ce411e5fbc1191a0a52ef"
		-- (tv #69) start encryption / load plaintext part 0
		(
			cycles		=>	1,
			mode_i		=>	(
								start		=>	'1',
								load_iv		=>	'0',
								din			=>	X"30c81c46",
								key_id		=>	(others => '-')
							),
			key_i		=>	(
								load_key	=>	'0',
								key_id		=>	(others => '-'),
								key			=>	(others => '-')
							),
			sep			=>	'=',
			mode_o 		=>	(
								busy		=>	'0',
								valid		=>	'0',
								dout		=>	(others => '-')
							),
			key_o 		=>	(busy => '0')
		),


		-- (tv #70) load plaintext part 1
		(
			cycles		=>	1,
			mode_i		=>	(
								start		=>	'0',
								load_iv		=>	'0',
								din			=>	X"a35ce411",
								key_id		=>	(others => '-')
							),
			key_i		=>	(
								load_key	=>	'0',
								key_id		=>	(others => '-'),
								key			=>	(others => '-')
							),
			sep			=>	'=',
			mode_o 		=>	(
								busy		=>	'1',
								valid		=>	'0',
								dout		=>	(others => '-')
							),
			key_o 		=>	(busy => '0')
		),

		-- (tv #71) load plaintext part 2
		(
			cycles		=>	1,
			mode_i		=>	(
								start		=>	'0',
								load_iv		=>	'0',
								din			=>	X"e5fbc119",
								key_id		=>	(others => '-')
							),
			key_i		=>	(
								load_key	=>	'0',
								key_id		=>	(others => '-'),
								key			=>	(others => '-')
							),
			sep			=>	'=',
			mode_o 		=>	(
								busy		=>	'1',
								valid		=>	'0',
								dout		=>	(others => '-')
							),
			key_o 		=>	(busy => '0')
		),


		-- (tv #72) load plaintext part 3
		(
			cycles		=>	1,
			mode_i		=>	(
								start		=>	'0',
								load_iv		=>	'0',
								din			=>	X"1a0a52ef",
								key_id		=>	(others => '-')
							),
			key_i		=>	(
								load_key	=>	'0',
								key_id		=>	(others => '-'),
								key			=>	(others => '-')
							),
			sep			=>	'=',
			mode_o 		=>	(
								busy		=>	'1',
								valid		=>	'0',
								dout		=>	(others => '-')
							),
			key_o 		=>	(busy => '0')
		),

		-- (tv #73) wait while busy
		(
			cycles		=>	47,
			mode_i		=>	(
								start		=>	'0',
								load_iv		=>	'0',
								din			=>	(others => '-'),
								key_id		=>	(others => '-')
							),
			key_i		=>	(
								load_key	=>	'0',
								key_id		=>	(others => '-'),
								key			=>	(others => '-')
							),
			sep			=>	'=',
			mode_o 		=>	(
								busy		=>	'1',
								valid		=>	'0',
								dout		=>	(others => '-')
							),
			key_o 		=>	(busy => '0')
		),

--
-- verify ciphertext
--

		-- ciphertext = X"73bed6b8e3c1743b7116e69e22229516"
		-- (tv #74) verify ciphertext part 0
		(
			cycles		=>	1,
			mode_i		=>	(
								start		=>	'0',
								load_iv		=>	'0',
								din			=>	(others => '-'),
								key_id		=>	(others => '-')
							),
			key_i		=>	(
								load_key	=>	'0',
								key_id		=>	(others => '-'),
								key			=>	(others => '-')
							),
			sep			=>	'=',
			mode_o 		=>	(
								busy		=>	'1',
								valid		=>	'1',
								dout		=>	X"73bed6b8"
							),
			key_o 		=>	(busy => '0')
		),

		-- (tv #75) verify ciphertext part 1
		(
			cycles		=>	1,
			mode_i		=>	(
								start		=>	'0',
								load_iv		=>	'0',
								din			=>	(others => '-'),
								key_id		=>	(others => '-')
							),
			key_i		=>	(
								load_key	=>	'0',
								key_id		=>	(others => '-'),
								key			=>	(others => '-')
							),
			sep			=>	'=',
			mode_o 		=>	(
								busy		=>	'1',
								valid		=>	'1',
								dout		=>	X"e3c1743b"
							),
			key_o 		=>	(busy => '0')
		),

		-- (tv #76) verify ciphertext part 2
		(
			cycles		=>	1,
			mode_i		=>	(
								start		=>	'0',
								load_iv		=>	'0',
								din			=>	(others => '-'),
								key_id		=>	(others => '-')
							),
			key_i		=>	(
								load_key	=>	'0',
								key_id		=>	(others => '-'),
								key			=>	(others => '-')
							),
			sep			=>	'=',
			mode_o 		=>	(
								busy		=>	'1',
								valid		=>	'1',
								dout		=>	X"7116e69e"
							),
			key_o 		=>	(busy => '0')
		),

		-- (tv #77) verify ciphertext part 3
		(
			cycles		=>	1,
			mode_i		=>	(
								start		=>	'0',
								load_iv		=>	'0',
								din			=>	(others => '-'),
								key_id		=>	(others => '-')
							),
			key_i		=>	(
								load_key	=>	'0',
								key_id		=>	(others => '-'),
								key			=>	(others => '-')
							),
			sep			=>	'=',
			mode_o 		=>	(
								busy		=>	'1',
								valid		=>	'1',
								dout		=>	X"22229516"
							),
			key_o 		=>	(busy => '0')
		),

--
-- encrypt data
--

		-- plaintext = X"f69f2445df4f9b17ad2b417be66c3710"
		-- (tv #78) start encryption / load plaintext part 0
		(
			cycles		=>	1,
			mode_i		=>	(
								start		=>	'1',
								load_iv		=>	'0',
								din			=>	X"f69f2445",
								key_id		=>	(others => '-')
							),
			key_i		=>	(
								load_key	=>	'0',
								key_id		=>	(others => '-'),
								key			=>	(others => '-')
							),
			sep			=>	'=',
			mode_o 		=>	(
								busy		=>	'0',
								valid		=>	'0',
								dout		=>	(others => '-')
							),
			key_o 		=>	(busy => '0')
		),


		-- (tv #79) load plaintext part 1
		(
			cycles		=>	1,
			mode_i		=>	(
								start		=>	'0',
								load_iv		=>	'0',
								din			=>	X"df4f9b17",
								key_id		=>	(others => '-')
							),
			key_i		=>	(
								load_key	=>	'0',
								key_id		=>	(others => '-'),
								key			=>	(others => '-')
							),
			sep			=>	'=',
			mode_o 		=>	(
								busy		=>	'1',
								valid		=>	'0',
								dout		=>	(others => '-')
							),
			key_o 		=>	(busy => '0')
		),

		-- (tv #80) load plaintext part 2
		(
			cycles		=>	1,
			mode_i		=>	(
								start		=>	'0',
								load_iv		=>	'0',
								din			=>	X"ad2b417b",
								key_id		=>	(others => '-')
							),
			key_i		=>	(
								load_key	=>	'0',
								key_id		=>	(others => '-'),
								key			=>	(others => '-')
							),
			sep			=>	'=',
			mode_o 		=>	(
								busy		=>	'1',
								valid		=>	'0',
								dout		=>	(others => '-')
							),
			key_o 		=>	(busy => '0')
		),


		-- (tv #81) load plaintext part 3
		(
			cycles		=>	1,
			mode_i		=>	(
								start		=>	'0',
								load_iv		=>	'0',
								din			=>	X"e66c3710",
								key_id		=>	(others => '-')
							),
			key_i		=>	(
								load_key	=>	'0',
								key_id		=>	(others => '-'),
								key			=>	(others => '-')
							),
			sep			=>	'=',
			mode_o 		=>	(
								busy		=>	'1',
								valid		=>	'0',
								dout		=>	(others => '-')
							),
			key_o 		=>	(busy => '0')
		),

		-- (tv #82) wait while busy
		(
			cycles		=>	47,
			mode_i		=>	(
								start		=>	'0',
								load_iv		=>	'0',
								din			=>	(others => '-'),
								key_id		=>	(others => '-')
							),
			key_i		=>	(
								load_key	=>	'0',
								key_id		=>	(others => '-'),
								key			=>	(others => '-')
							),
			sep			=>	'=',
			mode_o 		=>	(
								busy		=>	'1',
								valid		=>	'0',
								dout		=>	(others => '-')
							),
			key_o 		=>	(busy => '0')
		),

--
-- verify ciphertext
--

		-- ciphertext = X"3ff1caa1681fac09120eca307586e1a7"
		-- (tv #83) verify ciphertext part 0
		(
			cycles		=>	1,
			mode_i		=>	(
								start		=>	'0',
								load_iv		=>	'0',
								din			=>	(others => '-'),
								key_id		=>	(others => '-')
							),
			key_i		=>	(
								load_key	=>	'0',
								key_id		=>	(others => '-'),
								key			=>	(others => '-')
							),
			sep			=>	'=',
			mode_o 		=>	(
								busy		=>	'1',
								valid		=>	'1',
								dout		=>	X"3ff1caa1"
							),
			key_o 		=>	(busy => '0')
		),

		-- (tv #84) verify ciphertext part 1
		(
			cycles		=>	1,
			mode_i		=>	(
								start		=>	'0',
								load_iv		=>	'0',
								din			=>	(others => '-'),
								key_id		=>	(others => '-')
							),
			key_i		=>	(
								load_key	=>	'0',
								key_id		=>	(others => '-'),
								key			=>	(others => '-')
							),
			sep			=>	'=',
			mode_o 		=>	(
								busy		=>	'1',
								valid		=>	'1',
								dout		=>	X"681fac09"
							),
			key_o 		=>	(busy => '0')
		),

		-- (tv #85) verify ciphertext part 2
		(
			cycles		=>	1,
			mode_i		=>	(
								start		=>	'0',
								load_iv		=>	'0',
								din			=>	(others => '-'),
								key_id		=>	(others => '-')
							),
			key_i		=>	(
								load_key	=>	'0',
								key_id		=>	(others => '-'),
								key			=>	(others => '-')
							),
			sep			=>	'=',
			mode_o 		=>	(
								busy		=>	'1',
								valid		=>	'1',
								dout		=>	X"120eca30"
							),
			key_o 		=>	(busy => '0')
		),

		-- (tv #86) verify ciphertext part 3
		(
			cycles		=>	1,
			mode_i		=>	(
								start		=>	'0',
								load_iv		=>	'0',
								din			=>	(others => '-'),
								key_id		=>	(others => '-')
							),
			key_i		=>	(
								load_key	=>	'0',
								key_id		=>	(others => '-'),
								key			=>	(others => '-')
							),
			sep			=>	'=',
			mode_o 		=>	(
								busy		=>	'1',
								valid		=>	'1',
								dout		=>	X"7586e1a7"
							),
			key_o 		=>	(busy => '0')
		),

--
--
--

		-- (tv #87) idle
		(
			cycles		=>	1,
			mode_i		=>	(
								start		=>	'0',
								load_iv		=>	'0',
								din			=>	(others => '-'),
								key_id		=>	(others => '-')
							),
			key_i		=>	(
								load_key	=>	'0',
								key_id		=>	(others => '-'),
								key			=>	(others => '-')
							),
			sep			=>	'=',
			mode_o 		=>	(
								busy		=>	'0',
								valid		=>	'0',
								dout		=>	(others => '-')
							),
			key_o 		=>	(busy => '0')
		)


	);


	signal rst		: 	std_logic;						-- reset
	signal clk		:	std_logic;						-- clock
	signal mode_i	:	cbc_mode_encryption_in_type;	-- see package cbc_mode_iface
	signal mode_o	:	cbc_mode_encryption_out_type;	-- see package cbc_mode_iface
	signal key_i	:	key_schedule_128_in_type;		-- see package key_schedule_iface
	signal key_o	:	key_schedule_128_out_type;		-- see package key_schedule_iface
	signal sbld_i	:	sbox_stage_load_in_type;		-- see package tech_iface


	constant CLK_PERIOD : time  := 20 ns;


begin


	uut: cbc_128_encryption_core
		port map (
			rst		=> 	rst,
			clk		=>	clk,
			mode_i	=>	mode_i,
			mode_o	=>	mode_o,
			key_i	=>	key_i,
			key_o	=>	key_o,
			sbld_i	=>	sbld_i
		);


	init: sbox_loader
		port map (
			rst		=>	rst,
			clk		=>	clk,
			load_o	=>	sbld_i
		);


	tb: process
	begin

		clk <= '0';
		rst <= '1';
		mode_i.start <= '0';
		key_i.load_key <= '0';

		-- Virtex GSR-signal is deactivated 100ns after "configuration"
		wait for 200 ns;


		-- some clock cycles for reset
		for i in 0 to 3 loop
			wait for CLK_PERIOD / 2;
			clk <= '1';
			wait for CLK_PERIOD / 2;
			clk <= '0';
		end loop;


		wait for CLK_PERIOD / 2;
		clk <= '1';
		wait for CLK_PERIOD / 4;


		-- separate normal output from the ugly stuff displayed at start-up
		puts("#");
		puts("#");
		puts("# *** Releasing reset ***");
		puts("#");
		puts("#");

		rst <= '0';


		puts("#");
		puts("#");
		puts("# *** Pre-loading S-boxes ***");
		puts("#");
		puts("#");

		while (sbld_i.done = '0') loop

			wait for CLK_PERIOD / 4;
			clk <= '0';
			wait for CLK_PERIOD / 2;
			clk <= '1';
			wait for CLK_PERIOD / 4;

		end loop;


		-- some more clock cycles
		for i in 0 to 3 loop
			wait for CLK_PERIOD / 4;
			clk <= '0';
			wait for CLK_PERIOD / 2;
			clk <= '1';
			wait for CLK_PERIOD / 4;
		end loop;


		puts("#");
		puts("#");
		puts("# *** Processing Test-Vectors ***");
		puts("#");
		puts("#");


		for i in TEST_VECTORS'range loop

			-- assign stimuli
			mode_i <= TEST_VECTORS(i).mode_i;
			key_i <= TEST_VECTORS(i).key_i;


			for j in 1 to TEST_VECTORS(i).cycles loop

				wait for CLK_PERIOD / 4;
				clk <= '0';
				wait for CLK_PERIOD / 4;


				-- verify results (still during the same clock cycle)

				assert (mode_o.busy = TEST_VECTORS(i).mode_o.busy)
					report "Test vector #" & Integer'image(i+1) & " failed on <mode_o.busy>!"
						severity failure;

				assert (mode_o.valid = TEST_VECTORS(i).mode_o.valid)
					report "Test vector #" & Integer'image(i+1) & " failed on <mode_o.valid>!"
						severity failure;

				if (mode_o.valid = '1')
					then
						assert (mode_o.dout = TEST_VECTORS(i).mode_o.dout)
							report "Test vector #" & Integer'image(i+1) & " failed on <mode_o.dout>!"
								severity failure;
				end if;

				assert (key_o.busy = TEST_VECTORS(i).key_o.busy)
					report "Test vector #" & Integer'image(i+1) & " failed on <key_o.busy>!"
						severity failure;


				wait for CLK_PERIOD / 4;
				clk <= '1';
				wait for CLK_PERIOD / 4;

			end loop;

		end loop;



		puts("#");
		puts("#");
		puts("# *** All test vectors processed! ***");
		puts("#");
		puts("#");


		-- some more clock cycles
		for i in 0 to 10 loop
			wait for CLK_PERIOD / 4;
			clk <= '0';
			wait for CLK_PERIOD / 2;
			clk <= '1';
			wait for CLK_PERIOD / 4;
		end loop;


		puts("# *** End of test! ***");
		puts("#");
		puts("#");


		assert false
			report "Forced simulation halt"
				severity failure;

		wait;

	end process;


end stimuli;
