Skip to content

Commit

Permalink
[otp_ctrl,gen] Fix handling of partitions with digest
Browse files Browse the repository at this point in the history
Signed-off-by: Guillermo Maturana <[email protected]>
  • Loading branch information
matutem authored and msfschaffner committed Jan 25, 2024
1 parent d09cb15 commit 8b416b9
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 10 deletions.
8 changes: 8 additions & 0 deletions hw/ip/otp_ctrl/data/otp_ctrl_env_pkg.sv.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 4 additions & 5 deletions hw/ip/otp_ctrl/data/otp_ctrl_scoreboard.sv.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 &&
Expand Down
8 changes: 8 additions & 0 deletions hw/ip/otp_ctrl/dv/env/otp_ctrl_env_pkg.sv
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 4 additions & 5 deletions hw/ip/otp_ctrl/dv/env/otp_ctrl_scoreboard.sv
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 &&
Expand Down

0 comments on commit 8b416b9

Please sign in to comment.