hw/ip/alert_handler/rtl/alert_handler_class.sv Cov: 87.5%
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 gates the alert triggers with their enable bits, and correctly bins
6: // the enabled alerts into the class that they have been assigned to. The module
7: // produces the alert cause and class trigger signals.
8: //
9:
10: module alert_handler_class import alert_pkg::*; (
11: input [NAlerts-1:0] alert_trig_i, // alert trigger
12: input [N_LOC_ALERT-1:0] loc_alert_trig_i, // alert trigger
13: input [NAlerts-1:0] alert_en_i, // alert enable
14: input [N_LOC_ALERT-1:0] loc_alert_en_i, // alert enable
15: input [NAlerts-1:0] [CLASS_DW-1:0] alert_class_i, // class assignment
16: input [N_LOC_ALERT-1:0][CLASS_DW-1:0] loc_alert_class_i, // class assignment
17:
18: output logic [NAlerts-1:0] alert_cause_o, // alert cause
19: output logic [N_LOC_ALERT-1:0] loc_alert_cause_o, // alert cause
20: output logic [N_CLASSES-1:0] class_trig_o // class triggered
21: );
22:
23: // assign alert cause
24: assign alert_cause_o = alert_en_i & alert_trig_i;
25: assign loc_alert_cause_o = loc_alert_en_i & loc_alert_trig_i;
26:
27: // classification mapping
28: logic [N_CLASSES-1:0][NAlerts-1:0] class_masks;
29: logic [N_CLASSES-1:0][N_LOC_ALERT-1:0] loc_class_masks;
30:
31: // this is basically an address to onehot0 decoder
32: always_comb begin : p_class_mask
33: class_masks = '0;
34: loc_class_masks = '0;
35: for (int unsigned kk = 0; kk < NAlerts; kk++) begin
36: class_masks[alert_class_i[kk]][kk] = 1'b1;
37: end
38: for (int unsigned kk = 0; kk < N_LOC_ALERT; kk++) begin
39: loc_class_masks[loc_alert_class_i[kk]][kk] = 1'b1;
40: end
41: end
42:
43: // mask and OR reduction, followed by class enable gating
44: for (genvar k = 0; k < N_CLASSES; k++) begin : gen_classifier
45: assign class_trig_o[k] = (|{ alert_cause_o & class_masks[k],
46: loc_alert_cause_o & loc_class_masks[k] });
47: end
48:
49: endmodule : alert_handler_class
50: