Skip to content

Commit

Permalink
[es/dv] Add test_es_health_test_failed task to intr vseq
Browse files Browse the repository at this point in the history
This commit adds the new test_es_health_test_failed task to the intr vseq.
The new version not only checks for the interrupts if the health test fails,
it also checks whether the alert state is entered and no further entropy can
be consumed. Now the task also tests the health test failures in all of the
states that can transition into the alert state.

Signed-off-by: Hakim Filali <[email protected]>
  • Loading branch information
Hakim Filali authored and vogelpi committed Jan 2, 2024
1 parent 316431f commit b0fb96a
Show file tree
Hide file tree
Showing 4 changed files with 280 additions and 18 deletions.
16 changes: 16 additions & 0 deletions hw/ip/entropy_src/dv/env/entropy_src_env_cfg.sv
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ class entropy_src_env_cfg extends cip_base_env_cfg #(.RAL_T(entropy_src_reg_bloc
// RNG data. For other tests (which rely on fixed RNG sequences) we leave handshaking enabled.
bit rng_ignores_backpressure = 0;

// The number of seeds that are consumed via the CSRNG interface or the entopy_data register are
// recorded by the scoreboard.
int total_seeds_consumed = 0;

/////////////////////
// Knobs & Weights //
Expand Down Expand Up @@ -132,16 +135,27 @@ class entropy_src_env_cfg extends cip_base_env_cfg #(.RAL_T(entropy_src_reg_bloc
rand ht_fail_e which_ht_fail;
rand cntr_e which_cntr;
rand which_ht_e which_ht;
rand state_e which_ht_state;

rand uint which_cntr_replicate;

rand uint which_bin;

rand bit induce_targeted_transition;
// Read the entropy over the entropy_data register if this is set.
rand mubi4_t es_route_sw;

/////////////////
// Constraints //
/////////////////
constraint which_ht_state_c {
which_ht_state dist {
BootHTRunning :/ 25,
BootPhaseDone :/ 25,
StartupFail1 :/ 25,
ContHTRunning :/ 25
};
}

constraint otp_en_es_fw_read_c {
`DV_MUBI8_DIST(otp_en_es_fw_read, otp_en_es_fw_read_pct,
Expand Down Expand Up @@ -208,6 +222,8 @@ class entropy_src_env_cfg extends cip_base_env_cfg #(.RAL_T(entropy_src_reg_bloc
1 :/ induce_targeted_transition_pct,
0 :/ (100 - induce_targeted_transition_pct) };}

constraint es_route_sw_c {es_route_sw inside {MuBi4False, MuBi4True};}

///////////////
// Functions //
///////////////
Expand Down
6 changes: 6 additions & 0 deletions hw/ip/entropy_src/dv/env/entropy_src_scoreboard.sv
Original file line number Diff line number Diff line change
Expand Up @@ -936,6 +936,7 @@ class entropy_src_scoreboard extends cip_base_scoreboard#(
seed_tl_read_cnt = 0;
full_seed = entropy_data_q.pop_front();
entropy_data_seeds++;
cfg.total_seeds_consumed++;

end else if (seed_tl_read_cnt > CSRNG_BUS_WIDTH / TL_DW) begin
`uvm_error(`gfn, "testbench error: too many segments read from candidate seed")
Expand Down Expand Up @@ -1077,6 +1078,9 @@ class entropy_src_scoreboard extends cip_base_scoreboard#(
continuous_fail_count = 0;
cont_fail_in_last_sample = 0;

// Reset the total_seeds_consumed count.
cfg.total_seeds_consumed = 0;

// Clear interrupt state
known_intr_state = 0;
intr_en_mask = 0;
Expand Down Expand Up @@ -1414,6 +1418,7 @@ class entropy_src_scoreboard extends cip_base_scoreboard#(
"err_code_test": begin
end
"main_sm_state": begin
do_read_check = 1'b0;
end
default: begin
`uvm_fatal(`gfn, $sformatf("invalid csr: %0s", csr.get_full_name()))
Expand Down Expand Up @@ -2388,6 +2393,7 @@ class entropy_src_scoreboard extends cip_base_scoreboard#(
prediction = fips_csrng_q.pop_front();
if (prediction == item.d_data) begin
csrng_seeds++;
cfg.total_seeds_consumed++;
match_found = 1;
`uvm_info(`gfn, $sformatf("CSRNG Match found: %d\n", csrng_seeds), UVM_FULL)
break;
Expand Down
42 changes: 24 additions & 18 deletions hw/ip/entropy_src/dv/env/seq_lib/entropy_src_base_vseq.sv
Original file line number Diff line number Diff line change
Expand Up @@ -434,60 +434,66 @@ class entropy_src_base_vseq extends cip_base_vseq #(
m_rng_push_seq.start(p_sequencer.rng_sequencer_h);
endtask // run_rng_host_seq

task repcnt_ht_fail_seq(push_pull_host_seq#(entropy_src_pkg::RNG_BUS_WIDTH) m_rng_push_seq);
task repcnt_ht_fail_seq(push_pull_host_seq#(entropy_src_pkg::RNG_BUS_WIDTH) m_rng_push_seq,
int num_trans = m_rng_push_seq.num_trans);
// Set rng_val
// Use randomly generated but fixed rng_val through the test to cause the repcnt health test
// to fail
`DV_CHECK_STD_RANDOMIZE_FATAL(rng_val)
for (int i = 0; i < m_rng_push_seq.num_trans; i++) begin
for (int i = 0; i < num_trans; i++) begin
cfg.m_rng_agent_cfg.add_h_user_data(rng_val);
end
endtask // repcnt_ht_fail_seq

task adaptp_ht_fail_seq(push_pull_host_seq#(entropy_src_pkg::RNG_BUS_WIDTH) m_rng_push_seq,
bit[15:0] fips_thresh, bit[15:0] bypass_thresh);
ral.adaptp_hi_thresholds.fips_thresh.set(fips_thresh);
ral.adaptp_hi_thresholds.bypass_thresh.set(bypass_thresh);
bit[15:0] fips_lo_thresh, bit[15:0] fips_hi_thresh,
bit[15:0] bypass_lo_thresh, bit[15:0] bypass_hi_thresh,
int num_trans = m_rng_push_seq.num_trans);
ral.adaptp_hi_thresholds.fips_thresh.set(fips_hi_thresh);
ral.adaptp_hi_thresholds.bypass_thresh.set(bypass_hi_thresh);
csr_update(.csr(ral.adaptp_hi_thresholds));
ral.adaptp_lo_thresholds.fips_thresh.set(fips_thresh);
ral.adaptp_lo_thresholds.bypass_thresh.set(bypass_thresh);
ral.adaptp_lo_thresholds.fips_thresh.set(fips_lo_thresh);
ral.adaptp_lo_thresholds.bypass_thresh.set(bypass_lo_thresh);
csr_update(.csr(ral.adaptp_lo_thresholds));
// Turn on module_enable
enable_dut();
// Set rng_val
for (int i = 0; i < m_rng_push_seq.num_trans; i++) begin
for (int i = 0; i < num_trans; i++) begin
rng_val = (i % 16 == 0 ? (cfg.which_ht == high_test ? 0 : 1) :
(cfg.which_ht == high_test ? 1 : 0));
cfg.m_rng_agent_cfg.add_h_user_data(rng_val);
end
endtask // adaptp_ht_fail_seq

task bucket_ht_fail_seq(push_pull_host_seq#(entropy_src_pkg::RNG_BUS_WIDTH) m_rng_push_seq,
bit[15:0] fips_thresh, bit[15:0] bypass_thresh);
bit[15:0] fips_thresh, bit[15:0] bypass_thresh,
int num_trans = m_rng_push_seq.num_trans);
ral.bucket_thresholds.fips_thresh.set(fips_thresh);
ral.bucket_thresholds.bypass_thresh.set(bypass_thresh);
csr_update(.csr(ral.bucket_thresholds));
// Turn on module_enable
enable_dut();
// Set rng_val
for (int i = 0; i < m_rng_push_seq.num_trans; i++) begin
for (int i = 0; i < num_trans; i++) begin
rng_val = (i % 2 == 0 ? 5 : 10);
cfg.m_rng_agent_cfg.add_h_user_data(rng_val);
end
endtask // bucket_ht_fail_seq

task markov_ht_fail_seq(push_pull_host_seq#(entropy_src_pkg::RNG_BUS_WIDTH) m_rng_push_seq,
bit[15:0] fips_thresh, bit[15:0] bypass_thresh);
ral.markov_hi_thresholds.fips_thresh.set(fips_thresh);
ral.markov_hi_thresholds.bypass_thresh.set(bypass_thresh);
bit[15:0] fips_lo_thresh, bit[15:0] fips_hi_thresh,
bit[15:0] bypass_lo_thresh, bit[15:0] bypass_hi_thresh,
int num_trans = m_rng_push_seq.num_trans);
ral.markov_hi_thresholds.fips_thresh.set(fips_hi_thresh);
ral.markov_hi_thresholds.bypass_thresh.set(bypass_hi_thresh);
csr_update(.csr(ral.markov_hi_thresholds));
ral.markov_lo_thresholds.fips_thresh.set(fips_thresh);
ral.markov_lo_thresholds.bypass_thresh.set(bypass_thresh);
ral.markov_lo_thresholds.fips_thresh.set(fips_lo_thresh);
ral.markov_lo_thresholds.bypass_thresh.set(bypass_lo_thresh);
csr_update(.csr(ral.markov_lo_thresholds));
// Turn on module_enable
enable_dut();
// Set rng_val
for (int i = 0; i < m_rng_push_seq.num_trans; i++) begin
for (int i = 0; i < num_trans; i++) begin
rng_val = (i % 2 == 0 ? (cfg.which_ht == high_test ? 0 : 1) :
(cfg.which_ht == high_test ? 1 : 0));
cfg.m_rng_agent_cfg.add_h_user_data(rng_val);
Expand Down Expand Up @@ -607,7 +613,7 @@ class entropy_src_base_vseq extends cip_base_vseq #(
bit [15:0] fips_thresh = 16'h0008;
bit [15:0] bypass_thresh = 16'h0008;
`DV_CHECK_STD_RANDOMIZE_FATAL(path_err_val)
adaptp_ht_fail_seq(m_rng_push_seq, fips_thresh, bypass_thresh);
adaptp_ht_fail_seq(m_rng_push_seq, fips_thresh, fips_thresh, bypass_thresh, bypass_thresh);
// Start the sequence
m_rng_push_seq.start(p_sequencer.rng_sequencer_h);
cfg.clk_rst_vif.wait_clks(100);
Expand Down Expand Up @@ -656,7 +662,7 @@ class entropy_src_base_vseq extends cip_base_vseq #(

fips_thresh = 16'h0008;
bypass_thresh = 16'h0008;
markov_ht_fail_seq(m_rng_push_seq, fips_thresh, bypass_thresh);
markov_ht_fail_seq(m_rng_push_seq, fips_thresh, fips_thresh, bypass_thresh, bypass_thresh);
// Start the sequence
m_rng_push_seq.start(p_sequencer.rng_sequencer_h);
cfg.clk_rst_vif.wait_clks(100);
Expand Down
Loading

0 comments on commit b0fb96a

Please sign in to comment.