Location is Key: Leveraging Large Language Model for Functional Bug Localization in Verilog

Bingkun Yao, Ning Wang, Jie Zhou, Xi Wang, Hong Gao, Zhe Jiang, Nan GuanarXiv 2024 · DOI

Abstract

Functional bug localization in Verilog is a critical yet labor-intensive task in hardware design. We present LiK (Location is Key), an LLM-based framework specifically optimized for pinpointing logic errors in Verilog code. By employing a multi-stage training pipeline—including continual pre-training with reasoning thoughts, supervised fine-tuning, and simple preference optimization—LiK achieves a state-of-the-art 93.38% pass@1 accuracy on the RTLLM benchmark, significantly outperforming general-purpose models like GPT-4 and specialized traditional tools.

Introduction

In hardware design, identifying the source of a bug is often more challenging than fixing it. While syntax errors are easily caught by compilers, functional bugs—logic errors that allow code to compile but result in incorrect hardware behavior—are notoriously difficult to isolate. Traditionally, engineers rely on complex setups involving testbenches, assertions, or golden waveforms, which require significant domain expertise and time.

LiK addresses this by providing the first LLM-based solution dedicated to functional bug localization in Verilog. It performs "zero-shot" localization based purely on the text of the design description and the code, eliminating the need for external EDA tools or simulators during the inference phase.

Methodology

LiK is built upon the Deepseek-coder-V2-Lite-base-16B model. The researchers developed a multi-stage training pipeline to adapt this general coding model to the specific nuances of hardware description languages (HDLs).

The multi-stage training pipeline for LiK, incorporating pre-training, SFT, and SimPO.

Multi-Stage Training Pipeline

  1. Two-Round Continual Pre-Training (PT):
    • Round 1: Exposure to a massive corpus of Verilog and C code to reinforce hardware syntax understanding.
  2. Round 2 (Reasoning Thoughts): Training the model to follow a step-by-step reasoning process (Chain of Thought) to identify bugs, mimicking human engineering analysis.
  3. Supervised Fine-Tuning (SFT): The model is trained to output the exact content of the buggy line. The authors noted that focusing on code content rather than line numbers improved accuracy, as LLMs often struggle with precise arithmetic counting.
  4. SimPO (Simple Preference Optimization): This reinforcement learning stage penalizes "near-miss" errors and rewards correct identification, stabilizing performance across different model "temperatures."

Experimental Results

LiK was evaluated against the RTLLM benchmark, a standard for Verilog generation. The results demonstrate that LiK significantly outperforms both general-purpose LLMs and traditional state-of-the-art (SOTA) tools like Strider.

Ablation study showing the performance gains from each stage of the LiK training process.

As shown in the ablation study, the inclusion of reasoning thoughts during pre-training and the final SimPO optimization were crucial for reaching the peak 93.38% pass@1 accuracy. In comparison, GPT-4 scored 77.9% and Claude-3.5-Sonnet scored 90.8% on the same task. Furthermore, the authors demonstrated that accurate localization is a primary bottleneck for automated repair; providing GPT-3.5 with the exact bug location found by LiK increased its repair success rate from ~40% to nearly 59%.

Key Insights

  • Reasoning for Learning, Not Outputting: Forcing the model to output its reasoning thoughts during the final SFT stage actually increased noise and lowered accuracy. Reasoning is most effective when used as a latent capability developed during pre-training.
  • Independence from EDA Tools: Unlike traditional tools that require simulators, LiK operates as a standalone text-based analyzer, making it highly efficient for rapid debugging cycles.

Conclusion and Future Work

LiK represents a significant step forward in automated hardware debugging. While currently focused on single-module bugs, future work aims to expand the framework to handle hierarchical multi-module designs, incorporate feedback from EDA tools (such as waveforms), and support other hardware languages like VHDL and Chisel.

Summary updated

BibTeX
@misc{yao2024location,
  author = {Bingkun Yao and Ning Wang and Jie Zhou and Xi Wang and Hong Gao and Zhe Jiang and Nan Guan},
  title = {{Location is Key: Leveraging Large Language Model for Functional Bug Localization in Verilog}},
  year = {2024},
  eprint = {2409.15186},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2409.15186},
}
Figure