[rv_timer] Update scoreboard and the base sequence

Update the expected interrupt value when mtimecmp registers are updated.

Signed-off-by: Eunchan Kim <eunchan@opentitan.org>
Signed-off-by: Cindy Chen <chencindy@google.com>
diff --git a/hw/ip/rv_timer/dv/env/rv_timer_scoreboard.sv b/hw/ip/rv_timer/dv/env/rv_timer_scoreboard.sv
index 3697db5..8d97a3d 100644
--- a/hw/ip/rv_timer/dv/env/rv_timer_scoreboard.sv
+++ b/hw/ip/rv_timer/dv/env/rv_timer_scoreboard.sv
@@ -103,16 +103,30 @@
         (!uvm_re_match("compare_lower*", csr_name)): begin
           for (int i = 0; i < NUM_HARTS; i++) begin
             for (int j = 0; j < NUM_TIMERS; j++) begin
+              int timer_idx = i * NUM_TIMERS + j;
               compare_val[i][j][31:0] = get_reg_fld_mirror_value(
                                             ral, $sformatf("compare_lower%0d_%0d", i, j), "v");
+              // Reset the interrupt when mtimecmp is updated
+              intr_status_exp[i][j] = 0;
+              if (cfg.en_cov) begin
+                cov.sticky_intr_cov[{"rv_timer_sticky_intr_pin",
+                                    $sformatf("%0d", timer_idx)}].sample(1'b0);
+              end
             end
           end
         end
         (!uvm_re_match("compare_upper*", csr_name)): begin
           for (int i = 0; i < NUM_HARTS; i++) begin
             for (int j = 0; j < NUM_TIMERS; j++) begin
+              int timer_idx = i * NUM_TIMERS + j;
               compare_val[i][j][63:32] = get_reg_fld_mirror_value(
                                              ral, $sformatf("compare_upper%0d_%0d", i, j), "v");
+              // Reset the interrupt when mtimecmp is updated
+              intr_status_exp[i][j] = 0;
+              if (cfg.en_cov) begin
+                cov.sticky_intr_cov[{"rv_timer_sticky_intr_pin",
+                                    $sformatf("%0d", timer_idx)}].sample(1'b0);
+              end
             end
           end
         end
diff --git a/hw/ip/rv_timer/dv/env/seq_lib/rv_timer_base_vseq.sv b/hw/ip/rv_timer/dv/env/seq_lib/rv_timer_base_vseq.sv
index 62f2b24..5a81d6f 100644
--- a/hw/ip/rv_timer/dv/env/seq_lib/rv_timer_base_vseq.sv
+++ b/hw/ip/rv_timer/dv/env/seq_lib/rv_timer_base_vseq.sv
@@ -143,8 +143,9 @@
     `DV_CHECK_NE_FATAL(intr_state_rg, null)
     is_fld = intr_state_rg.get_field_by_name($sformatf("is%0d", timer));
     `DV_CHECK_NE_FATAL(is_fld, null)
-    is_fld.set(1);
-    csr_update(.csr(intr_state_rg));
+    //is_fld.set(1);
+    //csr_update(.csr(intr_state_rg));
+    set_compare_val(hart, timer, 1);
     csr_rd(.ptr(intr_state_rg), .value(status));
   endtask
 
diff --git a/sw/device/tests/rv_timer/rv_timer_test.c b/sw/device/tests/rv_timer/rv_timer_test.c
index 9e65a9b..017e747 100644
--- a/sw/device/tests/rv_timer/rv_timer_test.c
+++ b/sw/device/tests/rv_timer/rv_timer_test.c
@@ -2,10 +2,11 @@
 // Licensed under the Apache License, Version 2.0, see LICENSE for details.
 // SPDX-License-Identifier: Apache-2.0
 
-#include "sw/device/lib/common.h"
-#include "sw/device/lib/irq.h"
 #include "sw/device/lib/rv_timer.h"
+
+#include "sw/device/lib/common.h"
 #include "sw/device/lib/gpio.h"
+#include "sw/device/lib/irq.h"
 #include "sw/device/lib/pinmux.h"
 #include "sw/device/lib/uart.h"