VeriBug: An Attention-based Framework for Bug-Localization in Hardware Designs

Giuseppe Stracquadanio, Sourav Medya, Stefano Quer, Debjit PalDATE 2024

Abstract

As System-on-Chip (SoC) designs grow in complexity, debugging has become the most resource-intensive phase of the hardware development lifecycle. Traditional localization methods, such as formal verification and manual simulation analysis, often struggle with scalability or provide insufficient diagnostic information. This paper presents VeriBug, an automated framework that utilizes deep learning and attention mechanisms to pinpoint root causes of bugs in Register Transfer Level (RTL) designs. By learning execution semantics from simulation traces and performing differential analysis between passing and failing runs, VeriBug generates explainable heatmaps that guide engineers to buggy code. Experimental results demonstrate an average top-1 localization accuracy of 82.5% across various open-source designs, including a RISC-V processor controller.

1. Introduction

The verification of modern hardware designs is a daunting task. While simulation-based verification scales well to massive designs, it typically only indicates that a test failed, leaving the engineer to manually trace the error back to its source—a process that can take weeks. Existing Machine Learning (ML) approaches to automate this process often treat bug localization as a simple classification task or overfit to specific code structures, limiting their utility on novel designs.

VeriBug addresses these challenges by introducing a design-agnostic framework. It moves beyond simple pattern matching by learning the underlying "execution semantics" of hardware logic, allowing it to generalize across different architectures without requiring massive, manually labeled datasets of buggy hardware.

2. Methodology

VeriBug employs a multi-stage pipeline that integrates static analysis with deep learning to identify suspicious code segments.

2.1 Feature Extraction and Slicing

The process begins with a static analyzer (GOLDMINE) that generates Control-Data Flow Graphs (CDFG) from the Verilog source. To reduce noise, the tool performs "slicing," focusing exclusively on the logic paths relevant to the failing output signal. This ensures the model only processes signals that could theoretically contribute to the observed bug.

2.2 Semantic Learning via PathRNN

Rather than treating Verilog code as plain text, VeriBug extracts structural paths from Abstract Syntax Trees (ASTs). These paths are embedded into vectors using a Long Short-Term Memory (LSTM) network called PathRNN. This approach allows the model to understand the hierarchical and sequential nature of hardware logic.

2.3 The Attention Mechanism

The core of VeriBug is its attention-based neural network. The model is trained on a proxy task: predicting the output value of a statement based on its inputs. During training, the Attention Layer assigns "importance scores" to different operands. These scores represent how much weight the model gives to a specific input when determining the output value.

2.4 Differential Analysis and Heatmap Generation

To localize a bug, VeriBug compares the attention maps of a correct simulation trace ($T_c$) against a failure trace ($T_f$). If the importance of a specific statement or operand shifts significantly between a passing and failing run, it is flagged as highly suspicious. These suspiciousness scores are then mapped back to the original Verilog source code to create a visual heatmap for the verification engineer.

3. Experimental Setup

3.1 Training with RVDG

To ensure the model generalizes to unseen designs, the authors developed a Random Verilog Design Generator (RVDG). This synthetic dataset allows the model to learn general hardware logic and execution semantics from millions of random but synthetically valid logic structures, rather than memorizing specific chip architectures.

3.2 Evaluation Benchmarks

The framework was evaluated on four real-world open-source designs:

  • wb_mux_2: A Wishbone bus multiplexer.
  • usbf_pl & usbf_idma: USB 2.0 protocol and DMA components.
  • ibex_controller: The control unit for the Ibex RISC-V processor core.

3.3 Bug Injection

The researchers injected 103 observable bugs across three categories: Negation (logic inversion), Variable Misuse (incorrect signal assignment), and Operation Substitution (e.g., replacing an AND gate with an OR gate).

4. Results and Discussion

VeriBug achieved an average top-1 bug localization coverage of 82.5%. This indicates that in the majority of test cases, the single most suspicious line identified by the framework was the actual location of the bug.

Performance was particularly high on the complex ibex_controller, reaching 97.6% coverage. The wb_mux_2 design also saw strong results at 87.5%. These results suggest that the model's ability to learn from AST paths and basic logic structures allows for effective "zero-shot" generalization; a model trained on purely synthetic code can successfully debug a RISC-V processor it has never encountered before.

5. Limitations and Future Work

While highly effective for data-flow logic, VeriBug has limitations:

  • Control-Flow Complexity: It may struggle with bugs rooted in complex state machine transitions that are not easily captured in a single data-flow slice.
  • Threshold Sensitivity: The suspiciousness threshold (set to 0.10) is a hyperparameter that may require tuning for different hardware domains.
  • Trace Dependency: The method requires at least one passing and one failing trace. In scenarios where a bug is fundamental and no passing trace exists for a specific output, the differential analysis becomes less effective.

6. Conclusion

VeriBug represents a significant step toward explainable, automated hardware debugging. By repurposing attention weights as a quantitative measure of suspiciousness, the framework provides engineers with actionable insights, significantly reducing the manual effort required to maintain and verify complex SoC designs.

Summary updated

BibTeX
@inproceedings{stracquadanio2024veribug,
  author = {Giuseppe Stracquadanio and Sourav Medya and Stefano Quer and Debjit Pal},
  title = {{VeriBug: An Attention-based Framework for Bug-Localization in Hardware Designs}},
  booktitle = {DATE},
  year = {2024},
}
Figure