-- ------------------------------------------------------------------------
|
-- ------------------------------------------------------------------------
|
-- Copyright (C) 2005 Arif Endro Nugroho
|
-- Copyright (C) 2005 Arif Endro Nugroho
|
-- All rights reserved.
|
-- All rights reserved.
|
--
|
--
|
-- Redistribution and use in source and binary forms, with or without
|
-- Redistribution and use in source and binary forms, with or without
|
-- modification, are permitted provided that the following conditions
|
-- modification, are permitted provided that the following conditions
|
-- are met:
|
-- are met:
|
--
|
--
|
-- 1. Redistributions of source code must retain the above copyright
|
-- 1. Redistributions of source code must retain the above copyright
|
-- notice, this list of conditions and the following disclaimer.
|
-- notice, this list of conditions and the following disclaimer.
|
-- 2. Redistributions in binary form must reproduce the above copyright
|
-- 2. Redistributions in binary form must reproduce the above copyright
|
-- notice, this list of conditions and the following disclaimer in the
|
-- notice, this list of conditions and the following disclaimer in the
|
-- documentation and/or other materials provided with the distribution.
|
-- documentation and/or other materials provided with the distribution.
|
-- 3. The name of Arif Endro Nugroho may not be used to endorse or promote
|
|
-- products derived from this software without specific prior written
|
|
-- permission.
|
|
--
|
--
|
-- THIS SOFTWARE IS PROVIDED BY ARIF ENDRO NUGROHO "AS IS" AND ANY EXPRESS
|
-- THIS SOFTWARE IS PROVIDED BY ARIF ENDRO NUGROHO "AS IS" AND ANY EXPRESS
|
-- OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
-- OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
-- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
-- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
-- DISCLAIMED. IN NO EVENT SHALL ARIF ENDRO NUGROHO BE LIABLE FOR ANY
|
-- DISCLAIMED. IN NO EVENT SHALL ARIF ENDRO NUGROHO BE LIABLE FOR ANY
|
-- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
-- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
-- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
-- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
-- OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
-- OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
-- HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
-- HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
-- STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
-- STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
-- ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
-- ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
-- POSSIBILITY OF SUCH DAMAGE.
|
-- POSSIBILITY OF SUCH DAMAGE.
|
--
|
--
|
-- End Of License.
|
-- End Of License.
|
-- ------------------------------------------------------------------------
|
-- ------------------------------------------------------------------------
|
|
|
library ieee;
|
library ieee;
|
use ieee.std_logic_1164.all;
|
use ieee.std_logic_1164.all;
|
|
|
entity modelsim_bench is
|
entity modelsim_bench is
|
end modelsim_bench;
|
end modelsim_bench;
|
|
|
architecture structural of modelsim_bench is
|
architecture structural of modelsim_bench is
|
|
|
component mini_aes
|
component mini_aes
|
port (
|
port (
|
clock : in std_logic;
|
clock : in std_logic;
|
clear : in std_logic;
|
clear : in std_logic;
|
load_i : in std_logic;
|
load_i : in std_logic;
|
enc : in std_logic;
|
enc : in std_logic;
|
key_i : in std_logic_vector (007 downto 000);
|
key_i : in std_logic_vector (007 downto 000);
|
data_i : in std_logic_vector (007 downto 000);
|
data_i : in std_logic_vector (007 downto 000);
|
data_o : out std_logic_vector (007 downto 000);
|
data_o : out std_logic_vector (007 downto 000);
|
done_o : out std_logic
|
done_o : out std_logic
|
);
|
);
|
end component;
|
end component;
|
--
|
--
|
component input
|
component input
|
port (
|
port (
|
clock : out std_logic;
|
clock : out std_logic;
|
load : out std_logic;
|
load : out std_logic;
|
done : in std_logic;
|
done : in std_logic;
|
test_iteration : out integer;
|
test_iteration : out integer;
|
key_i_byte : out std_logic_vector (007 downto 000);
|
key_i_byte : out std_logic_vector (007 downto 000);
|
data_i_byte : out std_logic_vector (007 downto 000);
|
data_i_byte : out std_logic_vector (007 downto 000);
|
cipher_o_byte : out std_logic_vector (007 downto 000)
|
cipher_o_byte : out std_logic_vector (007 downto 000)
|
);
|
);
|
end component;
|
end component;
|
--
|
--
|
component output
|
component output
|
port (
|
port (
|
clock : in std_logic;
|
clock : in std_logic;
|
clear : in std_logic;
|
clear : in std_logic;
|
load : in std_logic;
|
load : in std_logic;
|
enc : in std_logic;
|
enc : in std_logic;
|
done : in std_logic;
|
done : in std_logic;
|
test_iteration : in integer;
|
test_iteration : in integer;
|
verifier : in std_logic_vector (007 downto 000);
|
verifier : in std_logic_vector (007 downto 000);
|
data_o : in std_logic_vector (007 downto 000)
|
data_o : in std_logic_vector (007 downto 000)
|
);
|
);
|
end component;
|
end component;
|
|
|
signal load_enc : std_logic;
|
signal load_enc : std_logic;
|
signal load_dec : std_logic;
|
signal load_dec : std_logic;
|
signal clock_enc : std_logic;
|
signal clock_enc : std_logic;
|
signal clock_dec : std_logic;
|
signal clock_dec : std_logic;
|
signal done_dec : std_logic;
|
signal done_dec : std_logic;
|
signal done_enc : std_logic;
|
signal done_enc : std_logic;
|
signal test_iteration_enc : integer;
|
signal test_iteration_enc : integer;
|
signal test_iteration_dec : integer;
|
signal test_iteration_dec : integer;
|
signal cipher_o_enc : std_logic_vector (007 downto 000);
|
signal cipher_o_enc : std_logic_vector (007 downto 000);
|
signal cipher_o_dec : std_logic_vector (007 downto 000);
|
signal cipher_o_dec : std_logic_vector (007 downto 000);
|
signal data_i_enc : std_logic_vector (007 downto 000);
|
signal data_i_enc : std_logic_vector (007 downto 000);
|
signal data_i_dec : std_logic_vector (007 downto 000);
|
signal data_i_dec : std_logic_vector (007 downto 000);
|
signal data_o_enc : std_logic_vector (007 downto 000);
|
signal data_o_enc : std_logic_vector (007 downto 000);
|
signal data_o_dec : std_logic_vector (007 downto 000);
|
signal data_o_dec : std_logic_vector (007 downto 000);
|
signal key_i_enc : std_logic_vector (007 downto 000);
|
signal key_i_enc : std_logic_vector (007 downto 000);
|
signal key_i_dec : std_logic_vector (007 downto 000);
|
signal key_i_dec : std_logic_vector (007 downto 000);
|
|
|
begin
|
begin
|
|
|
my_aes_enc : mini_aes
|
my_aes_enc : mini_aes
|
port map (
|
port map (
|
clock => clock_enc,
|
clock => clock_enc,
|
clear => '0',
|
clear => '0',
|
load_i => load_enc,
|
load_i => load_enc,
|
enc => '0',
|
enc => '0',
|
key_i => key_i_enc,
|
key_i => key_i_enc,
|
data_i => data_i_enc,
|
data_i => data_i_enc,
|
data_o => data_o_enc,
|
data_o => data_o_enc,
|
done_o => done_enc
|
done_o => done_enc
|
);
|
);
|
--
|
--
|
my_aes_dec : mini_aes
|
my_aes_dec : mini_aes
|
port map (
|
port map (
|
clock => clock_dec,
|
clock => clock_dec,
|
clear => '0',
|
clear => '0',
|
load_i => load_dec,
|
load_i => load_dec,
|
enc => '1',
|
enc => '1',
|
key_i => key_i_dec,
|
key_i => key_i_dec,
|
data_i => cipher_o_dec,
|
data_i => cipher_o_dec,
|
data_o => data_o_dec,
|
data_o => data_o_dec,
|
done_o => done_dec
|
done_o => done_dec
|
);
|
);
|
--
|
--
|
my_input_enc : input
|
my_input_enc : input
|
port map (
|
port map (
|
clock => clock_enc,
|
clock => clock_enc,
|
load => load_enc,
|
load => load_enc,
|
done => done_enc,
|
done => done_enc,
|
test_iteration => test_iteration_enc,
|
test_iteration => test_iteration_enc,
|
key_i_byte => key_i_enc,
|
key_i_byte => key_i_enc,
|
data_i_byte => data_i_enc,
|
data_i_byte => data_i_enc,
|
cipher_o_byte => cipher_o_enc
|
cipher_o_byte => cipher_o_enc
|
);
|
);
|
my_input_dec : input
|
my_input_dec : input
|
port map (
|
port map (
|
clock => clock_dec,
|
clock => clock_dec,
|
load => load_dec,
|
load => load_dec,
|
done => done_dec,
|
done => done_dec,
|
test_iteration => test_iteration_dec,
|
test_iteration => test_iteration_dec,
|
data_i_byte => data_i_dec,
|
data_i_byte => data_i_dec,
|
cipher_o_byte => cipher_o_dec,
|
cipher_o_byte => cipher_o_dec,
|
key_i_byte => key_i_dec
|
key_i_byte => key_i_dec
|
);
|
);
|
--
|
--
|
my_output_enc : output
|
my_output_enc : output
|
port map (
|
port map (
|
clock => clock_enc,
|
clock => clock_enc,
|
clear => '0',
|
clear => '0',
|
load => load_enc,
|
load => load_enc,
|
enc => '0',
|
enc => '0',
|
done => done_enc,
|
done => done_enc,
|
test_iteration => test_iteration_enc,
|
test_iteration => test_iteration_enc,
|
verifier => cipher_o_enc,
|
verifier => cipher_o_enc,
|
data_o => data_o_enc
|
data_o => data_o_enc
|
);
|
);
|
--
|
--
|
my_output_dec : output
|
my_output_dec : output
|
port map (
|
port map (
|
clock => clock_dec,
|
clock => clock_dec,
|
clear => '0',
|
clear => '0',
|
load => load_dec,
|
load => load_dec,
|
enc => '1',
|
enc => '1',
|
done => done_dec,
|
done => done_dec,
|
test_iteration => test_iteration_dec,
|
test_iteration => test_iteration_dec,
|
verifier => data_i_dec,
|
verifier => data_i_dec,
|
data_o => data_o_dec
|
data_o => data_o_dec
|
);
|
);
|
|
|
end structural;
|
end structural;
|
|
|