Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[edn] Improve FSM coverage #23092

Merged
merged 3 commits into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 22 additions & 3 deletions hw/ip/edn/dv/env/seq_lib/edn_err_vseq.sv
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ class edn_err_vseq extends edn_base_vseq;
// If EDN is configured in Boot mode, randomly select one of the Boot states.
`DV_CHECK_STD_RANDOMIZE_WITH_FATAL(exp_state,
exp_state inside {BootLoadIns, BootInsAckWait, BootLoadGen,
BootGenAckWait, BootPulse, BootDone};)
BootGenAckWait, BootPulse, BootDone,
BootLoadUni, BootUniAckWait};)
end else if (cfg.auto_req_mode == MuBi4True) begin
// If instead EDN is configured in Auto mode, randomly select one of the Auto states.
`DV_CHECK_STD_RANDOMIZE_WITH_FATAL(exp_state,
Expand All @@ -80,8 +81,10 @@ class edn_err_vseq extends edn_base_vseq;
AutoCaptGenCnt, AutoSendGenCmd,
AutoCaptReseedCnt, AutoSendReseedCmd};)
end else begin
// If EDN is configured neither in Boot nor in Auto mode, select the SW state.
exp_state = SWPortMode;
// If EDN is configured neither in Boot nor in Auto mode, select among the remaining non-idle
// states.
`DV_CHECK_STD_RANDOMIZE_WITH_FATAL(exp_state,
exp_state inside {SWPortMode, RejectCsrngEntropy};)
end

`uvm_info(`gfn, $sformatf("Waiting for main_sm to reach state %s", exp_state.name()), UVM_HIGH)
Expand Down Expand Up @@ -137,6 +140,22 @@ class edn_err_vseq extends edn_base_vseq;
// Set wait_cmd_req_done to 0 since we don't want to wait for the ack.
wr_cmd(.cmd_type(edn_env_pkg::Sw), .acmd(csrng_pkg::INS), .clen(0),
.flags(MuBi4False), .glen(0), .mode(mode), .wait_for_ack(0));
end else if (cfg.boot_req_mode == MuBi4True &&
(exp_state == BootLoadUni || exp_state == BootUniAckWait)) begin
// The Uninstantiate command is automatically sent upon disabling boot mode (after
// entering the BootDone state).
ral.ctrl.boot_req_mode.set(prim_mubi_pkg::MuBi4False);
csr_update(.csr(ral.ctrl));
end
if (exp_state == RejectCsrngEntropy) begin
// Make sure the next CSRNG acknowledgement returns an error status.
cfg.m_csrng_agent_cfg.rsp_sts_err = csrng_pkg::CMD_STS_INVALID_ACMD;
// Trigger a CSRNG acknowledgement. For boot and auto mode, we should eventually get
// a CSRNG command acknowledgement anyway. In SW mode, we could trigger any command.
if (cfg.boot_req_mode != MuBi4True && cfg.auto_req_mode != MuBi4True) begin
wr_cmd(.cmd_type(edn_env_pkg::Sw), .acmd(csrng_pkg::INS), .clen(0),
.flags(MuBi4False), .glen(0), .mode(mode), .wait_for_ack(0));
end
end
end
join_none
Expand Down
8 changes: 5 additions & 3 deletions hw/ip/edn/rtl/edn_core.sv
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ module edn_core import edn_pkg::*;

// CSRNG acknowledgement error status
assign csrng_ack_err = edn_enable_fo[CsrngAckErr] &&
csrng_cmd_i.csrng_rsp_sts && csrng_cmd_i.csrng_rsp_ack;
csrng_cmd_i.csrng_rsp_ack && (csrng_cmd_i.csrng_rsp_sts != csrng_pkg::CMD_STS_SUCCESS);
assign hw2reg.recov_alert_sts.csrng_ack_err.de = csrng_ack_err;
assign hw2reg.recov_alert_sts.csrng_ack_err.d = csrng_ack_err;

Expand Down Expand Up @@ -608,7 +608,8 @@ module edn_core import edn_pkg::*;
!edn_enable_fo[HwCmdSts] ? csrng_pkg::CMD_STS_SUCCESS :
sw_cmd_valid ? csrng_hw_cmd_sts_q :
(cs_cmd_req_vld_out_q && csrng_cmd_i.csrng_req_ready) ? csrng_pkg::CMD_STS_SUCCESS :
csrng_cmd_i.csrng_rsp_ack && csrng_cmd_i.csrng_rsp_sts ? csrng_cmd_i.csrng_rsp_sts :
csrng_cmd_i.csrng_rsp_ack && (csrng_cmd_i.csrng_rsp_sts != csrng_pkg::CMD_STS_SUCCESS) ?
csrng_cmd_i.csrng_rsp_sts :
csrng_hw_cmd_sts_q;
// Set the cmd_ack signal to high whenever a hardware command is acknowledged and set it
// to low whenever a new hardware command is issued to the CSRNG.
Expand Down Expand Up @@ -857,7 +858,8 @@ module edn_core import edn_pkg::*;

assign packer_cs_clr = !edn_enable_fo[CsrngPackerClr];
assign packer_cs_push = csrng_cmd_i.genbits_valid && !reject_csrng_entropy &&
!(csrng_cmd_i.csrng_rsp_sts && csrng_cmd_i.csrng_rsp_ack);
!((csrng_cmd_i.csrng_rsp_sts != csrng_pkg::CMD_STS_SUCCESS) &&
csrng_cmd_i.csrng_rsp_ack);
assign packer_cs_wdata = csrng_cmd_i.genbits_bus;
assign csrng_cmd_o.genbits_ready = packer_cs_wready && !reject_csrng_entropy;
assign packer_cs_rready = packer_arb_valid;
Expand Down
9 changes: 5 additions & 4 deletions hw/ip/edn/rtl/edn_main_sm.sv
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
//
// does hardware-based csrng app interface command requests

module edn_main_sm import edn_pkg::*; #(
localparam int StateWidth = 9
) (
module edn_main_sm import edn_pkg::*;
(
input logic clk_i,
input logic rst_ni,

Expand Down Expand Up @@ -181,7 +180,9 @@ module edn_main_sm import edn_pkg::*; #(
endcase

if (local_escalate_i || csrng_ack_err_i) begin
state_d = local_escalate_i ? Error : RejectCsrngEntropy;
// Either move into RejectCsrngEntropy or Error but don't move out of Error as it's terminal.
state_d = local_escalate_i ? Error :
state_q == Error ? Error : RejectCsrngEntropy;
Comment on lines +183 to +185

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great that you caught that.

// Tie off outputs, except for main_sm_err_o and reject_csrng_entropy_o.
boot_wr_ins_cmd_o = 1'b0;
boot_wr_gen_cmd_o = 1'b0;
Expand Down