Skip to content

Commit

Permalink
[dv,pwrmgr] Fix pwrmgr_escalation_timeout test
Browse files Browse the repository at this point in the history
The number of cycles esc_clk need to stop to trigger a timeout is unpredictable:
- The timeout counter can start at any number from 0 to 7.
- The reqack synchronizer adds some variable number of cycles due to its phase.

Avoid spurious failures by reducing the number of cycles of stoppage when
not expecting alerts, and wait reduce the number of cycles to trigger an expected
alert.

Also, avoid running the case that fails due to issue #20516.

Signed-off-by: Guillermo Maturana <[email protected]>
  • Loading branch information
matutem committed Jan 3, 2024
1 parent 0877240 commit 748235c
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 14 deletions.
10 changes: 8 additions & 2 deletions hw/ip_templates/pwrmgr/dv/env/pwrmgr_scoreboard.sv
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,14 @@ class pwrmgr_scoreboard extends cip_base_scoreboard #(
fork
forever
@(posedge cfg.esc_clk_rst_vif.clk_gate) begin
if (cfg.pwrmgr_vif.pwr_ast_req.io_clk_en && cfg.pwrmgr_vif.pwr_clk_req.io_ip_clk_en) begin
`uvm_info(`gfn, "Detected unexpected clk_esc_i stop", UVM_MEDIUM)
// A timeout could be triggered after more than 121 clk_i cycles, but this number
// is somewhat unpredictable for reasons explained in the pwrmgr_escalation_timeout
// sequence, so this relies on the sequence to avoid unpredictable stoppages.
`uvm_info(`gfn, "Detected unexpected clk_esc_i stop", UVM_MEDIUM)
cfg.clk_rst_vif.wait_clks(121);
if (cfg.esc_clk_rst_vif.clk_gate && cfg.pwrmgr_vif.pwr_ast_req.io_clk_en &&
cfg.pwrmgr_vif.pwr_clk_req.io_ip_clk_en) begin
`uvm_info(`gfn, "clk_esc_i has been inactive enough to trigger an alert", UVM_MEDIUM)
set_exp_alert("fatal_fault", 1, 500);
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class pwrmgr_escalation_timeout_vseq extends pwrmgr_base_vseq;
cfg.esc_clk_rst_vif.stop_clk();
cfg.clk_rst_vif.wait_clks(stop_cycles);
cfg.esc_clk_rst_vif.start_clk();
cfg.esc_clk_rst_vif.wait_clks(10000);
cfg.esc_clk_rst_vif.wait_clks(4000);
end
begin
cfg.clk_rst_vif.wait_clks(TIMEOUT_THRESHOLD);
Expand Down Expand Up @@ -50,12 +50,18 @@ class pwrmgr_escalation_timeout_vseq extends pwrmgr_base_vseq;
wait_for_fast_fsm_active();
cfg.slow_clk_rst_vif.set_freq_mhz(1);
cfg.esc_clk_rst_vif.wait_clks(200);
check_stopped_esc_clk(120, 1'b0);
// The timeout is not predictable for two reasons:
// - The initial count for the timeout can be from 0 to 7, which means the timeout could
// happen between 121 and 128 cycles after the clock.
// - The timeout has a req-ack synchronizer which has some randomness due to the phase.
// This adds a few more cycles of uncertainty.
// Keep the clock stopped for less than 118 cycles should be safe to avoid an alert.
check_stopped_esc_clk(118, 1'b0);
check_stopped_esc_clk(2000, 1'b1);
wait_for_fast_fsm_active();
// This fails to generate a reset, so the test fails. It should pass once
// lowrisc/opentitan#20516 is addressed.
check_stopped_esc_clk(136, 1'b1);
// This should generate a reset but it doesn't so the test will fail.
// TODO(lowrisc/opentitan#20516): Enable this test when this is fixed.
// check_stopped_esc_clk(136, 1'b1);
endtask : body

endclass
10 changes: 8 additions & 2 deletions hw/top_earlgrey/ip_autogen/pwrmgr/dv/env/pwrmgr_scoreboard.sv
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,14 @@ class pwrmgr_scoreboard extends cip_base_scoreboard #(
fork
forever
@(posedge cfg.esc_clk_rst_vif.clk_gate) begin
if (cfg.pwrmgr_vif.pwr_ast_req.io_clk_en && cfg.pwrmgr_vif.pwr_clk_req.io_ip_clk_en) begin
`uvm_info(`gfn, "Detected unexpected clk_esc_i stop", UVM_MEDIUM)
// A timeout could be triggered after more than 121 clk_i cycles, but this number
// is somewhat unpredictable for reasons explained in the pwrmgr_escalation_timeout
// sequence, so this relies on the sequence to avoid unpredictable stoppages.
`uvm_info(`gfn, "Detected unexpected clk_esc_i stop", UVM_MEDIUM)
cfg.clk_rst_vif.wait_clks(121);
if (cfg.esc_clk_rst_vif.clk_gate && cfg.pwrmgr_vif.pwr_ast_req.io_clk_en &&
cfg.pwrmgr_vif.pwr_clk_req.io_ip_clk_en) begin
`uvm_info(`gfn, "clk_esc_i has been inactive enough to trigger an alert", UVM_MEDIUM)
set_exp_alert("fatal_fault", 1, 500);
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class pwrmgr_escalation_timeout_vseq extends pwrmgr_base_vseq;
cfg.esc_clk_rst_vif.stop_clk();
cfg.clk_rst_vif.wait_clks(stop_cycles);
cfg.esc_clk_rst_vif.start_clk();
cfg.esc_clk_rst_vif.wait_clks(10000);
cfg.esc_clk_rst_vif.wait_clks(4000);
end
begin
cfg.clk_rst_vif.wait_clks(TIMEOUT_THRESHOLD);
Expand Down Expand Up @@ -50,12 +50,18 @@ class pwrmgr_escalation_timeout_vseq extends pwrmgr_base_vseq;
wait_for_fast_fsm_active();
cfg.slow_clk_rst_vif.set_freq_mhz(1);
cfg.esc_clk_rst_vif.wait_clks(200);
check_stopped_esc_clk(120, 1'b0);
// The timeout is not predictable for two reasons:
// - The initial count for the timeout can be from 0 to 7, which means the timeout could
// happen between 121 and 128 cycles after the clock.
// - The timeout has a req-ack synchronizer which has some randomness due to the phase.
// This adds a few more cycles of uncertainty.
// Keep the clock stopped for less than 118 cycles should be safe to avoid an alert.
check_stopped_esc_clk(118, 1'b0);
check_stopped_esc_clk(2000, 1'b1);
wait_for_fast_fsm_active();
// This fails to generate a reset, so the test fails. It should pass once
// lowrisc/opentitan#20516 is addressed.
check_stopped_esc_clk(136, 1'b1);
// This should generate a reset but it doesn't so the test will fail.
// TODO(lowrisc/opentitan#20516): Enable this test when this is fixed.
// check_stopped_esc_clk(136, 1'b1);
endtask : body

endclass

0 comments on commit 748235c

Please sign in to comment.