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

Subversion Repositories aes_highthroughput_lowarea

[/] [aes_highthroughput_lowarea/] [trunk/] [verilog/] [rtl/] [aes_top_example.v] - Blame information for rev 8

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 8 motilito
//---------------------------------------------------------------------------------------
2
//      Project:                        High Throughput / Low Area AES Core 
3
//
4
//      File name:                      aes_top_example.v               (March 30, 2012)
5
//
6
//      Writer:                         Moti Litochevski 
7
//
8
//      Description:
9
//              This file contains a very simple and not very area efficient implementation of 
10
//              instance instantiate ting the AES core. This file is also used to estimate the 
11
//              core synthesis results. 
12
//              The AES core includes direct interfaces to the key and data vectors which are 
13
//              fairly wide (256 & 128 bits). This file includes a simple wrapper to enable 32 
14
//              bit data bus and 4 bit address to select the input and output word portion. 
15
//
16
//      Revision History:
17
//
18
//      Rev <revnumber>                 <Date>                  <owner> 
19
//              <comment>
20
// 
21
//---------------------------------------------------------------------------------------
22
 
23
module aes_top_example
24
(
25
        clk, reset,
26
        i_enable, i_enc_dec,
27
        i_key_mode, i_data,
28
        i_data_sel, i_data_valid,
29
        o_data_sel, o_key_ready,
30
        o_ready, o_data,
31
        o_data_valid
32
);
33
//---------------------------------------------------------------------------------------
34
// module interfaces 
35
// global signals 
36
input                   clk;
37
input                   reset;
38
// AES core interface 
39
// inputs 
40
input                   i_enable;
41
input                   i_enc_dec;
42
input   [1:0]    i_key_mode;
43
input   [31:0]   i_data;
44
input   [3:0]    i_data_sel;
45
input                   i_data_valid;
46
input   [1:0]    o_data_sel;
47
// outputs 
48
output                  o_key_ready;
49
output                  o_ready;
50
output  [31:0]   o_data;
51
output                  o_data_valid;
52
 
53
//---------------------------------------------------------------------------------------
54
// registered outputs 
55
reg [31:0] o_data;
56
 
57
// internal signals and registers 
58
reg [255:0] int_key;
59
reg [127:0] int_data;
60
reg int_key_start, int_data_valid;
61
wire [127:0] int_o_data;
62
 
63
//---------------------------------------------------------------------------------------
64
// module implementation 
65
// internal key and data vectors write process 
66
always @ (posedge reset or posedge clk)
67
begin
68
        if (reset)
69
        begin
70
                int_key <= 256'b0;
71
                int_data <= 128'b0;
72
                int_key_start <= 1'b0;
73
                int_data_valid <= 1'b0;
74
        end
75
        else
76
        begin
77
                // input key and data write control 
78
                if (i_data_valid)
79
                begin
80
                        case (i_data_sel)
81
                                4'h0:   int_key[31:0] <= i_data;
82
                                4'h1:   int_key[63:32] <= i_data;
83
                                4'h2:   int_key[95:64] <= i_data;
84
                                4'h3:   int_key[127:96] <= i_data;
85
                                4'h4:   int_key[159:128] <= i_data;
86
                                4'h5:   int_key[191:160] <= i_data;
87
                                4'h6:   int_key[223:192] <= i_data;
88
                                4'h7:   int_key[255:224] <= i_data;
89
                                4'h8:   int_data[31:0] <= i_data;
90
                                4'h9:   int_data[63:32] <= i_data;
91
                                4'ha:   int_data[95:64] <= i_data;
92
                                4'hb:   int_data[127:96] <= i_data;
93
                        endcase
94
                end
95
 
96
                // key expansion start control 
97
                if ((i_data_sel == 4'h7) && i_data_valid)
98
                        int_key_start <= 1'b1;
99
                else
100
                        int_key_start <= 1'b0;
101
 
102
                // encryption / decryption start control 
103
                if ((i_data_sel == 4'hb) && i_data_valid)
104
                        int_data_valid <= 1'b1;
105
                else
106
                        int_data_valid <= 1'b0;
107
        end
108
end
109
 
110
// output data read control process 
111
always @ (posedge reset or posedge clk)
112
begin
113
        if (reset)
114
                o_data <= 32'b0;
115
        else
116
        begin
117
                case (o_data_sel)
118
                        2'h0:   o_data <= int_o_data[31:0];
119
                        2'h1:   o_data <= int_o_data[63:32];
120
                        2'h2:   o_data <= int_o_data[95:64];
121
                        2'h3:   o_data <= int_o_data[127:96];
122
                endcase
123
        end
124
end
125
 
126
// AES core instance 
127
aes u_aes
128
(
129
   .clk(clk),
130
   .reset(reset),
131
   .i_start(int_key_start),
132
   .i_enable(i_enable),
133
   .i_ende(i_enc_dec),
134
   .i_key(int_key),
135
   .i_key_mode(i_key_mode),
136
   .i_data(int_data),
137
   .i_data_valid(int_data_valid),
138
   .o_ready(o_ready),
139
   .o_data(int_o_data),
140
   .o_data_valid(o_data_valid),
141
   .o_key_ready(o_key_ready)
142
);
143
 
144
endmodule
145
//---------------------------------------------------------------------------------------
146
//                                              Th.. Th.. Th.. Thats all folks !!!
147
//---------------------------------------------------------------------------------------

powered by: WebSVN 2.1.0

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