Skip to content

Debug spec v1.0 implementation#1590

Open
JacobPease wants to merge 222 commits into
openhwgroup:debugfrom
JacobPease:debug
Open

Debug spec v1.0 implementation#1590
JacobPease wants to merge 222 commits into
openhwgroup:debugfrom
JacobPease:debug

Conversation

@JacobPease

@JacobPease JacobPease commented Dec 16, 2025

Copy link
Copy Markdown
Contributor

This pull request contains an early stage implementation of the Debug Specification. It has the basic features of halting, resuming, resetting, halting on reset, and reading GPRs, CSRs, and FPRs. In it's current state it provides a framework with which we can implement more complicated features, like stepping and going into debug mode on ebreaks in various privilege modes. Inside docs/debug/wallydebug.md is a list of features already implemented and features that are going to be implemented.

This PR also contains a new method of Verification for the Debug module. Since the Debug module is driven by commands sent over a JTAG interface, separate testvectors must drive the JTAG pins while Wally executes instructions. To accomplish this, a test building framework was developed taking advantage of the features of Spike and the RISC-V variant of OpenOCD which can be found at this repo: riscv-openocd

First we write assembly tests for Spike and we write Tcl scripts to drive OpenOCD. We then run these two programs together as separate processes and connect OpenOCD to Spike's remote bitbang interface. The Tcl commands drive the JTAG pins and allows the RISC-V code, which has certain stopping points in it, to finish executing, ending the test. OpenOCD is configured to output a log of all Debug Module Interface commands it writes over the JTAG interface. This log is scraped for testvectors and saved to a file.

When we run wsim with a configuration with DEBUG_SUPPORTED set high, the testbenches Debugger module is driven with the testvectors generated using OpenOCD and Spike. Several features have been verified using this method.

To build and run the debug tests, run the following commands starting in the cvw root directory:

source ./setup.sh
cd sim; make deriv
cd ../tests/debug
make
wsim debug64 wally64debug

In addition to remaining features to be added, there's room for other improvements and discussion on how to optimally modify the current setup. There are currently only tests written for the rv64gc configuration with Debug supported. Additionally, implementing Imperas support requires that wsim and the testbench be expanded to take two testvector references when doing single tests on a single elf file and a Debugger testvector file, though the rvvi interface to the DMI is simple and easy to add to the testbench. This rvvi DMI interface is serial interface agnostic and only requires that we connect the DMI signals.

JacobPease and others added 30 commits July 30, 2025 15:57
…mentation. These implementations will look less like how the JTAG spec mandates it and more like what the Debug spec says it should be.
update debug header for tap_controller.sv + some comments
…to reset the op when receiving an acknowledgement as to not trigger another transaction.
JacobPease and others added 24 commits April 17, 2026 13:34
… FPGA, but a test still needs to be written.
…eps, setting ebreak, resetting, and setting DCSR fields.
… stepping into a load or store instruction. Also added the stoptime field in the DCSR.
…comb block. Fixed knownExceptions in debugger now that hasresethaltreq is high. Spike doesn't have that bit set high.
…ported. Also added comments clarifying some things.
…not just LSUStallM, potentially removing possible bugs in the future. Also, treating WFI as a NOP during stepping and DebugMode is implemented, but it has not been tested.
…tep after designing wfiM to be treated as a NOP during stepping. Needs DebugMode awareness too
… will reliably fail if WFI triggers an exception during stepping.
@juanschroeder

Copy link
Copy Markdown
Contributor

Hi @JacobPease . It would be great to have this. Would it be working with current master? I don't have an Arty A7 but I can try to test it in a Nexys A7 or a Genesys 2 if that helps.

@stineje

stineje commented Jun 1, 2026 via email

Copy link
Copy Markdown
Member

…r time for a correct implementation stores the MTIME value in a new register in csrc.sv
…tion about Spike not implementing stopcount or stoptime.
…Tracer.sv and modified wsim to work with. type wsim debug64 <path/to/test> --lockstep --debug <path/to/testvector/file>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants