diff options
author | Joachim StroĢmbergson <joachim@secworks.se> | 2015-07-18 15:14:51 +0200 |
---|---|---|
committer | Joachim StroĢmbergson <joachim@secworks.se> | 2015-07-18 15:14:51 +0200 |
commit | 87e603dd294d43fb7335c1a139363552134a4886 (patch) | |
tree | 10d7d93a6cb8f41551bf2dfcb10c88c96e02fc45 /src/tb | |
parent | 6cf691bbf5fdfa5b93e60addf75111e51b9abf4e (diff) |
Adding initial version of test case for state restore functionality.
Diffstat (limited to 'src/tb')
-rw-r--r-- | src/tb/tb_sha512.v | 67 |
1 files changed, 66 insertions, 1 deletions
diff --git a/src/tb/tb_sha512.v b/src/tb/tb_sha512.v index c993cfc..a3409f5 100644 --- a/src/tb/tb_sha512.v +++ b/src/tb/tb_sha512.v @@ -662,6 +662,68 @@ module tb_sha512(); //---------------------------------------------------------------- + // state_restore_test() + // + // Perform test of state restore followed by block processing. + //---------------------------------------------------------------- + task state_restore_test(input [7 : 0] tc_number, + input [1 : 0] mode, + input [511 : 0] state, + input [1023 : 0] block, + input [511 : 0] expected + ); + reg [511 : 0] mask; + reg [511 : 0] masked_data; + begin + $display("*** TC%01d - State restore test started.", tc_ctr); + + // Write state. + write_word(ADDR_DIGEST0, state[511 : 480]); + write_word(ADDR_DIGEST0, state[479 : 448]); + write_word(ADDR_DIGEST0, state[447 : 416]); + write_word(ADDR_DIGEST0, state[415 : 384]); + write_word(ADDR_DIGEST0, state[383 : 352]); + write_word(ADDR_DIGEST0, state[351 : 320]); + write_word(ADDR_DIGEST0, state[319 : 288]); + write_word(ADDR_DIGEST0, state[287 : 256]); + write_word(ADDR_DIGEST0, state[255 : 224]); + write_word(ADDR_DIGEST0, state[223 : 192]); + write_word(ADDR_DIGEST0, state[191 : 160]); + write_word(ADDR_DIGEST0, state[159 : 128]); + write_word(ADDR_DIGEST0, state[127 : 096]); + write_word(ADDR_DIGEST0, state[095 : 064]); + write_word(ADDR_DIGEST0, state[063 : 032]); + write_word(ADDR_DIGEST0, state[031 : 000]); + + // Final block + write_block(block); + write_word(ADDR_CTRL, {28'h0000000, mode, CTRL_NEXT_VALUE}); + #(CLK_PERIOD); + wait_ready(); + read_digest(); + + mask = get_mask(mode); + masked_data = digest_data & mask; + + if (masked_data == expected) + begin + $display("TC%01d final block: OK.", tc_ctr); + end + else + begin + $display("TC%01d: ERROR in final digest", tc_ctr); + $display("TC%01d: Expected: 0x%0128x", tc_ctr, expected); + $display("TC%01d: Got: 0x%0128x", tc_ctr, masked_data); + error_ctr = error_ctr + 1; + end + + $display("*** TC%01d - Double block test done.", tc_ctr); + tc_ctr = tc_ctr + 1; + end + endtask // state_restore_test + + + //---------------------------------------------------------------- // work_factor_test() // // Perform test of the work factor function. @@ -782,7 +844,10 @@ module tb_sha512(); double_block_test(8'h08, MODE_SHA_384, double_block_one, double_block_two, tc11_expected, tc12_expected); // Work factor test. - work_factor_test(); +// work_factor_test(); + + // State restore test. + state_restore_test(8'h09, MODE_SHA_512, tc5_expected, double_block_two, tc6_expected); dump_dut_state(); |