Skip to content

Commit

Permalink
[otp_ctrl] Make ERR_CODE register non-compact
Browse files Browse the repository at this point in the history
This allows us to write more parametric DIF code.

Signed-off-by: Michael Schaffner <[email protected]>
  • Loading branch information
msfschaffner committed Jan 20, 2024
1 parent ff3724e commit bf9b50a
Show file tree
Hide file tree
Showing 12 changed files with 487 additions and 378 deletions.
1 change: 1 addition & 0 deletions hw/ip/otp_ctrl/data/otp_ctrl.hjson
Original file line number Diff line number Diff line change
Expand Up @@ -1773,6 +1773,7 @@
hwaccess: "hwo",
hwext: "true",
cname: "AGENT",
compact: "false",
resval: 0,
tags: [ // OTP internal HW can modify the error code registers
"excl:CsrAllTests:CsrExclCheck"],
Expand Down
1 change: 1 addition & 0 deletions hw/ip/otp_ctrl/data/otp_ctrl.hjson.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,7 @@
hwaccess: "hwo",
hwext: "true",
cname: "AGENT",
compact: "false",
resval: 0,
tags: [ // OTP internal HW can modify the error code registers
"excl:CsrAllTests:CsrExclCheck"],
Expand Down
17 changes: 13 additions & 4 deletions hw/ip/otp_ctrl/dv/env/otp_ctrl_env_cov.sv
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,16 @@ class otp_ctrl_csr_rd_after_alert_cg_wrap;
bins direct_access_rdata = {ral.direct_access_rdata[0].get_offset(),
ral.direct_access_rdata[1].get_offset()};
bins status = {ral.status.get_offset()};
bins error_code = {ral.err_code[0].get_offset()};
bins error_code = {ral.err_code[0].get_offset(),
ral.err_code[1].get_offset(),
ral.err_code[2].get_offset(),
ral.err_code[3].get_offset(),
ral.err_code[4].get_offset(),
ral.err_code[5].get_offset(),
ral.err_code[6].get_offset(),
ral.err_code[7].get_offset(),
ral.err_code[8].get_offset(),
ral.err_code[9].get_offset()};
}
endgroup

Expand Down Expand Up @@ -292,9 +301,9 @@ class otp_ctrl_env_cov extends cip_base_env_cov #(.CFG_T(otp_ctrl_env_cfg));

function void collect_err_code_cov(bit [TL_DW-1:0] val, int part_idx = DaiIdx);
dv_base_reg_field err_code_flds[$];
cfg.ral.err_code[0].get_dv_base_reg_fields(err_code_flds);
foreach (err_code_flds[i]) begin
collect_err_code_field_cov(i, get_field_val(err_code_flds[i], val), part_idx);
for (int k = 0; k <= OtpLciErrIdx; k++) begin
cfg.ral.err_code[k].get_dv_base_reg_fields(err_code_flds);
collect_err_code_field_cov(k, get_field_val(err_code_flds[0], val), part_idx);
end
endfunction

Expand Down
15 changes: 8 additions & 7 deletions hw/ip/otp_ctrl/dv/env/otp_ctrl_scoreboard.sv
Original file line number Diff line number Diff line change
Expand Up @@ -902,7 +902,8 @@ class otp_ctrl_scoreboard #(type CFG_T = otp_ctrl_env_cfg)
end
end
end
"err_code": begin
"err_code_0", "err_code_1", "err_code_2", "err_code_3", "err_code_4", "err_code_5",
"err_code_6", "err_code_7", "err_code_8", "err_code_9": begin
// If lc_prog in progress, err_code might update anytime in DUT. Ignore checking until req
// is acknowledged.
if (cfg.m_lc_prog_pull_agent_cfg.vif.req) do_read_check = 0;
Expand Down Expand Up @@ -1218,15 +1219,15 @@ class otp_ctrl_scoreboard #(type CFG_T = otp_ctrl_env_cfg)
if (err_code == OtpNoError) begin
`uvm_error(`gfn, $sformatf("please set status error: %0s error code", status_err_idx.name))
end
ral.err_code[0].get_dv_base_reg_fields(err_code_flds);
ral.err_code[status_err_idx].get_dv_base_reg_fields(err_code_flds);

if (`gmv(err_code_flds[status_err_idx]) inside {OTP_TERMINAL_ERRS}) begin
if (`gmv(err_code_flds[0]) inside {OTP_TERMINAL_ERRS}) begin
`uvm_info(`gfn, "terminal error cannot be updated", UVM_HIGH)
end else if (status_err_idx == OtpLciErrIdx &&
`gmv(err_code_flds[status_err_idx]) != OtpNoError) begin
`gmv(err_code_flds[0]) != OtpNoError) begin
`uvm_info(`gfn, "For LC partition, all errors are terminal error!", UVM_HIGH)
end else begin
void'(err_code_flds[status_err_idx].predict(.value(err_code), .kind(UVM_PREDICT_READ)));
void'(err_code_flds[0].predict(.value(err_code), .kind(UVM_PREDICT_READ)));
end
end

Expand All @@ -1240,8 +1241,8 @@ class otp_ctrl_scoreboard #(type CFG_T = otp_ctrl_env_cfg)

if (status_err_idx <= OtpLciErrIdx) begin
dv_base_reg_field err_code_flds[$];
ral.err_code[0].get_dv_base_reg_fields(err_code_flds);
void'(err_code_flds[status_err_idx].predict(OtpNoError));
ral.err_code[status_err_idx].get_dv_base_reg_fields(err_code_flds);
void'(err_code_flds[0].predict(OtpNoError));
end
endfunction

