Line 1... |
Line 1... |
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
---- ----
|
---- ----
|
|
---- Pipelined Aes IP Core ----
|
|
---- ----
|
|
---- This file is part of the Pipelined AES project ----
|
|
---- http://www.opencores.org/cores/aes_pipe/ ----
|
|
---- ----
|
|
---- Description ----
|
|
---- Implementation of AES IP core according to ----
|
|
---- FIPS PUB 197 specification document. ----
|
|
---- ----
|
|
---- To Do: ----
|
|
---- - ----
|
|
---- ----
|
|
---- Author: ----
|
|
---- - Subhasis Das, subhasis256@gmail.com ----
|
|
---- ----
|
|
----------------------------------------------------------------------
|
|
---- ----
|
|
---- Copyright (C) 2009 Authors and OPENCORES.ORG ----
|
|
---- ----
|
---- This source file may be used and distributed without ----
|
---- This source file may be used and distributed without ----
|
---- restriction provided that this copyright statement is not ----
|
---- restriction provided that this copyright statement is not ----
|
---- removed from the file and that any derivative work contains ----
|
---- removed from the file and that any derivative work contains ----
|
---- the original copyright notice and the associated disclaimer. ----
|
---- the original copyright notice and the associated disclaimer. ----
|
---- ----
|
---- ----
|
Line 23... |
Line 42... |
---- ----
|
---- ----
|
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
------------------------------------------------------
|
------------------------------------------------------
|
-- Project: AESFast
|
-- Project: AESFast
|
-- Author: Subhasis
|
-- Author: Subhasis
|
-- Last Modified: 20/03/10
|
-- Last Modified: 25/03/10
|
-- Email: subhasis256@gmail.com
|
-- Email: subhasis256@gmail.com
|
------------------------------------------------------
|
------------------------------------------------------
|
--
|
--
|
-- Description: The Overall Core
|
-- Description: The Overall Core
|
-- Ports:
|
-- Ports:
|
Line 46... |
Line 65... |
use work.aes_pkg.all;
|
use work.aes_pkg.all;
|
|
|
entity aes_top is
|
entity aes_top is
|
port(
|
port(
|
clk_i: in std_logic;
|
clk_i: in std_logic;
|
|
rst_i: in std_logic;
|
plaintext_i: in datablock;
|
plaintext_i: in datablock;
|
keyblock_i: in datablock;
|
keyblock_i: in datablock;
|
ciphertext_o: out datablock
|
ciphertext_o: out datablock
|
);
|
);
|
end aes_top;
|
end aes_top;
|
Line 61... |
Line 81... |
signal textnet_s_a: datablock;
|
signal textnet_s_a: datablock;
|
|
|
component sboxshr is
|
component sboxshr is
|
port(
|
port(
|
clk: in std_logic;
|
clk: in std_logic;
|
|
rst: in std_logic;
|
blockin: in datablock;
|
blockin: in datablock;
|
fc3: in blockcol;
|
fc3: in blockcol;
|
c0: in blockcol;
|
c0: in blockcol;
|
c1: in blockcol;
|
c1: in blockcol;
|
c2: in blockcol;
|
c2: in blockcol;
|
Line 74... |
Line 95... |
);
|
);
|
end component;
|
end component;
|
component colmix is
|
component colmix is
|
port(
|
port(
|
clk: in std_logic;
|
clk: in std_logic;
|
|
rst: in std_logic;
|
datain: in datablock;
|
datain: in datablock;
|
inrkey: in datablock;
|
inrkey: in datablock;
|
outrkey: out datablock;
|
outrkey: out datablock;
|
dataout: out datablock
|
dataout: out datablock
|
);
|
);
|
end component;
|
end component;
|
component addkey is
|
component addkey is
|
port(
|
port(
|
clk: in std_logic;
|
clk: in std_logic;
|
|
rst: in std_logic;
|
roundkey: in datablock;
|
roundkey: in datablock;
|
datain: in datablock;
|
datain: in datablock;
|
rcon: in std_logic_vector(7 downto 0);
|
rcon: in std_logic_vector(7 downto 0);
|
dataout: out datablock;
|
dataout: out datablock;
|
fc3: out blockcol;
|
fc3: out blockcol;
|
Line 107... |
Line 130... |
-- Sbox -> Addkey
|
-- Sbox -> Addkey
|
-------------------------------------------------------
|
-------------------------------------------------------
|
proc: for i in 8 downto 0 generate
|
proc: for i in 8 downto 0 generate
|
add: addkey port map(
|
add: addkey port map(
|
clk => clk_i,
|
clk => clk_i,
|
|
rst => rst_i,
|
roundkey => key_m(i),
|
roundkey => key_m(i),
|
datain => textnet_m_a(i),
|
datain => textnet_m_a(i),
|
rcon => rcon(i),
|
rcon => rcon(i),
|
dataout => textnet_a_s(i),
|
dataout => textnet_a_s(i),
|
fc3 => fc3(i),
|
fc3 => fc3(i),
|
Line 119... |
Line 143... |
c2 => c2(i),
|
c2 => c2(i),
|
c3 => c3(i)
|
c3 => c3(i)
|
);
|
);
|
sbox: sboxshr port map(
|
sbox: sboxshr port map(
|
clk => clk_i,
|
clk => clk_i,
|
|
rst => rst_i,
|
blockin => textnet_a_s(i),
|
blockin => textnet_a_s(i),
|
fc3 => fc3(i),
|
fc3 => fc3(i),
|
c0 => c0(i),
|
c0 => c0(i),
|
c1 => c1(i),
|
c1 => c1(i),
|
c2 => c2(i),
|
c2 => c2(i),
|
Line 130... |
Line 155... |
nextkey => key_s(i),
|
nextkey => key_s(i),
|
blockout => textnet_s_m(i)
|
blockout => textnet_s_m(i)
|
);
|
);
|
mix: colmix port map(
|
mix: colmix port map(
|
clk => clk_i,
|
clk => clk_i,
|
|
rst => rst_i,
|
datain => textnet_s_m(i),
|
datain => textnet_s_m(i),
|
inrkey => key_s(i),
|
inrkey => key_s(i),
|
outrkey => key_m(i+1),
|
outrkey => key_m(i+1),
|
dataout => textnet_m_a(i+1)
|
dataout => textnet_m_a(i+1)
|
);
|
);
|
end generate;
|
end generate;
|
add_f_1: addkey port map(
|
add_f_1: addkey port map(
|
clk => clk_i,
|
clk => clk_i,
|
|
rst => rst_i,
|
roundkey => key_m(9),
|
roundkey => key_m(9),
|
datain => textnet_m_a(9),
|
datain => textnet_m_a(9),
|
rcon => rcon(9),
|
rcon => rcon(9),
|
dataout => textnet_a_s(9),
|
dataout => textnet_a_s(9),
|
fc3 => fc3(9),
|
fc3 => fc3(9),
|
Line 150... |
Line 177... |
c2 => c2(9),
|
c2 => c2(9),
|
c3 => c3(9)
|
c3 => c3(9)
|
);
|
);
|
sbox_f_1: sboxshr port map(
|
sbox_f_1: sboxshr port map(
|
clk => clk_i,
|
clk => clk_i,
|
|
rst => rst_i,
|
blockin => textnet_a_s(9),
|
blockin => textnet_a_s(9),
|
fc3 => fc3(9),
|
fc3 => fc3(9),
|
c0 => c0(9),
|
c0 => c0(9),
|
c1 => c1(9),
|
c1 => c1(9),
|
c2 => c2(9),
|
c2 => c2(9),
|
Line 161... |
Line 189... |
nextkey => key_s(9),
|
nextkey => key_s(9),
|
blockout => textnet_s_a
|
blockout => textnet_s_a
|
);
|
);
|
add_f: addkey port map(
|
add_f: addkey port map(
|
clk => clk_i,
|
clk => clk_i,
|
|
rst => rst_i,
|
roundkey => key_s(9),
|
roundkey => key_s(9),
|
datain => textnet_s_a,
|
datain => textnet_s_a,
|
rcon => X"00",
|
rcon => X"00",
|
dataout => ciphertext_o
|
dataout => ciphertext_o
|
);
|
);
|