[aes] Fix lint warnings and errors
Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
diff --git a/hw/ip/aes/lint/aes.waiver b/hw/ip/aes/lint/aes.waiver
index 47b102d..e58b36f 100644
--- a/hw/ip/aes/lint/aes.waiver
+++ b/hw/ip/aes/lint/aes.waiver
@@ -3,3 +3,5 @@
# SPDX-License-Identifier: Apache-2.0
#
# waiver file for aes
+waive -rules COMBO_READ_WRITE -location {aes_key_expand.sv} -regexp {'regular\[[0-9]+\]\[2:1|4:2|6:5\]' is read from within the same combinational process block} \
+ -comment "regular[*] is assigned in a for loop, regular[*][1|2|5] depends on regular[*][0|1|4]"
diff --git a/hw/ip/aes/rtl/aes.sv b/hw/ip/aes/rtl/aes.sv
index 80fbdfc..0cefd6e 100644
--- a/hw/ip/aes/rtl/aes.sv
+++ b/hw/ip/aes/rtl/aes.sv
@@ -12,9 +12,7 @@
// cipher core. Masking requires the use of a masked S-Box,
// see SBoxImpl parameter. Note: currently, constant masks
// are used, this is of course not secure.
- parameter sbox_impl_e SBoxImpl = SBoxImplLut, // See aes_pkg.sv
-
- localparam int NumShares = Masking ? 2 : 1 // derived parameter
+ parameter sbox_impl_e SBoxImpl = SBoxImplLut // See aes_pkg.sv
) (
input clk_i,
input rst_ni,
diff --git a/hw/ip/aes/rtl/aes_cipher_core.sv b/hw/ip/aes/rtl/aes_cipher_core.sv
index 20b07d2..a05d5d4 100644
--- a/hw/ip/aes/rtl/aes_cipher_core.sv
+++ b/hw/ip/aes/rtl/aes_cipher_core.sv
@@ -168,6 +168,8 @@
logic [3:0][3:0][7:0] round_key [NumShares];
round_key_sel_e round_key_sel;
+ logic [255:0] prng_data_256;
+
//////////
// Data //
//////////
@@ -251,6 +253,7 @@
/////////
// Key //
/////////
+ assign prng_data_256 = {prng_data_i, prng_data_i, prng_data_i, prng_data_i};
// Full Key registers
always_comb begin : key_full_mux
@@ -258,8 +261,8 @@
KEY_FULL_ENC_INIT: key_full_d = key_init_i;
KEY_FULL_DEC_INIT: key_full_d = key_dec_q;
KEY_FULL_ROUND: key_full_d = key_expand_out;
- KEY_FULL_CLEAR: key_full_d ='{default: {prng_data_i, prng_data_i, prng_data_i, prng_data_i}};
- default: key_full_d ='{default: {prng_data_i, prng_data_i, prng_data_i, prng_data_i}};
+ KEY_FULL_CLEAR: key_full_d ='{default: prng_data_256};
+ default: key_full_d ='{default: prng_data_256};
endcase
end
@@ -273,8 +276,8 @@
always_comb begin : key_dec_mux
unique case (key_dec_sel)
KEY_DEC_EXPAND: key_dec_d = key_expand_out;
- KEY_DEC_CLEAR: key_dec_d = '{default: {prng_data_i, prng_data_i, prng_data_i, prng_data_i}};
- default: key_dec_d = '{default: {prng_data_i, prng_data_i, prng_data_i, prng_data_i}};
+ KEY_DEC_CLEAR: key_dec_d = '{default: prng_data_256};
+ default: key_dec_d = '{default: prng_data_256};
endcase
end
diff --git a/hw/ip/aes/rtl/aes_control.sv b/hw/ip/aes/rtl/aes_control.sv
index a8aeb30..5323634 100644
--- a/hw/ip/aes/rtl/aes_control.sv
+++ b/hw/ip/aes/rtl/aes_control.sv
@@ -327,7 +327,7 @@
key_init_load = cipher_dec_key_gen_i; // This key is no longer "new", but still clean.
key_init_arm = ~cipher_dec_key_gen_i; // The key is still "new", prevent partial updates.
iv_load = ~cipher_dec_key_gen_i & (doing_cbc_enc | doing_cbc_dec |
- doing_cfb_dec | doing_cfb_dec |
+ doing_cfb_enc | doing_cfb_dec |
doing_ofb | doing_ctr);
data_in_load = ~cipher_dec_key_gen_i;