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

Subversion Repositories csa

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

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

powered by: WebSVN 2.1.0

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