Skip to content

Commit

Permalink
[dv/pwrmgr] Add escalation_timeout test
Browse files Browse the repository at this point in the history
Test the escalation clock timeout feature of pwrmgr.
This test fails due to #20516.

Fixes #20158

Signed-off-by: Guillermo Maturana <[email protected]>
  • Loading branch information
matutem committed Nov 29, 2023
1 parent 1f5d71a commit 729f744
Show file tree
Hide file tree
Showing 10 changed files with 172 additions and 0 deletions.
19 changes: 19 additions & 0 deletions hw/ip_templates/pwrmgr/data/pwrmgr_testplan.hjson
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,25 @@
stage: V2
tests: ["pwrmgr_disable_rom_integrity_check"]
}
{
name: escalation_timeout
desc: '''This tests the escalation timeout feature.

If the escalation network doesn't respond to an outgoing "health"
requests within 128 cycles pwrmgr should issue an escalation reset
request.

**Stimulus**:
- Cause the external escalation network to stop responding, either
disabling the clock or jamming the differential pairs.

**Check**:
- After 128 cycles of inactivity an escalation reset should be
triggered.
'''
stage: V3
tests: ["pwrmgr_escalation_timeout"]
}
{
name: stress_all
desc: '''This runs random sequences in succession.
Expand Down
1 change: 1 addition & 0 deletions hw/ip_templates/pwrmgr/dv/env/pwrmgr_env.core
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ filesets:
- seq_lib/pwrmgr_esc_clk_rst_malfunc_vseq.sv: {is_include_file: true}
- seq_lib/pwrmgr_sec_cm_ctrl_config_regwen_vseq.sv: {is_include_file: true}
- seq_lib/pwrmgr_global_esc_vseq.sv: {is_include_file: true}
- seq_lib/pwrmgr_escalation_timeout_vseq.sv: {is_include_file: true}
- seq_lib/pwrmgr_glitch_vseq.sv: {is_include_file: true}
- seq_lib/pwrmgr_disable_rom_integrity_check_vseq.sv: {is_include_file: true}
- seq_lib/pwrmgr_reset_invalid_vseq.sv: {is_include_file: true}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// Copyright lowRISC contributors.
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0
// Description:
// This test checks that an escalation reset is generated when the escalation clock stops for
// enough cycles.
class pwrmgr_escalation_timeout_vseq extends pwrmgr_base_vseq;
`uvm_object_utils(pwrmgr_escalation_timeout_vseq)

`uvm_object_new

localparam int TIMEOUT_THRESHOLD = 128;

int trans_cnt = 0;
constraint num_trans_c {num_trans inside {[1 : 5]};}

task check_stopped_esc_clk(int stop_cycles, bit expect_reset);
fork
begin
`uvm_info(`gfn, $sformatf("Stopping escalation clock for %0d cycles", stop_cycles),
UVM_MEDIUM)
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);
end
begin
cfg.clk_rst_vif.wait_clks(TIMEOUT_THRESHOLD);
if (expect_reset) begin
`DV_WAIT(cfg.pwrmgr_vif.fetch_en != lc_ctrl_pkg::On,
"Timeout waiting for cpu fetch disable", 4000)
`uvm_info(`gfn, "cpu fetch disabled, indicating a reset", UVM_MEDIUM)
`DV_WAIT(cfg.pwrmgr_vif.pwr_rst_req.rstreqs[pwrmgr_reg_pkg::ResetEscIdx] == 1'b1 &&
cfg.pwrmgr_vif.pwr_rst_req.reset_cause == pwrmgr_pkg::HwReq,
"Timeout waiting for outgoing escalation reset", 40000)
`uvm_info(`gfn, "Outgoing escalation reset", UVM_MEDIUM)
end else begin
repeat (8000) begin
cfg.clk_rst_vif.wait_clks(1);
if (cfg.pwrmgr_vif.fetch_en != lc_ctrl_pkg::On) begin
`uvm_error(`gfn, "Unexpected cpu fetch disable, indicating a reset")
end
end
end
end
join
endtask

virtual task body();
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);
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);
endtask : body

endclass
1 change: 1 addition & 0 deletions hw/ip_templates/pwrmgr/dv/env/seq_lib/pwrmgr_vseq_list.sv
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
`include "pwrmgr_esc_clk_rst_malfunc_vseq.sv"
`include "pwrmgr_sec_cm_ctrl_config_regwen_vseq.sv"
`include "pwrmgr_global_esc_vseq.sv"
`include "pwrmgr_escalation_timeout_vseq.sv"
`include "pwrmgr_glitch_vseq.sv"
`include "pwrmgr_disable_rom_integrity_check_vseq.sv"
`include "pwrmgr_reset_invalid_vseq.sv"
Expand Down
4 changes: 4 additions & 0 deletions hw/ip_templates/pwrmgr/dv/pwrmgr_sim_cfg.hjson
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@
uvm_test_seq: pwrmgr_global_esc_vseq
run_opts: ["+test_timeout_ns=1000000000"]
}
{
name: pwrmgr_escalation_timeout
uvm_test_seq: pwrmgr_escalation_timeout_vseq
}
{
name: pwrmgr_glitch
uvm_test_seq: pwrmgr_glitch_vseq
Expand Down
19 changes: 19 additions & 0 deletions hw/top_earlgrey/ip_autogen/pwrmgr/data/pwrmgr_testplan.hjson
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,25 @@
stage: V2
tests: ["pwrmgr_disable_rom_integrity_check"]
}
{
name: escalation_timeout
desc: '''This tests the escalation timeout feature.

If the escalation network doesn't respond to an outgoing "health"
requests within 128 cycles pwrmgr should issue an escalation reset
request.

**Stimulus**:
- Cause the external escalation network to stop responding, either
disabling the clock or jamming the differential pairs.

**Check**:
- After 128 cycles of inactivity an escalation reset should be
triggered.
'''
stage: V3
tests: ["pwrmgr_escalation_timeout"]
}
{
name: stress_all
desc: '''This runs random sequences in succession.
Expand Down
1 change: 1 addition & 0 deletions hw/top_earlgrey/ip_autogen/pwrmgr/dv/env/pwrmgr_env.core
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ filesets:
- seq_lib/pwrmgr_esc_clk_rst_malfunc_vseq.sv: {is_include_file: true}
- seq_lib/pwrmgr_sec_cm_ctrl_config_regwen_vseq.sv: {is_include_file: true}
- seq_lib/pwrmgr_global_esc_vseq.sv: {is_include_file: true}
- seq_lib/pwrmgr_escalation_timeout_vseq.sv: {is_include_file: true}
- seq_lib/pwrmgr_glitch_vseq.sv: {is_include_file: true}
- seq_lib/pwrmgr_disable_rom_integrity_check_vseq.sv: {is_include_file: true}
- seq_lib/pwrmgr_reset_invalid_vseq.sv: {is_include_file: true}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// Copyright lowRISC contributors.
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0
// Description:
// This test checks that an escalation reset is generated when the escalation clock stops for
// enough cycles.
class pwrmgr_escalation_timeout_vseq extends pwrmgr_base_vseq;
`uvm_object_utils(pwrmgr_escalation_timeout_vseq)

`uvm_object_new

localparam int TIMEOUT_THRESHOLD = 128;

int trans_cnt = 0;
constraint num_trans_c {num_trans inside {[1 : 5]};}

task check_stopped_esc_clk(int stop_cycles, bit expect_reset);
fork
begin
`uvm_info(`gfn, $sformatf("Stopping escalation clock for %0d cycles", stop_cycles),
UVM_MEDIUM)
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);
end
begin
cfg.clk_rst_vif.wait_clks(TIMEOUT_THRESHOLD);
if (expect_reset) begin
`DV_WAIT(cfg.pwrmgr_vif.fetch_en != lc_ctrl_pkg::On,
"Timeout waiting for cpu fetch disable", 4000)
`uvm_info(`gfn, "cpu fetch disabled, indicating a reset", UVM_MEDIUM)
`DV_WAIT(cfg.pwrmgr_vif.pwr_rst_req.rstreqs[pwrmgr_reg_pkg::ResetEscIdx] == 1'b1 &&
cfg.pwrmgr_vif.pwr_rst_req.reset_cause == pwrmgr_pkg::HwReq,
"Timeout waiting for outgoing escalation reset", 40000)
`uvm_info(`gfn, "Outgoing escalation reset", UVM_MEDIUM)
end else begin
repeat (8000) begin
cfg.clk_rst_vif.wait_clks(1);
if (cfg.pwrmgr_vif.fetch_en != lc_ctrl_pkg::On) begin
`uvm_error(`gfn, "Unexpected cpu fetch disable, indicating a reset")
end
end
end
end
join
endtask

virtual task body();
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);
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);
endtask : body

endclass
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
`include "pwrmgr_esc_clk_rst_malfunc_vseq.sv"
`include "pwrmgr_sec_cm_ctrl_config_regwen_vseq.sv"
`include "pwrmgr_global_esc_vseq.sv"
`include "pwrmgr_escalation_timeout_vseq.sv"
`include "pwrmgr_glitch_vseq.sv"
`include "pwrmgr_disable_rom_integrity_check_vseq.sv"
`include "pwrmgr_reset_invalid_vseq.sv"
Expand Down
4 changes: 4 additions & 0 deletions hw/top_earlgrey/ip_autogen/pwrmgr/dv/pwrmgr_sim_cfg.hjson
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@
uvm_test_seq: pwrmgr_global_esc_vseq
run_opts: ["+test_timeout_ns=1000000000"]
}
{
name: pwrmgr_escalation_timeout
uvm_test_seq: pwrmgr_escalation_timeout_vseq
}
{
name: pwrmgr_glitch
uvm_test_seq: pwrmgr_glitch_vseq
Expand Down

0 comments on commit 729f744

Please sign in to comment.