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

Update coverage file and updated max memory depth #68

Merged
merged 16 commits into from
Jan 16, 2025
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
2 changes: 1 addition & 1 deletion .github/workflow_metadata/pr_hash
Original file line number Diff line number Diff line change
@@ -1 +1 @@
73ce940014b3267d66a729044d8baf1891c7a480835c20a37bfae6c5616d29fc656eb4941d9c293b685dfacafc6849bf
262f889638446963350fcd9f236d7e0f4a633d8ad83ac827fd3ca61a065b1a8ee5c55f9e77fbd20b612f0a7bc0fce614
2 changes: 1 addition & 1 deletion .github/workflow_metadata/pr_timestamp
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1736372754
1737070946
5 changes: 0 additions & 5 deletions src/mldsa_top/config/compile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,6 @@ targets:
- $COMPILE_ROOT/rtl/mldsa_top.sv
- $COMPILE_ROOT/rtl/mldsa_reg.sv
tops: [mldsa_top]
rtl_lint:
rtl_lint:
waiver_files:
- $MSFT_REPO_ROOT/src/mldsa_top/config/design_lint/sglint_waivers
options: []
global:
tool:
vcs:
Expand Down
91 changes: 49 additions & 42 deletions src/mldsa_top/coverage/mldsa_top_cov_if.sv
Original file line number Diff line number Diff line change
Expand Up @@ -17,44 +17,42 @@
interface mldsa_top_cov_if
(
input logic clk,
input logic reset_n,
input logic cptra_pwrgood
input logic rst_b

);

logic [2 : 0] mldsa_cmd;
logic [2 : 0] mldsa_sw_cmd;
logic zeroize;
// logic pcr_sign_mode;
logic pcr_sign_mode;
logic ready;
logic valid;

logic mldsa_privkey_lock;

logic error_flag;
// logic privkey_input_outofrange;
// logic r_output_outofrange;
// logic s_output_outofrange;
// logic r_input_outofrange;
// logic s_input_outofrange;
// logic pubkeyx_input_outofrange;
// logic pubkeyy_input_outofrange;
// logic pubkey_input_invalid;
// logic pcr_sign_input_invalid;
logic pcr_sign_input_invalid;
logic skdecode_error;
logic keygen_process;
logic signing_process;
logic verifying_process;
logic keygen_signing_process;

logic verify_failure;
logic normcheck_failure;
logic [2 : 0] normcheck_mode_failure;
logic makehint_failure;
logic invalid_hint;


assign mldsa_cmd = mldsa_top.mldsa_ctrl_inst.cmd_reg;
// assign pcr_sign_mode = mldsa_top.mldsa_ctrl_inst.pcr_sign_mode;
assign pcr_sign_mode = mldsa_top.mldsa_ctrl_inst.pcr_sign_mode;
assign zeroize = mldsa_top.mldsa_ctrl_inst.zeroize;
assign ready = mldsa_top.mldsa_ctrl_inst.mldsa_ready;
assign valid = mldsa_top.mldsa_ctrl_inst.mldsa_valid_reg;

always_ff @(posedge clk) begin
if (!reset_n) begin
if (!rst_b) begin
mldsa_sw_cmd <= '0;
end
else if (mldsa_top.mldsa_reg_inst.decoded_reg_strb.MLDSA_CTRL && mldsa_top.mldsa_reg_inst.decoded_req_is_wr) begin // SW write
Expand All @@ -64,58 +62,67 @@ interface mldsa_top_cov_if

assign mldsa_privkey_lock = mldsa_top.mldsa_ctrl_inst.mldsa_privkey_lock;

assign error_flag = mldsa_top.mldsa_dsa_ctrl_i.error_flag;
// assign privkey_input_outofrange = mldsa_top.mldsa_dsa_ctrl_i.privkey_input_outofrange;
// assign r_output_outofrange = mldsa_top.mldsa_dsa_ctrl_i.r_output_outofrange;
// assign s_output_outofrange = mldsa_top.mldsa_dsa_ctrl_i.s_output_outofrange;
// assign r_input_outofrange = mldsa_top.mldsa_dsa_ctrl_i.r_input_outofrange;
// assign s_input_outofrange = mldsa_top.mldsa_dsa_ctrl_i.s_input_outofrange;
// assign pubkeyx_input_outofrange = mldsa_top.mldsa_dsa_ctrl_i.pubkeyx_input_outofrange;
// assign pubkeyy_input_outofrange = mldsa_top.mldsa_dsa_ctrl_i.pubkeyy_input_outofrange;
// assign pubkey_input_invalid = mldsa_top.mldsa_dsa_ctrl_i.pubkey_input_invalid;
// assign pcr_sign_input_invalid = mldsa_top.mldsa_dsa_ctrl_i.pcr_sign_input_invalid;
assign error_flag = mldsa_top.mldsa_ctrl_inst.error_flag;
assign pcr_sign_input_invalid = mldsa_top.mldsa_ctrl_inst.pcr_sign_input_invalid;
assign skdecode_error = mldsa_top.mldsa_ctrl_inst.skdecode_error_i;

assign keygen_process = mldsa_top.mldsa_ctrl_inst.keygen_process;
assign signing_process = mldsa_top.mldsa_ctrl_inst.signing_process;
assign verifying_process = mldsa_top.mldsa_ctrl_inst.verifying_process;
assign keygen_signing_process = mldsa_top.mldsa_ctrl_inst.keygen_signing_process;

