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

Subversion Repositories aes_pipe

[/] [aes_pipe/] [trunk/] [rtl/] [vhdl/] [keysched1.vhdl] - Blame information for rev 9

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 subhasis25
----------------------------------------------------------------------
2
----                                                              ----
3 5 subhasis25
---- Pipelined Aes IP Core                                        ----
4
----                                                              ----
5
---- This file is part of the Pipelined AES project               ----
6
---- http://www.opencores.org/cores/aes_pipe/                     ----
7
----                                                              ----
8
---- Description                                                  ----
9
---- Implementation of AES IP core according to                   ----
10
---- FIPS PUB 197 specification document.                         ----
11
----                                                              ----
12
---- To Do:                                                       ----
13
----   -                                                          ----
14
----                                                              ----
15
---- Author:                                                      ----
16
----      - Subhasis Das, subhasis256@gmail.com                   ----
17
----                                                              ----
18
----------------------------------------------------------------------
19
----                                                              ----
20
---- Copyright (C) 2009 Authors and OPENCORES.ORG                 ----
21
----                                                              ----
22 2 subhasis25
---- This source file may be used and distributed without         ----
23
---- restriction provided that this copyright statement is not    ----
24 5 subhasis25
---- removed from the file and that any derivative work contains ----
25 2 subhasis25
---- the original copyright notice and the associated disclaimer. ----
26
----                                                              ----
27
---- This source file is free software; you can redistribute it   ----
28
---- and/or modify it under the terms of the GNU Lesser General   ----
29
---- Public License as published by the Free Software Foundation; ----
30
---- either version 2.1 of the License, or (at your option) any   ----
31
---- later version.                                               ----
32
----                                                              ----
33
---- This source is distributed in the hope that it will be       ----
34
---- useful, but WITHOUT ANY WARRANTY; without even the implied   ----
35
---- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ----
36 5 subhasis25
---- PURPOSE. See the GNU Lesser General Public License for more ----
37 2 subhasis25
---- details.                                                     ----
38
----                                                              ----
39
---- You should have received a copy of the GNU Lesser General    ----
40
---- Public License along with this source; if not, download it   ----
41 5 subhasis25
---- from http://www.opencores.org/lgpl.shtml                     ----
42 2 subhasis25
----                                                              ----
43
----------------------------------------------------------------------
44
------------------------------------------------------
45
-- Project: AESFast
46
-- Author: Subhasis
47 9 subhasis25
-- Last Modified: 25/03/10
48 2 subhasis25
-- Email: subhasis256@gmail.com
49
------------------------------------------------------
50
--
51
-- Description: First stage of key expansion
52
-- Ports:
53
--                      clk: System Clock
54
--                      roundkey: Current roundkey
55
--                      rcon: Rcon byte for the next byte
56
--                      fc3: Sbox(RotWord(column3 of rkey)) xor Rcon
57
--                      c0: column0 of rkey
58
--                      c1: column0 xor column1
59
--                      c2: column0 xor column1 xor column2
60
--                      c3: column0 xor column1 xor column2 xor column3
61
------------------------------------------------------
62
 
63
library IEEE;
64
use IEEE.std_logic_1164.all;
65
use IEEE.std_logic_arith.all;
66
use IEEE.std_logic_unsigned.all;
67
 
68
library work;
69
use work.aes_pkg.all;
70
 
71
entity keysched1 is
72
port(
73
        clk: in std_logic;
74 9 subhasis25
        rst: in std_logic;
75 2 subhasis25
        roundkey: in datablock;
76
        rcon: in std_logic_vector(7 downto 0);
77
        fc3: out blockcol;
78
        c0: out blockcol;
79
        c1: out blockcol;
80
        c2: out blockcol;
81
        c3: out blockcol
82
        );
83
end keysched1;
84
 
85
architecture rtl of keysched1 is
86
signal subst: blockcol;
87
signal key0, key1, key2, key3: std_logic_vector(7 downto 0);
88
component sbox is
89
port(
90
        clk: in std_logic;
91 9 subhasis25
        rst: in std_logic;
92 2 subhasis25
        bytein: in std_logic_vector(7 downto 0);
93
        byteout: out std_logic_vector(7 downto 0)
94
        );
95
end component;
96
signal rcon_d: std_logic_vector(7 downto 0);
97
begin
98
        sub0: sbox port map(
99
                                          clk => clk,
100 9 subhasis25
                                          rst => rst,
101 2 subhasis25
                                          bytein => roundkey(0, 3),
102
                                          byteout => subst(3)
103
                                          );
104
        sub1: sbox port map(
105
                                          clk => clk,
106 9 subhasis25
                                          rst => rst,
107 2 subhasis25
                                          bytein => roundkey(1, 3),
108
                                          byteout => subst(0)
109
                                          );
110
        sub2: sbox port map(
111
                                          clk => clk,
112 9 subhasis25
                                          rst => rst,
113 2 subhasis25
                                          bytein => roundkey(2, 3),
114
                                          byteout => subst(1)
115
                                          );
116
        sub3: sbox port map(
117
                                          clk => clk,
118 9 subhasis25
                                          rst => rst,
119 2 subhasis25
                                          bytein => roundkey(3, 3),
120
                                          byteout => subst(2)
121
                                          );
122
        fc3(0) <= subst(0) xor rcon_d;
123
        fc3(1) <= subst(1);
124
        fc3(2) <= subst(2);
125
        fc3(3) <= subst(3);
126 9 subhasis25
        process(clk,rst)
127 2 subhasis25
        begin
128 9 subhasis25
                if(rst = '1') then
129
                        rcon_d <= X"00";
130
                        c0 <= zero_col;
131
                        c1 <= zero_col;
132
                        c2 <= zero_col;
133
                        c3 <= zero_col;
134
                elsif(rising_edge(clk)) then
135 2 subhasis25
                        rcon_d <= rcon;
136
                        for j in 3 downto 0 loop
137
                                c0(j) <= roundkey(j, 0);
138
                                c1(j) <= roundkey(j, 0) xor roundkey(j, 1);
139
                                c2(j) <= roundkey(j, 0) xor roundkey(j, 1) xor roundkey(j, 2);
140
                                c3(j) <= roundkey(j, 0) xor roundkey(j, 1) xor roundkey(j, 2) xor roundkey(j, 3);
141
                        end loop;
142
                end if;
143
        end process;
144
end rtl;

powered by: WebSVN 2.1.0

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