From bfc89244c0e04c4edfc27f4f62a8dbb63f48bd36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joachim=20Stro=CC=88mbergson?= Date: Mon, 7 Sep 2015 10:41:00 +0200 Subject: Adding a new task that reads out a given number of random data words from the DUT. --- src/tb/tb_csprng.v | 53 +++++++++++++++++++++++++++++++++++++---------------- 1 file 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; @@ -356,6 +356,37 @@ module tb_csprng(); end + //---------------------------------------------------------------- + // 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() // @@ -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(); -- cgit v1.2.3