Skip to content

Commit b3170d6

Browse files
committed
[csrng/rtl] Use enum data type for cmd field in core data types
This is a pure refactor commmit that uses the acmd_e type for all `cmd` fields in the core data types instead of the equivalent pure-logic representation. This should substanitally aid during wave debugging. Signed-off-by: Florian Glaser <[email protected]>
1 parent 9c9ea5d commit b3170d6

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

hw/ip/csrng/rtl/csrng_block_encrypt.sv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ module csrng_block_encrypt import csrng_pkg::*; #(
145145

146146
assign rsp_data_o = '{
147147
inst_id: sfifo_cmdid_rdata[CmdWidth +: InstIdWidth],
148-
cmd: sfifo_cmdid_rdata[0 +: CmdWidth],
148+
cmd: acmd_e'(sfifo_cmdid_rdata[CmdWidth-1:0]),
149149
key: '0, // unused in rsp path
150150
v: cipher_data_out
151151
};

hw/ip/csrng/rtl/csrng_core.sv

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ module csrng_core import csrng_pkg::*; #(
286286
mubi4_t flag0_q, flag0_d;
287287
logic [NumAppsLg-1:0] cmd_arb_idx_q, cmd_arb_idx_d;
288288
logic genbits_stage_fips_sw_q, genbits_stage_fips_sw_d;
289-
logic [CmdWidth-1:0] cmd_req_ccmd_dly_q, cmd_req_ccmd_dly_d;
289+
acmd_e cmd_req_ccmd_dly_q, cmd_req_ccmd_dly_d;
290290
logic cs_aes_halt_q, cs_aes_halt_d;
291291
logic [SeedLen-1:0] entropy_src_seed_q, entropy_src_seed_d;
292292
logic entropy_src_fips_q, entropy_src_fips_d;
@@ -304,7 +304,7 @@ module csrng_core import csrng_pkg::*; #(
304304
flag0_q <= prim_mubi_pkg::MuBi4False;
305305
cmd_arb_idx_q <= '0;
306306
genbits_stage_fips_sw_q <= '0;
307-
cmd_req_ccmd_dly_q <= '0;
307+
cmd_req_ccmd_dly_q <= INV;
308308
cs_aes_halt_q <= '0;
309309
entropy_src_seed_q <= '0;
310310
entropy_src_fips_q <= '0;
@@ -1144,7 +1144,7 @@ module csrng_core import csrng_pkg::*; #(
11441144
// outputs: 416b K,V,RC
11451145

11461146
assign ctr_drbg_cmd_req_vld = !cs_enable_fo[45] ? 1'b0 : main_sm_cmd_vld;
1147-
assign cmd_req_ccmd_dly_d = !cs_enable_fo[44] ? '0 : acmd_hold;
1147+
assign cmd_req_ccmd_dly_d = !cs_enable_fo[44] ? INV : acmd_hold;
11481148

11491149
assign ctr_drbg_cmd_req_data = '{
11501150
inst_id: shid_q,

hw/ip/csrng/rtl/csrng_ctr_drbg_cmd.sv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ module csrng_ctr_drbg_cmd import csrng_pkg::*; (
202202
rsp_glast_o = req_glast_i;
203203
if (req_data_i.cmd == UNI) begin
204204
// Zeroize everything but inst_id and cmd (?)
205-
rsp_data_o = '{default: '0};
205+
rsp_data_o = '{cmd: INV, default: '0};
206206
rsp_data_o.inst_id = req_data_i.inst_id;
207207
rsp_data_o.cmd = req_data_i.cmd;
208208
end else if (!bypass_upd) begin

hw/ip/csrng/rtl/csrng_pkg.sv

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ package csrng_pkg;
8181
GEN = 3'h3,
8282
UPD = 3'h4,
8383
UNI = 3'h5,
84-
GENB = 3'h6,
85-
GENU = 3'h7
84+
GENB = 3'h6, // Rsp routing for block encrypt
85+
GENU = 3'h7 // Rsp routing for update unit
8686
} acmd_e;
8787

8888
typedef struct packed {
@@ -105,22 +105,22 @@ package csrng_pkg;
105105
logic [RsCtrWidth-1:0] rs_ctr;
106106
logic [SeedLen-1:0] pdata;
107107
logic [InstIdWidth-1:0] inst_id;
108-
logic [CmdWidth-1:0] cmd;
108+
acmd_e cmd;
109109
logic [KeyLen-1:0] key;
110110
logic [BlkLen-1:0] v;
111111
} csrng_core_data_t;
112112

113113
typedef struct packed {
114114
logic [SeedLen-1:0] pdata;
115115
logic [InstIdWidth-1:0] inst_id;
116-
logic [CmdWidth-1:0] cmd;
116+
acmd_e cmd;
117117
logic [KeyLen-1:0] key;
118118
logic [BlkLen-1:0] v;
119119
} csrng_upd_data_t;
120120

121121
typedef struct packed {
122122
logic [InstIdWidth-1:0] inst_id;
123-
logic [CmdWidth-1:0] cmd;
123+
acmd_e cmd;
124124
logic [KeyLen-1:0] key;
125125
logic [BlkLen-1:0] v;
126126
} csrng_benc_data_t;

0 commit comments

Comments
 (0)