diff options
-rw-r--r-- | src/tb/tb_keywrap.v | 92 |
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 |