[dv, rv_dm] Fix scoreboard

Now that the TCK period is randomized, we run into DMI busy
statuses, which was not previouslty accounted for in the scoreboard
check.

Signed-off-by: Srikrishna Iyer <sriyer@google.com>
diff --git a/hw/dv/sv/dv_utils/dv_macros.svh b/hw/dv/sv/dv_utils/dv_macros.svh
index 3440766..f2e8af5 100644
--- a/hw/dv/sv/dv_utils/dv_macros.svh
+++ b/hw/dv/sv/dv_utils/dv_macros.svh
@@ -575,7 +575,7 @@
 // Macros for constrain clk with common frequencies
 //
 // Nominal clock frequency range is 24Mhz - 100Mhz and use higher weights on 24, 25, 48, 50, 100,
-// To mimic manufacturing conditions (when clocks are uncalibrated), we need to be able to go as 
+// To mimic manufacturing conditions (when clocks are uncalibrated), we need to be able to go as
 // low as 5MHz.
 `ifndef DV_COMMON_CLK_CONSTRAINT
 `define DV_COMMON_CLK_CONSTRAINT(FREQ_) \
diff --git a/hw/ip/rv_dm/dv/env/rv_dm_scoreboard.sv b/hw/ip/rv_dm/dv/env/rv_dm_scoreboard.sv
index 6836982..a02a6ec 100644
--- a/hw/ip/rv_dm/dv/env/rv_dm_scoreboard.sv
+++ b/hw/ip/rv_dm/dv/env/rv_dm_scoreboard.sv
@@ -88,7 +88,14 @@
           void'(selected_dtm_csr.predict(.value(item.dr), .kind(UVM_PREDICT_WRITE)));
         end
         "dtmcs": begin
-          `DV_CHECK_EQ(item.dout, selected_dtm_csr.get_mirrored_value())
+          // DMI traffic is internal to rv_dm module. The stimulus in jtag_dmi_reg_frontdoor reads
+          // the dmistat field of dtmcs register to determine if the previous transaction completed.
+          // It is not possible to predict the value of this field, unless the internals of the
+          // design (dmi_jtag module) is probed. Instead of doing that, checking the correctness of
+          // dmistat field can be offloaded to a directed test that generates DMI busy scenarios.
+          uvm_reg_data_t mask = ~dv_base_reg_pkg::get_mask_from_fields(
+              {cfg.m_jtag_agent_cfg.jtag_dtm_ral.dtmcs.dmistat});
+          `DV_CHECK_EQ(item.dout & mask, selected_dtm_csr.get_mirrored_value() & mask)
           void'(selected_dtm_csr.predict(.value(item.dr), .kind(UVM_PREDICT_WRITE)));
         end
         default: `uvm_fatal(`gfn, $sformatf("Unknown DTM CSR: %0s", selected_dtm_csr.get_name()))