From f2b230b83b7234d04e211a2914bcbd5e0adf688b Mon Sep 17 00:00:00 2001 From: Andrea Caforio Date: Tue, 10 Dec 2024 13:52:04 +0100 Subject: [PATCH] [hmac, rtl] Do not skip padding after a hash stop command This commit removes some conditional FSM states transition that were deemed undesirable in `prim_sha2_pad`, see #23936. It made it possible to cancel an ongoing padding operation, which is disallowed by the HMAC module. As a side-effect, the removal plugs some existing FSM transition coverage holes in `prim_sha2_pad` whose manual exclusions can be removed as well. This change makes it impossible to transition into the `StFifoReceive` state from either `StPad80`, `StPad00`, `StLenHi` or `StLenLo` by asserting the `hash_go` signal. Signed-off-by: Andrea Caforio --- hw/ip/hmac/dv/cov/hmac_cov_excl.el | 25 ------------------------- hw/ip/hmac/dv/hmac_sim_cfg.hjson | 3 +-- hw/ip/prim/rtl/prim_sha2_pad.sv | 9 +++++++-- 3 files changed, 8 insertions(+), 29 deletions(-) delete mode 100644 hw/ip/hmac/dv/cov/hmac_cov_excl.el diff --git a/hw/ip/hmac/dv/cov/hmac_cov_excl.el b/hw/ip/hmac/dv/cov/hmac_cov_excl.el deleted file mode 100644 index e4f09b1f70408..0000000000000 --- a/hw/ip/hmac/dv/cov/hmac_cov_excl.el +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright lowRISC contributors (OpenTitan project). -// Licensed under the Apache License, Version 2.0, see LICENSE for details. -// SPDX-License-Identifier: Apache-2.0 - -//================================================== -// This file contains the Excluded objects -// Generated By User: gdessouky -// Format Version: 2 -// Date: Sat Jul 6 04:05:21 2024 -// ExclMode: default -//================================================== -CHECKSUM: "1683432060 1171249183" -INSTANCE: tb.dut.u_prim_sha2_512.gen_multimode_logic.u_prim_sha2_multimode.u_pad -Fsm st_q "1171249183" -ANNOTATION: "[INVALID] Intend to remove transition" -Transition StLenHi->StFifoReceive "4->1" -Fsm st_q "1171249183" -ANNOTATION: "[INVALID] Intend to remove transition" -Transition StPad80->StFifoReceive "2->1" -Fsm st_q "1171249183" -ANNOTATION: "[INVALID] Intend to remove transition" -Transition StPad00->StFifoReceive "3->1" -Fsm st_q "1171249183" -ANNOTATION: "[INVALID] Intend to remove transition" -Transition StLenLo->StFifoReceive "5->1" diff --git a/hw/ip/hmac/dv/hmac_sim_cfg.hjson b/hw/ip/hmac/dv/hmac_sim_cfg.hjson index 429ac0ae66c9b..b07ef3e6d06c9 100644 --- a/hw/ip/hmac/dv/hmac_sim_cfg.hjson +++ b/hw/ip/hmac/dv/hmac_sim_cfg.hjson @@ -41,8 +41,7 @@ reseed: 50 // Add HMAC specific exclusion files. - vcs_cov_excl_files: ["{proj_root}/hw/ip/hmac/dv/cov/hmac_unr_excl.el", - "{proj_root}/hw/ip/hmac/dv/cov/hmac_cov_excl.el"] + vcs_cov_excl_files: ["{proj_root}/hw/ip/hmac/dv/cov/hmac_unr_excl.el"] // Default UVM test and seq class name. uvm_test: hmac_base_test diff --git a/hw/ip/prim/rtl/prim_sha2_pad.sv b/hw/ip/prim/rtl/prim_sha2_pad.sv index 1dc010dfefabe..242698d7b0f27 100644 --- a/hw/ip/prim/rtl/prim_sha2_pad.sv +++ b/hw/ip/prim/rtl/prim_sha2_pad.sv @@ -337,8 +337,13 @@ module prim_sha2_pad import prim_sha2_pkg::*; end endcase - if (!sha_en_i) st_d = StIdle; - else if (hash_go) st_d = StFifoReceive; + if (!sha_en_i) begin + st_d = StIdle; + // We do not allow the cancellation of an ongoing padding operation, i.e., reverting back to the + // `StFifoReceive` state while being in the states `StPad80`, `StPad00`, `StLenHi` or `StLenLo`. + end else if (hash_go && (st_q == StIdle || st_q == StFifoReceive)) begin + st_d = StFifoReceive; + end end // tx_count