Wit-HW: Bug Localization in Hardware Design Code via Witness Test Case Generation

Ruiyang Ma, Daikang Kuang, Ziqian Liu, Jiaxi Zhang, Ping Fan, Guojie Luo

TL;DR

Wit-HW (Witnessing Hardware) is a novel framework that improves hardware bug localization by automatically generating "witness" test cases—passing tests that are executionally similar to a failing one. By comparing these successful runs against the failure using spectrum-based fault localization, Wit-HW can pinpoint buggy RTL code with significantly higher accuracy than existing methods.

What Problem Does This Paper Address?

Debugging hardware is a notorious bottleneck, often consuming over 50% of the total development cycle. When a simulation fails, engineers must sift through massive execution traces to find the "root cause."

Existing automated tools struggle with two main issues:

  1. Concurrency and Interconnectivity: Unlike serial software, hardware signals interact simultaneously, making it hard to isolate which specific statement caused a downstream error.
  2. Sequential Misalignment: Hardware errors often manifest many clock cycles after the buggy statement was actually executed.

Most current tools rely on a single bug-triggering test case. This provides a very narrow "view" of the design's behavior, making it nearly impossible to distinguish between buggy code and "innocent" code that just happened to be running at the same time.

Methods

Wit-HW transforms the localization problem into a test generation problem. It works in two stages:

1. Witness Test Case Generation

The goal is to find a set of passing test cases that "look" like the failing one but don't trigger the bug. To do this efficiently, the authors use a mutation-based evolutionary strategy guided by two key metrics:

  • Similarity Criterion: Uses Coverage Distance (which lines were hit) and State Distance (register value transitions). To handle the sequential nature of hardware, they employ Dynamic Time Warping (DTW) to compare register states across time, allowing for flexible matching even if events happen at slightly different clock cycles.
  • Diversity Criterion: Ensures the generated tests aren't redundant, helping to "cancel out" more innocent statements during the analysis phase.

2. Bug Localization

Once a pool of effective witness cases is generated, Wit-HW applies Spectrum-Based Fault Localization (SBFL) using the Ochiai coefficient. It calculates a "suspiciousness score" for every statement: code that is frequently executed in the failing case but rarely in the passing (witness) cases is flagged as highly suspicious.

Datasets

The authors evaluated Wit-HW on two main sets:

  • Standard Benchmarks: 41 bugs across 10 different hardware designs (e.g., ALU, FSM, I2C controllers, SHA3). These are categorized into Easy (combinational), Medium (small sequential), and Hard (industrial-scale) levels.
  • Real-World Bugs: 13 reproducible bugs harvested from open-source FPGA projects on GitHub/OpenCores to demonstrate "in-the-wild" effectiveness.

Key Insights and Ideas

  • The Power of "Almost" Failing: The most useful information for a debugger isn't just the failure itself, but the successful runs that come as close to the failure as possible. These "witnesses" help prune the search space by showing what the design looks like when it's behaving correctly under similar stress.
  • Registers as the "Source of Truth": While software tools look at variable values, Wit-HW focuses on register transitions. Registers define the state of a hardware system; by tracking their "heartbeat" via DTW, the tool can compare executions even when timing is non-linear.
  • Heuristics over Randomness: The paper proves that guided mutation (using similarity and diversity scores) is far more effective than random test generation for finding the specific inputs needed to isolate a bug.

Key Results

Wit-HW significantly outperformed state-of-the-art baselines like Tarsel and RTL-Repair:

  • Top-1 Accuracy: Wit-HW localized 49% of bugs as the #1 most suspicious statement (compared to 22% for Tarsel).
  • Top-10 Accuracy: It placed the bug within the top 10 results for 88% of the cases.
  • Scalability: On "Hard" designs (thousands of lines of code), Wit-HW maintained strong performance, while baseline tools often failed to provide useful rankings due to the sheer volume of suspicious statements.
  • Real-World Impact: It successfully localized 6 out of 13 complex real-world FPGA bugs at Rank 1.

Limitations and Future Work

  • Constant Execution Bugs: If a bug exists in a statement that is always running (like a global assign or a reset branch that is always triggered), SBFL cannot distinguish it from other "always-on" logic.
  • Complex Protocols: The current signal-level mutation can sometimes generate "illegal" input patterns that violate strict interface protocols (like AXI or PCIe). The authors suggest that integrating LLM-aided test generation or higher-level transaction mutations could solve this.
  • Simulation Overhead: Generating and running 100+ test cases per bug is computationally more expensive than single-trace analysis, though the authors argue the massive saving in manual engineering time justifies the CPU cycles.

Summary updated

BibTeX
@inproceedings{ma2025wit,
  author = {Ruiyang Ma and Daikang Kuang and Ziqian Liu and Jiaxi Zhang and Ping Fan and Guojie Luo},
  title = {{Wit-HW: Bug Localization in Hardware Design Code via Witness Test Case Generation}},
  booktitle = {ICCAD},
  year = {2025},
  doi = {10.1109/iccad66269.2025.11240909},
}
Figure