[dv/chip] Move common test to base sequence
This PR moves the commonly used `get_otp_token` task to base_vseq, and
rename to better reflect its purpose.
Signed-off-by: Cindy Chen <chencindy@opentitan.org>
diff --git a/hw/top_earlgrey/dv/env/seq_lib/chip_sw_base_vseq.sv b/hw/top_earlgrey/dv/env/seq_lib/chip_sw_base_vseq.sv
index 871194d..4a178ae 100644
--- a/hw/top_earlgrey/dv/env/seq_lib/chip_sw_base_vseq.sv
+++ b/hw/top_earlgrey/dv/env/seq_lib/chip_sw_base_vseq.sv
@@ -320,6 +320,25 @@
`uvm_info(`gfn, $sformatf("addr %0h = 0x%0h --> 0x%0h", addr, prev_data, data), UVM_HIGH)
endfunction
+ // LC state transition tasks
+ // This function takes the token value from the four LC_CTRL token CSRs, then runs through
+ // cshake128 to get a 768-bit XORed token output.
+ // The first 128 bits of the decoded token should match the OTP paritition's descrambled tokens
+ // value.
+ virtual function bit [TokenWidthBit-1:0] dec_otp_token_from_lc_csrs(
+ bit [7:0] token_in[TokenWidthByte]);
+
+ bit [7:0] dpi_digest[kmac_pkg::AppDigestW/8];
+ bit [kmac_pkg::AppDigestW-1:0] digest_bits;
+
+ digestpp_dpi_pkg::c_dpi_cshake128(token_in, "", "LC_CTRL", TokenWidthByte,
+ kmac_pkg::AppDigestW/8, dpi_digest);
+
+ digest_bits = {<< byte {dpi_digest}};
+ return (digest_bits[TokenWidthBit-1:0]);
+ endfunction
+
+
// LC_CTRL JTAG tasks
virtual task wait_lc_status(lc_ctrl_status_e expect_status, int max_attemp = 5000);
int i;
diff --git a/hw/top_earlgrey/dv/env/seq_lib/chip_sw_flash_rma_unlocked_vseq.sv b/hw/top_earlgrey/dv/env/seq_lib/chip_sw_flash_rma_unlocked_vseq.sv
index feec4ec..5f7533a 100644
--- a/hw/top_earlgrey/dv/env/seq_lib/chip_sw_flash_rma_unlocked_vseq.sv
+++ b/hw/top_earlgrey/dv/env/seq_lib/chip_sw_flash_rma_unlocked_vseq.sv
@@ -31,21 +31,6 @@
rand bit [7:0] creator_root_key0[KeyWidthByte];
rand bit [7:0] creator_root_key1[KeyWidthByte];
- // This function takes the token value from LC_CTRL token CSRs, then runs through cshake128 to
- // get a 768-bit XORed token output.
- // The first 128 bits of the decoded token should match the OTP's secret2 paritition's
- // descrambled tokens value.
- virtual function bit [TokenWidthBit-1:0] get_otp_token(bit [7:0] token_in[TokenWidthByte]);
- bit [7:0] dpi_digest[kmac_pkg::AppDigestW/8];
- bit [kmac_pkg::AppDigestW-1:0] digest_bits;
-
- digestpp_dpi_pkg::c_dpi_cshake128(token_in, "", "LC_CTRL", TokenWidthByte,
- kmac_pkg::AppDigestW / 8, dpi_digest);
-
- digest_bits = {<<byte{dpi_digest}};
- return (digest_bits[TokenWidthBit-1:0]);
- endfunction
-
virtual function bit [KeyWidthBit-1:0] get_otp_key(bit [7:0] key_in[KeyWidthByte]);
bit [kmac_pkg::AppDigestW-1:0] digest_bits;
bit [7:0] dpi_digest[kmac_pkg::AppDigestW/8];
@@ -114,7 +99,7 @@
// Second Boot.
// Override the rma unlock token to match SW test's input token.
cfg.mem_bkdr_util_h[Otp].otp_write_secret2_partition(
- .rma_unlock_token(get_otp_token(rma_unlock_token)),
+ .rma_unlock_token(dec_otp_token_from_lc_csrs(rma_unlock_token)),
.creator_root_key0(get_otp_key(creator_root_key0)),
.creator_root_key1(get_otp_key(creator_root_key1)));
diff --git a/hw/top_earlgrey/dv/env/seq_lib/chip_sw_lc_ctrl_transition_vseq.sv b/hw/top_earlgrey/dv/env/seq_lib/chip_sw_lc_ctrl_transition_vseq.sv
index 35daf9c..e2f2c3a 100644
--- a/hw/top_earlgrey/dv/env/seq_lib/chip_sw_lc_ctrl_transition_vseq.sv
+++ b/hw/top_earlgrey/dv/env/seq_lib/chip_sw_lc_ctrl_transition_vseq.sv
@@ -27,8 +27,8 @@
// Override the test exit token to match SW test's input token.
cfg.mem_bkdr_util_h[Otp].otp_write_secret0_partition(
- .unlock_token(get_otp_token(lc_unlock_token)),
- .exit_token(get_otp_token(lc_exit_token)));
+ .unlock_token(dec_otp_token_from_lc_csrs(lc_unlock_token)),
+ .exit_token(dec_otp_token_from_lc_csrs(lc_exit_token)));
endfunction
virtual task dut_init(string reset_kind = "HARD");
@@ -36,23 +36,6 @@
backdoor_override_otp();
endtask
- // This function takes the token value from LC_CTRL token CSRs, then runs through cshake128 to
- // get a 768-bit XORed token output.
- // The first 128 bits of the decoded token should match the OTP's secret0 paritition's
- // descrambled tokens value.
- virtual function bit [TokenWidthBit-1:0] get_otp_token(
- bit [7:0] token_in[TokenWidthByte]);
-
- bit [7:0] dpi_digest[kmac_pkg::AppDigestW/8];
- bit [kmac_pkg::AppDigestW-1:0] digest_bits;
-
- digestpp_dpi_pkg::c_dpi_cshake128(token_in, "", "LC_CTRL", TokenWidthByte,
- kmac_pkg::AppDigestW/8, dpi_digest);
-
- digest_bits = {<< byte {dpi_digest}};
- return (digest_bits[TokenWidthBit-1:0]);
- endfunction
-
virtual task body();
super.body();