From 0165294513694ed208c44231992bf5e7f1676246 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joachim=20Stro=CC=88mbergson?= Date: Fri, 17 Jul 2015 08:55:43 +0200 Subject: Fixed state restore testcase in core testbench. Fixed the double block test case to really test the core. Added data valid task. --- src/tb/tb_sha256_core.v | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/tb/tb_sha256_core.v b/src/tb/tb_sha256_core.v index 5527bf5..1b1c6ed 100644 --- a/src/tb/tb_sha256_core.v +++ b/src/tb/tb_sha256_core.v @@ -295,6 +295,25 @@ module tb_sha256_core(); endtask // wait_ready + //---------------------------------------------------------------- + // wait_data_valid() + // + // Wait for the data valid in th dut to be set. + // + // Note: It is the callers responsibility to call the function + // when the dut is actively processing and will in fact at some + // point set the flag. + //---------------------------------------------------------------- + task wait_data_valid(); + begin + while (!tb_digest_valid) + begin + #(CLK_PERIOD); + end + end + endtask // wait_data_valid + + //---------------------------------------------------------------- // single_block_test() // @@ -310,9 +329,9 @@ module tb_sha256_core(); tb_block = block; tb_init = 1; #(CLK_PERIOD); + tb_init = 0; wait_ready(); - if (tb_digest == expected) begin $display("*** TC %0d successful.", tc_number); @@ -354,15 +373,20 @@ module tb_sha256_core(); tb_block = block1; tb_init = 1; #(CLK_PERIOD); + tb_init = 0; wait_ready(); + db_digest1 = tb_digest; $display("*** TC %0d first block done.", tc_number); $display("*** TC %0d second block started.", tc_number); tb_block = block2; + dump_dut_state(); tb_next = 1; #(CLK_PERIOD); + tb_next = 0; wait_ready(); + $display("*** TC %0d second block done.", tc_number); if (db_digest1 == expected1) @@ -379,7 +403,7 @@ module tb_sha256_core(); db_error = 1; end - if (db_digest1 == expected1) + if (tb_digest == expected2) begin $display("*** TC %0d second block successful", tc_number); $display(""); @@ -413,7 +437,6 @@ module tb_sha256_core(); input [511 : 0] block, input [255 : 0] expected); - reg [255 : 0] db_digest1; reg db_error; begin $display("*** TC %0d state restore block test case started.", tc_number); @@ -463,16 +486,16 @@ module tb_sha256_core(); tb_state7_we = 0; #(CLK_PERIOD); - dump_H_state(); $display("*** TC %0d block started.", tc_number); tb_block = block; tb_next = 1; #(CLK_PERIOD); + tb_next = 0; wait_ready(); $display("*** TC %0d block done.", tc_number); - if (db_digest1 == expected) + if (tb_digest == expected) begin $display("*** TC %0d block successful", tc_number); $display(""); -- cgit v1.2.3