From 01336260cf2df771cd246c131238ef70b23d3c10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joachim=20Stro=CC=88mbergson?= Date: Wed, 26 Aug 2015 15:53:40 +0200 Subject: Adding test case for verifying reseed functionality in csprng. --- src/tb/tb_csprng.v | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'src') diff --git a/src/tb/tb_csprng.v b/src/tb/tb_csprng.v index 0404b56..7f7823e 100644 --- a/src/tb/tb_csprng.v +++ b/src/tb/tb_csprng.v @@ -353,6 +353,7 @@ module tb_csprng(); tb_seed_data = {8{64'haaaaaaaa55555555}}; tb_seed_syn = 1'b1; + // Start pulling data. tb_cs = 1'b1; tb_we = 1'b0; tb_address = ADDR_RND_DATA; @@ -364,6 +365,46 @@ module tb_csprng(); endtask // tc1_init_csprng + //---------------------------------------------------------------- + // tc2_reseed_csprng() + // + // TC2: Test that the CSPRNG is reseeded as expected. + // We set the max block size to a small value and pull data. + //---------------------------------------------------------------- + task tc2_reseed_csprng(); + begin + tc_ctr = tc_ctr + 1; + + $display("*** TC2: Test reseed of CSPRNG started."); + + tb_seed_data = {8{64'h0102030405060708}}; + tb_seed_syn = 1'b1; + + // Set the max block size to a low value + tb_cs = 1'b1; + tb_we = 1'b1; + tb_address = ADDR_NUM_BLOCKS_HIGH; + tb_write_data = 32'h00000000; + #(CLK_PERIOD); + tb_address = ADDR_NUM_BLOCKS_LOW; + tb_write_data = 32'h00000001; + #(CLK_PERIOD); + tb_cs = 1'b0; + tb_we = 1'b0; + #(CLK_PERIOD); + + // Start pulling data. + tb_cs = 1'b1; + tb_we = 1'b0; + tb_address = ADDR_RND_DATA; + + #(200 * CLK_PERIOD); + + $display("*** TC2 done.."); + end + endtask // tc2_reseed_csprng + + //---------------------------------------------------------------- // csprng_test // @@ -382,6 +423,7 @@ module tb_csprng(); dump_dut_state(); tc1_init_csprng(); + tc2_reseed_csprng(); display_test_results(); -- cgit v1.2.3