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

Subversion Repositories csa

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

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

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

powered by: WebSVN 2.1.0

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