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

Subversion Repositories csa

[/] [csa/] [trunk/] [rtl/] [key_schedule.v] - Blame information for rev 32

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

Line No. Rev Author Line
1 13 simon111
// this key_schedule module
2 21 simon111
module key_schedule(clk,rst,start,i_ck,busy,done,o_kk);
3
        input             clk;
4
        input             rst;
5
        input             start;
6
        input  [ 8*8-1:0] i_ck;
7
        output            busy;
8
        output            done;
9 13 simon111
        output [56*8-1:0] o_kk;
10
 
11 21 simon111
        reg    [56*8-1:0] o_kk;
12
        reg    [     2:0] cnt;
13 13 simon111
 
14 21 simon111
        wire   [ 8*8-1:0] ik;
15
        wire   [ 8*8-1:0] okd;
16
        wire   [ 8*8-1:0] oki;
17
        reg    [ 8*8-1:0] ok_d;
18
        reg               done;
19
        reg               busy;
20 13 simon111
 
21 21 simon111
        key_perm kpo(.i_key(ok_d), .o_key(okd));
22
        key_perm kpi(.i_key(i_ck), .o_key(oki));
23 13 simon111
 
24 21 simon111
        always @(posedge clk)
25
        begin
26
                done <= 1'h0;
27
                if(rst)
28
                begin
29
                        o_kk <= 448'h0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000;
30
                        cnt  <= 3'h0;
31
                        ok_d <= 64'h0000000000000000;
32
                        busy <= 1'h0;
33
                end
34
                else
35
                begin
36
                        if(cnt==3'h0 && busy)
37
                        begin
38
                                busy <= 1'h0;
39
                                done <= 1'h1;
40
                        end
41 13 simon111
 
42 15 simon111
 
43 21 simon111
                        if(start & ~busy)
44
                        begin
45
                                cnt  <= 3'h5;
46
                                o_kk <= {o_kk [(6*8)*8-1:8*0], i_ck};
47
                                busy <= 1'h1;
48
                                ok_d <= oki;
49
                                o_kk <= {o_kk [(6*8)*8-1:8*0],
50
                                                oki ^ 64'h0606060606060606};
51
                        end
52
 
53
                        if(busy)
54
                        begin
55
                                o_kk <= {o_kk [(6*8)*8-1:8*0],
56
                                                ok_d ^ {
57
                                                        5'h00, cnt,
58
                                                        5'h00, cnt,
59
                                                        5'h00, cnt,
60
                                                        5'h00, cnt,
61
                                                        5'h00, cnt,
62
                                                        5'h00, cnt,
63
                                                        5'h00, cnt,
64
                                                        5'h00, cnt
65
                                                      }
66
                                         };
67
                                if(cnt!=3'h0)
68
                                        cnt  <= cnt - 3'h1;
69
                                ok_d <= okd;
70
                        end
71
                end
72
        end
73
 
74
 
75
//        wire   [64*8-1:0] kb;
76
//        assign kb[(8*8)*8-1:(7*8)*8] = i_ck;
77
//
78
//        key_perm k1( .i_key(kb[(8*8)*8-1:(7*8)*8]) ,.o_key(kb[(7*8)*8-1:(6*8)*8]));
79
//        key_perm k2( .i_key(kb[(7*8)*8-1:(6*8)*8]) ,.o_key(kb[(6*8)*8-1:(5*8)*8]));
80
//        key_perm k3( .i_key(kb[(6*8)*8-1:(5*8)*8]) ,.o_key(kb[(5*8)*8-1:(4*8)*8]));
81
//        key_perm k4( .i_key(kb[(5*8)*8-1:(4*8)*8]) ,.o_key(kb[(4*8)*8-1:(3*8)*8]));
82
//        key_perm k5( .i_key(kb[(4*8)*8-1:(3*8)*8]) ,.o_key(kb[(3*8)*8-1:(2*8)*8]));
83
//        key_perm k6( .i_key(kb[(3*8)*8-1:(2*8)*8]) ,.o_key(kb[(2*8)*8-1:(1*8)*8]));
84
//        key_perm k7( .i_key(kb[(2*8)*8-1:(1*8)*8]) ,.o_key(kb[(1*8)*8-1:(0*8)*8]));
85
//
86
//        assign o_kk [(1*8)*8-1:(0*8)*8] = kb[(2*8)*8-1:(1*8)*8] ^ 64'h0000000000000000;
87
//        assign o_kk [(2*8)*8-1:(1*8)*8] = kb[(3*8)*8-1:(2*8)*8] ^ 64'h0101010101010101;
88
//        assign o_kk [(3*8)*8-1:(2*8)*8] = kb[(4*8)*8-1:(3*8)*8] ^ 64'h0202020202020202;
89
//        assign o_kk [(4*8)*8-1:(3*8)*8] = kb[(5*8)*8-1:(4*8)*8] ^ 64'h0303030303030303;
90
//        assign o_kk [(5*8)*8-1:(4*8)*8] = kb[(6*8)*8-1:(5*8)*8] ^ 64'h0404040404040404;
91
//        assign o_kk [(6*8)*8-1:(5*8)*8] = kb[(7*8)*8-1:(6*8)*8] ^ 64'h0505050505050505;
92
//        assign o_kk [(7*8)*8-1:(6*8)*8] = kb[(8*8)*8-1:(7*8)*8] ^ 64'h0606060606060606;
93
 
94
 
95 13 simon111
endmodule

powered by: WebSVN 2.1.0

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