OpenCores
URL https://opencores.org/ocsvn/aes-128_pipelined_encryption/aes-128_pipelined_encryption/trunk

Subversion Repositories aes-128_pipelined_encryption

[/] [aes-128_pipelined_encryption/] [trunk/] [rtl/] [KeyExpantion.v] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 Amr_Salah
/*
2
Project         : AES
3
Standard doc.   : FIPS 197
4
Module name     : KeyExpantion block
5
Dependancy      :
6
Design doc.     :
7
References      :
8
Description     : The key Expantion Module is used to
9
                  generate round keys from the cipher key using
10
                                  pipelined architecture
11
Owner           : Amr Salah
12
*/
13
 
14
`timescale 1 ns/1 ps
15
 
16
module KeyExpantion
17
#
18
(
19
parameter DATA_W = 128,               //data width
20
parameter KEY_L = 128,                //key length
21
parameter NO_ROUNDS = 10              //number of rounds
22
)
23
(
24
input clk,                            //system clock
25
input reset,                          //async reset               
26
input valid_in,                       //input valid in
27
input [KEY_L-1:0] cipher_key,         //cipher key
28
output [(NO_ROUNDS*DATA_W)-1:0] W,    //contains all generated round keys
29
output [NO_ROUNDS-1:0] valid_out      //output valid signal
30
);
31
 
32
wire [31:0] RCON [0:9];                       //round constant array of words
33
wire [NO_ROUNDS-1:0] keygen_valid_out;        //every bit represens output valid signal for every RoundKeyGen module 
34
wire [DATA_W-1:0] W_array  [0:NO_ROUNDS-1];   //array of round keys to form W output 
35
 
36
//round connstant values
37
assign RCON[0] = 32'h01000000;
38
assign RCON[1] = 32'h02000000;
39
assign RCON[2] = 32'h04000000;
40
assign RCON[3] = 32'h08000000;
41
assign RCON[4] = 32'h10000000;
42
assign RCON[5] = 32'h20000000;
43
assign RCON[6] = 32'h40000000;
44
assign RCON[7] = 32'h80000000;
45
assign RCON[8] = 32'h1b000000;
46
assign RCON[9] = 32'h36000000;
47
 
48
//instantiate number RounkeyGen modules = number of rounds to get number of roundkeys = number of  rounds
49
RoundKeyGen #(KEY_L)RKGEN_U0(clk,reset,RCON[0],valid_in,cipher_key,W_array[0],keygen_valid_out[0]);
50
 
51
genvar i;
52
generate
53
for (i=1 ;i<NO_ROUNDS;i=i+1) begin : ROUND_KEY_GEN
54
RoundKeyGen #(KEY_L)RKGEN_U(clk,reset,RCON[i],keygen_valid_out[i-1],W_array[i-1],W_array[i],keygen_valid_out[i]);
55
end
56
endgenerate
57
 
58
                         //assigning all the round keys to one output
59
assign W = {  W_array[0],
60
              W_array[1],
61
              W_array[2],
62
              W_array[3],
63
              W_array[4],
64
              W_array[5],
65
              W_array[6],
66
              W_array[7],
67
              W_array[8],
68
              W_array[9] };
69
 
70
assign valid_out = keygen_valid_out;
71
 
72
 
73
endmodule

powered by: WebSVN 2.1.0

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