[Cryptech-Commits] [core/util/keywrap] 30/95: Adding more tasks for tb infrastructure.

git at cryptech.is git at cryptech.is
Wed Mar 25 17:18:29 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 79cd68435bdd222a67a6c5ff17649d545e788560
Author: Joachim Strömbergson <joachim at secworks.se>
AuthorDate: Fri Jun 29 14:00:04 2018 +0200

    Adding more tasks for tb infrastructure.
---
 src/tb/tb_keywrap.v | 92 +++++++++++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 85 insertions(+), 7 deletions(-)

diff --git a/src/tb/tb_keywrap.v b/src/tb/tb_keywrap.v
index 29249ed..fee890c 100644
--- a/src/tb/tb_keywrap.v
+++ b/src/tb/tb_keywrap.v
@@ -146,6 +146,7 @@ module tb_keywrap();
       tb_address = address;
       tb_cs = 1;
       tb_we = 0;
+
       #(CLK_PERIOD);
       read_data = tb_read_data;
       tb_cs = 0;
@@ -177,7 +178,8 @@ module tb_keywrap();
       tb_write_data = word;
       tb_cs = 1;
       tb_we = 1;
-      #(2 * CLK_PERIOD);
+
+      #(1 * CLK_PERIOD);
       tb_cs = 0;
       tb_we = 0;
     end
@@ -203,25 +205,101 @@ module tb_keywrap();
   endtask // wait_ready
 
 
+  //----------------------------------------------------------------
+  // dump_dut_state()
+  //
+  // Dump the state of the dump when needed.
+  //----------------------------------------------------------------
+  task dump_dut_state;
+    begin
+      $display("cycle: 0x%016x", cycle_ctr);
+      $display("State of DUT");
+      $display("------------");
+      $display("");
+    end
+  endtask // dump_dut_state
+
+
+  //----------------------------------------------------------------
+  // display_test_results()
+  //
+  // Display the accumulated test results.
+  //----------------------------------------------------------------
+  task display_test_results;
+    begin
+      if (error_ctr == 0)
+        begin
+          $display("*** All %02d test cases completed successfully", tc_ctr);
+        end
+      else
+        begin
+          $display("*** %02d tests completed - %02d test cases did not complete successfully.",
+                   tc_ctr, error_ctr);
+        end
+    end
+  endtask // display_test_results
+
+
   //----------------------------------------------------------------
   // init_sim()
   //
   // Initialize all counters and testbed functionality as well
   // as setting the DUT inputs to defined values.
   //----------------------------------------------------------------
-  initial
+  task init_sim;
     begin
       cycle_ctr     = 0;
+      error_ctr     = 0;
+      tc_ctr        = 0;
+
       tb_clk        = 0;
-      tb_reset_n    = 0;
+      tb_reset_n    = 1;
 
-      #(CLK_PERIOD * 10);
+      tb_cs         = 0;
+      tb_we         = 0;
+      tb_address    = 8'h0;
+      tb_write_data = 32'h0;
+    end
+  endtask // init_sim
 
-      tb_reset_n    = 1;
 
-      #(CLK_PERIOD * 10);
-      $finish;
+  //----------------------------------------------------------------
+  // reset_dut()
+  //
+  // Toggle reset to put the DUT into a well known state.
+  //----------------------------------------------------------------
+  task reset_dut;
+    begin
+      $display("*** Toggling reset.");
+      tb_reset_n = 0;
+
+      #(2 * CLK_PERIOD);
+      tb_reset_n = 1;
+      $display("");
     end
+  endtask // reset_dut
+
+
+  //----------------------------------------------------------------
+  // main
+  //----------------------------------------------------------------
+  initial
+    begin : main
+      $display("   -= Testbench for Keywrap started =-");
+      $display("    ==================================");
+      $display("");
+
+      init_sim();
+      dump_dut_state();
+      reset_dut();
+      dump_dut_state();
+
+      display_test_results();
+
+      $display("");
+      $display("*** Keywrap simulation done. ***");
+      $finish;
+    end // main
 
 endmodule // tb_keywrap
 



More information about the Commits mailing list