aboutsummaryrefslogtreecommitdiff
path: root/src/tb/tb_keywrap.v
diff options
context:
space:
mode:
authorJoachim StroĢˆmbergson <joachim@secworks.se>2018-06-29 14:00:04 +0200
committerJoachim StroĢˆmbergson <joachim@secworks.se>2018-06-29 14:00:04 +0200
commit79cd68435bdd222a67a6c5ff17649d545e788560 (patch)
tree8aa8b9ba2d0ba2ca8f1684bac0c637cd22a81a9c /src/tb/tb_keywrap.v
parent1b987d12d7cc7fa220434f7ca093b23091066e50 (diff)
Adding more tasks for tb infrastructure.
Diffstat (limited to 'src/tb/tb_keywrap.v')
-rw-r--r--src/tb/tb_keywrap.v92
1 files 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
@@ -204,24 +206,100 @@ module tb_keywrap();
//----------------------------------------------------------------
+ // 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