Skip to content

Commit c61901b

Browse files
committed
[kmac,rtl] Implement the dynamic app interface
Signed-off-by: Pascal Etterli <pascal.etterli@lowrisc.org>
1 parent 176e986 commit c61901b

8 files changed

Lines changed: 1043 additions & 502 deletions

File tree

hw/ip/kmac/data/kmac.hjson

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@
133133
}
134134
{ name: "NumAppIntf"
135135
type: "int"
136-
default: "3"
136+
default: "4"
137137
desc: "Number of application interfaces"
138138
local: "false"
139139
expose: "true"
@@ -144,7 +144,7 @@
144144
'''
145145
type: "kmac_pkg::app_config_t"
146146
unpacked_dimensions: "[KmacNumAppIntf]"
147-
default: "'{kmac_pkg::AppCfgKeyMgr, kmac_pkg::AppCfgLcCtrl, kmac_pkg::AppCfgRomCtrl}"
147+
default: "'{kmac_pkg::AppCfgKeyMgr, kmac_pkg::AppCfgLcCtrl, kmac_pkg::AppCfgRomCtrl, kmac_pkg::AppCfgOtbn}"
148148
local: "false"
149149
expose: "true"
150150
}
@@ -222,6 +222,7 @@
222222
act: "rsp"
223223
package: "kmac_pkg"
224224
width: "NumAppIntf"
225+
default: "kmac_pkg::APP_REQ_DEFAULT"
225226
}
226227
{ struct: "edn"
227228
type: "req_rsp"

hw/ip/kmac/lint/kmac.waiver

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,3 @@ waive -rules {TAG_OVERLAP} -location {kmac_app.sv} \
2626
waive -rules {INTEGER} -location {kmac_entropy.sv} \
2727
-regexp {'i' of type int used as a non-constant value} \
2828
-comment "int i is compared with the storage_idx"
29-
30-
waive -rules {CASE_SEL_EXPR} -location {kmac_app.sv} \
31-
-comment "not a problem, just a suggested alternate implementation"
32-
33-
waive -rules TWO_STATE_TYPE -location {kmac_pkg.sv} \
34-
-regexp {'PrefixMode' is of two state type} \
35-
-comment "Enum bit is used as a generate selection. OK to be two state"
36-
waive -rules TWO_STATE_TYPE -location {kmac_pkg.sv} \
37-
-regexp {'app_mode_e' is of two state type} \
38-
-comment "Enum bit is used in ifs only. OK to be two state"
39-
waive -rules TWO_STATE_TYPE -location {kmac_pkg.sv} \
40-
-regexp {'Mode' is of two state type} \
41-
-comment "Enum bit is used in ifs only. OK to be two state"
42-
waive -rules TWO_STATE_TYPE -location {kmac_pkg.sv} \
43-
-regexp {'app_config_t' is of type struct which contains two state type field} \
44-
-comment "Struct fields waived separately. OK to be two state"

hw/ip/kmac/rtl/kmac.sv

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@ module kmac
2929

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

3536
parameter lfsr_perm_t RndCnstLfsrPerm = RndCnstLfsrPermDefault,
3637
parameter lfsr_seed_t RndCnstLfsrSeed = RndCnstLfsrSeedDefault,
@@ -153,7 +154,7 @@ module kmac
153154

154155
// SHA3 core control signals and its response.
155156
// Sequence: start --> process(multiple) --> get absorbed event --> {run -->} done
156-
logic sha3_start, sha3_run, unused_sha3_squeeze;
157+
logic sha3_start, sha3_run, sha3_squeezing;
157158
prim_mubi_pkg::mubi4_t sha3_done;
158159
prim_mubi_pkg::mubi4_t sha3_done_d;
159160
prim_mubi_pkg::mubi4_t sha3_absorbed;
@@ -240,6 +241,7 @@ module kmac
240241
logic [kmac_pkg::MsgWidth-1:0] mux2fifo_data[Share];
241242
logic [kmac_pkg::MsgWidth-1:0] mux2fifo_strb;
242243
logic mux2fifo_ready;
244+
logic mux2fifo_bypass;
243245

244246
// KMAC to SHA3 core
245247
logic msg_valid ;
@@ -299,6 +301,7 @@ module kmac
299301

300302
logic entropy_ready;
301303
entropy_mode_e entropy_mode;
304+
logic reg_entropy_fast_process;
302305
logic entropy_fast_process;
303306

304307
prim_mubi_pkg::mubi4_t entropy_configured;
@@ -540,7 +543,7 @@ module kmac
540543
assign entropy_ready = reg2hw.cfg_shadowed.entropy_ready.q
541544
& reg2hw.cfg_shadowed.entropy_ready.qe;
542545
assign entropy_mode = entropy_mode_e'(reg2hw.cfg_shadowed.entropy_mode.q);
543-
assign entropy_fast_process = reg2hw.cfg_shadowed.entropy_fast_process.q;
546+
assign reg_entropy_fast_process = reg2hw.cfg_shadowed.entropy_fast_process.q;
544547

545548
// msg_mask_en turns on the message LFSR when KMAC is enabled.
546549
assign cfg_msg_mask = reg2hw.cfg_shadowed.msg_mask.q;
@@ -717,10 +720,12 @@ module kmac
717720
logic counter_error, sha3_count_error, key_index_error;
718721
logic msgfifo_counter_error;
719722
logic kmac_entropy_hash_counter_error;
723+
logic kmac_app_counter_error;
720724
assign counter_error = sha3_count_error
721725
| kmac_entropy_hash_counter_error
722726
| key_index_error
723-
| msgfifo_counter_error;
727+
| msgfifo_counter_error
728+
| kmac_app_counter_error;
724729

725730
assign msgfifo_counter_error = msgfifo_err.valid;
726731

@@ -957,7 +962,7 @@ module kmac
957962
.lc_escalate_en_i (lc_escalate_en[2]),
958963

959964
.absorbed_o (sha3_absorbed),
960-
.squeezing_o (unused_sha3_squeeze),
965+
.squeezing_o (sha3_squeezing),
961966

962967
.block_processed_o (sha3_block_processed),
963968

@@ -1076,10 +1081,11 @@ module kmac
10761081
.key_valid_o (key_valid),
10771082

10781083
// to MSG_FIFO
1079-
.kmac_valid_o (mux2fifo_valid),
1080-
.kmac_data_o (mux2fifo_data),
1081-
.kmac_strb_o (mux2fifo_strb),
1082-
.kmac_ready_i (mux2fifo_ready),
1084+
.kmac_valid_o (mux2fifo_valid),
1085+
.kmac_data_o (mux2fifo_data),
1086+
.kmac_strb_o (mux2fifo_strb),
1087+
.kmac_ready_i (mux2fifo_ready),
1088+
.kmac_bypass_fifo_o(mux2fifo_bypass),
10831089

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

1103-
.absorbed_i (sha3_absorbed), // from SHA3
1104-
.absorbed_o (app_absorbed), // to SW
1109+
.absorbed_i (sha3_absorbed), // from SHA3
1110+
.squeezing_i(sha3_squeezing), // from SHA3
1111+
.absorbed_o (app_absorbed), // to SW
11051112

11061113
.app_active_o(app_active),
11071114

1115+
.entropy_fast_process_i(reg_entropy_fast_process),
1116+
.entropy_fast_process_o(entropy_fast_process),
1117+
11081118
.error_i (sha3_err.valid),
11091119
.err_processed_i (err_processed),
11101120

@@ -1122,8 +1132,8 @@ module kmac
11221132

11231133
// Error report
11241134
.error_o (app_err),
1125-
.sparse_fsm_error_o (kmac_app_state_error)
1126-
1135+
.sparse_fsm_error_o (kmac_app_state_error),
1136+
.counter_error_o (kmac_app_counter_error)
11271137
);
11281138

11291139
// Message FIFO
@@ -1139,7 +1149,7 @@ module kmac
11391149
.fifo_data_i (mux2fifo_data),
11401150
.fifo_strb_i (mux2fifo_strb),
11411151
.fifo_ready_o (mux2fifo_ready),
1142-
.fifo_bypass_i('0),
1152+
.fifo_bypass_i(mux2fifo_bypass),
11431153

11441154
.msg_valid_o (msgfifo_valid),
11451155
.msg_data_o (msgfifo_data),
@@ -1161,7 +1171,7 @@ module kmac
11611171
logic [sha3_pkg::StateW-1:0] reg_state_tl [Share];
11621172
always_comb begin
11631173
for (int i = 0 ; i < Share; i++) begin
1164-
reg_state_tl[i] = reg_state_valid ? reg_state[i] : 'b0;
1174+
reg_state_tl[i] = reg_state_valid ? reg_state[i] : '0;
11651175
end
11661176
end
11671177

@@ -1550,6 +1560,8 @@ module kmac
15501560
alert_tx_o[1])
15511561
`ASSERT_PRIM_COUNT_ERROR_TRIGGER_ALERT(KeyIndexCountCheck_A, u_kmac_core.u_key_index_count,
15521562
alert_tx_o[1])
1563+
`ASSERT_PRIM_COUNT_ERROR_TRIGGER_ALERT(AppDigestCountCheck_A, u_app_intf.u_digest_part_counter,
1564+
alert_tx_o[1])
15531565

15541566
// Sparse FSM state error
15551567
`ASSERT_PRIM_FSM_ERROR_TRIGGER_ALERT(KmacCoreFsmCheck_A, u_kmac_core.u_state_regs, alert_tx_o[1])

0 commit comments

Comments
 (0)