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 5

Go to most recent revision | 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
-- Last Modified: 20/03/10
48
-- 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
        roundkey: in datablock;
75
        rcon: in std_logic_vector(7 downto 0);
76
        fc3: out blockcol;
77
        c0: out blockcol;
78
        c1: out blockcol;
79
        c2: out blockcol;
80
        c3: out blockcol
81
        );
82
end keysched1;
83
 
84
architecture rtl of keysched1 is
85
signal subst: blockcol;
86
signal key0, key1, key2, key3: std_logic_vector(7 downto 0);
87
component sbox is
88
port(
89
        clk: in std_logic;
90
        bytein: in std_logic_vector(7 downto 0);
91
        byteout: out std_logic_vector(7 downto 0)
92
        );
93
end component;
94
signal rcon_d: std_logic_vector(7 downto 0);
95
begin
96
        sub0: sbox port map(
97
                                          clk => clk,
98
                                          bytein => roundkey(0, 3),
99
                                          byteout => subst(3)
100
                                          );
101
        sub1: sbox port map(
102
                                          clk => clk,
103
                                          bytein => roundkey(1, 3),
104
                                          byteout => subst(0)
105
                                          );
106
        sub2: sbox port map(
107
                                          clk => clk,
108
                                          bytein => roundkey(2, 3),
109
                                          byteout => subst(1)
110
                                          );
111
        sub3: sbox port map(
112
                                          clk => clk,
113
                                          bytein => roundkey(3, 3),
114
                                          byteout => subst(2)
115
                                          );
116
        fc3(0) <= subst(0) xor rcon_d;
117
        fc3(1) <= subst(1);
118
        fc3(2) <= subst(2);
119
        fc3(3) <= subst(3);
120
        process(clk)
121
        begin
122
                if(rising_edge(clk)) then
123
                        rcon_d <= rcon;
124
                        for j in 3 downto 0 loop
125
                                c0(j) <= roundkey(j, 0);
126
                                c1(j) <= roundkey(j, 0) xor roundkey(j, 1);
127
                                c2(j) <= roundkey(j, 0) xor roundkey(j, 1) xor roundkey(j, 2);
128
                                c3(j) <= roundkey(j, 0) xor roundkey(j, 1) xor roundkey(j, 2) xor roundkey(j, 3);
129
                        end loop;
130
                end if;
131
        end process;
132
end rtl;

powered by: WebSVN 2.1.0

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