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

Subversion Repositories csa

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

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 48 simon111
module key_schedule(clk,rst,start,ck,busy,done,kk);
4
        input             clk;        // main clock
5
        input             rst;        // reset , high active
6
        input             start;      // start key 
7
        input  [ 8*8-1:0] ck;
8 21 simon111
        output            busy;
9 48 simon111
        output            done; // one clck width
10
        output [56*8-1:0] kk;
11 13 simon111
 
12 48 simon111
        wire   [56*8-1:0] kk;
13 21 simon111
        reg               busy;
14 13 simon111
 
15 48 simon111
////////////////////////////////////////////////////////////////////////////////
16
// internal variable
17
////////////////////////////////////////////////////////////////////////////////
18
        reg   [56*8-1:0] kk_arry;       // the key array
19
        reg   [     2:0] cnt;
20
        wire  [ 8*8-1:0] next_kk;       // the next roundl kk
21 13 simon111
 
22 48 simon111
 
23
        always @(posedge clk )
24
        if(rst)
25
                cnt<=3'h0;
26
        else if(start)
27
                cnt <= 3'h6;
28
        else if(cnt!=3'h0)
29
                cnt <= cnt-3'h1;
30
 
31
 
32 21 simon111
        always @(posedge clk)
33 48 simon111
        if(rst)
34
                busy=1'h0;
35
        else if(start)
36
                busy<=1'h1;
37
        else if(cnt==3'h0)
38
                busy<=1'h0;
39 13 simon111
 
40 48 simon111
        assign done=busy & (cnt==3'h0);
41 15 simon111
 
42 48 simon111
        always @(posedge clk )
43
        if(rst)
44
                kk_arry<=448'h0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000;
45
        else if(start)
46
                kk_arry<={kk_arry[48*8-1:0],ck};
47
        else if(cnt!=3'h0)
48
                kk_arry<={kk_arry[48*8-1:0],next_kk};
49 21 simon111
 
50 48 simon111
        assign kk=kk_arry ^ {
51
                                64'h0606060606060606,
52
                                64'h0505050505050505,
53
                                64'h0404040404040404,
54
                                64'h0303030303030303,
55
                                64'h0202020202020202,
56
                                64'h0101010101010101,
57
                                64'h0000000000000000
58
                                };
59
        //assign busy=cnt!=3'h0;
60
 
61
        key_perm kpi(.i_key(kk_arry[8*8-1:0]), .o_key(next_kk));
62
 
63 13 simon111
endmodule

powered by: WebSVN 2.1.0

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