Skip to content
Rivoryxa Technologies

Proving a debug path in a RISC-V core can never run

An open coverage hole in a RISC-V core's controller. We proved two of its conditions can never happen and wrote a test that reaches the third.

Open source RISC-V core, coverage hole 1010Outcome: Dead code, proven

1The issue

Line 850 of the core's controller, and the 36 lines after it, never ran in any of the maintainers' simulations. The code handles debug single stepping while the core runs a hardware loop. The same code in another controller state is fully covered. The core's maintainers suspected it could never run, but could not set up a formal proof, so the hole stayed open.

The points on the issue

Row 1: single step offAlready covered by the maintainers' tests
Rows 2 and 3: single step on, outside debug modeCan never happen. Proven with formal verification.
Row 4: single step on, inside debug modeCan happen. Our new test reaches it.

2What we did

  1. 1Found why rows 2 and 3 can never happen. Single step can only be turned on by a debug return or a register write, and both send the controller back to its normal state. There it stops for the single step before it can enter the hardware loop state.
  2. 2Proved this with formal verification, which checks every reachable state, not only the ones a test happens to try.
  3. 3Checked the proof is meaningful. When we broke the design on purpose, the check failed, so it can catch a real bug.
  4. 4Wrote a test for row 4: in debug mode, turn on single step and run a hardware loop. It reaches the row on 28 clock cycles, and on none when single step is left off.

3Result

Every part of the hole is now either proven impossible or reached by a test. The part that can never happen can be waived safely. The part that can happen now has a test.

The proof covers the build without the floating point unit, run with open source tools. The report lists every limit.

Have a coverage hole like this one?

Describe the problem in a few lines. An engineer replies, and we agree the scope together.

Discuss a verification problem