aes_128加解密测试代码。

`timescale 1ns/1ns

module aes_top_tb();
reg             clk,rst_n;
reg             decrypt,start;
reg  [127:0]    din;
reg  [127:0]    key;
wire            ready;
wire [127:0]    dout;
parameter   CLOCK=16;

aes_top u_aes_top(
	.clk        (clk        ) , 
    .rst_n      (rst_n      ) ,
    .start_i    (start      ) ,
    .decrypt    (decrypt    ) ,
	.data_in    (din        ) ,
    .key_in     (key        ) ,
	.data_o     (dout       ) ,
    .ready_o    (ready      )  
);



initial begin
    clk = 0 ;
end
always  begin
    #(CLOCK/2)      clk = ~clk ;
end
//明文
//0000000000000000000000000000010F
//0E0D0C0B0A0908070605040302017412 


//密文
//5cfd2de13cefc05a6a4df19c4e830527
//ce3eb4552d43849f75004a9c7a143949
initial begin
        rst_n = 0 ;
        start = 0 ;
        decrypt = 0 ;
    #(CLOCK*5);
        rst_n = 1 ;
        decrypt = 0 ;
    #(CLOCK*10);
        din = 128'h0E0D0C0B0A0908070605040302017412; 
        key = 128'h10a58869d74be5a374cf867cfb473859;
    #(CLOCK );
        start = 1;
    #(CLOCK );
        start = 0;
    #(CLOCK*1200 );
        decrypt = 1 ;
        din = 128'hce3eb4552d43849f75004a9c7a143949;
        key = 128'h10a58869d74be5a374cf867cfb473859;
    #(CLOCK );
        start = 1;
    #(CLOCK );
        start = 0;
    #(CLOCK*1200);
    //
    #(CLOCK*5);
        decrypt = 0 ;
    #(CLOCK*10);
        din = 128'h0000000000000000000000000000010F;
        key = 128'h10a58869d74be5a374cf867cfb473859;
    #(CLOCK );
        start = 1;
    #(CLOCK );
        start = 0;
    #(CLOCK*1200 );
        decrypt = 1 ;
        din = 128'h5cfd2de13cefc05a6a4df19c4e830527;
        key = 128'h10a58869d74be5a374cf867cfb473859;
    #(CLOCK );
        start = 1;
    #(CLOCK );
        start = 0;
    #(CLOCK*1200);
        $stop;
end

endmodule

/*
d55e84a7432520bcc02483881d158800 
24754066967ba41b8301a334dd310b88 
3bb7253eb20ee47d157a072f5e30a8bc 
6dcef98d89b9c143a774e3524b4aaf93 
9fe78143e47738ce2ecd2211ec3e4cc1
b278f1667b90b98dcaba1adfc2f36ed0 
99ea8756c9e848ebb12aa3520849740f 
6ae4cb005002cfbd78c2ebb9b963d75d 
5c0fa2783ae604bd28c02404c1a13ce4 
b1a2436666e9a6c5122620b9e96118e0
10a58869d74be5a374cf867cfb473859 

*/


你可能感兴趣的:(fpga)