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

Subversion Repositories csa

[/] [csa/] [trunk/] [rtl/] [stream_iteration.v] - Blame information for rev 38

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 20 simon111
 
2
// this module do a iteration operation for 2 bit
3
 
4
module stream_iteration(init,in1,in2,
5
                                Ai,Bi,Di,Ei,Fi,Xi,Yi,Zi,pi,qi,ri,
6
                                Ao,Bo,Do,Eo,Fo,Xo,Yo,Zo,po,qo,ro,
7
                                op);
8
input    init;
9
input [3     :0] in1;
10
input [3     :0] in2;
11
 
12
input [10*4-1:0] Ai;
13
input [10*4-1:0] Bi;
14
input [3     :0] Di;
15
input [3     :0] Ei;
16
input [3     :0] Fi;
17
input [3     :0] Xi;
18
input [3     :0] Yi;
19
input [3     :0] Zi;
20
input            pi;
21
input            qi;
22
input            ri;
23
 
24
output [10*4-1:0] Ao;
25
output [10*4-1:0] Bo;
26
output [3     :0] Do;
27
output [3     :0] Eo;
28
output [3     :0] Fo;
29
output [3     :0] Xo;
30
output [3     :0] Yo;
31
output [3     :0] Zo;
32
output            po;
33
output            qo;
34
output            ro;
35
 
36
output[1     :0] op;
37
 
38
wire [1:0] s1;
39
wire [1:0] s2;
40
wire [1:0] s3;
41
wire [1:0] s4;
42
wire [1:0] s5;
43
wire [1:0] s6;
44
wire [1:0] s7;
45
 
46
wire [3:0] extra_B;
47
wire [3:0] next_A1;
48
wire [3:0] _next_B1;
49
wire [3:0] next_B1;
50
wire [3:0] next_E;
51
 
52
wire [4:0] total;
53
 
54
sboxes b(
55
                .A(Ai[9*4-1:0])
56
               ,.s1(s1)
57
               ,.s2(s2)
58
               ,.s3(s3)
59
               ,.s4(s4)
60
               ,.s5(s5)
61
               ,.s6(s6)
62
               ,.s7(s7)
63
        );
64
 
65
assign extra_B ={( Bi[(3-1)*4+0] ^ Bi[(6-1)*4+1] ^ Bi[(7-1)*4+2] ^ Bi[(9-1)*4+3]) ,
66
                 ( Bi[(6-1)*4+0] ^ Bi[(8-1)*4+1] ^ Bi[(3-1)*4+3] ^ Bi[(4-1)*4+2]) ,
67
                 ( Bi[(5-1)*4+3] ^ Bi[(8-1)*4+2] ^ Bi[(4-1)*4+0] ^ Bi[(5-1)*4+1]) ,
68
                 ( Bi[(9-1)*4+2] ^ Bi[(6-1)*4+3] ^ Bi[(3-1)*4+1] ^ Bi[(8-1)*4+0]) };
69
 
70
assign next_A1=(init)?   Ai[(10)*4-1:(10-1)*4] ^ Xi ^ Di ^ in2
71
                        :Ai[(10)*4-1:(10-1)*4] ^ Xi;
72
 
73
assign _next_B1=(init)?  Bi[7*4-1:(7-1)*4] ^ Bi[10*4-1:(10-1)*4] ^ Yi ^ in1
74
                        :Bi[7*4-1:(7-1)*4] ^ Bi[10*4-1:(10-1)*4] ^ Yi ;
75
 
76
assign next_B1=(pi)?{ _next_B1[2:0], _next_B1[3] }: _next_B1;
77
 
78
assign Do = Ei ^ Zi ^ extra_B;
79
 
80
assign next_E=Fi;
81
 
82
assign total=Zi+Ei+ri;
83
 
84
assign Fo=(qi)? total[3:0]:Ei;
85
assign ro=(qi)? total[4]:ri;
86
 
87
assign Eo=next_E;
88
 
89
assign Ao[10*4-1:4]=Ai[9*4-1:0];
90
assign Ao[1*4-1:0] =next_A1;
91
assign Bo[10*4-1:4]=Bi[9*4-1:0];
92
assign Bo[1*4-1:0] =next_B1;
93
 
94
assign Xo ={s4[0] , s3[0] , s2[1] , s1[1] };
95
assign Yo ={s6[0] , s5[0] , s4[1] , s3[1] };
96
assign Zo ={s2[0] , s1[0] , s6[1] , s5[1] };
97
 
98
assign po=s7[1];
99
assign qo=s7[0];
100
 
101
assign op = { Do[3] ^ Do[2], Do[1] ^ Do[0]  };
102
endmodule

powered by: WebSVN 2.1.0

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