1 |
21 |
rameli |
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@//
|
2 |
|
|
// Design Name: Substitution Layer for Present Cipher //
|
3 |
|
|
// Module Name: substitution //
|
4 |
|
|
// Language: Verilog //
|
5 |
|
|
// Date Created: 1/16/2011 //
|
6 |
|
|
// Author: Reza Ameli //
|
7 |
|
|
// Digital Systems Lab //
|
8 |
|
|
// Ferdowsi University of Mashhad, Iran //
|
9 |
|
|
// http://commeng.um.ac.ir/dslab //
|
10 |
|
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@//
|
11 |
|
|
// //
|
12 |
|
|
// This source file may be used and distributed without //
|
13 |
|
|
// restriction provided that this copyright statement is not //
|
14 |
|
|
// removed from the file and that any derivative work contains //
|
15 |
|
|
// the original copyright notice and the associated disclaimer. //
|
16 |
|
|
// //
|
17 |
|
|
// This source file is free software; you can redistribute it //
|
18 |
|
|
// and/or modify it under the terms of the GNU Lesser General //
|
19 |
|
|
// Public License as published by the Free Software Foundation; //
|
20 |
|
|
// either version 2.1 of the License, or (at your option) any //
|
21 |
|
|
// later version. //
|
22 |
|
|
// //
|
23 |
|
|
// This source is distributed in the hope that it will be //
|
24 |
|
|
// useful, but WITHOUT ANY WARRANTY; without even the implied //
|
25 |
|
|
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR //
|
26 |
|
|
// PURPOSE. See the GNU Lesser General Public License for more //
|
27 |
|
|
// details. //
|
28 |
|
|
// //
|
29 |
|
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@//
|
30 |
|
|
|
31 |
|
|
module substitution(data_o,data_i); // Present cipher uses 16 S-Boxes in parallel to process the data
|
32 |
|
|
// this module implements those 16 S-Boxes using the sbox module
|
33 |
|
|
|
34 |
|
|
//- Module IOs ----------------------------------------------------------------
|
35 |
|
|
|
36 |
|
|
output wire [63:0] data_o;
|
37 |
|
|
input wire [63:0] data_i;
|
38 |
|
|
|
39 |
|
|
//- Variables, Registers and Parameters ---------------------------------------
|
40 |
|
|
|
41 |
|
|
genvar j;
|
42 |
|
|
|
43 |
|
|
//- Instantiations ------------------------------------------------------------
|
44 |
|
|
|
45 |
|
|
generate
|
46 |
|
|
for (j = 0; j < 16; j = j+1)
|
47 |
|
|
begin : boxes
|
48 |
|
|
sbox substitution_sbox (.data_o(data_o[j*4+3 : j*4]),.data_i(data_i[j*4+3 : j*4]));
|
49 |
|
|
end
|
50 |
|
|
endgenerate
|
51 |
|
|
|
52 |
|
|
//-----------------------------------------------------------------------------
|
53 |
|
|
endmodule
|