aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJoachim StroĢˆmbergson <joachim@secworks.se>2018-11-06 14:16:01 +0100
committerJoachim StroĢˆmbergson <joachim@secworks.se>2018-11-06 14:16:01 +0100
commit74efb3cd734209511d50b43cf22b8dd77364bc24 (patch)
treed1f3bab949c71f966ac980ac620b42288d7e613b /src
parent9c66245ee6304146b107e1dd13b9b125e7609142 (diff)
Adding test case to observe auto-load of key and status after reset.
Diffstat (limited to 'src')
-rw-r--r--src/tb/tb_keywrap_mkmif.v49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/tb/tb_keywrap_mkmif.v b/src/tb/tb_keywrap_mkmif.v
index 8d42c6d..8bd3a05 100644
--- a/src/tb/tb_keywrap_mkmif.v
+++ b/src/tb/tb_keywrap_mkmif.v
@@ -55,6 +55,8 @@ module tb_keywrap_mkm();
integer error_ctr;
integer tc_ctr;
+ integer show_spi;
+
reg tb_clk;
reg tb_reset_n;
wire tb_mkm_spi_sclk;
@@ -119,6 +121,11 @@ module tb_keywrap_mkm();
begin : sys_monitor
cycle_ctr = cycle_ctr + 1;
+ if (show_spi)
+ begin
+ $display("spi_clk: 0x%01x, spi_cs_n: 0x%01x, spi_do: 0x%01x, spi_di: 0x%01x",
+ tb_mkm_spi_sclk, tb_mkm_spi_cs_n, tb_mkm_spi_do, tb_mkm_spi_di);
+ end
#(CLK_PERIOD);
end
@@ -135,6 +142,8 @@ module tb_keywrap_mkm();
error_ctr = 0;
tc_ctr = 0;
+ show_spi = 0;
+
tb_clk = 1'h0;
tb_reset_n = 1'h1;
tb_mkm_spi_do = 1'h0;
@@ -151,6 +160,45 @@ module tb_keywrap_mkm();
//----------------------------------------------------------------
+ // reset_dut()
+ //
+ // Toggle reset to put the DUT into a well known state.
+ //----------------------------------------------------------------
+ task reset_dut;
+ begin
+ $display("TB: Resetting dut.");
+ tb_reset_n = 0;
+ #(2 * CLK_PERIOD);
+ tb_reset_n = 1;
+ end
+ endtask // reset_dut
+
+
+ //----------------------------------------------------------------
+ // test_auto_load
+ //----------------------------------------------------------------
+ task test_auto_load;
+ begin
+ tc_ctr = tc_ctr + 1;
+
+ $display("TEST AUTO-LOAD START");
+ $display("Check that correct ICV is generated for a single block message.");
+
+ // Observe SPI for a number of cycles. Reset the DUT during monitoring.
+ show_spi = 1;
+ #(10 * CLK_PERIOD);
+ reset_dut();
+ #(100 * CLK_PERIOD);
+ show_spi = 0;
+
+ $display("TEST AUTO-LOAD END");
+ $display("");
+ end
+ endtask // auto_load
+
+
+
+ //----------------------------------------------------------------
// main
//----------------------------------------------------------------
initial
@@ -160,6 +208,7 @@ module tb_keywrap_mkm();
$display("");
init_sim();
+ test_auto_load();
$display("");
$display("*** Keywrap mkmif wrapper testbench done. ***");