arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2510.15914cs.ARcs.AIcs.PL
收藏

VeriGRAG:利用结构感知软提示增强基于 LLM 的 Verilog 代码生成

VeriGRAG: Enhancing LLM-Based Verilog Code Generation with Structure-Aware Soft Prompts

Jiayu Zhao, Zehua Pei, Zetao Guo, Bei Yu, Song Chen

AI总结:

本文提出 VeriGRAG 框架,通过 GNN 提取 Verilog 结构图嵌入、多模态检索与 VeriFormer 对齐生成结构感知软提示,从而提升 LLM 的 Verilog 代码正确性,并在 VerilogEval 和 RTLLM 上取得优异性能。

摘要:

大型语言模型(LLM)已展现出根据自然语言描述生成 Verilog 代码的强大能力。然而,Verilog 代码本身编码了硬件电路的结构信息。如何有效利用这些结构信息来提升 LLM 生成的 Verilog 代码在功能和语法上的正确性,仍是一项重大挑战。为应对该挑战,我们提出 VeriGRAG,这是一个新颖框架,使用图神经网络(GNN)从 Verilog 代码中提取结构图嵌入。随后,多模态检索器为给定生成任务选择最相关的图嵌入,并通过 VeriFormer 模块将这些嵌入与代码模态对齐,以生成结构感知的软提示。实验表明,VeriGRAG 显著提高了 Verilog 代码生成的正确性,在 VerilogEval 和 RTLLM 两个基准上均达到最先进或更优的性能。

英文摘要:

Large language models (LLMs) have demonstrated remarkable capabilities in generating Verilog code from natural language descriptions. However, Verilog code inherently encodes the structural characteristics of hardware circuits, including data path organization and interconnections among components. Effectively leveraging these structural characteristics to enhance the functional and syntactic correctness of LLM-based Verilog code generation remains a significant challenge. To address this challenge, we propose VeriGRAG, a novel framework that converts Verilog code into data path graphs and employs graph neural networks (GNNs) to encode their structural information. A multimodal retriever, trained through knowledge distillation from a cross-attention encoder to a dual encoder, then selects the graph embeddings most relevant to the input hardware description. The VeriFormer module uses learnable query tokens and two-stage training to extract code-relevant structural features and align them with the LLM's input embedding space, producing structure-aware soft prompts. Experiments on VerilogEval and RTLLM show improvements in both syntactic and functional correctness. With Qwen2.5-Coder-32B as its backbone, VeriGRAG achieves the highest functional $pass@1$ and $pass@5$ scores among the compared methods on both benchmarks.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