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

Subversion Repositories csa

[/] [csa/] [trunk/] [rtl/] [key_schedule.v] - Diff between revs 40 and 48

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 40 Rev 48
Line 1... Line 1...
`include "../bench/timescale.v"
`include "../bench/timescale.v"
// this key_schedule module
// this key_schedule module
module key_schedule(clk,rst,start,i_ck,busy,done,o_kk);
module key_schedule(clk,rst,start,ck,busy,done,kk);
        input             clk;
        input             clk;        // main clock
        input             rst;
        input             rst;        // reset , high active
        input             start;
        input             start;      // start key 
        input  [ 8*8-1:0] i_ck;
        input  [ 8*8-1:0] ck;
        output            busy;
        output            busy;
        output            done;
        output            done; // one clck width
        output [56*8-1:0] o_kk;
        output [56*8-1:0] kk;
 
 
        reg    [56*8-1:0] o_kk;
        wire   [56*8-1:0] kk;
        reg    [     2:0] cnt;
 
 
 
        wire   [ 8*8-1:0] ik;
 
        wire   [ 8*8-1:0] okd;
 
        wire   [ 8*8-1:0] oki;
 
        reg    [ 8*8-1:0] ok_d;
 
        reg               done;
 
        reg               busy;
        reg               busy;
 
 
        key_perm kpo(.i_key(ok_d), .o_key(okd));
////////////////////////////////////////////////////////////////////////////////
        key_perm kpi(.i_key(i_ck), .o_key(oki));
// internal variable
 
////////////////////////////////////////////////////////////////////////////////
 
        reg   [56*8-1:0] kk_arry;       // the key array
 
        reg   [     2:0] cnt;
 
        wire  [ 8*8-1:0] next_kk;       // the next roundl kk
 
 
 
 
        always @(posedge clk)
        always @(posedge clk)
        begin
 
                done <= 1'h0;
 
                if(rst)
                if(rst)
                begin
 
                        o_kk <= 448'h0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000;
 
                        cnt  <= 3'h0;
                        cnt  <= 3'h0;
                        ok_d <= 64'h0000000000000000;
        else if(start)
                        busy <= 1'h0;
                cnt <= 3'h6;
                end
        else if(cnt!=3'h0)
                else
                cnt <= cnt-3'h1;
                begin
 
                        if(cnt==3'h0 && busy)
 
                        begin
 
                                busy <= 1'h0;
 
                                done <= 1'h1;
 
                        end
 
 
 
 
 
                        if(start & ~busy)
        always @(posedge clk)
                        begin
        if(rst)
                                cnt  <= 3'h5;
                busy=1'h0;
                                o_kk <= {o_kk [(6*8)*8-1:8*0], i_ck};
        else if(start)
                                busy <= 1'h1;
                                busy <= 1'h1;
                                ok_d <= oki;
        else if(cnt==3'h0)
                                o_kk <= {o_kk [(6*8)*8-1:8*0],
                busy<=1'h0;
                                                i_ck ^ 64'h0606060606060606};
 
                        end
        assign done=busy & (cnt==3'h0);
 
 
                        if(busy)
        always @(posedge clk )
                        begin
        if(rst)
                                o_kk <= {o_kk [(6*8)*8-1:8*0],
                kk_arry<=448'h0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000;
                                                ok_d ^ {
        else if(start)
                                                        5'h00, cnt,
                kk_arry<={kk_arry[48*8-1:0],ck};
                                                        5'h00, cnt,
        else if(cnt!=3'h0)
                                                        5'h00, cnt,
                kk_arry<={kk_arry[48*8-1:0],next_kk};
                                                        5'h00, cnt,
 
                                                        5'h00, cnt,
        assign kk=kk_arry ^ {
                                                        5'h00, cnt,
                                64'h0606060606060606,
                                                        5'h00, cnt,
                                64'h0505050505050505,
                                                        5'h00, cnt
                                64'h0404040404040404,
                                                      }
                                64'h0303030303030303,
 
                                64'h0202020202020202,
 
                                64'h0101010101010101,
 
                                64'h0000000000000000
                                         };
                                         };
                                if(cnt!=3'h0)
        //assign busy=cnt!=3'h0;
                                        cnt  <= cnt - 3'h1;
 
                                ok_d <= okd;
        key_perm kpi(.i_key(kk_arry[8*8-1:0]), .o_key(next_kk));
                        end
 
                end
 
        end
 
endmodule
endmodule
 
 
 No newline at end of file
 No newline at end of file

powered by: WebSVN 2.1.0

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