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

Subversion Repositories des

[/] [des/] [trunk/] [rtl/] [verilog/] [area_opt/] [des.v] - Blame information for rev 9

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 5 rudi
/////////////////////////////////////////////////////////////////////
2
////                                                             ////
3
////  DES                                                        ////
4
////  DES Top Level module                                       ////
5
////                                                             ////
6
////  Author: Rudolf Usselmann                                   ////
7
////          rudi@asics.ws                                      ////
8
////                                                             ////
9
/////////////////////////////////////////////////////////////////////
10
////                                                             ////
11
//// Copyright (C) 2001 Rudolf Usselmann                         ////
12
////                    rudi@asics.ws                            ////
13
////                                                             ////
14
//// This source file may be used and distributed without        ////
15
//// restriction provided that this copyright statement is not   ////
16
//// removed from the file and that any derivative work contains ////
17
//// the original copyright notice and the associated disclaimer.////
18
////                                                             ////
19
////     THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY     ////
20
//// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED   ////
21
//// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS   ////
22
//// FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL THE AUTHOR      ////
23
//// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,         ////
24
//// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES    ////
25
//// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE   ////
26
//// GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR        ////
27
//// BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF  ////
28
//// LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT  ////
29
//// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT  ////
30
//// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE         ////
31
//// POSSIBILITY OF SUCH DAMAGE.                                 ////
32
////                                                             ////
33
/////////////////////////////////////////////////////////////////////
34
 
35
module des(desOut, desIn, key, decrypt, roundSel, clk);
36
output  [63:0]   desOut;
37
input   [63:0]   desIn;
38
input   [55:0]   key;
39
input           decrypt;
40
input   [3:0]    roundSel;
41
input           clk;
42
 
43
wire    [1:48]  K_sub;
44
wire    [1:64]  IP, FP;
45
reg     [1:32]  L, R;
46
wire    [1:32]  Xin;
47
wire    [1:32]  Lout, Rout;
48
wire    [1:32]  out;
49
 
50
assign Lout = (roundSel == 0) ? IP[33:64] : R;
51
assign Xin  = (roundSel == 0) ? IP[01:32] : L;
52
assign Rout = Xin ^ out;
53
assign FP = { Rout, Lout};
54
 
55
crp u0( .P(out), .R(Lout), .K_sub(K_sub) );
56
 
57
always @(posedge clk)
58
        L <= #1 Lout;
59
 
60
always @(posedge clk)
61
        R <= #1 Rout;
62
 
63
// Select a subkey from key.
64
key_sel u1(
65
        .K_sub(         K_sub           ),
66
        .K(             key             ),
67
        .roundSel(      roundSel        ),
68
        .decrypt(       decrypt         )
69
        );
70
 
71
// Perform initial permutation
72
assign IP[1:64] = {     desIn[06], desIn[14], desIn[22], desIn[30], desIn[38], desIn[46],
73
                        desIn[54], desIn[62], desIn[04], desIn[12], desIn[20], desIn[28],
74
                        desIn[36], desIn[44], desIn[52], desIn[60], desIn[02], desIn[10],
75
                        desIn[18], desIn[26], desIn[34], desIn[42], desIn[50], desIn[58],
76
                        desIn[00], desIn[08], desIn[16], desIn[24], desIn[32], desIn[40],
77
                        desIn[48], desIn[56], desIn[07], desIn[15], desIn[23], desIn[31],
78
                        desIn[39], desIn[47], desIn[55], desIn[63], desIn[05], desIn[13],
79
                        desIn[21], desIn[29], desIn[37], desIn[45], desIn[53], desIn[61],
80
                        desIn[03], desIn[11], desIn[19], desIn[27], desIn[35], desIn[43],
81
                        desIn[51], desIn[59], desIn[01], desIn[09], desIn[17], desIn[25],
82
                        desIn[33], desIn[41], desIn[49], desIn[57] };
83
 
84
// Perform final permutation
85
assign desOut = {       FP[40], FP[08], FP[48], FP[16], FP[56], FP[24], FP[64], FP[32],
86
                        FP[39], FP[07], FP[47], FP[15], FP[55], FP[23], FP[63], FP[31],
87
                        FP[38], FP[06], FP[46], FP[14], FP[54], FP[22], FP[62], FP[30],
88
                        FP[37], FP[05], FP[45], FP[13], FP[53], FP[21], FP[61], FP[29],
89
                        FP[36], FP[04], FP[44], FP[12], FP[52], FP[20], FP[60], FP[28],
90
                        FP[35], FP[03], FP[43], FP[11], FP[51], FP[19], FP[59], FP[27],
91
                        FP[34], FP[02], FP[42], FP[10], FP[50], FP[18], FP[58], FP[26],
92
                        FP[33], FP[01], FP[41], FP[09], FP[49], FP[17], FP[57], FP[25] };
93
 
94
 
95
endmodule

powered by: WebSVN 2.1.0

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