../src/lowrisc_ip_alert_handler_component_0.1/rtl/alert_pkg.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:
6: package alert_pkg;
7:
8: // these localparams are generated based on the system top-level configuration
9: localparam int unsigned NAlerts = alert_handler_reg_pkg::NAlerts; // maximum 252
10: localparam int unsigned EscCntDw = alert_handler_reg_pkg::EscCntDw; // maximum 32
11: localparam int unsigned AccuCntDw = alert_handler_reg_pkg::AccuCntDw; // maximum 32
12: // seed for the ping timer (must be nonzero!)
13: localparam logic [31:0] LfsrSeed = alert_handler_reg_pkg::LfsrSeed;
14: // enable async transitions for specific RX/TX pairs
15: localparam bit [NAlerts-1:0] AsyncOn = alert_handler_reg_pkg::AsyncOn;
16:
17: // common constants, do not change
18: localparam int unsigned N_CLASSES = alert_handler_reg_pkg::N_CLASSES;
19: localparam int unsigned N_ESC_SEV = alert_handler_reg_pkg::N_ESC_SEV;
20: localparam int unsigned N_PHASES = alert_handler_reg_pkg::N_PHASES;
21: localparam int unsigned N_LOC_ALERT = alert_handler_reg_pkg::N_LOC_ALERT;
22:
23: localparam int unsigned PING_CNT_DW = alert_handler_reg_pkg::PING_CNT_DW;
24: localparam int unsigned PHASE_DW = alert_handler_reg_pkg::PHASE_DW;
25: localparam int unsigned CLASS_DW = alert_handler_reg_pkg::CLASS_DW;
26:
27: // do not change the phase encoding
28: typedef enum logic [2:0] {Idle = 3'b000, Timeout = 3'b001, Terminal = 3'b011,
29: Phase0 = 3'b100, Phase1 = 3'b101, Phase2 = 3'b110,
30: Phase3 = 3'b111} cstate_e;
31:
32: // struct containing the current alert handler state
33: // can be used to gather crashdump information in HW
34: typedef struct packed {
35: // alerts
36: logic [NAlerts-1:0] alert_cause; // alert cause bits
37: logic [N_LOC_ALERT-1:0] loc_alert_cause; // local alert cause bits
38: // class state
39: logic [N_CLASSES-1:0][AccuCntDw-1:0] class_accum_cnt; // current accumulator value
40: logic [N_CLASSES-1:0][EscCntDw-1:0] class_esc_cnt; // current escalation counter value
41: cstate_e [N_CLASSES-1:0] class_esc_state; // current escalation protocol state
42: } alert_crashdump_t;
43:
44: // breakout wrapper structs
45: typedef struct packed {
46: // alerts
47: logic [NAlerts-1:0] alert_cause; // alert cause bits
48: logic [N_LOC_ALERT-1:0] loc_alert_cause; // local alert cause bits
49: // class state
50: logic [N_CLASSES-1:0] class_trig; // class trigger
51: logic [N_CLASSES-1:0] class_esc_trig; // escalation trigger
52: logic [N_CLASSES-1:0][AccuCntDw-1:0] class_accum_cnt; // current accumulator value
53: logic [N_CLASSES-1:0][EscCntDw-1:0] class_esc_cnt; // current escalation counter value
54: cstate_e [N_CLASSES-1:0] class_esc_state; // current escalation protocol state
55: } hw2reg_wrap_t;
56:
57: typedef struct packed {
58: // ping config
59: logic config_locked; // locked -> ping enabled
60: logic [PING_CNT_DW-1:0] ping_timeout_cyc; // ping timeout config
61: // alert config
62: logic [N_LOC_ALERT-1:0] loc_alert_en; // alert enable
63: logic [N_LOC_ALERT-1:0][CLASS_DW-1:0] loc_alert_class; // alert class config
64: logic [NAlerts-1:0] alert_en; // alert enable
65: logic [NAlerts-1:0][CLASS_DW-1:0] alert_class; // alert class config
66: // class config
67: logic [N_CLASSES-1:0] class_en; // enables esc mechanisms
68: logic [N_CLASSES-1:0] class_clr; // clears esc/accu
69: logic [N_CLASSES-1:0][AccuCntDw-1:0] class_accum_thresh; // accum esc threshold
70: logic [N_CLASSES-1:0][EscCntDw-1:0] class_timeout_cyc; // interrupt timeout
71: logic [N_CLASSES-1:0][N_PHASES-1:0][EscCntDw-1:0] class_phase_cyc; // length of phases 0..3
72: logic [N_CLASSES-1:0][N_ESC_SEV-1:0] class_esc_en; // esc signal enables
73: logic [N_CLASSES-1:0][N_ESC_SEV-1:0][PHASE_DW-1:0] class_esc_map; // esc signal/phase map
74: } reg2hw_wrap_t;
75:
76: endpackage : alert_pkg
77:
78:
79: