✨ [rtl] on-chip debugger: add RISC-V trigger module for hardware breakpoints #274
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds a simple implementation of the RISC-V trigger module to the CPU core. It complies to the RISC-V debug spec. v0.13.2. A copy of this spec. can be found in docs/references.
💡 The NEORV32 trigger module is part of the on-chip debugger and implements a single instruction address match trigger that can be used to add "hardware-assisted breakpoints" when debugging code that is executed from ROM.
The idea to add this was triggered by @emb4fun.
Hardware Breakpoints vs. Software Breakpoints
The "normal" software breakpoints using gdb's
b
/break
command temporarily replace the instruction word, where the debugger shall halt, by a BREAK instruction (ebreak
orc.ebreak
). After the CPU has halted and entered debug mode, the debugger will restore the original instruction word to maintain correct operation. Obviously, this concept is only possible when the program being executed resides in RAM.Example: Adding a software breakpoint at address 0xffff0000 in gdb:
b *0xffff0000
When debugging code, which is executed from ROM, one needs to use hardware-assisted breakpoints using gdb's
hb
/hbreak
commands. A hardware breakpoint uses the CPU's trigger module to store the address of the instruction that shall trigger a breakpoint. Whenever execution reaches this specific address the CPU is halted and enters debug mode.Example: Adding a hardware-assisted breakpoint at address 0xffff0000 in gdb:
hb *0xffff0000
🐛 This PR also fixes a minor bug in
ebreak
instruction'sdcsr.cause
value (was 0b010 but has to be 0b001).