1 |
2 |
truemind |
//////////////////////////////////////////////////////////////////////
|
2 |
|
|
//// ////
|
3 |
|
|
//// Subkey generator of 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 SKG(
|
44 |
|
|
i_op ,
|
45 |
|
|
i_rnd_idx ,
|
46 |
|
|
i_mk ,
|
47 |
|
|
|
48 |
|
|
o_sk3x ,
|
49 |
|
|
o_sk2x ,
|
50 |
|
|
o_sk1x ,
|
51 |
|
|
o_sk0x
|
52 |
|
|
);
|
53 |
|
|
|
54 |
|
|
|
55 |
|
|
//=====================================
|
56 |
|
|
//
|
57 |
|
|
// PARAMETERS
|
58 |
|
|
//
|
59 |
|
|
//=====================================
|
60 |
|
|
|
61 |
|
|
|
62 |
|
|
//=====================================
|
63 |
|
|
//
|
64 |
|
|
// I/O PORTS
|
65 |
|
|
//
|
66 |
|
|
//=====================================
|
67 |
|
|
input i_op ;
|
68 |
|
|
input[4:0] i_rnd_idx ;
|
69 |
|
|
input[127:0] i_mk ;
|
70 |
|
|
|
71 |
|
|
output[7:0] o_sk3x ;
|
72 |
|
|
output[7:0] o_sk2x ;
|
73 |
|
|
output[7:0] o_sk1x ;
|
74 |
|
|
output[7:0] o_sk0x ;
|
75 |
|
|
|
76 |
|
|
|
77 |
|
|
//=====================================
|
78 |
|
|
//
|
79 |
|
|
// REGISTERS
|
80 |
|
|
//
|
81 |
|
|
//=====================================
|
82 |
|
|
|
83 |
|
|
|
84 |
|
|
//=====================================
|
85 |
|
|
//
|
86 |
|
|
// WIRES
|
87 |
|
|
//
|
88 |
|
|
//=====================================
|
89 |
|
|
// w_mk15 ~ w_mk0
|
90 |
|
|
wire[7:0] w_mk15 = i_mk[127:120];
|
91 |
|
|
wire[7:0] w_mk14 = i_mk[119:112];
|
92 |
|
|
wire[7:0] w_mk13 = i_mk[111:104];
|
93 |
|
|
wire[7:0] w_mk12 = i_mk[103: 96];
|
94 |
|
|
wire[7:0] w_mk11 = i_mk[ 95: 88];
|
95 |
|
|
wire[7:0] w_mk10 = i_mk[ 87: 80];
|
96 |
|
|
wire[7:0] w_mk9 = i_mk[ 79: 72];
|
97 |
|
|
wire[7:0] w_mk8 = i_mk[ 71: 64];
|
98 |
|
|
wire[7:0] w_mk7 = i_mk[ 63: 56];
|
99 |
|
|
wire[7:0] w_mk6 = i_mk[ 55: 48];
|
100 |
|
|
wire[7:0] w_mk5 = i_mk[ 47: 40];
|
101 |
|
|
wire[7:0] w_mk4 = i_mk[ 39: 32];
|
102 |
|
|
wire[7:0] w_mk3 = i_mk[ 31: 24];
|
103 |
|
|
wire[7:0] w_mk2 = i_mk[ 23: 16];
|
104 |
|
|
wire[7:0] w_mk1 = i_mk[ 15: 8];
|
105 |
|
|
wire[7:0] w_mk0 = i_mk[ 7: 0];
|
106 |
|
|
|
107 |
|
|
// w_base
|
108 |
|
|
wire[4:0] w_base;
|
109 |
|
|
|
110 |
|
|
// w_d3x ~ w_d0x
|
111 |
|
|
reg[6:0] w_d3x;
|
112 |
|
|
reg[6:0] w_d2x;
|
113 |
|
|
reg[6:0] w_d1x;
|
114 |
|
|
reg[6:0] w_d0x;
|
115 |
|
|
|
116 |
|
|
// w_mk3x ~ w_mk0x
|
117 |
|
|
reg[7:0] w_mk3x;
|
118 |
|
|
reg[7:0] w_mk2x;
|
119 |
|
|
reg[7:0] w_mk1x;
|
120 |
|
|
reg[7:0] w_mk0x;
|
121 |
|
|
|
122 |
|
|
// w_sk3x_tmp ~ w_sk0x_tmp
|
123 |
|
|
wire[7:0] w_sk3x_tmp;
|
124 |
|
|
wire[7:0] w_sk2x_tmp;
|
125 |
|
|
wire[7:0] w_sk1x_tmp;
|
126 |
|
|
wire[7:0] w_sk0x_tmp;
|
127 |
|
|
|
128 |
|
|
|
129 |
|
|
//=====================================
|
130 |
|
|
//
|
131 |
|
|
// MAIN
|
132 |
|
|
//
|
133 |
|
|
//=====================================
|
134 |
|
|
// w_base
|
135 |
|
|
assign w_base = (~i_op) ? i_rnd_idx :
|
136 |
|
|
5'd31 - i_rnd_idx ;
|
137 |
|
|
|
138 |
|
|
// w_d3x
|
139 |
|
|
always @(w_base)
|
140 |
|
|
case(w_base)
|
141 |
|
|
5'd00 : w_d3x <= 7'h1b; // idx : 3
|
142 |
|
|
5'd01 : w_d3x <= 7'h41; // idx : 7
|
143 |
|
|
5'd02 : w_d3x <= 7'h4c; // idx : 11
|
144 |
|
|
5'd03 : w_d3x <= 7'h2c; // idx : 15
|
145 |
|
|
5'd04 : w_d3x <= 7'h4a; // idx : 19
|
146 |
|
|
5'd05 : w_d3x <= 7'h1c; // idx : 23
|
147 |
|
|
5'd06 : w_d3x <= 7'h79; // idx : 27
|
148 |
|
|
5'd07 : w_d3x <= 7'h37; // idx : 31
|
149 |
|
|
5'd08 : w_d3x <= 7'h0b; // idx : 35
|
150 |
|
|
5'd09 : w_d3x <= 7'h50; // idx : 39
|
151 |
|
|
5'd10 : w_d3x <= 7'h55; // idx : 43
|
152 |
|
|
5'd11 : w_d3x <= 7'h7d; // idx : 47
|
153 |
|
|
5'd12 : w_d3x <= 7'h17; // idx : 51
|
154 |
|
|
5'd13 : w_d3x <= 7'h29; // idx : 55
|
155 |
|
|
5'd14 : w_d3x <= 7'h62; // idx : 59
|
156 |
|
|
5'd15 : w_d3x <= 7'h76; // idx : 63
|
157 |
|
|
5'd16 : w_d3x <= 7'h47; // idx : 67
|
158 |
|
|
5'd17 : w_d3x <= 7'h7c; // idx : 71
|
159 |
|
|
5'd18 : w_d3x <= 7'h1f; // idx : 75
|
160 |
|
|
5'd19 : w_d3x <= 7'h61; // idx : 79
|
161 |
|
|
5'd20 : w_d3x <= 7'h6e; // idx : 83
|
162 |
|
|
5'd21 : w_d3x <= 7'h1e; // idx : 87
|
163 |
|
|
5'd22 : w_d3x <= 7'h69; // idx : 91
|
164 |
|
|
5'd23 : w_d3x <= 7'h26; // idx : 95
|
165 |
|
|
5'd24 : w_d3x <= 7'h12; // idx : 99
|
166 |
|
|
5'd25 : w_d3x <= 7'h01; // idx : 103
|
167 |
|
|
5'd26 : w_d3x <= 7'h08; // idx : 107
|
168 |
|
|
5'd27 : w_d3x <= 7'h48; // idx : 111
|
169 |
|
|
5'd28 : w_d3x <= 7'h0c; // idx : 115
|
170 |
|
|
5'd29 : w_d3x <= 7'h68; // idx : 119
|
171 |
|
|
5'd30 : w_d3x <= 7'h2e; // idx : 123
|
172 |
|
|
5'd31 : w_d3x <= 7'h5a; // idx : 127
|
173 |
|
|
endcase
|
174 |
|
|
|
175 |
|
|
// w_d2x
|
176 |
|
|
always @(w_base)
|
177 |
|
|
case(w_base)
|
178 |
|
|
5'd00 : w_d2x <= 7'h36; // idx : 2
|
179 |
|
|
5'd01 : w_d2x <= 7'h03; // idx : 6
|
180 |
|
|
5'd02 : w_d2x <= 7'h18; // idx : 10
|
181 |
|
|
5'd03 : w_d2x <= 7'h59; // idx : 14
|
182 |
|
|
5'd04 : w_d2x <= 7'h15; // idx : 18
|
183 |
|
|
5'd05 : w_d2x <= 7'h39; // idx : 22
|
184 |
|
|
5'd06 : w_d2x <= 7'h73; // idx : 26
|
185 |
|
|
5'd07 : w_d2x <= 7'h6f; // idx : 30
|
186 |
|
|
5'd08 : w_d2x <= 7'h16; // idx : 34
|
187 |
|
|
5'd09 : w_d2x <= 7'h21; // idx : 38
|
188 |
|
|
5'd10 : w_d2x <= 7'h2a; // idx : 42
|
189 |
|
|
5'd11 : w_d2x <= 7'h7a; // idx : 46
|
190 |
|
|
5'd12 : w_d2x <= 7'h2f; // idx : 50
|
191 |
|
|
5'd13 : w_d2x <= 7'h52; // idx : 54
|
192 |
|
|
5'd14 : w_d2x <= 7'h45; // idx : 58
|
193 |
|
|
5'd15 : w_d2x <= 7'h6c; // idx : 62
|
194 |
|
|
5'd16 : w_d2x <= 7'h0e; // idx : 66
|
195 |
|
|
5'd17 : w_d2x <= 7'h78; // idx : 70
|
196 |
|
|
5'd18 : w_d2x <= 7'h3f; // idx : 74
|
197 |
|
|
5'd19 : w_d2x <= 7'h43; // idx : 78
|
198 |
|
|
5'd20 : w_d2x <= 7'h5c; // idx : 82
|
199 |
|
|
5'd21 : w_d2x <= 7'h3d; // idx : 86
|
200 |
|
|
5'd22 : w_d2x <= 7'h53; // idx : 90
|
201 |
|
|
5'd23 : w_d2x <= 7'h4d; // idx : 94
|
202 |
|
|
5'd24 : w_d2x <= 7'h24; // idx : 98
|
203 |
|
|
5'd25 : w_d2x <= 7'h02; // idx : 102
|
204 |
|
|
5'd26 : w_d2x <= 7'h10; // idx : 106
|
205 |
|
|
5'd27 : w_d2x <= 7'h11; // idx : 110
|
206 |
|
|
5'd28 : w_d2x <= 7'h19; // idx : 114
|
207 |
|
|
5'd29 : w_d2x <= 7'h51; // idx : 118
|
208 |
|
|
5'd30 : w_d2x <= 7'h5d; // idx : 122
|
209 |
|
|
5'd31 : w_d2x <= 7'h35; // idx : 126
|
210 |
|
|
endcase
|
211 |
|
|
|
212 |
|
|
// w_d1x
|
213 |
|
|
always @(w_base)
|
214 |
|
|
case(w_base)
|
215 |
|
|
5'd00 : w_d1x <= 7'h6d; // idx : 1
|
216 |
|
|
5'd01 : w_d1x <= 7'h06; // idx : 5
|
217 |
|
|
5'd02 : w_d1x <= 7'h30; // idx : 9
|
218 |
|
|
5'd03 : w_d1x <= 7'h33; // idx : 13
|
219 |
|
|
5'd04 : w_d1x <= 7'h2b; // idx : 17
|
220 |
|
|
5'd05 : w_d1x <= 7'h72; // idx : 21
|
221 |
|
|
5'd06 : w_d1x <= 7'h67; // idx : 25
|
222 |
|
|
5'd07 : w_d1x <= 7'h5e; // idx : 29
|
223 |
|
|
5'd08 : w_d1x <= 7'h2d; // idx : 33
|
224 |
|
|
5'd09 : w_d1x <= 7'h42; // idx : 37
|
225 |
|
|
5'd10 : w_d1x <= 7'h54; // idx : 41
|
226 |
|
|
5'd11 : w_d1x <= 7'h75; // idx : 45
|
227 |
|
|
5'd12 : w_d1x <= 7'h5f; // idx : 49
|
228 |
|
|
5'd13 : w_d1x <= 7'h25; // idx : 53
|
229 |
|
|
5'd14 : w_d1x <= 7'h0a; // idx : 57
|
230 |
|
|
5'd15 : w_d1x <= 7'h58; // idx : 61
|
231 |
|
|
5'd16 : w_d1x <= 7'h1d; // idx : 65
|
232 |
|
|
5'd17 : w_d1x <= 7'h71; // idx : 69
|
233 |
|
|
5'd18 : w_d1x <= 7'h7f; // idx : 73
|
234 |
|
|
5'd19 : w_d1x <= 7'h07; // idx : 77
|
235 |
|
|
5'd20 : w_d1x <= 7'h38; // idx : 81
|
236 |
|
|
5'd21 : w_d1x <= 7'h7b; // idx : 85
|
237 |
|
|
5'd22 : w_d1x <= 7'h27; // idx : 89
|
238 |
|
|
5'd23 : w_d1x <= 7'h1a; // idx : 93
|
239 |
|
|
5'd24 : w_d1x <= 7'h49; // idx : 97
|
240 |
|
|
5'd25 : w_d1x <= 7'h04; // idx : 101
|
241 |
|
|
5'd26 : w_d1x <= 7'h20; // idx : 105
|
242 |
|
|
5'd27 : w_d1x <= 7'h22; // idx : 109
|
243 |
|
|
5'd28 : w_d1x <= 7'h32; // idx : 113
|
244 |
|
|
5'd29 : w_d1x <= 7'h23; // idx : 117
|
245 |
|
|
5'd30 : w_d1x <= 7'h3a; // idx : 121
|
246 |
|
|
5'd31 : w_d1x <= 7'h6b; // idx : 125
|
247 |
|
|
endcase
|
248 |
|
|
|
249 |
|
|
// w_d0x
|
250 |
|
|
always @(w_base)
|
251 |
|
|
case(w_base)
|
252 |
|
|
5'd00 : w_d0x <= 7'h5a; // idx : 0
|
253 |
|
|
5'd01 : w_d0x <= 7'h0d; // idx : 4
|
254 |
|
|
5'd02 : w_d0x <= 7'h60; // idx : 8
|
255 |
|
|
5'd03 : w_d0x <= 7'h66; // idx : 12
|
256 |
|
|
5'd04 : w_d0x <= 7'h56; // idx : 16
|
257 |
|
|
5'd05 : w_d0x <= 7'h65; // idx : 20
|
258 |
|
|
5'd06 : w_d0x <= 7'h4e; // idx : 24
|
259 |
|
|
5'd07 : w_d0x <= 7'h3c; // idx : 28
|
260 |
|
|
5'd08 : w_d0x <= 7'h5b; // idx : 32
|
261 |
|
|
5'd09 : w_d0x <= 7'h05; // idx : 36
|
262 |
|
|
5'd10 : w_d0x <= 7'h28; // idx : 40
|
263 |
|
|
5'd11 : w_d0x <= 7'h6a; // idx : 44
|
264 |
|
|
5'd12 : w_d0x <= 7'h3e; // idx : 48
|
265 |
|
|
5'd13 : w_d0x <= 7'h4b; // idx : 52
|
266 |
|
|
5'd14 : w_d0x <= 7'h14; // idx : 56
|
267 |
|
|
5'd15 : w_d0x <= 7'h31; // idx : 60
|
268 |
|
|
5'd16 : w_d0x <= 7'h3b; // idx : 64
|
269 |
|
|
5'd17 : w_d0x <= 7'h63; // idx : 68
|
270 |
|
|
5'd18 : w_d0x <= 7'h7e; // idx : 72
|
271 |
|
|
5'd19 : w_d0x <= 7'h0f; // idx : 76
|
272 |
|
|
5'd20 : w_d0x <= 7'h70; // idx : 80
|
273 |
|
|
5'd21 : w_d0x <= 7'h77; // idx : 84
|
274 |
|
|
5'd22 : w_d0x <= 7'h4f; // idx : 88
|
275 |
|
|
5'd23 : w_d0x <= 7'h34; // idx : 92
|
276 |
|
|
5'd24 : w_d0x <= 7'h13; // idx : 96
|
277 |
|
|
5'd25 : w_d0x <= 7'h09; // idx : 100
|
278 |
|
|
5'd26 : w_d0x <= 7'h40; // idx : 104
|
279 |
|
|
5'd27 : w_d0x <= 7'h44; // idx : 108
|
280 |
|
|
5'd28 : w_d0x <= 7'h64; // idx : 112
|
281 |
|
|
5'd29 : w_d0x <= 7'h46; // idx : 116
|
282 |
|
|
5'd30 : w_d0x <= 7'h74; // idx : 120
|
283 |
|
|
5'd31 : w_d0x <= 7'h57; // idx : 124
|
284 |
|
|
endcase
|
285 |
|
|
|
286 |
|
|
// w_mk3x
|
287 |
|
|
always @(*)
|
288 |
|
|
case(w_base)
|
289 |
|
|
5'd00 : w_mk3x <= w_mk3 ; // idx : 3
|
290 |
|
|
5'd01 : w_mk3x <= w_mk7 ; // idx : 7
|
291 |
|
|
5'd02 : w_mk3x <= w_mk11; // idx : 11
|
292 |
|
|
5'd03 : w_mk3x <= w_mk15; // idx : 15
|
293 |
|
|
5'd04 : w_mk3x <= w_mk2 ; // idx : 19
|
294 |
|
|
5'd05 : w_mk3x <= w_mk6 ; // idx : 23
|
295 |
|
|
5'd06 : w_mk3x <= w_mk10; // idx : 27
|
296 |
|
|
5'd07 : w_mk3x <= w_mk14; // idx : 31
|
297 |
|
|
5'd08 : w_mk3x <= w_mk1 ; // idx : 35
|
298 |
|
|
5'd09 : w_mk3x <= w_mk5 ; // idx : 39
|
299 |
|
|
5'd10 : w_mk3x <= w_mk9 ; // idx : 43
|
300 |
|
|
5'd11 : w_mk3x <= w_mk13; // idx : 47
|
301 |
|
|
5'd12 : w_mk3x <= w_mk0 ; // idx : 51
|
302 |
|
|
5'd13 : w_mk3x <= w_mk4 ; // idx : 55
|
303 |
|
|
5'd14 : w_mk3x <= w_mk8 ; // idx : 59
|
304 |
|
|
5'd15 : w_mk3x <= w_mk12; // idx : 63
|
305 |
|
|
5'd16 : w_mk3x <= w_mk7 ; // idx : 67
|
306 |
|
|
5'd17 : w_mk3x <= w_mk3 ; // idx : 71
|
307 |
|
|
5'd18 : w_mk3x <= w_mk15; // idx : 75
|
308 |
|
|
5'd19 : w_mk3x <= w_mk11; // idx : 79
|
309 |
|
|
5'd20 : w_mk3x <= w_mk6 ; // idx : 83
|
310 |
|
|
5'd21 : w_mk3x <= w_mk2 ; // idx : 87
|
311 |
|
|
5'd22 : w_mk3x <= w_mk14; // idx : 91
|
312 |
|
|
5'd23 : w_mk3x <= w_mk10; // idx : 95
|
313 |
|
|
5'd24 : w_mk3x <= w_mk5 ; // idx : 99
|
314 |
|
|
5'd25 : w_mk3x <= w_mk1 ; // idx : 103
|
315 |
|
|
5'd26 : w_mk3x <= w_mk13; // idx : 107
|
316 |
|
|
5'd27 : w_mk3x <= w_mk9 ; // idx : 111
|
317 |
|
|
5'd28 : w_mk3x <= w_mk4 ; // idx : 115
|
318 |
|
|
5'd29 : w_mk3x <= w_mk0 ; // idx : 119
|
319 |
|
|
5'd30 : w_mk3x <= w_mk12; // idx : 123
|
320 |
|
|
5'd31 : w_mk3x <= w_mk8 ; // idx : 127
|
321 |
|
|
endcase
|
322 |
|
|
|
323 |
|
|
// w_mk2x
|
324 |
|
|
always @(*)
|
325 |
|
|
case(w_base)
|
326 |
|
|
5'd00 : w_mk2x <= w_mk2 ; // idx : 2
|
327 |
|
|
5'd01 : w_mk2x <= w_mk6 ; // idx : 6
|
328 |
|
|
5'd02 : w_mk2x <= w_mk10; // idx : 10
|
329 |
|
|
5'd03 : w_mk2x <= w_mk14; // idx : 14
|
330 |
|
|
5'd04 : w_mk2x <= w_mk1 ; // idx : 18
|
331 |
|
|
5'd05 : w_mk2x <= w_mk5 ; // idx : 22
|
332 |
|
|
5'd06 : w_mk2x <= w_mk9 ; // idx : 26
|
333 |
|
|
5'd07 : w_mk2x <= w_mk13; // idx : 30
|
334 |
|
|
5'd08 : w_mk2x <= w_mk0 ; // idx : 34
|
335 |
|
|
5'd09 : w_mk2x <= w_mk4 ; // idx : 38
|
336 |
|
|
5'd10 : w_mk2x <= w_mk8 ; // idx : 42
|
337 |
|
|
5'd11 : w_mk2x <= w_mk12; // idx : 46
|
338 |
|
|
5'd12 : w_mk2x <= w_mk7 ; // idx : 50
|
339 |
|
|
5'd13 : w_mk2x <= w_mk3 ; // idx : 54
|
340 |
|
|
5'd14 : w_mk2x <= w_mk15; // idx : 58
|
341 |
|
|
5'd15 : w_mk2x <= w_mk11; // idx : 62
|
342 |
|
|
5'd16 : w_mk2x <= w_mk6 ; // idx : 66
|
343 |
|
|
5'd17 : w_mk2x <= w_mk2 ; // idx : 70
|
344 |
|
|
5'd18 : w_mk2x <= w_mk14; // idx : 74
|
345 |
|
|
5'd19 : w_mk2x <= w_mk10; // idx : 78
|
346 |
|
|
5'd20 : w_mk2x <= w_mk5 ; // idx : 82
|
347 |
|
|
5'd21 : w_mk2x <= w_mk1 ; // idx : 86
|
348 |
|
|
5'd22 : w_mk2x <= w_mk13; // idx : 90
|
349 |
|
|
5'd23 : w_mk2x <= w_mk9 ; // idx : 94
|
350 |
|
|
5'd24 : w_mk2x <= w_mk4 ; // idx : 98
|
351 |
|
|
5'd25 : w_mk2x <= w_mk0 ; // idx : 102
|
352 |
|
|
5'd26 : w_mk2x <= w_mk12; // idx : 106
|
353 |
|
|
5'd27 : w_mk2x <= w_mk8 ; // idx : 110
|
354 |
|
|
5'd28 : w_mk2x <= w_mk3 ; // idx : 114
|
355 |
|
|
5'd29 : w_mk2x <= w_mk7 ; // idx : 118
|
356 |
|
|
5'd30 : w_mk2x <= w_mk11; // idx : 122
|
357 |
|
|
5'd31 : w_mk2x <= w_mk15; // idx : 126
|
358 |
|
|
endcase
|
359 |
|
|
|
360 |
|
|
// w_mk1x
|
361 |
|
|
always @(*)
|
362 |
|
|
case(w_base)
|
363 |
|
|
5'd00 : w_mk1x <= w_mk1 ; // idx : 1
|
364 |
|
|
5'd01 : w_mk1x <= w_mk5 ; // idx : 5
|
365 |
|
|
5'd02 : w_mk1x <= w_mk9 ; // idx : 9
|
366 |
|
|
5'd03 : w_mk1x <= w_mk13; // idx : 13
|
367 |
|
|
5'd04 : w_mk1x <= w_mk0 ; // idx : 17
|
368 |
|
|
5'd05 : w_mk1x <= w_mk4 ; // idx : 21
|
369 |
|
|
5'd06 : w_mk1x <= w_mk8 ; // idx : 25
|
370 |
|
|
5'd07 : w_mk1x <= w_mk12; // idx : 29
|
371 |
|
|
5'd08 : w_mk1x <= w_mk7 ; // idx : 33
|
372 |
|
|
5'd09 : w_mk1x <= w_mk3 ; // idx : 37
|
373 |
|
|
5'd10 : w_mk1x <= w_mk15; // idx : 41
|
374 |
|
|
5'd11 : w_mk1x <= w_mk11; // idx : 45
|
375 |
|
|
5'd12 : w_mk1x <= w_mk6 ; // idx : 49
|
376 |
|
|
5'd13 : w_mk1x <= w_mk2 ; // idx : 53
|
377 |
|
|
5'd14 : w_mk1x <= w_mk14; // idx : 57
|
378 |
|
|
5'd15 : w_mk1x <= w_mk10; // idx : 61
|
379 |
|
|
5'd16 : w_mk1x <= w_mk5 ; // idx : 65
|
380 |
|
|
5'd17 : w_mk1x <= w_mk1 ; // idx : 69
|
381 |
|
|
5'd18 : w_mk1x <= w_mk13; // idx : 73
|
382 |
|
|
5'd19 : w_mk1x <= w_mk9 ; // idx : 77
|
383 |
|
|
5'd20 : w_mk1x <= w_mk4 ; // idx : 81
|
384 |
|
|
5'd21 : w_mk1x <= w_mk0 ; // idx : 85
|
385 |
|
|
5'd22 : w_mk1x <= w_mk12; // idx : 89
|
386 |
|
|
5'd23 : w_mk1x <= w_mk8 ; // idx : 93
|
387 |
|
|
5'd24 : w_mk1x <= w_mk3 ; // idx : 97
|
388 |
|
|
5'd25 : w_mk1x <= w_mk7 ; // idx : 101
|
389 |
|
|
5'd26 : w_mk1x <= w_mk11; // idx : 105
|
390 |
|
|
5'd27 : w_mk1x <= w_mk15; // idx : 109
|
391 |
|
|
5'd28 : w_mk1x <= w_mk2 ; // idx : 113
|
392 |
|
|
5'd29 : w_mk1x <= w_mk6 ; // idx : 117
|
393 |
|
|
5'd30 : w_mk1x <= w_mk10; // idx : 121
|
394 |
|
|
5'd31 : w_mk1x <= w_mk14; // idx : 125
|
395 |
|
|
endcase
|
396 |
|
|
|
397 |
|
|
// w_mk0x
|
398 |
|
|
always @(*)
|
399 |
|
|
case(w_base)
|
400 |
|
|
5'd00 : w_mk0x <= w_mk0 ; // idx : 0
|
401 |
|
|
5'd01 : w_mk0x <= w_mk4 ; // idx : 4
|
402 |
|
|
5'd02 : w_mk0x <= w_mk8 ; // idx : 8
|
403 |
|
|
5'd03 : w_mk0x <= w_mk12; // idx : 12
|
404 |
|
|
5'd04 : w_mk0x <= w_mk7 ; // idx : 16
|
405 |
|
|
5'd05 : w_mk0x <= w_mk3 ; // idx : 20
|
406 |
|
|
5'd06 : w_mk0x <= w_mk15; // idx : 24
|
407 |
|
|
5'd07 : w_mk0x <= w_mk11; // idx : 28
|
408 |
|
|
5'd08 : w_mk0x <= w_mk6 ; // idx : 32
|
409 |
|
|
5'd09 : w_mk0x <= w_mk2 ; // idx : 36
|
410 |
|
|
5'd10 : w_mk0x <= w_mk14; // idx : 40
|
411 |
|
|
5'd11 : w_mk0x <= w_mk10; // idx : 44
|
412 |
|
|
5'd12 : w_mk0x <= w_mk5 ; // idx : 48
|
413 |
|
|
5'd13 : w_mk0x <= w_mk1 ; // idx : 52
|
414 |
|
|
5'd14 : w_mk0x <= w_mk13; // idx : 56
|
415 |
|
|
5'd15 : w_mk0x <= w_mk9 ; // idx : 60
|
416 |
|
|
5'd16 : w_mk0x <= w_mk4 ; // idx : 64
|
417 |
|
|
5'd17 : w_mk0x <= w_mk0 ; // idx : 68
|
418 |
|
|
5'd18 : w_mk0x <= w_mk12; // idx : 72
|
419 |
|
|
5'd19 : w_mk0x <= w_mk8 ; // idx : 76
|
420 |
|
|
5'd20 : w_mk0x <= w_mk3 ; // idx : 80
|
421 |
|
|
5'd21 : w_mk0x <= w_mk7 ; // idx : 84
|
422 |
|
|
5'd22 : w_mk0x <= w_mk11; // idx : 88
|
423 |
|
|
5'd23 : w_mk0x <= w_mk15; // idx : 92
|
424 |
|
|
5'd24 : w_mk0x <= w_mk2 ; // idx : 96
|
425 |
|
|
5'd25 : w_mk0x <= w_mk6 ; // idx : 100
|
426 |
|
|
5'd26 : w_mk0x <= w_mk10; // idx : 104
|
427 |
|
|
5'd27 : w_mk0x <= w_mk14; // idx : 108
|
428 |
|
|
5'd28 : w_mk0x <= w_mk1 ; // idx : 112
|
429 |
|
|
5'd29 : w_mk0x <= w_mk5 ; // idx : 116
|
430 |
|
|
5'd30 : w_mk0x <= w_mk9 ; // idx : 120
|
431 |
|
|
5'd31 : w_mk0x <= w_mk13; // idx : 124
|
432 |
|
|
endcase
|
433 |
|
|
|
434 |
|
|
// w_sk3x_tmp
|
435 |
|
|
assign w_sk3x_tmp = {1'b0,w_d3x} + w_mk3x;
|
436 |
|
|
|
437 |
|
|
// w_sk2x_tmp
|
438 |
|
|
assign w_sk2x_tmp = {1'b0,w_d2x} + w_mk2x;
|
439 |
|
|
|
440 |
|
|
// w_sk1x_tmp
|
441 |
|
|
assign w_sk1x_tmp = {1'b0,w_d1x} + w_mk1x;
|
442 |
|
|
|
443 |
|
|
// w_sk0x_tmp
|
444 |
|
|
assign w_sk0x_tmp = {1'b0,w_d0x} + w_mk0x;
|
445 |
|
|
|
446 |
|
|
// o_sk3x
|
447 |
|
|
assign o_sk3x = (~i_op) ? w_sk3x_tmp : // i_op == 0
|
448 |
|
|
w_sk0x_tmp ; // i_op == 1
|
449 |
|
|
|
450 |
|
|
// o_sk2x
|
451 |
|
|
assign o_sk2x = (~i_op) ? w_sk2x_tmp : // i_op == 0
|
452 |
|
|
w_sk1x_tmp ; // i_op == 1
|
453 |
|
|
|
454 |
|
|
// o_sk1x
|
455 |
|
|
assign o_sk1x = (~i_op) ? w_sk1x_tmp : // i_op == 0
|
456 |
|
|
w_sk2x_tmp ; // i_op == 1
|
457 |
|
|
|
458 |
|
|
// o_sk0x
|
459 |
|
|
assign o_sk0x = (~i_op) ? w_sk0x_tmp : // i_op == 0
|
460 |
|
|
w_sk3x_tmp ; // i_op == 1
|
461 |
|
|
|
462 |
|
|
endmodule
|
463 |
|
|
|
464 |
|
|
|
465 |
|
|
|
466 |
|
|
|
467 |
|
|
|
468 |
|
|
|
469 |
|
|
|
470 |
|
|
|