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

Subversion Repositories csa

[/] [csa/] [trunk/] [rtl/] [stream_cypher.v] - Blame information for rev 27

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

Line No. Rev Author Line
1 20 simon111
 
2
 
3
// this file implement the stream cypher module
4
 
5 21 simon111
module stream_cypher(clk,rst,en,init,ck,sb,cb);
6 20 simon111
input                 clk;
7 21 simon111
input                 rst;   // hi enable
8 20 simon111
input                 en;      // hi enable
9
input                 init;    // hi enable
10
input  [8 *8-1:0]     ck;
11
input  [8 *8-1:0]     sb;
12
output [8 *8-1:0]     cb;
13
 
14 21 simon111
 
15 20 simon111
// intermediate variable
16
reg    [10*4-1 : 0]A;
17
reg    [10*4-1 : 0]B;
18
reg    [4-1    : 0]X;
19
reg    [4-1    : 0]Y;
20
reg    [4-1    : 0]Z;
21
reg    [4-1    : 0]D;
22
reg    [4-1    : 0]E;
23
reg    [4-1    : 0]F;
24
reg                p;
25
reg                q;
26
reg                r;
27 21 simon111
reg    [8 *8-1 : 0]cb;
28 20 simon111
 
29
wire   [10*4-1 : 0]Ao;
30
wire   [10*4-1 : 0]Ainit;
31
wire   [10*4-1 : 0]Bo;
32
wire   [10*4-1 : 0]Binit;
33
wire   [4-1    : 0]Xo;
34
wire   [4-1    : 0]Yo;
35
wire   [4-1    : 0]Zo;
36
wire   [4-1    : 0]Do;
37
wire   [4-1    : 0]Eo;
38
wire   [4-1    : 0]Fo;
39
wire               po;
40
wire               qo;
41
wire               ro;
42 21 simon111
wire   [8 *8-1 : 0]cbo;
43 20 simon111
 
44
assign Ainit = {
45
                4'b0,         4'b0,
46
        ck[7*4-1:6*4],ck[8*4-1:7*4],
47
        ck[5*4-1:4*4],ck[6*4-1:5*4],
48
        ck[3*4-1:2*4],ck[4*4-1:3*4],
49
        ck[1*4-1:0*4],ck[2*4-1:1*4]
50
};
51
 
52
assign Binit = {
53
                   4'b0,           4'b0,
54
        ck[15*4-1:14*4],ck[16*4-1:15*4],
55
        ck[13*4-1:12*4],ck[14*4-1:13*4],
56
        ck[11*4-1:10*4],ck[12*4-1:11*4],
57
        ck[ 9*4-1: 8*4],ck[10*4-1: 9*4]
58
};
59
 
60
always @(posedge clk)
61
begin
62 21 simon111
        if(rst)
63 20 simon111
        begin
64
                A<= 40'h0000000000;
65
                B<= 40'h0000000000;
66
                X<=  8'h00;
67
                Y<=  8'h00;
68
                Z<=  8'h00;
69
                D<=  8'h00;
70
                E<=  8'h00;
71
                F<=  8'h00;
72
                p<=  8'h00;
73
                q<=  8'h00;
74
                r<=  8'h00;
75
        end
76
        else
77
        begin
78 21 simon111
                if(en)
79 20 simon111
                begin
80 21 simon111
                        cb <= cbo;
81 20 simon111
                        A<=  Ao;
82
                        B<=  Bo;
83
                        X<=  Xo;
84
                        Y<=  Yo;
85
                        Z<=  Zo;
86
                        D<=  Do;
87
                        E<=  Eo;
88
                        F<=  Fo;
89
                        p<=  po;
90
                        q<=  qo;
91
                        r<=  ro;
92
                end
93
        end
94
end
95
 
96
 
97
stream_8bytes b(
98
                        .init(init)
99
                       ,.sb(sb)
100
                       ,.Ai((init)?Ainit:A)
101
                       ,.Bi((init)?Binit:B)
102
                       ,.Di((init)?4'b0 :D)
103
                       ,.Ei((init)?4'b0 :E)
104
                       ,.Fi((init)?4'b0 :F)
105
                       ,.Xi((init)?4'b0 :X)
106
                       ,.Yi((init)?4'b0 :Y)
107
                       ,.Zi((init)?4'b0 :Z)
108
                       ,.pi((init)?1'b0 :p)
109
                       ,.qi((init)?1'b0 :q)
110
                       ,.ri((init)?1'b0 :r)
111
 
112
                       ,.Ao(Ao)
113
                       ,.Bo(Bo)
114
                       ,.Do(Do)
115
                       ,.Eo(Eo)
116
                       ,.Fo(Fo)
117
                       ,.Xo(Xo)
118
                       ,.Yo(Yo)
119
                       ,.Zo(Zo)
120
                       ,.po(po)
121
                       ,.qo(qo)
122
                       ,.ro(ro)
123 21 simon111
                       ,.cb(cbo)
124 20 simon111
                );
125
 
126
endmodule

powered by: WebSVN 2.1.0

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