Browse Source

moved array type definitions out of functions to head of package, instances now also in package head and are constants

T. Meissner 6 years ago
parent
commit
716ce2725b
1 changed files with 113 additions and 110 deletions
  1. 113
    110
      cbcdes/rtl/vhdl/des_pkg.vhd

+ 113
- 110
cbcdes/rtl/vhdl/des_pkg.vhd View File

@@ -29,8 +29,10 @@ USE ieee.std_logic_1164.all;
29 29
 USE ieee.numeric_std.ALL;
30 30
 
31 31
 
32
+
32 33
 PACKAGE des_pkg IS
33 34
 
35
+
34 36
   FUNCTION ip  ( input_vector : std_logic_vector(0 TO 63) ) RETURN std_logic_vector;
35 37
   FUNCTION ipn ( input_vector : std_logic_vector(0 TO 63) ) RETURN std_logic_vector;
36 38
 
@@ -52,14 +54,8 @@ PACKAGE des_pkg IS
52 54
   FUNCTION pc1_d ( input_vector : std_logic_vector(0 TO 63) ) RETURN std_logic_vector;
53 55
   FUNCTION pc2   ( input_vector : std_logic_vector(0 TO 55) ) RETURN std_logic_vector;
54 56
 
55
-END PACKAGE des_pkg;
56
-
57
-
58
-PACKAGE BODY des_pkg IS
59
-
60
-  FUNCTION ip ( input_vector : std_logic_vector(0 TO 63) ) RETURN std_logic_vector IS
61
-    TYPE matrix IS ARRAY (0 TO 63) OF natural RANGE 0 TO 63;
62
-    VARIABLE table : matrix := (57, 49, 41, 33, 25, 17,  9, 1,
57
+  TYPE ip_matrix IS ARRAY (0 TO 63) OF natural RANGE 0 TO 63;
58
+  constant ip_table : ip_matrix := (57, 49, 41, 33, 25, 17,  9, 1,
63 59
                                 59, 51, 43, 35, 27, 19, 11, 3,
64 60
                                 61, 53, 45, 37, 29, 21, 13, 5,
65 61
                                 63, 55, 47, 39, 31, 23, 15, 7,
@@ -67,56 +63,125 @@ PACKAGE BODY des_pkg IS
67 63
                                 58, 50, 42, 34, 26, 18, 10, 2,
68 64
                                 60, 52, 44, 36, 28, 20, 12, 4,
69 65
                                 62, 54, 46, 38, 30, 22, 14, 6);
66
+  constant ipn_table : ip_matrix := (39,  7, 47, 15, 55, 23, 63, 31,
67
+                                38,  6, 46, 14, 54, 22, 62, 30,
68
+                                37,  5, 45, 13, 53, 21, 61, 29,
69
+                                36,  4, 44, 12, 52, 20, 60, 28,
70
+                                35,  3, 43, 11, 51, 19, 59, 27,
71
+                                34,  2, 42, 10, 50, 18, 58, 26,
72
+                                33,  1, 41,  9, 49, 17, 57, 25,
73
+                                32,  0, 40,  8, 48, 16, 56, 24);
74
+
75
+  TYPE e_matrix IS ARRAY (0 TO 47) OF natural RANGE 0 TO 31;
76
+  constant e_table : e_matrix := (31,  0,  1,  2,  3,  4,
77
+                                 3,  4,  5,  6,  7,  8,
78
+                                 7,  8,  9, 10, 11, 12,
79
+                                11, 12, 13, 14, 15, 16,
80
+                                15, 16, 17, 18, 19, 20,
81
+                                19, 20, 21, 22, 23, 24,
82
+                                23, 24, 25, 26, 27, 28,
83
+                                27, 28, 29, 30, 31,  0);
84
+
85
+  TYPE s_matrix IS ARRAY (0 TO 3, 0 TO 15) OF integer RANGE 0 TO 15;
86
+  constant s1_table  : s_matrix := (0 => (14,  4, 13,  1,  2, 15, 11,  8,  3, 10,  6, 12,  5,  9,  0,  7),
87
+                                    1 => ( 0, 15,  7,  4, 14,  2, 13,  1, 10,  6, 12, 11,  9,  5,  3,  8),
88
+                                    2 => ( 4,  1, 14,  8, 13,  6,  2, 11, 15, 12,  9,  7,  3, 10,  5,  0),
89
+                                    3 => (15, 12,  8,  2,  4,  9,  1,  7,  5, 11,  3, 14, 10,  0,  6, 13));
90
+  constant s2_table  : s_matrix := (0 => (15,  1,  8, 14,  6, 11,  3,  4,  9,  7,  2, 13, 12,  0,  5, 10),
91
+                                    1 => ( 3, 13,  4,  7, 15,  2,  8, 14, 12,  0,  1, 10,  6,  9, 11,  5),
92
+                                    2 => ( 0, 14,  7, 11, 10,  4, 13,  1,  5,  8, 12,  6,  9,  3,  2, 15),
93
+                                    3 => (13,  8, 10,  1,  3, 15,  4,  2, 11,  6,  7, 12,  0,  5, 14,  9));
94
+  constant s3_table  : s_matrix := (0 => (10,  0,  9, 14,  6,  3, 15,  5,  1, 13, 12,  7, 11,  4,  2,  8),
95
+                                    1 => (13,  7,  0,  9,  3,  4,  6, 10,  2,  8,  5, 14, 12, 11, 15,  1),
96
+                                    2 => (13,  6,  4,  9,  8, 15,  3,  0, 11,  1,  2, 12,  5, 10, 14,  7),
97
+                                    3 => ( 1, 10, 13,  0,  6,  9,  8,  7,  4, 15, 14,  3, 11,  5,  2, 12));
98
+  constant s4_table  : s_matrix := (0 => ( 7, 13, 14,  3,  0,  6,  9, 10,  1,  2,  8,  5, 11, 12,  4,  15),
99
+                                    1 => (13,  8, 11,  5,  6, 15,  0,  3,  4,  7,  2, 12,  1, 10, 14,   9),
100
+                                    2 => (10,  6,  9,  0, 12, 11,  7, 13, 15,  1,  3, 14,  5,  2,  8,   4),
101
+                                    3 => ( 3, 15,  0,  6, 10,  1, 13,  8,  9,  4,  5, 11, 12,  7,  2,  14));
102
+  constant s5_table  : s_matrix := (0 => ( 2, 12,  4,  1,  7, 10, 11,  6,  8,  5,  3, 15, 13,  0, 14,  9),
103
+                                    1 => (14, 11,  2, 12,  4,  7, 13,  1,  5,  0, 15, 10,  3,  9,  8,  6),
104
+                                    2 => ( 4,  2,  1, 11, 10, 13,  7,  8, 15,  9, 12,  5,  6,  3,  0, 14),
105
+                                    3 => (11,  8, 12,  7,  1, 14,  2, 13,  6, 15,  0,  9, 10,  4,  5,  3));
106
+  constant s6_table  : s_matrix := (0 => (12,  1, 10, 15,  9,  2,  6,  8,  0, 13,  3,  4, 14,  7,  5, 11),
107
+                                    1 => (10, 15,  4,  2,  7, 12,  9,  5,  6,  1, 13, 14,  0, 11,  3,  8),
108
+                                    2 => ( 9, 14, 15,  5,  2,  8, 12,  3,  7,  0,  4, 10,  1, 13, 11,  6),
109
+                                    3 => ( 4,  3,  2, 12,  9,  5, 15, 10, 11, 14,  1,  7,  6,  0,  8, 13));
110
+  constant s7_table  : s_matrix := (0 => ( 4, 11,  2, 14, 15,  0,  8, 13,  3, 12,  9,  7,  5, 10,  6,  1),
111
+                                    1 => (13,  0, 11,  7,  4,  9,  1, 10, 14,  3,  5, 12,  2, 15,  8,  6),
112
+                                    2 => ( 1,  4, 11, 13, 12,  3,  7, 14, 10, 15,  6,  8,  0,  5,  9,  2),
113
+                                    3 => ( 6, 11, 13,  8,  1,  4, 10,  7,  9,  5,  0, 15, 14,  2,  3, 12));
114
+  constant s8_table  : s_matrix := (0 => (13,  2,  8,  4,  6, 15, 11,  1, 10,  9,  3, 14,  5,  0, 12,  7),
115
+                                    1 => ( 1, 15, 13,  8, 10,  3,  7,  4, 12,  5,  6, 11,  0, 14,  9,  2),
116
+                                    2 => ( 7, 11,  4,  1,  9, 12, 14,  2,  0,  6, 10, 13, 15,  3,  5,  8),
117
+                                    3 => ( 2,  1, 14,  7,  4, 10,  8, 13, 15, 12,  9,  0,  3,  5,  6, 11));
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
+
149
+
150
+END PACKAGE des_pkg;
151
+
152
+
153
+
154
+PACKAGE BODY des_pkg IS
155
+
156
+
157
+  FUNCTION ip ( input_vector : std_logic_vector(0 TO 63) ) RETURN std_logic_vector IS
70 158
     VARIABLE result : std_logic_vector(0 TO 63);
71 159
   BEGIN
72 160
     FOR index IN 0 TO 63 LOOP
73
-      result( index ) := input_vector( table( index ) );
161
+      result( index ) := input_vector( ip_table( index ) );
74 162
     END LOOP;
75 163
     RETURN result;
76 164
   END FUNCTION ip;
77 165
 
78 166
   FUNCTION ipn ( input_vector : std_logic_vector(0 TO 63) ) RETURN std_logic_vector IS
79
-    TYPE matrix IS ARRAY (0 TO 63) OF natural RANGE 0 TO 63;
80
-    VARIABLE table : matrix := (39,  7, 47, 15, 55, 23, 63, 31,
81
-                                38,  6, 46, 14, 54, 22, 62, 30,
82
-                                37,  5, 45, 13, 53, 21, 61, 29,
83
-                                36,  4, 44, 12, 52, 20, 60, 28,
84
-                                35,  3, 43, 11, 51, 19, 59, 27,
85
-                                34,  2, 42, 10, 50, 18, 58, 26,
86
-                                33,  1, 41,  9, 49, 17, 57, 25,
87
-                                32,  0, 40,  8, 48, 16, 56, 24);
88 167
     VARIABLE result : std_logic_vector(0 TO 63);
89 168
   BEGIN
90 169
     FOR index IN 0 TO 63 LOOP
91
-      result( index ) := input_vector( table( index ) );
170
+      result( index ) := input_vector( ipn_table( index ) );
92 171
     END LOOP;
93 172
     RETURN result;
94 173
   END FUNCTION ipn;
95 174
 
96 175
   FUNCTION e (input_vector : std_logic_vector(0 TO 31) ) RETURN std_logic_vector IS
97
-    TYPE matrix IS ARRAY (0 TO 47) OF natural RANGE 0 TO 31;
98
-    VARIABLE table : matrix := (31,  0,  1,  2,  3,  4,
99
-                                 3,  4,  5,  6,  7,  8,
100
-                                 7,  8,  9, 10, 11, 12,
101
-                                11, 12, 13, 14, 15, 16,
102
-                                15, 16, 17, 18, 19, 20,
103
-                                19, 20, 21, 22, 23, 24,
104
-                                23, 24, 25, 26, 27, 28,
105
-                                27, 28, 29, 30, 31,  0);
106 176
     VARIABLE result : std_logic_vector(0 TO 47);
107 177
   BEGIN
108 178
     FOR index IN 0 TO 47 LOOP
109
-      result( index ) := input_vector( table( index ) );
179
+      result( index ) := input_vector( e_table( index ) );
110 180
     END LOOP;
111 181
     RETURN result;
112 182
   END FUNCTION e;
113 183
 
114 184
   FUNCTION s1 ( input_vector : std_logic_vector(0 TO 5) ) RETURN std_logic_vector IS
115
-    TYPE matrix IS ARRAY (0 TO 3, 0 TO 15) OF integer RANGE 0 TO 15;
116
-    VARIABLE table  : matrix := (0 => (14,  4, 13,  1,  2, 15, 11,  8,  3, 10,  6, 12,  5,  9,  0,  7),
117
-                                 1 => ( 0, 15,  7,  4, 14,  2, 13,  1, 10,  6, 12, 11,  9,  5,  3,  8),
118
-                                 2 => ( 4,  1, 14,  8, 13,  6,  2, 11, 15, 12,  9,  7,  3, 10,  5,  0),
119
-                                 3 => (15, 12,  8,  2,  4,  9,  1,  7,  5, 11,  3, 14, 10,  0,  6, 13));
120 185
     VARIABLE int : std_logic_vector(0 TO 1);
121 186
     VARIABLE i : integer RANGE 0 TO 3;
122 187
     VARIABLE j : integer RANGE 0 TO 15;
@@ -125,16 +190,11 @@ PACKAGE BODY des_pkg IS
125 190
     int := input_vector( 0 ) & input_vector( 5 );
126 191
     i := to_integer( unsigned( int ) );
127 192
     j := to_integer( unsigned( input_vector( 1 TO 4) ) );
128
-    result := std_logic_vector( to_unsigned( table( i, j ), 4 ) );
193
+    result := std_logic_vector( to_unsigned( s1_table( i, j ), 4 ) );
129 194
     RETURN result;
130 195
   END FUNCTION s1;
131 196
 
132 197
   FUNCTION s2 ( input_vector : std_logic_vector(0 TO 5) ) RETURN std_logic_vector IS
133
-    TYPE matrix IS ARRAY (0 TO 3, 0 TO 15) OF integer RANGE 0 TO 15;
134
-    VARIABLE table  : matrix := (0 => (15,  1,  8, 14,  6, 11,  3,  4,  9,  7,  2, 13, 12,  0,  5, 10),
135
-                                 1 => ( 3, 13,  4,  7, 15,  2,  8, 14, 12,  0,  1, 10,  6,  9, 11,  5),
136
-                                 2 => ( 0, 14,  7, 11, 10,  4, 13,  1,  5,  8, 12,  6,  9,  3,  2, 15),
137
-                                 3 => (13,  8, 10,  1,  3, 15,  4,  2, 11,  6,  7, 12,  0,  5, 14,  9));
138 198
     VARIABLE int : std_logic_vector(0 TO 1);
139 199
     VARIABLE i : integer RANGE 0 TO 3;
140 200
     VARIABLE j : integer RANGE 0 TO 15;
@@ -143,16 +203,11 @@ PACKAGE BODY des_pkg IS
143 203
     int := input_vector( 0 ) & input_vector( 5 );
144 204
     i := to_integer( unsigned( int ) );
145 205
     j := to_integer( unsigned( input_vector( 1 TO 4) ) );
146
-    result := std_logic_vector( to_unsigned( table( i, j ), 4 ) );
206
+    result := std_logic_vector( to_unsigned( s2_table( i, j ), 4 ) );
147 207
     RETURN result;
148 208
   END FUNCTION s2;
149 209
 
150 210
   FUNCTION s3 ( input_vector : std_logic_vector(0 TO 5) ) RETURN std_logic_vector IS
151
-    TYPE matrix IS ARRAY (0 TO 3, 0 TO 15) OF integer RANGE 0 TO 15;
152
-    VARIABLE table  : matrix := (0 => (10,  0,  9, 14,  6,  3, 15,  5,  1, 13, 12,  7, 11,  4,  2,  8),
153
-                                 1 => (13,  7,  0,  9,  3,  4,  6, 10,  2,  8,  5, 14, 12, 11, 15,  1),
154
-                                 2 => (13,  6,  4,  9,  8, 15,  3,  0, 11,  1,  2, 12,  5, 10, 14,  7),
155
-                                 3 => ( 1, 10, 13,  0,  6,  9,  8,  7,  4, 15, 14,  3, 11,  5,  2, 12));
156 211
     VARIABLE int : std_logic_vector(0 TO 1);
157 212
     VARIABLE i : integer RANGE 0 TO 3;
158 213
     VARIABLE j : integer RANGE 0 TO 15;
@@ -161,16 +216,11 @@ PACKAGE BODY des_pkg IS
161 216
     int := input_vector( 0 ) & input_vector( 5 );
162 217
     i := to_integer( unsigned( int ) );
163 218
     j := to_integer( unsigned( input_vector( 1 TO 4) ) );
164
-    result := std_logic_vector( to_unsigned( table( i, j ), 4 ) );
219
+    result := std_logic_vector( to_unsigned( s3_table( i, j ), 4 ) );
165 220
     RETURN result;
166 221
   END FUNCTION s3;
167 222
 
168 223
   FUNCTION s4 ( input_vector : std_logic_vector(0 TO 5) ) RETURN std_logic_vector IS
169
-    TYPE matrix IS ARRAY (0 TO 3, 0 TO 15) OF integer RANGE 0 TO 15;
170
-    VARIABLE table  : matrix := (0 => ( 7, 13, 14,  3,  0,  6,  9, 10,  1,  2,  8,  5, 11, 12,  4,  15),
171
-                                 1 => (13,  8, 11,  5,  6, 15,  0,  3,  4,  7,  2, 12,  1, 10, 14,   9),
172
-                                 2 => (10,  6,  9,  0, 12, 11,  7, 13, 15,  1,  3, 14,  5,  2,  8,   4),
173
-                                 3 => ( 3, 15,  0,  6, 10,  1, 13,  8,  9,  4,  5, 11, 12,  7,  2,  14));
174 224
     VARIABLE int : std_logic_vector(0 TO 1);
175 225
     VARIABLE i : integer RANGE 0 TO 3;
176 226
     VARIABLE j : integer RANGE 0 TO 15;
@@ -179,16 +229,11 @@ PACKAGE BODY des_pkg IS
179 229
     int := input_vector( 0 ) & input_vector( 5 );
180 230
     i := to_integer( unsigned( int ) );
181 231
     j := to_integer( unsigned( input_vector( 1 TO 4) ) );
182
-    result := std_logic_vector( to_unsigned( table( i, j ), 4 ) );
232
+    result := std_logic_vector( to_unsigned( s4_table( i, j ), 4 ) );
183 233
     RETURN result;
184 234
   END FUNCTION s4;
185 235
 
186 236
   FUNCTION s5 ( input_vector : std_logic_vector(0 TO 5) ) RETURN std_logic_vector IS
187
-    TYPE matrix IS ARRAY (0 TO 3, 0 TO 15) OF integer RANGE 0 TO 15;
188
-    VARIABLE table  : matrix := (0 => ( 2, 12,  4,  1,  7, 10, 11,  6,  8,  5,  3, 15, 13,  0, 14,  9),
189
-                                 1 => (14, 11,  2, 12,  4,  7, 13,  1,  5,  0, 15, 10,  3,  9,  8,  6),
190
-                                 2 => ( 4,  2,  1, 11, 10, 13,  7,  8, 15,  9, 12,  5,  6,  3,  0, 14),
191
-                                 3 => (11,  8, 12,  7,  1, 14,  2, 13,  6, 15,  0,  9, 10,  4,  5,  3));
192 237
     VARIABLE int : std_logic_vector(0 TO 1);
193 238
     VARIABLE i : integer RANGE 0 TO 3;
194 239
     VARIABLE j : integer RANGE 0 TO 15;
@@ -197,16 +242,11 @@ PACKAGE BODY des_pkg IS
197 242
     int := input_vector( 0 ) & input_vector( 5 );
198 243
     i := to_integer( unsigned( int ) );
199 244
     j := to_integer( unsigned( input_vector( 1 TO 4) ) );
200
-    result := std_logic_vector( to_unsigned( table( i, j ), 4 ) );
245
+    result := std_logic_vector( to_unsigned( s5_table( i, j ), 4 ) );
201 246
     RETURN result;
202 247
   END FUNCTION s5;
203 248
 
204 249
   FUNCTION s6 ( input_vector : std_logic_vector(0 TO 5) ) RETURN std_logic_vector IS
205
-    TYPE matrix IS ARRAY (0 TO 3, 0 TO 15) OF integer RANGE 0 TO 15;
206
-    VARIABLE table  : matrix := (0 => (12,  1, 10, 15,  9,  2,  6,  8,  0, 13,  3,  4, 14,  7,  5, 11),
207
-                                 1 => (10, 15,  4,  2,  7, 12,  9,  5,  6,  1, 13, 14,  0, 11,  3,  8),
208
-                                 2 => ( 9, 14, 15,  5,  2,  8, 12,  3,  7,  0,  4, 10,  1, 13, 11,  6),
209
-                                 3 => ( 4,  3,  2, 12,  9,  5, 15, 10, 11, 14,  1,  7,  6,  0,  8, 13));
210 250
     VARIABLE int : std_logic_vector(0 TO 1);
211 251
     VARIABLE i : integer RANGE 0 TO 3;
212 252
     VARIABLE j : integer RANGE 0 TO 15;
@@ -215,16 +255,11 @@ PACKAGE BODY des_pkg IS
215 255
     int := input_vector( 0 ) & input_vector( 5 );
216 256
     i := to_integer( unsigned( int ) );
217 257
     j := to_integer( unsigned( input_vector( 1 TO 4) ) );
218
-    result := std_logic_vector( to_unsigned( table( i, j ), 4 ) );
258
+    result := std_logic_vector( to_unsigned( s6_table( i, j ), 4 ) );
219 259
     RETURN result;
220 260
   END FUNCTION s6;
221 261
 
222 262
   FUNCTION s7 ( input_vector : std_logic_vector(0 TO 5) ) RETURN std_logic_vector IS
223
-    TYPE matrix IS ARRAY (0 TO 3, 0 TO 15) OF integer RANGE 0 TO 15;
224
-    VARIABLE table  : matrix := (0 => ( 4, 11,  2, 14, 15,  0,  8, 13,  3, 12,  9,  7,  5, 10,  6,  1),
225
-                                 1 => (13,  0, 11,  7,  4,  9,  1, 10, 14,  3,  5, 12,  2, 15,  8,  6),
226
-                                 2 => ( 1,  4, 11, 13, 12,  3,  7, 14, 10, 15,  6,  8,  0,  5,  9,  2),
227
-                                 3 => ( 6, 11, 13,  8,  1,  4, 10,  7,  9,  5,  0, 15, 14,  2,  3, 12));
228 263
     VARIABLE int : std_logic_vector(0 TO 1);
229 264
     VARIABLE i : integer RANGE 0 TO 3;
230 265
     VARIABLE j : integer RANGE 0 TO 15;
@@ -233,16 +268,11 @@ PACKAGE BODY des_pkg IS
233 268
     int := input_vector( 0 ) & input_vector( 5 );
234 269
     i := to_integer( unsigned( int ) );
235 270
     j := to_integer( unsigned( input_vector( 1 TO 4) ) );
236
-    result := std_logic_vector( to_unsigned( table( i, j ), 4 ) );
271
+    result := std_logic_vector( to_unsigned( s7_table( i, j ), 4 ) );
237 272
     RETURN result;
238 273
   END FUNCTION s7;
239 274
 
240 275
   FUNCTION s8 ( input_vector : std_logic_vector(0 TO 5) ) RETURN std_logic_vector IS
241
-    TYPE matrix IS ARRAY (0 TO 3, 0 TO 15) OF integer RANGE 0 TO 15;
242
-    VARIABLE table  : matrix := (0 => (13,  2,  8,  4,  6, 15, 11,  1, 10,  9,  3, 14,  5,  0, 12,  7),
243
-                                 1 => ( 1, 15, 13,  8, 10,  3,  7,  4, 12,  5,  6, 11,  0, 14,  9,  2),
244
-                                 2 => ( 7, 11,  4,  1,  9, 12, 14,  2,  0,  6, 10, 13, 15,  3,  5,  8),
245
-                                 3 => ( 2,  1, 14,  7,  4, 10,  8, 13, 15, 12,  9,  0,  3,  5,  6, 11));
246 276
     VARIABLE int : std_logic_vector(0 TO 1);
247 277
     VARIABLE i : integer RANGE 0 TO 3;
248 278
     VARIABLE j : integer RANGE 0 TO 15;
@@ -251,24 +281,15 @@ PACKAGE BODY des_pkg IS
251 281
     int := input_vector( 0 ) & input_vector( 5 );
252 282
     i := to_integer( unsigned( int ) );
253 283
     j := to_integer( unsigned( input_vector( 1 TO 4) ) );
254
-    result := std_logic_vector( to_unsigned( table( i, j ), 4 ) );
284
+    result := std_logic_vector( to_unsigned( s8_table( i, j ), 4 ) );
255 285
     RETURN result;
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,50 +305,32 @@ 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;
331 334
 
332 335
 
333
-END PACKAGE BODY des_pkg;
336
+END PACKAGE BODY des_pkg;