# Copyright lowRISC contributors (OpenTitan project).
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0
#
# waiver file for SHA-2: prim_sha2, prim_sha2_pad, prim_sha2_32, prim_sha2_pkg

waive -rules {CONST_FF RESET_ONLY PARTIAL_CONST_ASSIGN} -location {prim_sha2.sv} -regexp {processed_length\[8:0\]} \
      -comment "lower 512bits of message are aligned. So ignoring txcount for lower 9 bits"
waive -rules {CONST_FF RESET_ONLY PARTIAL_CONST_ASSIGN} -location {prim_sha2_pad.sv} -regexp {tx_count\[4:0\]} \
      -comment "lower 32bits of message are aligned. So ignoring txcount for lower 5 bits"
waive -rules {NOT_READ HIER_NET_NOT_READ CONST_OUTPUT} -location {prim_sha2_pad.sv prim_sha2.sv} \
      -regexp {padded_length\[8:0\]} \
      -comment "lower 512bits of padded message are 0 (always aligned message)"

waive -rules {EXPLICIT_BITLEN} -location {prim_sha2.sv} -regexp {.*(0|1)} \
      -comment "Added or subtracted by 1"

waive -rules {HIER_BRANCH_NOT_READ INPUT_NOT_READ} -location {prim_sha2_pad.sv} -regexp {wipe_(secret|v)} \
      -comment "Not used but remained for future use"

# ARITH_CONTEXT
waive -rules {ARITH_CONTEXT} -location {prim_sha2.sv}     -regexp {Bitlength of arithmetic operation '.processed_length.63:9. \+ 1'b1.'} \
      -comment "Bitwidth overflow is intended"
waive -rules {ARITH_CONTEXT} -location {prim_sha2_pad.sv} -regexp {Bitlength of arithmetic operation 'tx_count.63:5. \+ 2'd1'} \
      -comment "Bitwidth overflow is intended"
waive -rules {ARITH_CONTEXT} -location {prim_sha2_pad.sv} -regexp {Bitlength of arithmetic operation 'message_length.63:9. \+ (1'b1|2'b10)'} \
      -comment "Bitwidth overflow is intended"
waive -rules {ARITH_CONTEXT} -location {prim_sha2_pkg.sv} -regexp {Bitlength of arithmetic operation 'h_i\[3\]\[31:0\] \+ temp1' is self-determined in this context} \
      -comment "Bitwidth overflow is intended"
waive -rules {ARITH_CONTEXT} -location {prim_sha2_pkg.sv} -regexp {Bitlength of arithmetic operation '\(temp1 \+ temp2\)' is self-determined in this context} \
      -comment "Bitwidth overflow is intended"

# INPUT_NOT_READ
waive -rules {INPUT_NOT_READ} -location {prim_sha2_pkg.sv} -regexp {Input port 'h_i\[0:7\]\[63:32\]' is not read from in function 'compress_multi_256'}
      -comment "Upper bits are only used in SHA2-384/512"

# INTEGER
waive -rules {INTEGER}        -location {prim_sha2_pkg.sv} -regexp {'amt' of type int used as a}
waive -rules {TWO_STATE_TYPE} -location {prim_sha2_pkg.sv} -regexp {'amt' is of two state type 'int'} \
      -comment "shift function behaves as static, it is called with constant in the design"
waive -rules {INTEGER}        -location {prim_sha2_pkg.sv} -regexp {'amt' of type integer used as a non-constant value} \
      -comment "rotate function behaves as static function - it is called with a constant value in the design"
