Provide opt-in wedge debugging info

When DEBUG_WEDGE is defined, expose the last committed and next in the
reorder buffer PC and corresponding instruction via DMI registers, since
even when the core is wedged and we can't read GPRs etc we can still
interact with the debug module itself. Hopefully this proves useful for
debugging wedges.
This commit is contained in:
Jessica Clarke
2020-07-07 23:59:35 +01:00
parent 40f8109263
commit 68d3bd484e
10 changed files with 174 additions and 2 deletions

View File

@@ -22,7 +22,7 @@ package DM_Common;
typedef Bit #(7) DM_Addr;
DM_Addr max_DM_Addr = 'h5F;
DM_Addr max_DM_Addr = 'h7F;
typedef Bit #(32) DM_Word;
@@ -79,6 +79,26 @@ DM_Addr dm_addr_sbdata1 = 'h3d;
DM_Addr dm_addr_sbdata2 = 'h3e;
DM_Addr dm_addr_sbdata3 = 'h3f;
// ----------------
// Custom registers
DM_Addr dm_addr_custom0 = 'h70;
DM_Addr dm_addr_custom1 = 'h71;
DM_Addr dm_addr_custom2 = 'h72;
DM_Addr dm_addr_custom3 = 'h73;
DM_Addr dm_addr_custom4 = 'h74;
DM_Addr dm_addr_custom5 = 'h75;
DM_Addr dm_addr_custom6 = 'h76;
DM_Addr dm_addr_custom7 = 'h77;
DM_Addr dm_addr_custom8 = 'h78;
DM_Addr dm_addr_custom9 = 'h79;
DM_Addr dm_addr_custom10 = 'h7a;
DM_Addr dm_addr_custom11 = 'h7b;
DM_Addr dm_addr_custom12 = 'h7c;
DM_Addr dm_addr_custom13 = 'h7d;
DM_Addr dm_addr_custom14 = 'h7e;
DM_Addr dm_addr_custom15 = 'h7f;
// ================================================================
function Fmt fshow_dm_addr (DM_Addr dm_addr);

View File

@@ -91,6 +91,12 @@ import DM_Run_Control :: *;
import DM_Abstract_Commands :: *;
import DM_System_Bus :: *;
`ifdef DEBUG_WEDGE
import ConfigReg :: *;
import CHERICap :: *;
import CHERICC_Fat :: *;
`endif
// ================================================================
export DM_Common :: *;
@@ -126,6 +132,15 @@ interface Debug_Module_IFC;
// CSR access
interface Client #(DM_CPU_Req #(12, XLEN), DM_CPU_Rsp #(XLEN)) hart0_csr_mem_client;
// Optional debug from commit stage and ROB
`ifdef DEBUG_WEDGE
(* always_enabled *)
method Action hart0_last_inst (Tuple2 #(CapMem, Bit #(32)) pcc_inst);
(* always_enabled *)
method Action hart0_next_inst (Tuple2 #(CapMem, Bit #(32)) pcc_inst);
`endif
// ----------------
// Facing Platform
@@ -154,6 +169,13 @@ module mkDebug_Module (Debug_Module_IFC);
FIFO#(DM_Addr) f_read_addr <- mkFIFO1;
`ifdef DEBUG_WEDGE
Reg #(CapMem) rg_last_pcc <- mkConfigReg (unpack (0));
Reg #(Bit #(32)) rg_last_inst <- mkConfigReg (0);
Reg #(CapMem) rg_next_pcc <- mkConfigReg (unpack (0));
Reg #(Bit #(32)) rg_next_inst <- mkConfigReg (0);
`endif
// ================================================================
// Reset all three parts when dm_run_control.dmactive is low
@@ -228,6 +250,32 @@ module mkDebug_Module (Debug_Module_IFC);
dm_word <- dm_system_bus.av_read (dm_addr);
`ifdef DEBUG_WEDGE
else if (dm_addr == dm_addr_custom0)
dm_word = getAddr (rg_last_pcc) [31:0];
else if (dm_addr == dm_addr_custom1)
dm_word = getAddr (rg_last_pcc) [63:32];
else if (dm_addr == dm_addr_custom2)
dm_word = rg_last_inst;
else if (dm_addr == dm_addr_custom3)
dm_word = getAddr (rg_next_pcc) [31:0];
else if (dm_addr == dm_addr_custom4)
dm_word = getAddr (rg_next_pcc) [63:32];
else if (dm_addr == dm_addr_custom5)
dm_word = rg_next_inst;
`endif
else begin
// TODO: set error status?
dm_word = 0;
@@ -315,6 +363,19 @@ module mkDebug_Module (Debug_Module_IFC);
// CSR access
interface Client hart0_csr_mem_client = dm_abstract_commands.hart0_csr_mem_client;
// Optional debug from commit stage
`ifdef DEBUG_WEDGE
method Action hart0_last_inst (Tuple2 #(CapMem, Bit #(32)) pcc_inst);
rg_last_pcc <= tpl_1 (pcc_inst);
rg_last_inst <= tpl_2 (pcc_inst);
endmethod
method Action hart0_next_inst (Tuple2 #(CapMem, Bit #(32)) pcc_inst);
rg_next_pcc <= tpl_1 (pcc_inst);
rg_next_inst <= tpl_2 (pcc_inst);
endmethod
`endif
// ----------------
// Facing Platform