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

Subversion Repositories hight

[/] [hight/] [trunk/] [rtl/] [CRYPTO_PATH.v] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 truemind
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  Main datapath 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 CRYPTO_PATH(
44
        rstn             ,
45
        clk              ,
46
 
47
        i_op             ,
48
 
49
        i_wrsk           ,
50
 
51
        i_text_in        ,
52
 
53
        i_xf_sel         ,
54
        i_rf_final       ,
55
 
56
        o_text_out
57
);
58
 
59
 
60
//=====================================
61
//
62
//          PARAMETERS 
63
//
64
//=====================================
65
 
66
 
67
//=====================================
68
//
69
//          I/O PORTS 
70
//
71
//=====================================
72
input        rstn           ;
73
input        clk            ;
74
 
75
input        i_op           ;
76
 
77
input[31:0]  i_wrsk         ;
78
 
79
input[63:0]  i_text_in      ;
80
 
81
input[2:0]   i_xf_sel       ;
82
input        i_rf_final     ;
83
 
84
output[63:0] o_text_out     ;
85
 
86
 
87
//=====================================
88
//
89
//          REGISTERS
90
//
91
//=====================================
92
// xf register
93
reg[63:0]   r_xf         ;
94
 
95
 
96
//=====================================
97
//
98
//          WIRES
99
//
100
//=====================================
101
// wf_in mux
102
wire[63:0]  w_wf_in_mux  ;
103
// w_wf_out
104
wire[63:0]  w_wf_out     ;
105
// w_rf_out
106
wire[63:0]  w_rf_out     ;
107
// xf mux
108
wire[63:0]  w_xf_mux   ;
109
 
110
//=====================================
111
//
112
//          MAIN
113
//
114
//=====================================
115
// WF(WhiteningFunction) instance
116
WF u_WF(
117
        .i_op        ( i_op        )  ,
118
        .i_wk        ( i_wrsk      )  ,
119
        .i_wf_in     ( w_wf_in_mux )  ,
120
 
121
        .o_wf_out    ( w_wf_out    )
122
);
123
 
124
// RF(RoundFunction) instance
125
RF u_RF(
126
        .i_op        ( i_op        )  ,
127
        .i_rf_final  ( i_rf_final  )  ,
128
        .i_rf_in     ( r_xf        )  ,
129
        .i_rsk       ( i_wrsk      )  ,
130
 
131
        .o_rf_out    ( w_rf_out    )
132
);
133
 
134
// wf_in mux 
135
assign      w_wf_in_mux = (~i_xf_sel[2]) ? r_xf      :  // i_xf_sel[2] == 0
136
                                           i_text_in ;  // i_xf_sel[2] == 1
137
 
138
// xf mux
139
assign      w_xf_mux   = (i_xf_sel[1:0] == 2'b00) ? r_xf      : // i_xf_sel[1:0] == 0
140
                         (i_xf_sel[1:0] == 2'b01) ? w_wf_out  : // i_xf_sel[1:0] == 1
141
                                                    w_rf_out  ; // i_xf_sel[1:0] == 2, 3
142
 
143
// xf register 
144
always @(negedge rstn or posedge clk)
145
        if(~rstn)
146
                r_xf <= #1 64'h0     ;
147
        else
148
                r_xf <= #1 w_xf_mux  ;
149
 
150
// o_text_out
151
assign      o_text_out = r_xf;
152
 
153
endmodule
154
 
155
 

powered by: WebSVN 2.1.0

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