Skip to content

Commit b68efc3

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

4 files changed

Lines changed: 892 additions & 388 deletions

File tree

hw/ip/kmac/data/kmac.hjson

Lines changed: 2 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
}

hw/ip/kmac/rtl/kmac.sv

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ 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, AppCfgRomCtrl, AppCfgOtbn},
3434

3535
parameter lfsr_perm_t RndCnstLfsrPerm = RndCnstLfsrPermDefault,
3636
parameter lfsr_seed_t RndCnstLfsrSeed = RndCnstLfsrSeedDefault,
@@ -153,7 +153,7 @@ module kmac
153153

154154
// SHA3 core control signals and its response.
155155
// Sequence: start --> process(multiple) --> get absorbed event --> {run -->} done
156-
logic sha3_start, sha3_run, unused_sha3_squeeze;
156+
logic sha3_start, sha3_run, sha3_squeezing;
157157
prim_mubi_pkg::mubi4_t sha3_done;
158158
prim_mubi_pkg::mubi4_t sha3_done_d;
159159
prim_mubi_pkg::mubi4_t sha3_absorbed;
@@ -240,6 +240,7 @@ module kmac
240240
logic [kmac_pkg::MsgWidth-1:0] mux2fifo_data[Share];
241241
logic [kmac_pkg::MsgWidth-1:0] mux2fifo_strb;
242242
logic mux2fifo_ready;
243+
logic mux2fifo_bypass;
243244

244245
// KMAC to SHA3 core
245246
logic msg_valid ;
@@ -717,10 +718,12 @@ module kmac
717718
logic counter_error, sha3_count_error, key_index_error;
718719
logic msgfifo_counter_error;
719720
logic kmac_entropy_hash_counter_error;
721+
logic kmac_app_counter_error;
720722
assign counter_error = sha3_count_error
721723
| kmac_entropy_hash_counter_error
722724
| key_index_error
723-
| msgfifo_counter_error;
725+
| msgfifo_counter_error
726+
| kmac_app_counter_error;
724727

725728
assign msgfifo_counter_error = msgfifo_err.valid;
726729

@@ -957,7 +960,7 @@ module kmac
957960
.lc_escalate_en_i (lc_escalate_en[2]),
958961

959962
.absorbed_o (sha3_absorbed),
960-
.squeezing_o (unused_sha3_squeeze),
963+
.squeezing_o (sha3_squeezing),
961964

962965
.block_processed_o (sha3_block_processed),
963966

@@ -1076,10 +1079,11 @@ module kmac
10761079
.key_valid_o (key_valid),
10771080

10781081
// 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),
1082+
.kmac_valid_o (mux2fifo_valid),
1083+
.kmac_data_o (mux2fifo_data),
1084+
.kmac_strb_o (mux2fifo_strb),
1085+
.kmac_ready_i (mux2fifo_ready),
1086+
.kmac_bypass_fifo_o(mux2fifo_bypass),
10831087

10841088
// to KMAC Core
10851089
.kmac_en_o (app_kmac_en),
@@ -1100,8 +1104,9 @@ module kmac
11001104
// Configuration: Sideloaded Key
11011105
.keymgr_key_en_i (reg2hw.cfg_shadowed.sideload.q),
11021106

1103-
.absorbed_i (sha3_absorbed), // from SHA3
1104-
.absorbed_o (app_absorbed), // to SW
1107+
.absorbed_i (sha3_absorbed), // from SHA3
1108+
.squeezing_i(sha3_squeezing), // from SHA3 TODO: also mubi like absorbed?
1109+
.absorbed_o (app_absorbed), // to SW
11051110

11061111
.app_active_o(app_active),
11071112

@@ -1122,8 +1127,8 @@ module kmac
11221127

11231128
// Error report
11241129
.error_o (app_err),
1125-
.sparse_fsm_error_o (kmac_app_state_error)
1126-
1130+
.sparse_fsm_error_o (kmac_app_state_error),
1131+
.counter_error_o (kmac_app_counter_error)
11271132
);
11281133

11291134
// Message FIFO
@@ -1139,7 +1144,7 @@ module kmac
11391144
.fifo_data_i (mux2fifo_data),
11401145
.fifo_strb_i (mux2fifo_strb),
11411146
.fifo_ready_o (mux2fifo_ready),
1142-
.fifo_bypass_i('0),
1147+
.fifo_bypass_i(mux2fifo_bypass),
11431148

11441149
.msg_valid_o (msgfifo_valid),
11451150
.msg_data_o (msgfifo_data),
@@ -1161,7 +1166,7 @@ module kmac
11611166
logic [sha3_pkg::StateW-1:0] reg_state_tl [Share];
11621167
always_comb begin
11631168
for (int i = 0 ; i < Share; i++) begin
1164-
reg_state_tl[i] = reg_state_valid ? reg_state[i] : 'b0;
1169+
reg_state_tl[i] = reg_state_valid ? reg_state[i] : '0;
11651170
end
11661171
end
11671172

@@ -1550,6 +1555,8 @@ module kmac
15501555
alert_tx_o[1])
15511556
`ASSERT_PRIM_COUNT_ERROR_TRIGGER_ALERT(KeyIndexCountCheck_A, u_kmac_core.u_key_index_count,
15521557
alert_tx_o[1])
1558+
`ASSERT_PRIM_COUNT_ERROR_TRIGGER_ALERT(AppDigestCountCheck_A, u_app_intf.u_digest_part_counter,
1559+
alert_tx_o[1])
15531560

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

0 commit comments

Comments
 (0)