Organizing the Minimal RISC-V Debug Configuration (4. Interface for Debug Register Access)

Continuing from last time: https://msyksphinz-en.hatenablog.com/entry/2026/02/03/040000msyksphinz-en.hatenablog.com

Interface for register access

Next, let's consider the interface for accessing the HART's register file and debug CSRs from the DM.

In the minimal configuration, it is enough to be able to read and write

  • GPR
  • dcsr
  • dpc

via Abstract Command.

For this purpose, it is easy to understand if we place an internal interface like the following between the DM and the HART.

DM → HART

  • abs_req_valid
  • abs_req_write
  • abs_regno
  • abs_wdata

HART → DM

  • abs_req_ready
  • abs_rsp_valid
  • abs_rdata
  • abs_error

The specification does not require these names, but this level of partitioning is easy to work with in RTL. The DM interprets command and issues this internal interface, and the HART converts the requests into accesses to the register file and debug CSRs.


Debug control inside the CPU

Inside the HART, I think it is much cleaner to have a dedicated debug_ctrl. At a minimum, we want internal signals such as the following.

  • debug_mode
  • debug_entry
  • debug_resume
  • debug_cause
  • step_en

Furthermore, for CSR access, it is good to also provide controls such as

  • csr_dcsr_we
  • csr_dpc_we

When entering Debug Mode, dpc is saved and the cause of the halt is reflected in dcsr.cause. On resume, pc ← dpc is executed by a dret-equivalent operation.


The block diagram

Putting everything so far into a block diagram looks like this.

After all, thinking of the interface between the DM and the HART as divided into three parts

  • Execution control
  • Status notification
  • Register access

is the easiest to understand.


This is an English translation of the original Japanese post: RISC-V Debugの最小構成を整理する(4. Debugのレジスタアクセス用のインタフェース)