Expand Down
2 changes: 1 addition & 1 deletion hw/ip/otp_ctrl/dv/env/seq_lib/otp_ctrl_base_vseq.sv
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ class otp_ctrl_base_vseq extends cip_base_vseq #(
forever begin
bit [TL_DW-1:0] err_val;
cfg.clk_rst_vif.wait_clks(1);
csr_rd(.ptr(ral.err_code[0].err_code[7]), .value(err_val), .backdoor(1));
csr_rd(.ptr(ral.err_code[DaiIdx].err_code), .value(err_val), .backdoor(1));
// Break if error will cause fatal alerts
if (err_val inside {OTP_TERMINAL_ERRS}) break;
end
Expand Down
4 changes: 2 additions & 2 deletions hw/ip/otp_ctrl/dv/env/seq_lib/otp_ctrl_init_fail_vseq.sv
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@ class otp_ctrl_init_fail_vseq extends otp_ctrl_smoke_vseq;
OtpCheckFailError : OtpMacroEccUncorrError;
otp_err_code_e err_code;
dv_base_reg_field err_code_flds[$];
ral.err_code[0].get_dv_base_reg_fields(err_code_flds);

cfg.otp_ctrl_vif.drive_pwr_otp_init(1);

Expand All @@ -200,8 +199,9 @@ class otp_ctrl_init_fail_vseq extends otp_ctrl_smoke_vseq;
// escalation. The logic below tries to confirm the first fatal alert is triggered with the
// correct error code.
for (int i = 0; i <= OtpLciErrIdx; i++) begin
ral.err_code[i].get_dv_base_reg_fields(err_code_flds);
if (exp_status[i]) begin
csr_rd(err_code_flds[i], err_code);
csr_rd(err_code_flds[0], err_code);
if (err_code == exp_err_code) begin
error_cnt++;
end else if (err_code != OtpFsmStateError) begin
Expand Down
30 changes: 25 additions & 5 deletions hw/ip/otp_ctrl/dv/env/seq_lib/otp_ctrl_smoke_vseq.sv
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,11 @@ class otp_ctrl_smoke_vseq extends otp_ctrl_base_vseq;

if (do_lc_trans && !cfg.otp_ctrl_vif.alert_reqs) begin
req_lc_transition(do_lc_trans, lc_prog_blocking);
if (cfg.otp_ctrl_vif.lc_prog_req == 0) csr_rd(.ptr(ral.err_code[0]), .value(tlul_val));
if (cfg.otp_ctrl_vif.lc_prog_req == 0) begin
for (int k = 0; k <= LciIdx; k++) begin
csr_rd(.ptr(ral.err_code[k]), .value(tlul_val));
end
end
end

for (int i = 0; i < num_dai_op; i++) begin
Expand All @@ -152,7 +156,11 @@ class otp_ctrl_smoke_vseq extends otp_ctrl_base_vseq;
// OTP write via DAI
if (rand_wr && !digest_calculated[part_idx]) begin
dai_wr(dai_addr, wdata0, wdata1);
if (cfg.otp_ctrl_vif.lc_prog_req == 0) csr_rd(.ptr(ral.err_code[0]), .value(tlul_val));
if (cfg.otp_ctrl_vif.lc_prog_req == 0) begin
for (int k = 0; k <= LciIdx; k++) begin
csr_rd(.ptr(ral.err_code[k]), .value(tlul_val));
end
end
end

// Inject ECC error.
Expand Down Expand Up @@ -186,7 +194,11 @@ class otp_ctrl_smoke_vseq extends otp_ctrl_base_vseq;
if (!$urandom_range(0, 9) && access_locked_parts) write_sw_digests();
if ($urandom_range(0, 1)) csr_rd(.ptr(ral.direct_access_regwen), .value(tlul_val));
if ($urandom_range(0, 1)) csr_rd(.ptr(ral.status), .value(tlul_val));
if (cfg.otp_ctrl_vif.lc_prog_req == 0) csr_rd(.ptr(ral.err_code[0]), .value(tlul_val));
if (cfg.otp_ctrl_vif.lc_prog_req == 0) begin
for (int k = 0; k <= LciIdx; k++) begin
csr_rd(.ptr(ral.err_code[k]), .value(tlul_val));
end
end
end

// Read/write test access memory
Expand All @@ -197,7 +209,11 @@ class otp_ctrl_smoke_vseq extends otp_ctrl_base_vseq;
cal_hw_digests();
if ($urandom_range(0, 1)) csr_rd(.ptr(ral.status), .value(tlul_val));

if (cfg.otp_ctrl_vif.lc_prog_req == 0) csr_rd(.ptr(ral.err_code[0]), .value(tlul_val));
if (cfg.otp_ctrl_vif.lc_prog_req == 0) begin
for (int k = 0; k <= LciIdx; k++) begin
csr_rd(.ptr(ral.err_code[k]), .value(tlul_val));
end
end

if ($urandom_range(0, 1)) rd_digests();
if (do_dut_init) dut_init();
Expand All @@ -208,7 +224,11 @@ class otp_ctrl_smoke_vseq extends otp_ctrl_base_vseq;
// send request to the interfaces again after partitions are locked
if (do_lc_trans && !cfg.otp_ctrl_vif.alert_reqs) begin
req_lc_transition(do_lc_trans, lc_prog_blocking);
if (cfg.otp_ctrl_vif.lc_prog_req == 0) csr_rd(.ptr(ral.err_code[0]), .value(tlul_val));
if (cfg.otp_ctrl_vif.lc_prog_req == 0) begin
for (int k = 0; k <= LciIdx; k++) begin
csr_rd(.ptr(ral.err_code[k]), .value(tlul_val));
end
end
end

if (do_req_keys && !cfg.otp_ctrl_vif.alert_reqs && !cfg.smoke_test) begin
Expand Down
Loading

0 comments on commit bf9b50a

Please sign in to comment.