Fix problem with chip_sw_pwrmgr_random_sleep_all_reset_reqs

Bug: 300686315

1. Don't configure alerts after the last boot up to avoid unnecessary
   reset in drain time
2. Use randc to make sure all test scenarios are covered in one run

Change-Id: I3ae32f704f5b5145af3383a8461124f2306e89f1
diff --git a/hw/top_matcha/dv/env/seq_lib/chip_sw_random_sleep_all_reset_vseq.sv b/hw/top_matcha/dv/env/seq_lib/chip_sw_random_sleep_all_reset_vseq.sv
index c655277..ffeda99 100644
--- a/hw/top_matcha/dv/env/seq_lib/chip_sw_random_sleep_all_reset_vseq.sv
+++ b/hw/top_matcha/dv/env/seq_lib/chip_sw_random_sleep_all_reset_vseq.sv
@@ -1,3 +1,4 @@
+// Copyright 2023 Google LLC.
 // Copyright lowRISC contributors.
 // Licensed under the Apache License, Version 2.0, see LICENSE for details.
 // SPDX-License-Identifier: Apache-2.0
@@ -29,19 +30,25 @@
   constraint cycles_tll_reset_c {cycles_till_reset inside {[0 : 200]};}
   constraint reset_delay_c {reset_delay inside {[0 : 10]};}
 
-  rand bit[7:0] assa[NumRound-1];
-  constraint assa_c {
-    foreach (assa[i]) assa[i] inside {[0:NumRound-2]};
-  }
+  class assa;
+    randc bit[7:0] val;
+
+    constraint assa_c {
+      val inside {[0:NumRound-2]};
+    }
+  endclass
 
   virtual task cpu_init();
     bit[7:0] rst_idx[NumRound];
+    assa ias = new ();
+
     for (int i=0; i< NumRound; i = i+1) begin
       if (i == (NumRound-1)) begin
         rst_idx[i] = i;
       end
       else begin
-        rst_idx[i] = assa[i];
+        ias.randomize();
+        rst_idx[i] = ias.val;
       end
     end
     super.cpu_init();
diff --git a/sw/device/tests/sim_dv/pwrmgr_random_sleep_all_reset_reqs_test.c b/sw/device/tests/sim_dv/pwrmgr_random_sleep_all_reset_reqs_test.c
index 440a84b..fb71c0c 100644
--- a/sw/device/tests/sim_dv/pwrmgr_random_sleep_all_reset_reqs_test.c
+++ b/sw/device/tests/sim_dv/pwrmgr_random_sleep_all_reset_reqs_test.c
@@ -462,11 +462,13 @@
                                      kTopMatchaPlicIrqIdAlertHandlerClassa,
                                      kTopMatchaPlicIrqIdAlertHandlerClassd);
 
-  alert_handler_config();
-
   // First check the flash stored value
   uint32_t event_idx = flash_ctrl_testutils_counter_get(0);
 
+  // Don't configure alerts after the last boot up to avoid unnecessary
+  // reset in drain time
+  if (RST_IDX[event_idx] < 11) alert_handler_config();
+
   // Enable flash access
   flash_ctrl_testutils_default_region_access(&flash_ctrl,
                                              /*rd_en*/ true,