[Cryptech-Commits] [core/util/keywrap] 25/37: Adding outputs to observe dut API. Adding support in Makefile for using the vendor supplied memory model.

git at cryptech.is git at cryptech.is
Wed Apr 29 16:52:01 UTC 2020


This is an automated email from the git hooks/post-receive script.

paul at psgd.org pushed a commit to branch master
in repository core/util/keywrap.

commit 33a7ad0aa4f30582d0858ca31a442316fe075396
Author: Joachim Strömbergson <joachim at secworks.se>
AuthorDate: Thu Nov 22 15:37:26 2018 +0100

    Adding outputs to observe dut API. Adding support in Makefile for using the vendor supplied memory model.
---
 src/tb/tb_keywrap_mkmif.v | 44 +++++++++++++++++++++++++++++++++++++-------
 1 file 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.
@@ -99,6 +105,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
   //
@@ -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
 //======================================================================



More information about the Commits mailing list