OpenCores
URL https://opencores.org/ocsvn/aes_pipe/aes_pipe/trunk

Subversion Repositories aes_pipe

[/] [aes_pipe/] [trunk/] [rtl/] [vhdl/] [keysched1.vhdl] - Diff between revs 5 and 9

Only display areas with differences | Details | Blame | View Log

Rev 5 Rev 9
----------------------------------------------------------------------
----------------------------------------------------------------------
----                                                              ----
----                                                              ----
---- Pipelined Aes IP Core                                        ----
---- Pipelined Aes IP Core                                        ----
----                                                              ----
----                                                              ----
---- This file is part of the Pipelined AES project               ----
---- This file is part of the Pipelined AES project               ----
---- http://www.opencores.org/cores/aes_pipe/                     ----
---- http://www.opencores.org/cores/aes_pipe/                     ----
----                                                              ----
----                                                              ----
---- Description                                                  ----
---- Description                                                  ----
---- Implementation of AES IP core according to                   ----
---- Implementation of AES IP core according to                   ----
---- FIPS PUB 197 specification document.                         ----
---- FIPS PUB 197 specification document.                         ----
----                                                              ----
----                                                              ----
---- To Do:                                                       ----
---- To Do:                                                       ----
----   -                                                          ----
----   -                                                          ----
----                                                              ----
----                                                              ----
---- Author:                                                      ----
---- Author:                                                      ----
----      - Subhasis Das, subhasis256@gmail.com                   ----
----      - Subhasis Das, subhasis256@gmail.com                   ----
----                                                              ----
----                                                              ----
----------------------------------------------------------------------
----------------------------------------------------------------------
----                                                              ----
----                                                              ----
---- Copyright (C) 2009 Authors and OPENCORES.ORG                 ----
---- 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. ----
----                                                              ----
----                                                              ----
---- This source file is free software; you can redistribute it   ----
---- This source file is free software; you can redistribute it   ----
---- and/or modify it under the terms of the GNU Lesser General   ----
---- and/or modify it under the terms of the GNU Lesser General   ----
---- Public License as published by the Free Software Foundation; ----
---- Public License as published by the Free Software Foundation; ----
---- either version 2.1 of the License, or (at your option) any   ----
---- either version 2.1 of the License, or (at your option) any   ----
---- later version.                                               ----
---- later version.                                               ----
----                                                              ----
----                                                              ----
---- This source is distributed in the hope that it will be       ----
---- This source is distributed in the hope that it will be       ----
---- useful, but WITHOUT ANY WARRANTY; without even the implied   ----
---- useful, but WITHOUT ANY WARRANTY; without even the implied   ----
---- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ----
---- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ----
---- PURPOSE. See the GNU Lesser General Public License for more ----
---- PURPOSE. See the GNU Lesser General Public License for more ----
---- details.                                                     ----
---- details.                                                     ----
----                                                              ----
----                                                              ----
---- You should have received a copy of the GNU Lesser General    ----
---- You should have received a copy of the GNU Lesser General    ----
---- Public License along with this source; if not, download it   ----
---- Public License along with this source; if not, download it   ----
---- from http://www.opencores.org/lgpl.shtml                     ----
---- from http://www.opencores.org/lgpl.shtml                     ----
----                                                              ----
----                                                              ----
----------------------------------------------------------------------
----------------------------------------------------------------------
------------------------------------------------------
------------------------------------------------------
-- 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: First stage of key expansion
-- Description: First stage of key expansion
-- Ports:
-- Ports:
--                      clk: System Clock
--                      clk: System Clock
--                      roundkey: Current roundkey
--                      roundkey: Current roundkey
--                      rcon: Rcon byte for the next byte
--                      rcon: Rcon byte for the next byte
--                      fc3: Sbox(RotWord(column3 of rkey)) xor Rcon
--                      fc3: Sbox(RotWord(column3 of rkey)) xor Rcon
--                      c0: column0 of rkey
--                      c0: column0 of rkey
--                      c1: column0 xor column1
--                      c1: column0 xor column1
--                      c2: column0 xor column1 xor column2
--                      c2: column0 xor column1 xor column2
--                      c3: column0 xor column1 xor column2 xor column3
--                      c3: column0 xor column1 xor column2 xor column3
------------------------------------------------------
------------------------------------------------------
 
 
library IEEE;
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.std_logic_1164.all;
use IEEE.std_logic_arith.all;
use IEEE.std_logic_arith.all;
use IEEE.std_logic_unsigned.all;
use IEEE.std_logic_unsigned.all;
 
 
library work;
library work;
use work.aes_pkg.all;
use work.aes_pkg.all;
 
 
entity keysched1 is
entity keysched1 is
port(
port(
        clk: in std_logic;
        clk: in std_logic;
 
        rst: in std_logic;
        roundkey: in datablock;
        roundkey: in datablock;
        rcon: in std_logic_vector(7 downto 0);
        rcon: in std_logic_vector(7 downto 0);
        fc3: out blockcol;
        fc3: out blockcol;
        c0: out blockcol;
        c0: out blockcol;
        c1: out blockcol;
        c1: out blockcol;
        c2: out blockcol;
        c2: out blockcol;
        c3: out blockcol
        c3: out blockcol
        );
        );
