# 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 prim_clock_div

waive -rules CLOCK_EDGE -location {prim_clock_div.sv} -msg {Falling edge of clock 'clk_i' used here, should use rising edge} \
      -comment "The clock switch signal is synchronized on negative edge to ensure it is away from any transition"

waive -rules DUAL_EDGE_CLOCK -location {prim_clock_div.sv} -regexp {.*} \
      -comment "The clock switch signal is synchronized on negative edge to ensure it is away from any transition"

waive -rules CLOCK_MUX -location {prim_clock_div.sv} -regexp {.*reaches a multiplexer here, used as a clock.*} \
      -comment "A mux is used during scan bypass, and for switching between div by 2 and div by 1 clocks"

waive -rules CLOCK_USE -location {prim_clock_div.sv} -regexp {'clk_i' is connected to 'prim_clock_mux2' port 'clk1_i', and used as a clock} \
      -comment "This clock mux usage is OK."

waive -rules SAME_NAME_TYPE -location {prim_clock_div.sv} -regexp {'ResetValue' is used as a parameter here, and as an enumeration value at} \
      -comment "Reused parameter name."

waive -rules CLOCK_DRIVER -location {prim_clock_div.sv} -regexp {'gen_div2.q_p' is driven by instance 'gen_div2\^u_div2' of module 'prim_flop', and used as a clock 'clk_i'} \
      -comment "A 'prim_flop' is used together with a 'prim_clock_inv' to implement a division by 2"

waive -rules CLOCK_USE -location {prim_clock_div.sv} -regexp {'gen_div2.q_n' is connected to 'prim_flop' port 'd_i\[0\]', and used as a clock 'clk_i'} \
      -comment "A 'prim_flop' is used together with a 'prim_clock_inv' to implement a division by 2"

waive -rules INV_CLOCK -location {prim_clock_div.sv} -regexp {'gen_div2.q_p' is inverted, used as clock 'clk_i'} \
      -comment "A 'prim_flop' is used together with a 'prim_clock_inv' to implement a division by 2"

waive -rules CLOCK_DRIVER -location {prim_clock_div.sv} -regexp {'clk_int' is driven here, and used as a clock} \
      -comment "The division by more than 2 is implemented using a behavioral toggle counter"

waive -rules CLOCK_MUX -location {prim_clock_div.sv} -regexp {Clock 'clk_int' is driven by a multiplexer here, used as a clock 'clk_i'} \
      -comment "This clock mux usage is OK."

waive -rules CLOCK_MUX -location {prim_clock_div.sv} -regexp {Clock 'clk_muxed' is driven by a multiplexer here, used as a clock} \
      -comment "This clock mux usage is OK."

waive -rules CLOCK_USE -location {prim_clock_div.sv} -regexp {'clk_muxed' is used for some other purpose, and as clock} \
      -comment "The division by more than 2 is implemented using a behavioral toggle counter driven by 'clk_muxed'"

waive -rules INV_CLOCK -location {prim_clock_div.sv} -regexp {'clk_muxed' is inverted, used as clock} \
      -comment "The division by more than 2 is implemented using a behavioral toggle counter driven by 'clk_muxed'"
