aboutsummaryrefslogtreecommitdiff
path: root/src/tb
diff options
context:
space:
mode:
authorJoachim StroĢˆmbergson <joachim@secworks.se>2015-09-07 10:41:00 +0200
committerJoachim StroĢˆmbergson <joachim@secworks.se>2015-09-07 10:41:00 +0200
commitbfc89244c0e04c4edfc27f4f62a8dbb63f48bd36 (patch)
tree77a60140e3b6c183612b3bb2703f1fca428b16c4 /src/tb
parent7167afd469c16d15e9a89db4aa767ff10ea060a5 (diff)
Adding a new task that reads out a given number of random data words from the DUT.
Diffstat (limited to 'src/tb')
-rw-r--r--src/tb/tb_csprng.v53
1 files changed, 37 insertions, 16 deletions
diff --git a/src/tb/tb_csprng.v b/src/tb/tb_csprng.v
index b9ec4f9..a1ddfbd 100644
--- a/src/tb/tb_csprng.v
+++ b/src/tb/tb_csprng.v
@@ -50,7 +50,7 @@ module tb_csprng();
//----------------------------------------------------------------
// Internal constant and parameter definitions.
//----------------------------------------------------------------
- parameter DEBUG = 1;
+ parameter DEBUG = 0;
parameter CLK_HALF_PERIOD = 1;
parameter CLK_PERIOD = 2 * CLK_HALF_PERIOD;
@@ -357,6 +357,37 @@ module tb_csprng();
//----------------------------------------------------------------
+ // read_rng_data()
+ //
+ // Support task that reads a given number of data words
+ // from the DUT via the API.
+ //----------------------------------------------------------------
+ task read_rng_data(input [31 : 0] num_words);
+ reg [31 : 0] i;
+ begin
+ i = 32'h00000000;
+
+ $display("*** Trying to read 0x%08x RNG data words", num_words);
+ while (i < num_words)
+ begin
+ tb_cs = 1'b1;
+ tb_we = 1'b0;
+ tb_address = ADDR_RND_DATA;
+ i = i + 1;
+
+ #CLK_PERIOD;
+
+ if (DEBUG)
+ $display("*** RNG data word 0x%08x: 0x%08x", i, tb_read_data);
+ end
+
+ tb_cs = 1'b0;
+ $display("*** Reading of RNG data words completed.");
+ end
+ endtask // read_rng_data
+
+
+ //----------------------------------------------------------------
// tc1_init_csprng()
//
// TC1: Test that the DUT automatically starts initialize when
@@ -373,11 +404,7 @@ module tb_csprng();
tb_seed_syn = 1'b1;
// Start pulling data.
- tb_cs = 1'b1;
- tb_we = 1'b0;
- tb_address = ADDR_RND_DATA;
-
- #(200 * CLK_PERIOD);
+ read_rng_data(32'h100);
$display("*** TC1: Test automatic init of csprng done.");
end
@@ -399,16 +426,11 @@ module tb_csprng();
tb_seed_data = {8{64'h0102030405060708}};
tb_seed_syn = 1'b1;
- // Set the max block size to a low value
+ // Set the max number of blocks to a low value
write_word(ADDR_NUM_BLOCKS_HIGH, 32'h00000000);
- write_word(ADDR_NUM_BLOCKS_LOW, 32'h00000001);
-
- // Start pulling data.
- tb_cs = 1'b1;
- tb_we = 1'b0;
- tb_address = ADDR_RND_DATA;
+ write_word(ADDR_NUM_BLOCKS_LOW, 32'h00000007);
- #(200 * CLK_PERIOD);
+ read_rng_data(32'h10000);
$display("*** TC2 done..");
end
@@ -432,8 +454,7 @@ module tb_csprng();
reset_dut();
dump_dut_state();
- test_gen_data();
- tc1_init_csprng();
+// tc1_init_csprng();
tc2_reseed_csprng();
display_test_results();