[dv/hmac] add rand read before hash_start

HMAC should maintain its previous digest value until hmac_start
Special handle if next sequence changes the digest_swap value
diff --git a/hw/ip/hmac/dv/env/hmac_scoreboard.sv b/hw/ip/hmac/dv/env/hmac_scoreboard.sv
index 87795f0..88f2fa0 100644
--- a/hw/ip/hmac/dv/env/hmac_scoreboard.sv
+++ b/hw/ip/hmac/dv/env/hmac_scoreboard.sv
@@ -96,6 +96,17 @@
         do_read_check = 1'b0;
         status_msg_fifo_full = item.d_data[HmacStaMsgFifoFull];
       end
+      if (!uvm_re_match("digest*", csr.get_name())) begin
+        // HW default output Littie Endian for each digest (32 bits)
+        // But standard DPI function expect output is in Big Endian
+        // So digest_swap = 0 will require flip the expect value
+        if (ral.cfg.digest_swap.get_mirrored_value() == 1'b0) begin
+          bit [TL_AW-1:0] digest_data = {<<8{csr.get_mirrored_value()}};
+          `DV_CHECK_EQ(item.d_data, digest_data);
+          // do not want to update mirror value here, directly return
+          return;
+        end
+      end
       if (do_read_check) begin
         `uvm_info(`gfn, $sformatf("%s reg is checked with expected value %0h",
                                   csr.get_name(), csr.get_mirrored_value()), UVM_HIGH);
@@ -151,12 +162,6 @@
         exp_digest = '{default:0};
       end
     endcase
-    // HW default output Littie Endian for each digest (32 bits)
-    // But standard DPI function expect output is in Big Endian
-    // So digest_swap = 0 will require flip the expect value
-    if (ral.cfg.digest_swap.get_mirrored_value() == 1'b0) begin
-      foreach (exp_digest[i]) exp_digest[i] = {<<8{exp_digest[i]}};
-    end
     ral.digest0.predict(exp_digest[0]);
     ral.digest1.predict(exp_digest[1]);
     ral.digest2.predict(exp_digest[2]);
diff --git a/hw/ip/hmac/dv/env/seq_lib/hmac_sanity_vseq.sv b/hw/ip/hmac/dv/env/seq_lib/hmac_sanity_vseq.sv
index 588d60e..f5ab0eb 100644
--- a/hw/ip/hmac/dv/env/seq_lib/hmac_sanity_vseq.sv
+++ b/hw/ip/hmac/dv/env/seq_lib/hmac_sanity_vseq.sv
@@ -38,9 +38,15 @@
       // hmac_init only sha
       hmac_init(.hmac_en(hmac_en), .endian_swap(endian_swap), .digest_swap(digest_swap));
 
+      // can randomly read previous digest
+      if (i != 1 && $urandom_range(0, 1)) rd_digest();
+
       // write key
       wr_key(key);
 
+      // can randomly read previous digest
+      if (i != 1 && $urandom_range(0, 1)) rd_digest();
+
       // start stream in msg
       trigger_hash();