aboutsummaryrefslogtreecommitdiff
path: root/src/tb
diff options
context:
space:
mode:
authorJoachim StroĢˆmbergson <joachim@assured.se>2019-01-17 09:47:37 +0100
committerJoachim StroĢˆmbergson <joachim@assured.se>2019-01-17 09:47:37 +0100
commit4b8d7ab1c473653d79c2d6e5d6409a502df15fb6 (patch)
treea0174abe20f795bc7e26c1ab17737c8556bb1041 /src/tb
parente481321d25be2a469cec2f6ec3b7ef1b0849f0af (diff)
Adding key timeout output port to allow core to inform the top level wrapper that timeout has occured. Added functionality to zeroise API key registers when timout has happened. Updated all auto_zeroise test cases to check that API key registers are properly zeroised.
Diffstat (limited to 'src/tb')
-rw-r--r--src/tb/tb_keywrap.v53
-rw-r--r--src/tb/tb_keywrap_core.v4
2 files changed, 55 insertions, 2 deletions
diff --git a/src/tb/tb_keywrap.v b/src/tb/tb_keywrap.v
index 82a827c..d0800fa 100644
--- a/src/tb/tb_keywrap.v
+++ b/src/tb/tb_keywrap.v
@@ -1236,6 +1236,12 @@ module tb_keywrap();
read_word(ADDR_STATUS);
$display("Status register: 0x%032b", read_data);
+ $display("Contents of the API key registers:");
+ $display("0x%04x 0x%04x 0x%04x 0x%04x",
+ dut.key_reg[0], dut.key_reg[1], dut.key_reg[2], dut.key_reg[3]);
+ $display("0x%04x 0x%04x 0x%04x 0x%04x",
+ dut.key_reg[4], dut.key_reg[5], dut.key_reg[6], dut.key_reg[7]);
+
// Display contents in one of the key expansion registers
$display("Contents in key_mem[2]: 0x%016x",
dut.core.aes.keymem.key_mem[2]);
@@ -1262,6 +1268,12 @@ module tb_keywrap();
$display("Contents in key_mem[2] after timeout: 0x%016x",
dut.core.aes.keymem.key_mem[2]);
+ $display("Contents of the API key registers:");
+ $display("0x%04x 0x%04x 0x%04x 0x%04x",
+ dut.key_reg[0], dut.key_reg[1], dut.key_reg[2], dut.key_reg[3]);
+ $display("0x%04x 0x%04x 0x%04x 0x%04x",
+ dut.key_reg[4], dut.key_reg[5], dut.key_reg[6], dut.key_reg[7]);
+
if (dut.core.aes.keymem.key_mem[2] != 128'h62636363626363636263636362636363)
begin
error_ctr = error_ctr + 1;
@@ -1367,6 +1379,13 @@ module tb_keywrap();
dut.core.key_timeout_ctr_reg);
read_word(ADDR_STATUS);
$display("Status register: 0x%032b", read_data);
+
+ $display("Contents of the API key registers:");
+ $display("0x%04x 0x%04x 0x%04x 0x%04x",
+ dut.key_reg[0], dut.key_reg[1], dut.key_reg[2], dut.key_reg[3]);
+ $display("0x%04x 0x%04x 0x%04x 0x%04x",
+ dut.key_reg[4], dut.key_reg[5], dut.key_reg[6], dut.key_reg[7]);
+
$display("Contents of the key_mem[2]: 0x%016x",
dut.core.aes.keymem.key_mem[2]);
@@ -1392,9 +1411,23 @@ module tb_keywrap();
#(40 * CLK_PERIOD);
read_word(ADDR_STATUS);
$display("Status register: 0x%032b", read_data);
+
+ $display("Contents of the API key registers:");
+ $display("0x%04x 0x%04x 0x%04x 0x%04x",
+ dut.key_reg[0], dut.key_reg[1], dut.key_reg[2], dut.key_reg[3]);
+ $display("0x%04x 0x%04x 0x%04x 0x%04x",
+ dut.key_reg[4], dut.key_reg[5], dut.key_reg[6], dut.key_reg[7]);
+
$display("Contents of the key_mem[2]: 0x%016x",
dut.core.aes.keymem.key_mem[2]);
+ if (dut.core.aes.keymem.key_mem[2] != 128'h62636363626363636263636362636363)
+ begin
+ error_ctr = error_ctr + 1;
+ $display("Error. Contents in key_mem[2]: 0x%016x, expected 0x62636363626363636263636362636363",
+ dut.core.aes.keymem.key_mem[2]);
+ end
+
$display("** TC test_zeroise2 END.\n");
end
endtask // test_zeroise2
@@ -1430,7 +1463,6 @@ module tb_keywrap();
// 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("* Initializing.");
write_word(ADDR_CTRL, 32'h00000001);
#(2 * CLK_PERIOD);
@@ -1441,6 +1473,12 @@ module tb_keywrap();
read_word(ADDR_STATUS);
$display("Status register: 0b%032b", read_data);
+ $display("Contents of the API key registers:");
+ $display("0x%04x 0x%04x 0x%04x 0x%04x",
+ dut.key_reg[0], dut.key_reg[1], dut.key_reg[2], dut.key_reg[3]);
+ $display("0x%04x 0x%04x 0x%04x 0x%04x",
+ dut.key_reg[4], dut.key_reg[5], dut.key_reg[6], dut.key_reg[7]);
+
// Display contents in key expansion register 2.
$display("Contents of the key_mem[2] after init: 0x%016x",
dut.core.aes.keymem.key_mem[2]);
@@ -1457,10 +1495,23 @@ module tb_keywrap();
read_word(ADDR_STATUS);
$display("Status register: 0x%032b", read_data);
+ $display("Contents of the API key registers:");
+ $display("0x%04x 0x%04x 0x%04x 0x%04x",
+ dut.key_reg[0], dut.key_reg[1], dut.key_reg[2], dut.key_reg[3]);
+ $display("0x%04x 0x%04x 0x%04x 0x%04x",
+ dut.key_reg[4], dut.key_reg[5], dut.key_reg[6], dut.key_reg[7]);
+
// Display contents in key expansion register 2.
$display("Contents of the key_mem[2] after zeroisation: 0x%016x",
dut.core.aes.keymem.key_mem[2]);
+ if (dut.core.aes.keymem.key_mem[2] != 128'h62636363626363636263636362636363)
+ begin
+ error_ctr = error_ctr + 1;
+ $display("Error. Contents in key_mem[2]: 0x%016x, expected 0x62636363626363636263636362636363",
+ dut.core.aes.keymem.key_mem[2]);
+ end
+
$display("** TC test_zerois3 END.\n");
end
endtask // test_zeroise3
diff --git a/src/tb/tb_keywrap_core.v b/src/tb/tb_keywrap_core.v
index 7f9c42d..6ec76be 100644
--- a/src/tb/tb_keywrap_core.v
+++ b/src/tb/tb_keywrap_core.v
@@ -71,6 +71,7 @@ module tb_keywrap_core();
reg [31 : 0] tb_timeout;
reg tb_ping;
reg tb_zeroise;
+ wire tb_dut_timeout;
reg [(RLEN_BITS - 1) : 0] tb_rlen;
reg [255 : 0] tb_key;
reg tb_keylen;
@@ -98,9 +99,10 @@ module tb_keywrap_core();
.valid(tb_valid),
.loaded(tb_loaded),
- .timeout(tb_timeout),
+ .timeout_delay(tb_timeout),
.ping(tb_ping),
.zeroise(tb_zeroise),
+ .timeout(tb_dut_timeout),
.rlen(tb_rlen),
.key(tb_key),