Line 1... |
Line 1... |
-- $Id: input.vhdl,v 1.1.1.1 2005-12-06 02:47:46 arif_endro Exp $
|
-- $Id: input.vhdl,v 1.2 2005-12-23 04:27:00 arif_endro Exp $
|
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
-- Title : Input
|
-- Title : Input
|
-- Project : Mini AES 128
|
-- Project : Mini AES 128
|
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
-- File : input.vhdl
|
-- File : input.vhdl
|
Line 50... |
Line 50... |
use std_developerskit.std_iopak.all; -- Function From_HexString
|
use std_developerskit.std_iopak.all; -- Function From_HexString
|
|
|
entity input is
|
entity input is
|
port (
|
port (
|
clock : out std_logic;
|
clock : out std_logic;
|
clear : out std_logic;
|
load : out std_logic;
|
done : in std_logic;
|
done : in std_logic;
|
test_iteration : out integer;
|
test_iteration : out integer;
|
data_i : out std_logic_vector (127 downto 000);
|
key_i_byte : out std_logic_vector (007 downto 000);
|
cipher_o : out std_logic_vector (127 downto 000);
|
data_i_byte : out std_logic_vector (007 downto 000);
|
key_i : out std_logic_vector (127 downto 000)
|
cipher_o_byte : out std_logic_vector (007 downto 000)
|
);
|
);
|
end input;
|
end input;
|
|
|
architecture test_bench of input is
|
architecture test_bench of input is
|
|
|
--
|
--
|
file in_file_ptr : text open read_mode is "../data/ecb_tbl.txt";
|
file in_file_ptr : text open read_mode is "../data/ecb_tbl.txt";
|
--
|
--
|
signal clock_int : std_logic := '0';
|
signal clock_int : std_logic := '0';
|
|
signal ct : std_logic_vector (127 downto 000);
|
|
signal pt : std_logic_vector (127 downto 000);
|
|
signal ky : std_logic_vector (127 downto 000);
|
--
|
--
|
begin
|
begin
|
--
|
--
|
clock_int <= not(clock_int) after 1 ns;
|
clock_int <= not(clock_int) after 1 ns;
|
clock <= clock_int;
|
clock <= clock_int;
|
Line 103... |
Line 106... |
read(in_line, plain_text);
|
read(in_line, plain_text);
|
readline(in_file_ptr, in_line);
|
readline(in_file_ptr, in_line);
|
read(in_line, junk_cipher_text);
|
read(in_line, junk_cipher_text);
|
read(in_line, cipher_text);
|
read(in_line, cipher_text);
|
--
|
--
|
|
ky <= to_StdLogicVector(From_HexString(key( 01 to 32)));
|
|
pt <= to_StdLogicVector(From_HexString(plain_text( 01 to 32 )));
|
|
ct <= to_StdLogicVector(From_HexString(cipher_text( 01 to 32 )));
|
|
--
|
|
for a in 1 to key'length/2 loop
|
wait until rising_edge(clock_int);
|
wait until rising_edge(clock_int);
|
key_i <= to_StdLogicVector(From_HexString(key( 01 to 32)));
|
key_i_byte <= to_StdLogicVector(From_HexString(key(2*a-1 to 2*a)));
|
data_i <= to_StdLogicVector(From_HexString(plain_text( 01 to 32 )));
|
data_i_byte <= to_StdLogicVector(From_HexString(plain_text(2*a-1 to 2*a)));
|
cipher_o <= to_StdLogicVector(From_HexString(cipher_text( 01 to 32 )));
|
cipher_o_byte <= to_StdLogicVector(From_HexString(cipher_text(2*a-1 to 2*a)));
|
|
load <= '1';
|
test_iteration <= test;
|
test_iteration <= test;
|
|
end loop;
|
--
|
--
|
clear <= '1';
|
|
wait until rising_edge(clock_int);
|
wait until rising_edge(clock_int);
|
clear <= '0';
|
load <= '0';
|
wait until rising_edge(done);
|
--
|
|
wait until falling_edge(done);
|
wait until rising_edge(clock_int);
|
wait until rising_edge(clock_int);
|
--
|
--
|
end loop;
|
end loop;
|
wait;
|
wait;
|
end process;
|
end process;
|