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

Subversion Repositories aes_pipe

[/] [aes_pipe/] [trunk/] [rtl/] [vhdl/] [aes_top.vhdl] - Blame information for rev 5

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 5 subhasis25
---- from http://www.opencores.org/lgpl.shtml                     ----
23 2 subhasis25
----                                                              ----
24
----------------------------------------------------------------------
25
------------------------------------------------------
26
-- Project: AESFast
27
-- Author: Subhasis
28
-- Last Modified: 20/03/10
29
-- Email: subhasis256@gmail.com
30
------------------------------------------------------
31
--
32 4 subhasis25
-- Description: The Overall Core
33 2 subhasis25
-- Ports:
34 5 subhasis25
--                      clk_i: System Clock
35
--                      plaintext_i: Input plaintext blocks
36
--                      keyblock_i: Input keyblock
37
--                      ciphertext_o: Output Cipher Block
38 2 subhasis25
------------------------------------------------------
39
 
40
library IEEE;
41
use IEEE.std_logic_1164.all;
42
use IEEE.std_logic_arith.all;
43
use IEEE.std_logic_unsigned.all;
44
 
45
library work;
46
use work.aes_pkg.all;
47
 
48 5 subhasis25
entity aes_top is
49 2 subhasis25
port(
50 5 subhasis25
        clk_i: in std_logic;
51
        plaintext_i: in datablock;
52
        keyblock_i: in datablock;
53
        ciphertext_o: out datablock
54 2 subhasis25
        );
55 5 subhasis25
end aes_top;
56 2 subhasis25
 
57 5 subhasis25
architecture rtl of aes_top is
58 2 subhasis25
signal fc3, c0, c1, c2, c3: colnet(9 downto 0);
59
signal textnet_a_s, textnet_s_m, textnet_m_a: datanet(9 downto 0);
60
signal key_m, key_s: datanet(9 downto 0);
61
signal textnet_s_a: datablock;
62
 
63
component sboxshr is
64
port(
65
        clk: in std_logic;
66
        blockin: in datablock;
67
        fc3: in blockcol;
68
        c0: in blockcol;
69
        c1: in blockcol;
70
        c2: in blockcol;
71
        c3: in blockcol;
72
        nextkey: out datablock;
73
        blockout: out datablock
74
        );
75
end component;
76
component colmix is
77
port(
78
        clk: in std_logic;
79
        datain: in datablock;
80
        inrkey: in datablock;
81
        outrkey: out datablock;
82
        dataout: out datablock
83
        );
84
end component;
85
component addkey is
86
port(
87
        clk: in std_logic;
88
        roundkey: in datablock;
89
        datain: in datablock;
90
        rcon: in std_logic_vector(7 downto 0);
91
        dataout: out datablock;
92
        fc3: out blockcol;
93
        c0: out blockcol;
94
        c1: out blockcol;
95
        c2: out blockcol;
96
        c3: out blockcol
97
        );
98
end component;
99
begin
100 5 subhasis25
        key_m(0) <= keyblock_i;
101
        textnet_m_a(0) <= plaintext_i;
102 2 subhasis25
        -------------------------------------------------------
103
        -- Instead of the conventional order of
104
        -- Addkey -> (Sbox -> Mixcol -> Addkey) ... 9 times
105
        -- -> Sbox -> Addkey, we code the design as
106
        -- (Addkey -> Sbox -> Mixcol) ... 9 times -> Addkey ->
107
        -- Sbox -> Addkey
108
        -------------------------------------------------------
109
        proc: for i in 8 downto 0 generate
110
                add: addkey port map(
111 5 subhasis25
                                                        clk => clk_i,
112 2 subhasis25
                                                        roundkey => key_m(i),
113
                                                        datain => textnet_m_a(i),
114
                                                        rcon => rcon(i),
115
                                                        dataout => textnet_a_s(i),
116
                                                        fc3 => fc3(i),
117
                                                        c0 => c0(i),
118
                                                        c1 => c1(i),
119
                                                        c2 => c2(i),
120
                                                        c3 => c3(i)
121
                                                        );
122
                sbox: sboxshr port map(
123 5 subhasis25
                                                          clk => clk_i,
124 2 subhasis25
                                                          blockin => textnet_a_s(i),
125
                                                          fc3 => fc3(i),
126
                                                          c0 => c0(i),
127
                                                          c1 => c1(i),
128
                                                          c2 => c2(i),
129
                                                          c3 => c3(i),
130
                                                          nextkey => key_s(i),
131
                                                          blockout => textnet_s_m(i)
132
                                                          );
133
                mix: colmix port map(
134 5 subhasis25
                                                        clk => clk_i,
135 2 subhasis25
                                                        datain => textnet_s_m(i),
136
                                                        inrkey => key_s(i),
137
                                                        outrkey => key_m(i+1),
138
                                                        dataout => textnet_m_a(i+1)
139
                                                        );
140
        end generate;
141
        add_f_1: addkey port map(
142 5 subhasis25
                                                        clk => clk_i,
143 2 subhasis25
                                                        roundkey => key_m(9),
144
                                                        datain => textnet_m_a(9),
145
                                                        rcon => rcon(9),
146
                                                        dataout => textnet_a_s(9),
147
                                                        fc3 => fc3(9),
148
                                                        c0 => c0(9),
149
                                                        c1 => c1(9),
150
                                                        c2 => c2(9),
151
                                                        c3 => c3(9)
152
                                                        );
153
        sbox_f_1: sboxshr port map(
154 5 subhasis25
                                                          clk => clk_i,
155 2 subhasis25
                                                          blockin => textnet_a_s(9),
156
                                                          fc3 => fc3(9),
157
                                                          c0 => c0(9),
158
                                                          c1 => c1(9),
159
                                                          c2 => c2(9),
160
                                                          c3 => c3(9),
161
                                                          nextkey => key_s(9),
162
                                                          blockout => textnet_s_a
163
                                                          );
164
        add_f: addkey port map(
165 5 subhasis25
                                                  clk => clk_i,
166 2 subhasis25
                                                  roundkey => key_s(9),
167
                                                  datain => textnet_s_a,
168
                                                  rcon => X"00",
169 5 subhasis25
                                                  dataout => ciphertext_o
170 2 subhasis25
                                                  );
171
end rtl;

powered by: WebSVN 2.1.0

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