arXiv:2505.13479cs.PLcs.AR2025-05中稿 · the IEEE Internati…被引 36

用图结构提升大模型生成硬件代码的准确率

RTL++: Graph-enhanced LLM for RTL Code Generation

  • 将Verilog代码转为控制流与数据流图,增强上下文理解
  • 在VerilogEval上Pass@1达67.3%,超越现有模型
  • 适合芯片设计自动化研究者和工程团队使用

随着硬件设计复杂度提升,电子设计自动化(EDA)亟需先进自动化手段。传统寄存器传输级(RTL)设计依赖人工,耗时且易出错。虽商业指令微调大语言模型(LLM)展现潜力,但存在安全与隐私风险;开源模型则因高质量RTL数据稀缺,常导致生成质量不足。本文提出RTL++,首个基于图结构增强的LLM RTL代码生成方法,通过将代码转化为文本化的控制流图(CFG)与数据流图(DFG),捕捉代码内部层次、依赖与关联关系。该结构化图表示法显著扩展了LLM的上下文信息,使其更精准理解与生成指令。相比仅依赖代码输入的模型,本方法提升了生成多样性与准确性。实验表明,RTL++在VerilogEval基准上的Pass@1/5/10分别为67.3%/82.1%/87.4%,优于当前最优微调模型及RTLLM1.1模型,验证了图增强上下文对提升LLM辅助RTL生成能力的有效性。

原文摘要 · Abstract (English)

As hardware design complexity escalates, there is an urgent need for advanced automation in electronic design automation (EDA). Traditional register transfer level (RTL) design methods are manual, time-consuming, and prone to errors. While commercial (instruction-tuned) large language models (LLMs) shows promising performance for automation, they pose security and privacy concerns. Open-source models offer alternatives; however, they frequently fall short in quality/correctness, largely due to limited, high-quality RTL code data essential for effective training and generalization. This paper proposes RTL++, a first-of-its-kind LLM-assisted method for RTL code generation that utilizes graph representations of code structures to enhance the quality of generated code. By encoding RTL code into a textualized control flowgraphs (CFG) and data flow graphs (DFG), RTL++ captures the inherent hierarchy, dependencies, and relationships within the code. This structured graph-based approach enhances the context available to LLMs, enabling them to better understand and generate instructions. By focusing on data generation through graph representations, RTL++ addresses the limitations of previous approaches that rely solely on code and suffer from lack of diversity. Experimental results demonstrate that RTL++ outperforms state-of-the-art models fine-tuned for RTL generation, as evaluated using the VerilogEval benchmark's Pass@1/5/10 metric, as well as the RTLLM1.1 model, which highlight the effectiveness of graph-enhanced context in advancing the capabilities of LLM-assisted RTL code generation.

硬件生成图神经网络大模型应用

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。