Skip to content
Closed
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
5 changes: 3 additions & 2 deletions hw/ip/kmac/data/kmac.hjson
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
}
{ name: "NumAppIntf"
type: "int"
default: "3"
default: "4"
desc: "Number of application interfaces"
local: "false"
expose: "true"
Expand All @@ -144,7 +144,7 @@
'''
type: "kmac_pkg::app_config_t"
unpacked_dimensions: "[KmacNumAppIntf]"
default: "'{kmac_pkg::AppCfgKeyMgr, kmac_pkg::AppCfgLcCtrl, kmac_pkg::AppCfgRomCtrl}"
default: "'{kmac_pkg::AppCfgKeyMgr, kmac_pkg::AppCfgLcCtrl, kmac_pkg::AppCfgRomCtrl, kmac_pkg::AppCfgOtbn}"
local: "false"
expose: "true"
}
Expand Down Expand Up @@ -222,6 +222,7 @@
act: "rsp"
package: "kmac_pkg"
width: "NumAppIntf"
default: "kmac_pkg::APP_REQ_DEFAULT"
}
{ struct: "edn"
type: "req_rsp"
Expand Down
4 changes: 4 additions & 0 deletions hw/ip/kmac/doc/kmac-data-path.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
582 changes: 516 additions & 66 deletions hw/ip/kmac/doc/theory_of_operation.md

Large diffs are not rendered by default.

16 changes: 0 additions & 16 deletions hw/ip/kmac/lint/kmac.waiver
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,3 @@ waive -rules {TAG_OVERLAP} -location {kmac_app.sv} \
waive -rules {INTEGER} -location {kmac_entropy.sv} \
-regexp {'i' of type int used as a non-constant value} \
-comment "int i is compared with the storage_idx"

waive -rules {CASE_SEL_EXPR} -location {kmac_app.sv} \
-comment "not a problem, just a suggested alternate implementation"

waive -rules TWO_STATE_TYPE -location {kmac_pkg.sv} \
-regexp {'PrefixMode' is of two state type} \
-comment "Enum bit is used as a generate selection. OK to be two state"
waive -rules TWO_STATE_TYPE -location {kmac_pkg.sv} \
-regexp {'app_mode_e' is of two state type} \
-comment "Enum bit is used in ifs only. OK to be two state"
waive -rules TWO_STATE_TYPE -location {kmac_pkg.sv} \
-regexp {'Mode' is of two state type} \
-comment "Enum bit is used in ifs only. OK to be two state"
waive -rules TWO_STATE_TYPE -location {kmac_pkg.sv} \
-regexp {'app_config_t' is of type struct which contains two state type field} \
-comment "Struct fields waived separately. OK to be two state"
44 changes: 28 additions & 16 deletions hw/ip/kmac/rtl/kmac.sv
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ module kmac

// Accept SW message when idle and before receiving a START command. Useful for SCA only.
parameter bit SecIdleAcceptSwMsg = 1'b0,
parameter int unsigned NumAppIntf = 3,
parameter app_config_t AppCfg[NumAppIntf] = '{AppCfgKeyMgr, AppCfgLcCtrl, AppCfgRomCtrl},
parameter int unsigned NumAppIntf = 4,
parameter app_config_t AppCfg[NumAppIntf] = '{AppCfgKeyMgr, AppCfgLcCtrl,
AppCfgRomCtrl, AppCfgOtbn},

parameter lfsr_perm_t RndCnstLfsrPerm = RndCnstLfsrPermDefault,
parameter lfsr_seed_t RndCnstLfsrSeed = RndCnstLfsrSeedDefault,
Expand Down Expand Up @@ -153,7 +154,7 @@ module kmac

// SHA3 core control signals and its response.
// Sequence: start --> process(multiple) --> get absorbed event --> {run -->} done
logic sha3_start, sha3_run, unused_sha3_squeeze;
logic sha3_start, sha3_run, sha3_squeezing;
prim_mubi_pkg::mubi4_t sha3_done;
prim_mubi_pkg::mubi4_t sha3_done_d;
prim_mubi_pkg::mubi4_t sha3_absorbed;
Expand Down Expand Up @@ -240,6 +241,7 @@ module kmac
logic [kmac_pkg::MsgWidth-1:0] mux2fifo_data[Share];
logic [kmac_pkg::MsgWidth-1:0] mux2fifo_strb;
logic mux2fifo_ready;
logic mux2fifo_bypass;

// KMAC to SHA3 core
logic msg_valid ;
Expand Down Expand Up @@ -299,6 +301,7 @@ module kmac

logic entropy_ready;
entropy_mode_e entropy_mode;
logic reg_entropy_fast_process;
logic entropy_fast_process;

prim_mubi_pkg::mubi4_t entropy_configured;
Expand Down Expand Up @@ -540,7 +543,7 @@ module kmac
assign entropy_ready = reg2hw.cfg_shadowed.entropy_ready.q
& reg2hw.cfg_shadowed.entropy_ready.qe;
assign entropy_mode = entropy_mode_e'(reg2hw.cfg_shadowed.entropy_mode.q);
assign entropy_fast_process = reg2hw.cfg_shadowed.entropy_fast_process.q;
assign reg_entropy_fast_process = reg2hw.cfg_shadowed.entropy_fast_process.q;

// msg_mask_en turns on the message LFSR when KMAC is enabled.
assign cfg_msg_mask = reg2hw.cfg_shadowed.msg_mask.q;
Expand Down Expand Up @@ -717,10 +720,12 @@ module kmac
logic counter_error, sha3_count_error, key_index_error;
logic msgfifo_counter_error;
logic kmac_entropy_hash_counter_error;
logic kmac_app_counter_error;
assign counter_error = sha3_count_error
| kmac_entropy_hash_counter_error
| key_index_error
| msgfifo_counter_error;
| msgfifo_counter_error
| kmac_app_counter_error;

assign msgfifo_counter_error = msgfifo_err.valid;

Expand Down Expand Up @@ -957,7 +962,7 @@ module kmac
.lc_escalate_en_i (lc_escalate_en[2]),

.absorbed_o (sha3_absorbed),
.squeezing_o (unused_sha3_squeeze),
.squeezing_o (sha3_squeezing),

.block_processed_o (sha3_block_processed),

Expand Down Expand Up @@ -1076,10 +1081,11 @@ module kmac
.key_valid_o (key_valid),

// to MSG_FIFO
.kmac_valid_o (mux2fifo_valid),
.kmac_data_o (mux2fifo_data),
.kmac_strb_o (mux2fifo_strb),
.kmac_ready_i (mux2fifo_ready),
.kmac_valid_o (mux2fifo_valid),
.kmac_data_o (mux2fifo_data),
.kmac_strb_o (mux2fifo_strb),
.kmac_ready_i (mux2fifo_ready),
.kmac_bypass_fifo_o(mux2fifo_bypass),

// to KMAC Core
.kmac_en_o (app_kmac_en),
Expand All @@ -1100,11 +1106,15 @@ module kmac
// Configuration: Sideloaded Key
.keymgr_key_en_i (reg2hw.cfg_shadowed.sideload.q),

.absorbed_i (sha3_absorbed), // from SHA3
.absorbed_o (app_absorbed), // to SW
.absorbed_i (sha3_absorbed), // from SHA3
.squeezing_i(sha3_squeezing), // from SHA3
.absorbed_o (app_absorbed), // to SW

.app_active_o(app_active),

.entropy_fast_process_i(reg_entropy_fast_process),
.entropy_fast_process_o(entropy_fast_process),

.error_i (sha3_err.valid),
.err_processed_i (err_processed),

Expand All @@ -1122,8 +1132,8 @@ module kmac

// Error report
.error_o (app_err),
.sparse_fsm_error_o (kmac_app_state_error)

.sparse_fsm_error_o (kmac_app_state_error),
.counter_error_o (kmac_app_counter_error)
);

// Message FIFO
Expand All @@ -1139,7 +1149,7 @@ module kmac
.fifo_data_i (mux2fifo_data),
.fifo_strb_i (mux2fifo_strb),
.fifo_ready_o (mux2fifo_ready),
.fifo_bypass_i('0),
.fifo_bypass_i(mux2fifo_bypass),

.msg_valid_o (msgfifo_valid),
.msg_data_o (msgfifo_data),
Expand All @@ -1161,7 +1171,7 @@ module kmac
logic [sha3_pkg::StateW-1:0] reg_state_tl [Share];
always_comb begin
for (int i = 0 ; i < Share; i++) begin
reg_state_tl[i] = reg_state_valid ? reg_state[i] : 'b0;
reg_state_tl[i] = reg_state_valid ? reg_state[i] : '0;
end
end

Expand Down Expand Up @@ -1550,6 +1560,8 @@ module kmac
alert_tx_o[1])
`ASSERT_PRIM_COUNT_ERROR_TRIGGER_ALERT(KeyIndexCountCheck_A, u_kmac_core.u_key_index_count,
alert_tx_o[1])
`ASSERT_PRIM_COUNT_ERROR_TRIGGER_ALERT(AppDigestCountCheck_A, u_app_intf.u_digest_part_counter,
alert_tx_o[1])

// Sparse FSM state error
`ASSERT_PRIM_FSM_ERROR_TRIGGER_ALERT(KmacCoreFsmCheck_A, u_kmac_core.u_state_regs, alert_tx_o[1])
Expand Down
Loading
Loading