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

Subversion Repositories csa

[/] [csa/] [trunk/] [rtl/] [group_decrypt.v] - Diff between revs 44 and 49

Show entire file | Details | Blame | View Log

Rev 44 Rev 49
Line 1... Line 1...
`include "../bench/timescale.v"
`include "../bench/timescale.v"
// this moduel do a decrypt group
// this moduel do a decrypt group
 
 
module group_decrypt(
module group_decrypt(
                          input                    clk
                          input                    clk          // clk 
                        , input                    rst
                        , input                    rst          // rst, high active
                        , input                    en
                        , input                    en           // input enable
                        , input                    dec
                        , input                    init         // the first packet
                        , input                    init
                        , input                    last         // the last packet
                        , input         [ 8*8-1:0] ck
                        , input         [ 8*8-1:0] ck           // ck 
                        , input         [56*8-1:0] kk
                        , input         [56*8-1:0] kk           // kk 
                        , input         [ 8*8-1:0] group
                        , input         [ 8*8-1:0] group        // packet
                        , input         [   4-1:0] bytes
                        , output                   valid        // output vaild
 
                        , output        [ 8*8-1:0] ogroup       // output packet
                        , output                   valid
 
                        , output        [ 8*8-1:0] ogroup
 
                        , output        [   4-1:0] obytes
 
                );
                );
 
 
        reg init_d;
 
        wire [8*8-1:0] stream;
        wire [8*8-1:0] stream;
        wire [8*8-1:0] ib;
        wire [8*8-1:0] block;
        reg  [8*8-1:0] bco_d;
        reg  [8*8-1:0] block_d;
        wire  [8*8-1:0] bco;
        reg  [8*8-1:0] init_d;
        reg en_d;
        reg  [8*8-1:0] last_d;
 
        reg  [8*8-1:0] last_dd;
        always @(posedge clk)
        reg  [8*8-1:0] en_d;
                en_d<=en;
        reg  [8*8-1:0] en_dd;
 
 
        always @(posedge clk)
 
                init_d<=init;
 
 
 
        always @(posedge clk)
        reg            busy;
                if(en_d)
        wire [8*8-1:0] ib;
                        bco_d<=bco;
 
 
 
        assign ib=(init_d)?group:group^stream;
 
 
 
        stream_cypher stream_cypher(
        stream_cypher stream_cypher(
                            .clk   (clk)
                            .clk   (clk)
                          , .rst   (rst)
                          , .rst   (rst)
                          , .en    (en)
                          , .en    (en)
Line 47... Line 36...
                          );
                          );
 
 
        block_decypher block_decypher(
        block_decypher block_decypher(
                                  .kk (kk)
                                  .kk (kk)
                                , .ib (ib)
                                , .ib (ib)
                                , .bd (bco)
                         , .bd (block)
                                );
                                );
 
 
        assign ogroup=group^bco_d^stream;
 
 
 
        assign valid=en_d & ~init_d;
        always @(posedge clk)
        assign obytes=4'h8;
                if(en_d)
 
                        block_d<=block;
 
 
 
        always @(posedge clk)
 
                if(en)
 
                        init_d<=init;
 
 
 
        always @(posedge clk)
 
                        last_dd<=last_d;
 
 
 
        always @(posedge clk)
 
                if(en)
 
                        last_d<=last;
 
 
 
        always @(posedge clk)
 
                        en_d<=en;
 
 
 
        always @(posedge clk)
 
                        en_dd<=en_d;
 
 
 
        assign ogroup=(en_dd&last_dd)?block_d:ib^block_d;
 
 
 
        assign valid=((busy)&en) | (en_dd&last_dd);
 
 
 
        assign ib=(init)?group:group^stream;
 
 
 
        always @(posedge clk )
 
                if(rst)
 
                        busy<=1'h0;
 
                else
 
                begin
 
                        if(init_d)
 
                                busy<=1'h1;
 
                        if(last_d)
 
                                busy<=1'h0;
 
                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.