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

Subversion Repositories aes_pipe

[/] [aes_pipe/] [tags/] [P0/] [rtl/] [vhdl/] [subsh.vhdl] - Blame information for rev 3

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 subhasis25
----------------------------------------------------------------------
2
----                                                              ----
3
---- This source file may be used and distributed without         ----
4
---- restriction provided that this copyright statement is not    ----
5
---- removed from the file and that any derivative work contains  ----
6
---- the original copyright notice and the associated disclaimer. ----
7
----                                                              ----
8
---- This source file is free software; you can redistribute it   ----
9
---- and/or modify it under the terms of the GNU Lesser General   ----
10
---- Public License as published by the Free Software Foundation; ----
11
---- either version 2.1 of the License, or (at your option) any   ----
12
---- later version.                                               ----
13
----                                                              ----
14
---- This source is distributed in the hope that it will be       ----
15
---- useful, but WITHOUT ANY WARRANTY; without even the implied   ----
16
---- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ----
17
---- PURPOSE.  See the GNU Lesser General Public License for more ----
18
---- details.                                                     ----
19
----                                                              ----
20
---- You should have received a copy of the GNU Lesser General    ----
21
---- Public License along with this source; if not, download it   ----
22
---- from http:--www.opencores.org/lgpl.shtml                     ----
23
----                                                              ----
24
----------------------------------------------------------------------
25
------------------------------------------------------
26
-- Project: AESFast
27
-- Author: Subhasis
28
-- Last Modified: 20/03/10
29
-- Email: subhasis256@gmail.com
30
------------------------------------------------------
31
--
32
-- Description: The Sbox and Shiftrows step
33
-- Ports:
34
--                      clk: System Clock
35
--                      blockin: Input state block
36
--                      fc3: See keysched1 for explanation
37
--                      c0: See keysched1 for explanation
38
--                      c1: See keysched1 for explanation
39
--                      c2: See keysched1 for explanation
40
--                      c3: See keysched1 for explanation
41
--                      nextkey: Roundkey for next round
42
--                      blockout: output state block
43
------------------------------------------------------
44
 
45
library IEEE;
46
use IEEE.std_logic_1164.all;
47
use IEEE.std_logic_arith.all;
48
use IEEE.std_logic_unsigned.all;
49
 
50
library work;
51
use work.aes_pkg.all;
52
 
53
entity sboxshr is
54
port(
55
        clk: in std_logic;
56
        blockin: in datablock;
57
        fc3: in blockcol;
58
        c0: in blockcol;
59
        c1: in blockcol;
60
        c2: in blockcol;
61
        c3: in blockcol;
62
        nextkey: out datablock;
63
        blockout: out datablock
64
        );
65
end sboxshr;
66
 
67
architecture rtl of sboxshr is
68
component sbox is
69
port(
70
        clk: in std_logic;
71
        bytein: in std_logic_vector(7 downto 0);
72
        byteout: out std_logic_vector(7 downto 0)
73
        );
74
end component;
75
begin
76
        -- The sbox, the output going to the appropriate state byte after shiftrows
77
        g0: for i in 3 downto 0 generate
78
                g1: for j in 3 downto 0 generate
79
                        sub: sbox port map(
80
                                                          clk => clk,
81
                                                          bytein => blockin(i,j),
82
                                                          byteout => blockout(i,(j-i) mod 4)
83
                                                          );
84
                end generate;
85
        end generate;
86
        process(clk)
87
        begin
88
                if(rising_edge(clk)) then
89
                        -- col0 of nextkey = fc3 xor col0
90
                        -- col1 of nextkey = fc3 xor col0 xor col1
91
                        -- col2 of nextkey = fc3 xor col0 xor col1 xor col2
92
                        -- col3 of nextkey = fc3 xor col0 xor col1 xor col2 xor col3
93
                        genkey: for j in 3 downto 0 loop
94
                                nextkey(j, 0) <= fc3(j) xor c0(j);
95
                                nextkey(j, 1) <= fc3(j) xor c1(j);
96
                                nextkey(j, 2) <= fc3(j) xor c2(j);
97
                                nextkey(j, 3) <= fc3(j) xor c3(j);
98
                        end loop;
99
                end if;
100
        end process;
101
end rtl;

powered by: WebSVN 2.1.0

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