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

Subversion Repositories hight

[/] [hight/] [trunk/] [rtl/] [KEY_SCHED.v] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 truemind
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  Key scheduler for HIGHT Crypto Core                         ////
4
////                                                              ////
5
////  This file is part of the HIGHT Crypto Core project          ////
6
////  http://github.com/OpenSoCPlus/hight_crypto_core             ////
7
////  http://www.opencores.org/project,hight                      ////
8
////                                                              ////
9
////  Description                                                 ////
10
////  __description__                                             ////
11
////                                                              ////
12
////  Author(s):                                                  ////
13
////      - JoonSoo Ha, json.ha@gmail.com                         ////
14
////      - Younjoo Kim, younjookim.kr@gmail.com                  ////
15
////                                                              ////
16
//////////////////////////////////////////////////////////////////////
17
////                                                              ////
18
//// Copyright (C) 2015 Authors, OpenSoCPlus and OPENCORES.ORG    ////
19
////                                                              ////
20
//// This source file may be used and distributed without         ////
21
//// restriction provided that this copyright statement is not    ////
22
//// removed from the file and that any derivative work contains  ////
23
//// the original copyright notice and the associated disclaimer. ////
24
////                                                              ////
25
//// This source file is free software; you can redistribute it   ////
26
//// and/or modify it under the terms of the GNU Lesser General   ////
27
//// Public License as published by the Free Software Foundation; ////
28
//// either version 2.1 of the License, or (at your option) any   ////
29
//// later version.                                               ////
30
////                                                              ////
31
//// This source is distributed in the hope that it will be       ////
32
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
33
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
34
//// PURPOSE.  See the GNU Lesser General Public License for more ////
35
//// details.                                                     ////
36
////                                                              ////
37
//// You should have received a copy of the GNU Lesser General    ////
38
//// Public License along with this source; if not, download it   ////
39
//// from http://www.opencores.org/lgpl.shtml                     ////
40
////                                                              ////
41
//////////////////////////////////////////////////////////////////////
42
 
43
module KEY_SCHED(
44
        rstn          ,
45
        clk           ,
46
 
47
        i_mk          ,
48
 
49
        i_op          ,
50
 
51
        i_key_sel     ,
52
        i_rnd_idx     ,
53
        i_wf_post_pre ,
54
 
55
        o_rnd_key
56
);
57
 
58
 
59
//=====================================
60
//
61
//          PARAMETERS 
62
//
63
//=====================================
64
 
65
 
66
//=====================================
67
//
68
//          I/O PORTS 
69
//
70
//=====================================
71
input        rstn           ;
72
input        clk            ;
73
 
74
input[127:0] i_mk           ;
75
 
76
input        i_op           ;
77
 
78
input        i_key_sel      ;
79
input[4:0]   i_rnd_idx      ;
80
input        i_wf_post_pre  ;
81
 
82
output[31:0] o_rnd_key      ;
83
 
84
 
85
//=====================================
86
//
87
//          REGISTERS
88
//
89
//=====================================
90
// r_rnd_key_3x ~ r_rnd_key_0x register
91
reg[7:0]    r_rnd_key_3x    ;
92
reg[7:0]    r_rnd_key_2x    ;
93
reg[7:0]    r_rnd_key_1x    ;
94
reg[7:0]    r_rnd_key_0x    ;
95
 
96
 
97
//=====================================
98
//
99
//          WIRES
100
//
101
//=====================================
102
// w_wk3x ~ w_wk0x
103
wire[7:0]   w_wk3x          ;
104
wire[7:0]   w_wk2x          ;
105
wire[7:0]   w_wk1x          ;
106
wire[7:0]   w_wk0x          ;
107
 
108
// w_sk3x ~ w_sk0x
109
wire[7:0]   w_sk3x          ;
110
wire[7:0]   w_sk2x          ;
111
wire[7:0]   w_sk1x          ;
112
wire[7:0]   w_sk0x          ;
113
 
114
 
115
//=====================================
116
//
117
//          MAIN
118
//
119
//=====================================
120
// WKG(Whitening Key Generator) instance
121
WKG u_WKG(
122
        .i_op           (i_op         ) ,
123
 
124
        .i_wf_post_pre  (i_wf_post_pre) ,
125
 
126
        .i_mk3to0       (i_mk[31:0]   ) ,
127
        .i_mk15to12     (i_mk[127:96] ) ,
128
 
129
        .o_wk3_7        (w_wk3x       ) ,
130
        .o_wk2_6        (w_wk2x       ) ,
131
        .o_wk1_5        (w_wk1x       ) ,
132
        .o_wk0_4        (w_wk0x       )
133
);
134
 
135
// SKG(SubKey Generator) instance
136
SKG u_SKG(
137
        .i_op           (i_op         ) ,
138
        .i_rnd_idx      (i_rnd_idx    ) ,
139
        .i_mk           (i_mk         ) ,
140
 
141
        .o_sk3x         (w_sk3x       ) ,
142
        .o_sk2x         (w_sk2x       ) ,
143
        .o_sk1x         (w_sk1x       ) ,
144
        .o_sk0x         (w_sk0x       )
145
);
146
 
147
// r_rnd_key_3x ~ r_rnd_key_0x register
148
always @(negedge rstn or posedge clk)
149
        if(~rstn) begin
150
                r_rnd_key_3x <= #1 8'h00;
151
                r_rnd_key_2x <= #1 8'h00;
152
                r_rnd_key_1x <= #1 8'h00;
153
                r_rnd_key_0x <= #1 8'h00;
154
        end
155
        else begin
156
                if(~i_key_sel) begin
157
                        r_rnd_key_3x <= #1 w_wk3x;
158
                        r_rnd_key_2x <= #1 w_wk2x;
159
                        r_rnd_key_1x <= #1 w_wk1x;
160
                        r_rnd_key_0x <= #1 w_wk0x;
161
                end
162
                else begin
163
                        r_rnd_key_3x <= #1 w_sk3x;
164
                        r_rnd_key_2x <= #1 w_sk2x;
165
                        r_rnd_key_1x <= #1 w_sk1x;
166
                        r_rnd_key_0x <= #1 w_sk0x;
167
                end
168
        end
169
 
170
// o_rnd_key
171
assign      o_rnd_key = {r_rnd_key_3x,r_rnd_key_2x,r_rnd_key_1x,r_rnd_key_0x};
172
 
173
endmodule
174
 
175
 
176
 
177
 
178
 
179
 
180
 
181
 
182
 
183
 
184
 
185
 
186
 
187
 
188
 
189
 
190
 
191
 
192
 
193
 

powered by: WebSVN 2.1.0

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