diff options
author | Joachim StroĢmbergson <joachim@secworks.se> | 2018-09-11 12:37:28 +0200 |
---|---|---|
committer | Joachim StroĢmbergson <joachim@secworks.se> | 2018-09-11 12:37:28 +0200 |
commit | 6cfcc1ec5bc0e2c944ec66bd62d58740d2b8823d (patch) | |
tree | ab5e4297fae849a154b51aa6840a22c44ff0ca29 /src/tb | |
parent | 1d9543b47f1d0cfccb726ba60217c42a1ca6e377 (diff) |
Adding a huge, self testing test case.
Diffstat (limited to 'src/tb')
-rw-r--r-- | src/tb/tb_keywrap.v | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/src/tb/tb_keywrap.v b/src/tb/tb_keywrap.v index 59409e9..4d1c25c 100644 --- a/src/tb/tb_keywrap.v +++ b/src/tb/tb_keywrap.v @@ -1055,6 +1055,94 @@ module tb_keywrap(); endtask // test_kwp_ad_128_2 + + //---------------------------------------------------------------- + // test_big_wrap_256 + // Implements wrap test with a huge (16 kB+) data object + // and 256 bit key. + //---------------------------------------------------------------- + task test_big_wrap_256; + begin : test_big_wrap_256 + integer i; + integer err; + + err = 0; + + tc_ctr = tc_ctr + 1; + + $display("** TC test_big_wrap_256 START."); + + // Write key and keylength, we also want to encrypt/wrap. + write_word(ADDR_KEY0, 32'h55aa55aa); + write_word(ADDR_KEY1, 32'h55aa55aa); + write_word(ADDR_KEY2, 32'h55aa55aa); + write_word(ADDR_KEY3, 32'h55aa55aa); + write_word(ADDR_KEY4, 32'h55aa55aa); + write_word(ADDR_KEY5, 32'h55aa55aa); + write_word(ADDR_KEY6, 32'h55aa55aa); + write_word(ADDR_KEY7, 32'h55aa55aa); + write_word(ADDR_CONFIG, 32'h00000003); + + // Initialize the AES engine (to expand the key). + // Wait for init to complete. + // Note, not actually needed to wait. We can write R data during init. + $display("* Trying to initialize."); + write_word(ADDR_CTRL, 32'h00000001); + #(2 * CLK_PERIOD); + wait_ready(); + $display("* Init should be done."); + + + // Set the length or R in blocks. + // Write the R bank to be written to. + // Write the R blocks to be processed. + write_word(ADDR_RLEN, 32'h000007f8); + + + // Write the data to be wrapped. + for (i = 0 ; i < 4080 ; i = i + 1) + write_word(MEM_BASE + i, 32'h01010101); + + // Write magic words to A. + write_word(ADDR_A0, 32'ha65959a6); + write_word(ADDR_A1, 32'h00003fc0); + + // Start wrapping and wait for wrap to complete. + $display("* Trying to start processing."); + write_word(ADDR_CTRL, 32'h00000002); + #(2 * CLK_PERIOD); + wait_ready(); + $display("* Processing should be done."); + + + // Read and check the A registers. + read_word(ADDR_A0); + if (read_data != 32'h53179eb9) + begin + $display("Error A0 after wrap: 0x%08x, expected 0x53179eb9", read_data); + err = 1; + end + + read_word(ADDR_A1); + if (read_data != 32'ha90ce632) + begin + $display("Error A1 after wrap: 0x%08x, expected 0xa90ce632", read_data); + err = 1; + end + + if (err) + begin + $display("test_big_wrap_256 completed with errors."); + error_ctr = error_ctr + 1; + end + else + $display("test_big_wrap_256 completed successfully."); + + $display("** TC test_big_wrap_256 END.\n"); + end + endtask // test_big_wrap_256 + + //---------------------------------------------------------------- // main //---------------------------------------------------------------- @@ -1081,6 +1169,8 @@ module tb_keywrap(); test_kwp_ae_128_2(); test_kwp_ad_128_2(); + test_big_wrap_256(); + display_test_results(); $display(""); |