1 |
11 |
dinesha |
/// Copyright by Syntacore LLC © 2016-2021. See LICENSE for details
|
2 |
|
|
/// @file
|
3 |
|
|
/// @brief HART Debug Unit definitions file
|
4 |
|
|
///
|
5 |
|
|
|
6 |
|
|
`ifndef SCR1_INCLUDE_HDU_DEFS
|
7 |
|
|
`define SCR1_INCLUDE_HDU_DEFS
|
8 |
|
|
|
9 |
|
|
`include "scr1_arch_description.svh"
|
10 |
|
|
`include "scr1_csr.svh"
|
11 |
|
|
|
12 |
|
|
`ifdef SCR1_MMU_EN
|
13 |
|
|
`define SCR1_HDU_FEATURE_MPRVEN
|
14 |
|
|
`endif // SCR1_MMU_EN
|
15 |
|
|
|
16 |
|
|
//==============================================================================
|
17 |
|
|
// Parameters
|
18 |
|
|
//==============================================================================
|
19 |
|
|
//localparam int unsigned SCR1_HDU_DEBUGCSR_BASE_ADDR = 12'h7B0;
|
20 |
|
|
localparam int unsigned SCR1_HDU_DEBUGCSR_ADDR_SPAN = 4; // YOSYS FIX
|
21 |
|
|
localparam int unsigned SCR1_HDU_DEBUGCSR_ADDR_WIDTH = $clog2(SCR1_HDU_DEBUGCSR_ADDR_SPAN);
|
22 |
|
|
localparam bit [3:0] SCR1_HDU_DEBUGCSR_DCSR_XDEBUGVER = 4'h4;
|
23 |
|
|
localparam int unsigned SCR1_HDU_PBUF_ADDR_SPAN = 8;
|
24 |
|
|
localparam int unsigned SCR1_HDU_PBUF_ADDR_WIDTH = $clog2(SCR1_HDU_PBUF_ADDR_SPAN);
|
25 |
|
|
localparam int unsigned SCR1_HDU_DATA_REG_WIDTH = 32;
|
26 |
|
|
localparam int unsigned SCR1_HDU_CORE_INSTR_WIDTH = 32;
|
27 |
|
|
|
28 |
|
|
|
29 |
|
|
//==============================================================================
|
30 |
|
|
// Types
|
31 |
|
|
//==============================================================================
|
32 |
|
|
|
33 |
|
|
// HART Debug States:
|
34 |
|
|
typedef enum logic [1:0] {
|
35 |
|
|
SCR1_HDU_DBGSTATE_RESET = 2'b00,
|
36 |
|
|
SCR1_HDU_DBGSTATE_RUN = 2'b01,
|
37 |
|
|
SCR1_HDU_DBGSTATE_DHALTED = 2'b10,
|
38 |
|
|
SCR1_HDU_DBGSTATE_DRUN = 2'b11
|
39 |
|
|
`ifdef SCR1_XPROP_EN
|
40 |
|
|
,
|
41 |
|
|
SCR1_HDU_DBGSTATE_XXX = 'X
|
42 |
|
|
`endif // SCR1_XPROP_EN
|
43 |
|
|
} type_scr1_hdu_dbgstates_e;
|
44 |
|
|
|
45 |
|
|
typedef enum logic [1:0] {
|
46 |
|
|
SCR1_HDU_PBUFSTATE_IDLE = 2'b00,
|
47 |
|
|
SCR1_HDU_PBUFSTATE_FETCH = 2'b01,
|
48 |
|
|
SCR1_HDU_PBUFSTATE_EXCINJECT = 2'b10,
|
49 |
|
|
SCR1_HDU_PBUFSTATE_WAIT4END = 2'b11
|
50 |
|
|
`ifdef SCR1_XPROP_EN
|
51 |
|
|
,
|
52 |
|
|
SCR1_HDU_PBUFSTATE_XXX = 'X
|
53 |
|
|
`endif // SCR1_XPROP_EN
|
54 |
|
|
} type_scr1_hdu_pbufstates_e;
|
55 |
|
|
|
56 |
|
|
typedef enum logic {
|
57 |
|
|
SCR1_HDU_HARTCMD_RESUME = 1'b0,
|
58 |
|
|
SCR1_HDU_HARTCMD_HALT = 1'b1
|
59 |
|
|
`ifdef SCR1_XPROP_EN
|
60 |
|
|
,
|
61 |
|
|
SCR1_HDU_HARTCMD_XXX = 1'bX
|
62 |
|
|
`endif // SCR1_XPROP_EN
|
63 |
|
|
} type_scr1_hdu_hart_command_e;
|
64 |
|
|
|
65 |
|
|
typedef enum logic {
|
66 |
|
|
SCR1_HDU_FETCH_SRC_NORMAL = 1'b0,
|
67 |
|
|
SCR1_HDU_FETCH_SRC_PBUF = 1'b1
|
68 |
|
|
`ifdef SCR1_XPROP_EN
|
69 |
|
|
,
|
70 |
|
|
SCR1_HDU_FETCH_SRC_XXX = 1'bX
|
71 |
|
|
`endif // SCR1_XPROP_EN
|
72 |
|
|
} type_scr1_hdu_fetch_src_e;
|
73 |
|
|
|
74 |
|
|
typedef struct packed {
|
75 |
|
|
//logic reset_n;
|
76 |
|
|
logic except;
|
77 |
|
|
logic ebreak;
|
78 |
|
|
type_scr1_hdu_dbgstates_e dbg_state;
|
79 |
|
|
} type_scr1_hdu_hartstatus_s;
|
80 |
|
|
|
81 |
|
|
// Debug Mode Redirection control:
|
82 |
|
|
typedef struct packed {
|
83 |
|
|
logic sstep; // Single Step
|
84 |
|
|
logic ebreak; // Redirection after EBREAK execution
|
85 |
|
|
} type_scr1_hdu_redirect_s;
|
86 |
|
|
|
87 |
|
|
typedef struct packed {
|
88 |
|
|
logic irq_dsbl;
|
89 |
|
|
type_scr1_hdu_fetch_src_e fetch_src;
|
90 |
|
|
logic pc_advmt_dsbl;
|
91 |
|
|
logic hwbrkpt_dsbl;
|
92 |
|
|
type_scr1_hdu_redirect_s redirect;
|
93 |
|
|
} type_scr1_hdu_runctrl_s;
|
94 |
|
|
|
95 |
|
|
// HART Halt Status:
|
96 |
|
|
typedef enum logic [2:0] {
|
97 |
|
|
SCR1_HDU_HALTCAUSE_NONE = 3'b000,
|
98 |
|
|
SCR1_HDU_HALTCAUSE_EBREAK = 3'b001,
|
99 |
|
|
SCR1_HDU_HALTCAUSE_TMREQ = 3'b010,
|
100 |
|
|
SCR1_HDU_HALTCAUSE_DMREQ = 3'b011,
|
101 |
|
|
SCR1_HDU_HALTCAUSE_SSTEP = 3'b100,
|
102 |
|
|
SCR1_HDU_HALTCAUSE_RSTEXIT = 3'b101
|
103 |
|
|
`ifdef SCR1_XPROP_EN
|
104 |
|
|
,
|
105 |
|
|
SCR1_HDU_HALTCAUSE_XXX = 'X
|
106 |
|
|
`endif // SCR1_XPROP_EN
|
107 |
|
|
} type_scr1_hdu_haltcause_e;
|
108 |
|
|
|
109 |
|
|
typedef struct packed {
|
110 |
|
|
logic except;
|
111 |
|
|
type_scr1_hdu_haltcause_e cause;
|
112 |
|
|
} type_scr1_hdu_haltstatus_s;
|
113 |
|
|
|
114 |
|
|
|
115 |
|
|
// Debug CSR map
|
116 |
|
|
localparam SCR1_HDU_DBGCSR_OFFS_DCSR = SCR1_HDU_DEBUGCSR_ADDR_WIDTH'( 'd0 );
|
117 |
|
|
localparam SCR1_HDU_DBGCSR_OFFS_DPC = SCR1_HDU_DEBUGCSR_ADDR_WIDTH'( 'd1 );
|
118 |
|
|
localparam SCR1_HDU_DBGCSR_OFFS_DSCRATCH0 = SCR1_HDU_DEBUGCSR_ADDR_WIDTH'( 'd2 );
|
119 |
|
|
localparam SCR1_HDU_DBGCSR_OFFS_DSCRATCH1 = SCR1_HDU_DEBUGCSR_ADDR_WIDTH'( 'd3 );
|
120 |
|
|
|
121 |
|
|
localparam bit [SCR1_CSR_ADDR_WIDTH-1:0] SCR1_HDU_DBGCSR_ADDR_DCSR = SCR1_CSR_ADDR_HDU_MBASE + SCR1_HDU_DBGCSR_OFFS_DCSR;
|
122 |
|
|
localparam bit [SCR1_CSR_ADDR_WIDTH-1:0] SCR1_HDU_DBGCSR_ADDR_DPC = SCR1_CSR_ADDR_HDU_MBASE + SCR1_HDU_DBGCSR_OFFS_DPC;
|
123 |
|
|
localparam bit [SCR1_CSR_ADDR_WIDTH-1:0] SCR1_HDU_DBGCSR_ADDR_DSCRATCH0 = SCR1_CSR_ADDR_HDU_MBASE + SCR1_HDU_DBGCSR_OFFS_DSCRATCH0;
|
124 |
|
|
localparam bit [SCR1_CSR_ADDR_WIDTH-1:0] SCR1_HDU_DBGCSR_ADDR_DSCRATCH1 = SCR1_CSR_ADDR_HDU_MBASE + SCR1_HDU_DBGCSR_OFFS_DSCRATCH1;
|
125 |
|
|
|
126 |
|
|
// Debug CSRs :: DCSR
|
127 |
|
|
typedef enum int {
|
128 |
|
|
SCR1_HDU_DCSR_PRV_BIT_R = 0,
|
129 |
|
|
SCR1_HDU_DCSR_PRV_BIT_L = 1,
|
130 |
|
|
SCR1_HDU_DCSR_STEP_BIT = 2,
|
131 |
|
|
SCR1_HDU_DCSR_RSRV0_BIT_R = 3,
|
132 |
|
|
SCR1_HDU_DCSR_RSRV0_BIT_L = 5,
|
133 |
|
|
SCR1_HDU_DCSR_CAUSE_BIT_R = 6,
|
134 |
|
|
SCR1_HDU_DCSR_CAUSE_BIT_L = 8,
|
135 |
|
|
SCR1_HDU_DCSR_RSRV1_BIT_R = 9,
|
136 |
|
|
SCR1_HDU_DCSR_RSRV1_BIT_L = 10,
|
137 |
|
|
SCR1_HDU_DCSR_STEPIE_BIT = 11,
|
138 |
|
|
SCR1_HDU_DCSR_RSRV2_BIT_R = 12,
|
139 |
|
|
SCR1_HDU_DCSR_RSRV2_BIT_L = 14,
|
140 |
|
|
SCR1_HDU_DCSR_EBREAKM_BIT = 15,
|
141 |
|
|
SCR1_HDU_DCSR_RSRV3_BIT_R = 16,
|
142 |
|
|
SCR1_HDU_DCSR_RSRV3_BIT_L = 27,
|
143 |
|
|
SCR1_HDU_DCSR_XDEBUGVER_BIT_R = 28,
|
144 |
|
|
SCR1_HDU_DCSR_XDEBUGVER_BIT_L = 31
|
145 |
|
|
} type_scr1_hdu_dcsr_bits_e;
|
146 |
|
|
|
147 |
|
|
//localparam int unsigned SCR1_HDU_DEBUGCSR_DCSR_PRV_WIDTH = SCR1_HDU_DCSR_PRV_BIT_L-SCR1_HDU_DCSR_PRV_BIT_R+1;
|
148 |
|
|
|
149 |
|
|
typedef struct packed {
|
150 |
|
|
logic [SCR1_HDU_DCSR_XDEBUGVER_BIT_L-SCR1_HDU_DCSR_XDEBUGVER_BIT_R:0] xdebugver;
|
151 |
|
|
logic [SCR1_HDU_DCSR_RSRV3_BIT_L-SCR1_HDU_DCSR_RSRV3_BIT_R:0] rsrv3;
|
152 |
|
|
logic ebreakm;
|
153 |
|
|
logic [SCR1_HDU_DCSR_RSRV2_BIT_L-SCR1_HDU_DCSR_RSRV2_BIT_R:0] rsrv2;
|
154 |
|
|
logic stepie;
|
155 |
|
|
logic [SCR1_HDU_DCSR_RSRV1_BIT_L-SCR1_HDU_DCSR_RSRV1_BIT_R:0] rsrv1;
|
156 |
|
|
logic [SCR1_HDU_DCSR_CAUSE_BIT_L-SCR1_HDU_DCSR_CAUSE_BIT_R:0] cause;
|
157 |
|
|
logic [SCR1_HDU_DCSR_RSRV0_BIT_L-SCR1_HDU_DCSR_RSRV0_BIT_R:0] rsrv0;
|
158 |
|
|
logic step;
|
159 |
|
|
logic [SCR1_HDU_DCSR_PRV_BIT_L-SCR1_HDU_DCSR_PRV_BIT_R:0] prv;
|
160 |
|
|
} type_scr1_hdu_dcsr_s;
|
161 |
|
|
|
162 |
|
|
|
163 |
|
|
`endif // SCR1_INCLUDE_HDU_DEFS
|