Browse Source

more moving of type & constant definitions to pkg header

T. Meissner 6 years ago
parent
commit
45c9409572
1 changed files with 35 additions and 32 deletions
  1. 35
    32
      des/rtl/vhdl/des_pkg.vhd

+ 35
- 32
des/rtl/vhdl/des_pkg.vhd View File

@@ -116,6 +116,36 @@ PACKAGE des_pkg IS
116 116
                                     2 => ( 7, 11,  4,  1,  9, 12, 14,  2,  0,  6, 10, 13, 15,  3,  5,  8),
117 117
                                     3 => ( 2,  1, 14,  7,  4, 10,  8, 13, 15, 12,  9,  0,  3,  5,  6, 11));
118 118
 
119
+  type pc_matrix IS ARRAY (0 TO 27) OF natural RANGE 0 TO 63;
120
+  constant pc1c_table : pc_matrix := (56, 48, 40, 32, 24, 16,  8,
121
+                                 0, 57, 49, 41, 33, 25, 17,
122
+                                 9,  1, 58, 50, 42, 34, 26,
123
+                                18, 10,  2, 59, 51, 43, 35);
124
+  constant pc1d_table : pc_matrix := (62, 54, 46, 38, 30, 22, 14,
125
+                                 6, 61, 53, 45, 37, 29, 21,
126
+                                13,  5, 60, 52, 44, 36, 28,
127
+                                20, 12,  4, 27, 19, 11,  3);
128
+
129
+  type p_matrix IS ARRAY (0 TO 31) OF natural RANGE 0 TO 31;
130
+  constant p_table : p_matrix := (15,  6, 19, 20,
131
+                                28, 11, 27, 16,
132
+                                 0, 14, 22, 25,
133
+                                 4, 17, 30,  9,
134
+                                 1,  7, 23, 13,
135
+                                31, 26,  2,  8,
136
+                                18, 12, 29,  5,
137
+                                21, 10,  3, 24);
138
+
139
+  type pc2_matrix IS ARRAY (0 TO 47) OF natural RANGE 0 TO 63;
140
+  constant pc2_table : pc2_matrix := (13, 16, 10, 23,  0,  4,
141
+                                 2, 27, 14,  5, 20,  9,
142
+                                22, 18, 11,  3, 25,  7,
143
+                                15,  6, 26, 19, 12,  1,
144
+                                40, 51, 30, 36, 46, 54,
145
+                                29, 39, 50, 44, 32, 47,
146
+                                43, 48, 38, 55, 33, 52,
147
+                                45, 41, 49, 35, 28, 31);
148
+
119 149
 
120 150
 END PACKAGE des_pkg;
121 151
 
@@ -256,19 +286,10 @@ PACKAGE BODY des_pkg IS
256 286
   END FUNCTION s8;
257 287
 
258 288
   FUNCTION p (input_vector : std_logic_vector(0 TO 31) ) RETURN std_logic_vector IS
259
-    TYPE matrix IS ARRAY (0 TO 31) OF natural RANGE 0 TO 31;
260
-    VARIABLE table : matrix := (15,  6, 19, 20,
261
-                                28, 11, 27, 16,
262
-                                 0, 14, 22, 25,
263
-                                 4, 17, 30,  9,
264
-                                 1,  7, 23, 13,
265
-                                31, 26,  2,  8,
266
-                                18, 12, 29,  5,
267
-                                21, 10,  3, 24);
268 289
     VARIABLE result : std_logic_vector(0 TO 31);
269 290
   BEGIN
270 291
     FOR index IN 0 TO 31 LOOP
271
-      result( index ) := input_vector( table( index ) );
292
+      result( index ) := input_vector( p_table( index ) );
272 293
     END LOOP;
273 294
     RETURN result;
274 295
   END FUNCTION p;
@@ -284,47 +305,29 @@ PACKAGE BODY des_pkg IS
284 305
   END FUNCTION f;
285 306
 
286 307
   FUNCTION pc1_c ( input_vector : std_logic_vector(0 TO 63) ) RETURN std_logic_vector IS
287
-    TYPE matrix IS ARRAY (0 TO 27) OF natural RANGE 0 TO 63;
288
-    VARIABLE table : matrix := (56, 48, 40, 32, 24, 16,  8,
289
-                                 0, 57, 49, 41, 33, 25, 17,
290
-                                 9,  1, 58, 50, 42, 34, 26,
291
-                                18, 10,  2, 59, 51, 43, 35);
292 308
     VARIABLE result : std_logic_vector(0 TO 27);
293 309
   BEGIN
294 310
     FOR index IN 0 TO 27 LOOP
295
-      result( index ) := input_vector( table( index ) );
311
+      result( index ) := input_vector( pc1c_table( index ) );
296 312
     END LOOP;
297 313
     RETURN result;
298 314
   END FUNCTION pc1_c;
299 315
 
300 316
   FUNCTION pc1_d ( input_vector : std_logic_vector(0 TO 63) ) RETURN std_logic_vector IS
301
-    TYPE matrix IS ARRAY (0 TO 27) OF natural RANGE 0 TO 63;
302
-    VARIABLE table : matrix := (62, 54, 46, 38, 30, 22, 14,
303
-                                 6, 61, 53, 45, 37, 29, 21,
304
-                                13,  5, 60, 52, 44, 36, 28,
305
-                                20, 12,  4, 27, 19, 11,  3);
317
+
306 318
     VARIABLE result : std_logic_vector(0 TO 27);
307 319
   BEGIN
308 320
     FOR index IN 0 TO 27 LOOP
309
-      result( index ) := input_vector( table( index ) );
321
+      result( index ) := input_vector( pc1d_table( index ) );
310 322
     END LOOP;
311 323
     RETURN result;
312 324
   END FUNCTION pc1_d;
313 325
 
314 326
   FUNCTION pc2 ( input_vector : std_logic_vector(0 TO 55) ) RETURN std_logic_vector IS
315
-    TYPE matrix IS ARRAY (0 TO 47) OF natural RANGE 0 TO 63;
316
-    VARIABLE table : matrix := (13, 16, 10, 23,  0,  4,
317
-                                 2, 27, 14,  5, 20,  9,
318
-                                22, 18, 11,  3, 25,  7,
319
-                                15,  6, 26, 19, 12,  1,
320
-                                40, 51, 30, 36, 46, 54,
321
-                                29, 39, 50, 44, 32, 47,
322
-                                43, 48, 38, 55, 33, 52,
323
-                                45, 41, 49, 35, 28, 31);
324 327
     VARIABLE result : std_logic_vector(0 TO 47);
325 328
   BEGIN
326 329
     FOR index IN 0 TO 47 LOOP
327
-      result( index ) := input_vector( table( index ) );
330
+      result( index ) := input_vector( pc2_table( index ) );
328 331
     END LOOP;
329 332
     RETURN result;
330 333
   END FUNCTION pc2;