end keysched1;
end keysched1;
 
 
architecture rtl of keysched1 is
architecture rtl of keysched1 is
signal subst: blockcol;
signal subst: blockcol;
signal key0, key1, key2, key3: std_logic_vector(7 downto 0);
signal key0, key1, key2, key3: std_logic_vector(7 downto 0);
component sbox is
component sbox is
port(
port(
        clk: in std_logic;
        clk: in std_logic;
 
        rst: in std_logic;
        bytein: in std_logic_vector(7 downto 0);
        bytein: in std_logic_vector(7 downto 0);
        byteout: out std_logic_vector(7 downto 0)
        byteout: out std_logic_vector(7 downto 0)
        );
        );
end component;
end component;
signal rcon_d: std_logic_vector(7 downto 0);
signal rcon_d: std_logic_vector(7 downto 0);
begin
begin
        sub0: sbox port map(
        sub0: sbox port map(
                                          clk => clk,
                                          clk => clk,
 
                                          rst => rst,
                                          bytein => roundkey(0, 3),
                                          bytein => roundkey(0, 3),
                                          byteout => subst(3)
                                          byteout => subst(3)
                                          );
                                          );
        sub1: sbox port map(
        sub1: sbox port map(
                                          clk => clk,
                                          clk => clk,
 
                                          rst => rst,
                                          bytein => roundkey(1, 3),
                                          bytein => roundkey(1, 3),
                                          byteout => subst(0)
                                          byteout => subst(0)
                                          );
                                          );
        sub2: sbox port map(
        sub2: sbox port map(
                                          clk => clk,
                                          clk => clk,
 
                                          rst => rst,
                                          bytein => roundkey(2, 3),
                                          bytein => roundkey(2, 3),
                                          byteout => subst(1)
                                          byteout => subst(1)
                                          );
                                          );
        sub3: sbox port map(
        sub3: sbox port map(
                                          clk => clk,
                                          clk => clk,
 
                                          rst => rst,
                                          bytein => roundkey(3, 3),
                                          bytein => roundkey(3, 3),
                                          byteout => subst(2)
                                          byteout => subst(2)
                                          );
                                          );
        fc3(0) <= subst(0) xor rcon_d;
        fc3(0) <= subst(0) xor rcon_d;
        fc3(1) <= subst(1);
        fc3(1) <= subst(1);
        fc3(2) <= subst(2);
        fc3(2) <= subst(2);
        fc3(3) <= subst(3);
        fc3(3) <= subst(3);
        process(clk)
        process(clk,rst)
        begin
        begin
                if(rising_edge(clk)) then
                if(rst = '1') then
 
                        rcon_d <= X"00";
 
                        c0 <= zero_col;
 
                        c1 <= zero_col;
 
                        c2 <= zero_col;
 
                        c3 <= zero_col;
 
                elsif(rising_edge(clk)) then
                        rcon_d <= rcon;
                        rcon_d <= rcon;
                        for j in 3 downto 0 loop
                        for j in 3 downto 0 loop
                                c0(j) <= roundkey(j, 0);
                                c0(j) <= roundkey(j, 0);
                                c1(j) <= roundkey(j, 0) xor roundkey(j, 1);
                                c1(j) <= roundkey(j, 0) xor roundkey(j, 1);
                                c2(j) <= roundkey(j, 0) xor roundkey(j, 1) xor roundkey(j, 2);
                                c2(j) <= roundkey(j, 0) xor roundkey(j, 1) xor roundkey(j, 2);
                                c3(j) <= roundkey(j, 0) xor roundkey(j, 1) xor roundkey(j, 2) xor roundkey(j, 3);
                                c3(j) <= roundkey(j, 0) xor roundkey(j, 1) xor roundkey(j, 2) xor roundkey(j, 3);
                        end loop;
                        end loop;
                end if;
                end if;
        end process;
        end process;
end rtl;
end rtl;
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.