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

Subversion Repositories csa

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

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

Line No. Rev Author Line
1 40 simon111
`include "../bench/timescale.v"
2 13 simon111
// this key_schedule module
3 21 simon111
module key_schedule(clk,rst,start,i_ck,busy,done,o_kk);
4
        input             clk;
5
        input             rst;
6
        input             start;
7
        input  [ 8*8-1:0] i_ck;
8
        output            busy;
9
        output            done;
10 13 simon111
        output [56*8-1:0] o_kk;
11
 
12 21 simon111
        reg    [56*8-1:0] o_kk;
13
        reg    [     2:0] cnt;
14 13 simon111
 
15 21 simon111
        wire   [ 8*8-1:0] ik;
16
        wire   [ 8*8-1:0] okd;
17
        wire   [ 8*8-1:0] oki;
18
        reg    [ 8*8-1:0] ok_d;
19
        reg               done;
20
        reg               busy;
21 13 simon111
 
22 21 simon111
        key_perm kpo(.i_key(ok_d), .o_key(okd));
23
        key_perm kpi(.i_key(i_ck), .o_key(oki));
24 13 simon111
 
25 21 simon111
        always @(posedge clk)
26
        begin
27
                done <= 1'h0;
28
                if(rst)
29
                begin
30
                        o_kk <= 448'h0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000;
31
                        cnt  <= 3'h0;
32
                        ok_d <= 64'h0000000000000000;
33
                        busy <= 1'h0;
34
                end
35
                else
36
                begin
37
                        if(cnt==3'h0 && busy)
38
                        begin
39
                                busy <= 1'h0;
40
                                done <= 1'h1;
41
                        end
42 13 simon111
 
43 15 simon111
 
44 21 simon111
                        if(start & ~busy)
45
                        begin
46
                                cnt  <= 3'h5;
47
                                o_kk <= {o_kk [(6*8)*8-1:8*0], i_ck};
48
                                busy <= 1'h1;
49
                                ok_d <= oki;
50
                                o_kk <= {o_kk [(6*8)*8-1:8*0],
51 40 simon111
                                                i_ck ^ 64'h0606060606060606};
52 21 simon111
                        end
53
 
54
                        if(busy)
55
                        begin
56
                                o_kk <= {o_kk [(6*8)*8-1:8*0],
57
                                                ok_d ^ {
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
                                                        5'h00, cnt
66
                                                      }
67
                                         };
68
                                if(cnt!=3'h0)
69
                                        cnt  <= cnt - 3'h1;
70
                                ok_d <= okd;
71
                        end
72
                end
73
        end
74 13 simon111
endmodule

powered by: WebSVN 2.1.0

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