aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJoachim StroĢˆmbergson <joachim@secworks.se>2018-11-22 15:37:26 +0100
committerJoachim StroĢˆmbergson <joachim@secworks.se>2018-11-22 15:37:26 +0100
commit33a7ad0aa4f30582d0858ca31a442316fe075396 (patch)
tree6e8e68254f3b12530257354bab21bbc3e885848b /src
parent038eb4f4f4e5ca2cf6ad80e02091df0a34e6bde3 (diff)
Adding outputs to observe dut API. Adding support in Makefile for using the vendor supplied memory model.
Diffstat (limited to 'src')
-rw-r--r--src/tb/tb_keywrap_mkmif.v44
1 files changed, 37 insertions, 7 deletions
diff --git a/src/tb/tb_keywrap_mkmif.v b/src/tb/tb_keywrap_mkmif.v
index e917c2c..faef1df 100644
--- a/src/tb/tb_keywrap_mkmif.v
+++ b/src/tb/tb_keywrap_mkmif.v
@@ -37,7 +37,10 @@
//
//======================================================================
-module tb_keywrap_mkm();
+// We need this since the specific memory module sets timescale.
+`timescale 1ns/10ps
+
+module tb_keywrap_mkmif();
//----------------------------------------------------------------
// Parameters.
@@ -56,12 +59,13 @@ module tb_keywrap_mkm();
integer tc_ctr;
integer show_spi;
+ integer show_dut_state;
reg tb_clk;
reg tb_reset_n;
wire tb_mkm_spi_sclk;
wire tb_mkm_spi_cs_n;
- reg tb_mkm_spi_do;
+ wire tb_mkm_spi_do;
wire tb_mkm_spi_di;
reg tb_init;
reg tb_read;
@@ -73,6 +77,8 @@ module tb_keywrap_mkm();
reg [255 : 0] tb_wr_key;
wire [255 : 0] tb_rd_key;
+ wire mem_hold_n = 1'b1;
+
//----------------------------------------------------------------
// Device Under Test.
@@ -100,6 +106,18 @@ module tb_keywrap_mkm();
//----------------------------------------------------------------
+ // Memory model. See README.md in src/tech for info on how
+ // to get the vendor specific model needed here.
+ //----------------------------------------------------------------
+ M23K640 memory(.SI(tb_mkm_spi_di),
+ .SO(tb_mkm_spi_do),
+ .SCK(tb_mkm_spi_sclk),
+ .CS_N(tb_mkm_spi_cs_n),
+ .HOLD_N(mem_hold_n),
+ .RESET(tb_reset_n));
+
+
+ //----------------------------------------------------------------
// clk_gen
//
// Always running clock generator process.
@@ -120,11 +138,21 @@ module tb_keywrap_mkm();
always
begin : sys_monitor
cycle_ctr = cycle_ctr + 1;
+ $display("cycle: %08d", cycle_ctr);
+
+ if (show_dut_state)
+ begin
+ $display("init: 0x%01x read: 0x%01x write: 0x%01x key_status: 0x%01x",
+ dut.init, dut.read, dut.write, dut.key_status);
+ $display("ready: 0x%01x ctrl_state: 0x%02x", dut.ready, dut.keywrap_mkmif_ctrl_reg);
+ end
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);
+ $display();
+ $display();
end
#(CLK_PERIOD);
end
@@ -142,11 +170,11 @@ module tb_keywrap_mkm();
error_ctr = 0;
tc_ctr = 0;
- show_spi = 0;
+ show_spi = 0;
+ show_dut_state = 1;
tb_clk = 1'h0;
tb_reset_n = 1'h1;
- tb_mkm_spi_do = 1'h0;
tb_init = 1'h0;
tb_read = 1'h0;
tb_write = 1'h0;
@@ -166,10 +194,11 @@ module tb_keywrap_mkm();
//----------------------------------------------------------------
task reset_dut;
begin
- $display("TB: Resetting dut.");
+ $display("Asserting reset.");
tb_reset_n = 0;
#(2 * CLK_PERIOD);
tb_reset_n = 1;
+ $display("Deasserting reset.");
end
endtask // reset_dut
@@ -183,6 +212,7 @@ module tb_keywrap_mkm();
$display("TEST AUTO-LOAD START");
$display("Check that key and key status is read automatically after reset.");
+ $display();
// Observe SPI for a number of cycles. Reset the DUT during observation.
show_spi = 1;
@@ -245,8 +275,8 @@ module tb_keywrap_mkm();
$finish;
end // main
-endmodule // tb_keywrap_mkm
+endmodule // tb_keywrap_mkmif
//======================================================================
-// EOF tb_keywrap_mkm.v
+// EOF tb_keywrap_mkmif.v
//======================================================================