../src/lowrisc_ip_alert_handler_component_0.1/rtl/alert_handler_accu.sv Cov: 100%
1: // Copyright lowRISC contributors.
2: // Licensed under the Apache License, Version 2.0, see LICENSE for details.
3: // SPDX-License-Identifier: Apache-2.0
4: //
5: // This module accumulates incoming alert triggers. Once the current accumulator
6: // value is greater or equal the accumulator threshold, the next occurence of
7: // class_trig_i will trigger escalation.
8: //
9: // Note that the accumulator is implemented using a saturation counter which
10: // does not wrap around.
11: //
12:
13: `include "prim_assert.sv"
14:
15: module alert_handler_accu import alert_pkg::*; (
16: input clk_i,
17: input rst_ni,
18: input class_en_i, // class enable
19: input clr_i, // clear the accumulator
20: input class_trig_i, // increments the accu
21: input [AccuCntDw-1:0] thresh_i, // escalation trigger threshold
22: output logic [AccuCntDw-1:0] accu_cnt_o, // output of current accu value
23: output logic accu_trig_o // escalation trigger output
24: );
25:
26: logic trig_gated;
27: logic [AccuCntDw-1:0] accu_d, accu_q;
28:
29: assign trig_gated = class_trig_i & class_en_i;
30:
31: assign accu_d = (clr_i) ? '0 : // clear
32: (trig_gated && !(&accu_q)) ? accu_q + 1'b1 : // saturate counter at maximum
33: accu_q;
34:
35: assign accu_trig_o = (accu_q >= thresh_i) & trig_gated;
36:
37: assign accu_cnt_o = accu_q;
38:
39: always_ff @(posedge clk_i or negedge rst_ni) begin : p_regs
40: if (!rst_ni) begin
41: accu_q <= '0;
42: end else begin
43: accu_q <= accu_d;
44: end
45: end
46:
47:
48: ////////////////
49: // Assertions //
50: ////////////////
51:
52: `ASSERT(DisabledNoTrigFwd_A, !class_en_i |-> !accu_trig_o)
53: `ASSERT(DisabledNoTrigBkwd_A, accu_trig_o |-> class_en_i)
54:
55: endmodule : alert_handler_accu
56: