diff --git a/hw/ip/otp_ctrl/data/otp_ctrl_env_pkg.sv.tpl b/hw/ip/otp_ctrl/data/otp_ctrl_env_pkg.sv.tpl index 8c0a75b53d04f..0084db958bb0a 100644 --- a/hw/ip/otp_ctrl/data/otp_ctrl_env_pkg.sv.tpl +++ b/hw/ip/otp_ctrl/data/otp_ctrl_env_pkg.sv.tpl @@ -190,6 +190,14 @@ package otp_ctrl_env_pkg; return PartInfo[part_index].secret; endfunction + function automatic bit part_has_digest(int part_idx); + return PartInfo[part_idx].hw_digest || PartInfo[part_idx].sw_digest; + endfunction + + function automatic bit part_has_hw_digest(int part_idx); + return PartInfo[part_idx].hw_digest; + endfunction + function automatic bit is_sw_digest(bit [TL_DW-1:0] addr); int part_idx = get_part_index(addr); if (PartInfo[part_idx].sw_digest) begin diff --git a/hw/ip/otp_ctrl/data/otp_ctrl_scoreboard.sv.tpl b/hw/ip/otp_ctrl/data/otp_ctrl_scoreboard.sv.tpl index b8c4f4bc051ef..9399a1e451139 100644 --- a/hw/ip/otp_ctrl/data/otp_ctrl_scoreboard.sv.tpl +++ b/hw/ip/otp_ctrl/data/otp_ctrl_scoreboard.sv.tpl @@ -580,7 +580,7 @@ class otp_ctrl_scoreboard #(type CFG_T = otp_ctrl_env_cfg) ecc_err = read_a_word_with_ecc_raw(dai_addr, read_out); end - if (cfg.en_cov) begin + if (part_has_digest(part_idx) && cfg.en_cov) begin cov.unbuf_access_lock_cg_wrap[part_idx].sample(.read_lock(0), .write_lock(get_digest_reg_val(part_idx) != 0), .is_write(0)); end @@ -712,7 +712,7 @@ class otp_ctrl_scoreboard #(type CFG_T = otp_ctrl_env_cfg) cov.dai_access_secret2_cg.sample( !(cfg.otp_ctrl_vif.lc_creator_seed_sw_rw_en_i != lc_ctrl_pkg::On), dai_cmd_e'(item.a_data)); - end else if (is_sw_part_idx(part_idx) && + end else if (is_sw_part_idx(part_idx) && part_has_digest(part_idx) && item.a_data inside {DaiRead, DaiWrite}) begin cov.unbuf_access_lock_cg_wrap[part_idx].sample(.read_lock(sw_read_lock), .write_lock(get_digest_reg_val(part_idx) != 0), @@ -787,7 +787,7 @@ class otp_ctrl_scoreboard #(type CFG_T = otp_ctrl_env_cfg) bit[TL_AW-1:0] otp_addr = get_scb_otp_addr(); bit is_write_locked; // check if write locked - if (PartInfo[part_idx].hw_digest || PartInfo[part_idx].sw_digest) begin + if (part_has_digest(part_idx)) begin is_write_locked = get_digest_reg_val(part_idx) != 0; end else begin is_write_locked = 0; @@ -1158,8 +1158,7 @@ class otp_ctrl_scoreboard #(type CFG_T = otp_ctrl_env_cfg) if (cfg.otp_ctrl_vif.under_error_states()) return; - if (get_digest_reg_val(part_idx) != 0 || - part_idx inside {VendorTestIdx, CreatorSwCfgIdx, OwnerSwCfgIdx, LifeCycleIdx}) begin + if (!part_has_hw_digest(part_idx) || get_digest_reg_val(part_idx) != 0) begin predict_err(OtpDaiErrIdx, OtpAccessError); return; end else if (PartInfo[part_idx].iskeymgr && diff --git a/hw/ip/otp_ctrl/dv/env/otp_ctrl_env_pkg.sv b/hw/ip/otp_ctrl/dv/env/otp_ctrl_env_pkg.sv index 54e44e9af6c81..cecd06cb0275e 100644 --- a/hw/ip/otp_ctrl/dv/env/otp_ctrl_env_pkg.sv +++ b/hw/ip/otp_ctrl/dv/env/otp_ctrl_env_pkg.sv @@ -183,6 +183,14 @@ package otp_ctrl_env_pkg; return PartInfo[part_index].secret; endfunction + function automatic bit part_has_digest(int part_idx); + return PartInfo[part_idx].hw_digest || PartInfo[part_idx].sw_digest; + endfunction + + function automatic bit part_has_hw_digest(int part_idx); + return PartInfo[part_idx].hw_digest; + endfunction + function automatic bit is_sw_digest(bit [TL_DW-1:0] addr); int part_idx = get_part_index(addr); if (PartInfo[part_idx].sw_digest) begin diff --git a/hw/ip/otp_ctrl/dv/env/otp_ctrl_scoreboard.sv b/hw/ip/otp_ctrl/dv/env/otp_ctrl_scoreboard.sv index 63f7c900b29fe..cd2d10f91b202 100644 --- a/hw/ip/otp_ctrl/dv/env/otp_ctrl_scoreboard.sv +++ b/hw/ip/otp_ctrl/dv/env/otp_ctrl_scoreboard.sv @@ -575,7 +575,7 @@ class otp_ctrl_scoreboard #(type CFG_T = otp_ctrl_env_cfg) ecc_err = read_a_word_with_ecc_raw(dai_addr, read_out); end - if (cfg.en_cov) begin + if (part_has_digest(part_idx) && cfg.en_cov) begin cov.unbuf_access_lock_cg_wrap[part_idx].sample(.read_lock(0), .write_lock(get_digest_reg_val(part_idx) != 0), .is_write(0)); end @@ -702,7 +702,7 @@ class otp_ctrl_scoreboard #(type CFG_T = otp_ctrl_env_cfg) cov.dai_access_secret2_cg.sample( !(cfg.otp_ctrl_vif.lc_creator_seed_sw_rw_en_i != lc_ctrl_pkg::On), dai_cmd_e'(item.a_data)); - end else if (is_sw_part_idx(part_idx) && + end else if (is_sw_part_idx(part_idx) && part_has_digest(part_idx) && item.a_data inside {DaiRead, DaiWrite}) begin cov.unbuf_access_lock_cg_wrap[part_idx].sample(.read_lock(sw_read_lock), .write_lock(get_digest_reg_val(part_idx) != 0), @@ -777,7 +777,7 @@ class otp_ctrl_scoreboard #(type CFG_T = otp_ctrl_env_cfg) bit[TL_AW-1:0] otp_addr = get_scb_otp_addr(); bit is_write_locked; // check if write locked - if (PartInfo[part_idx].hw_digest || PartInfo[part_idx].sw_digest) begin + if (part_has_digest(part_idx)) begin is_write_locked = get_digest_reg_val(part_idx) != 0; end else begin is_write_locked = 0; @@ -1252,8 +1252,7 @@ class otp_ctrl_scoreboard #(type CFG_T = otp_ctrl_env_cfg) if (cfg.otp_ctrl_vif.under_error_states()) return; - if (get_digest_reg_val(part_idx) != 0 || - part_idx inside {VendorTestIdx, CreatorSwCfgIdx, OwnerSwCfgIdx, LifeCycleIdx}) begin + if (!part_has_hw_digest(part_idx) || get_digest_reg_val(part_idx) != 0) begin predict_err(OtpDaiErrIdx, OtpAccessError); return; end else if (PartInfo[part_idx].iskeymgr &&