assign verify_failure = mldsa_top.mldsa_ctrl_inst.clear_verify_valid;
assign normcheck_failure = mldsa_top.mldsa_ctrl_inst.normcheck_done_i & mldsa_top.mldsa_ctrl_inst.normcheck_invalid_i;
assign normcheck_mode_failure[0] = normcheck_failure & (mldsa_top.mldsa_ctrl_inst.normcheck_mode_o == 2'b00);
assign normcheck_mode_failure[1] = normcheck_failure & (mldsa_top.mldsa_ctrl_inst.normcheck_mode_o == 2'b01);
assign normcheck_mode_failure[2] = normcheck_failure & (mldsa_top.mldsa_ctrl_inst.normcheck_mode_o == 2'b10);
assign makehint_failure = mldsa_top.mldsa_ctrl_inst.makehint_done_i & mldsa_top.mldsa_ctrl_inst.makehint_invalid_i;
assign invalid_hint = mldsa_top.mldsa_ctrl_inst.sigdecode_h_invalid_i;

covergroup mldsa_top_cov_grp @(posedge clk);
reset_cp: coverpoint reset_n;
cptra_pwrgood_cp: coverpoint cptra_pwrgood;
reset_cp: coverpoint rst_b;

mldsa_cmd_cp: coverpoint mldsa_cmd;
// pcr_sign_cp: coverpoint pcr_sign_mode;
pcr_sign_cp: coverpoint pcr_sign_mode;
zeroize_cp: coverpoint zeroize;
ready_cp: coverpoint ready;
valid_cp: coverpoint valid;

mldsa_privkey_lock_cp: coverpoint mldsa_privkey_lock;

error_flag_cp: coverpoint error_flag;
// privkey_input_outofrange_cp: coverpoint privkey_input_outofrange;
// r_output_outofrange_cp: coverpoint r_output_outofrange;
// s_output_outofrange_cp: coverpoint s_output_outofrange;
// r_input_outofrange_cp: coverpoint r_input_outofrange;
// s_input_outofrange_cp: coverpoint s_input_outofrange;
// pubkeyx_input_outofrange_cp: coverpoint pubkeyx_input_outofrange;
// pubkeyy_input_outofrange_cp: coverpoint pubkeyy_input_outofrange;
// pubkey_input_invalid_cp: coverpoint pubkey_input_invalid;
// pcr_sign_input_invalid_cp: coverpoint pcr_sign_input_invalid;

// cmd_ready_cp: cross mldsa_sw_cmd, ready;
pcr_sign_input_invalid_cp: coverpoint pcr_sign_input_invalid;
skdecode_error_cp: coverpoint skdecode_error;
verify_failure_cp: coverpoint verify_failure;
normcheck_mode_failure_sign_cp: coverpoint normcheck_mode_failure {
bins mode_0 = {0};
bins mode_1 = {1};
bins mode_2 = {2};
}
normcheck_mode_failure_verify_cp: coverpoint normcheck_mode_failure {
bins mode_0 = {0};
}
makehint_failure_cp: coverpoint makehint_failure;
invalid_hint_cp: coverpoint invalid_hint;

cmd_ready_cp: cross mldsa_sw_cmd, ready;
cmd_kv_cp: cross mldsa_cmd, mldsa_privkey_lock;
// pcr_ready_cp: cross ready, pcr_sign_mode;
// pcr_cmd_cp: cross pcr_sign_mode, mldsa_cmd;
// zeroize_pcr_cp: cross zeroize, pcr_sign_mode;
pcr_ready_cp: cross ready, pcr_sign_mode;
pcr_cmd_cp: cross pcr_sign_mode, mldsa_cmd;
zeroize_pcr_cp: cross zeroize, pcr_sign_mode;
zeroize_cmd_cp: cross zeroize, mldsa_cmd;
zeroize_error_cp: cross zeroize, error_flag;
zeroize_ready_cp: cross ready, zeroize;
// pcr_sign_input_invalid_cmd_cp: cross error_flag, mldsa_cmd;
pcr_sign_input_invalid_cmd_cp: cross error_flag, mldsa_cmd;
error_keygen_cp: cross error_flag, keygen_process;
error_signing_cp: cross error_flag, signing_process;
error_verifying_cp: cross error_flag, verifying_process;
error_keygen_signing_cp: cross error_flag, keygen_signing_process;

normcheck_signing_failure_cp: cross normcheck_mode_failure_sign_cp, signing_process;
normcheck_verifying_failure_cp: cross normcheck_mode_failure_verify_cp, verifying_process;
normcheck_pcr_failure_cp: cross normcheck_mode_failure_sign_cp, pcr_sign_mode;
makehint_pcr_failure_cp: cross makehint_failure, pcr_sign_mode;

endgroup

Expand Down
2 changes: 1 addition & 1 deletion src/mldsa_top/rtl/mldsa_params_pkg.sv
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ package mldsa_params_pkg;
parameter COEFF_PER_CLK = 4;

//Memory interface - FIXME calculate the width based on depth not the other way
parameter MLDSA_MEM_MAX_DEPTH = 1664; //FIXME
parameter MLDSA_MEM_MAX_DEPTH = 1408; //FIXME
parameter MLDSA_MEM_DATA_WIDTH = COEFF_PER_CLK * MLDSA_Q_WIDTH;
parameter MLDSA_MEM_ADDR_WIDTH = $clog2(MLDSA_MEM_MAX_DEPTH) + 3; //+ 3 bits for bank selection

Expand Down