迈向 LLM 驱动的 Verilog RTL 助手:自验证与自校正
Towards LLM-Powered Verilog RTL Assistant: Self-Verification and Self-Correction
AI总结:
本文提出LLM驱动的Verilog RTL编程助手VeriAssist,通过集成自动提示系统与RTL模拟器实现代码自验证与自校正,显著提升了生成代码的语法与功能正确性,降低人工干预并使新手能进行RTL设计。
摘要:
我们探索使用大型语言模型(LLMs)以最少的人工干预生成高质量的寄存器传输级(RTL)代码。传统的 RTL 设计工作流需要人类专家手动编写高质量的 RTL 代码,这既耗时又容易出错。借助新兴的 LLMs,开发者可以向 LLMs 描述其需求,随后 LLMs 会生成相应的 Python、C、Java 等代码。然而,采用 LLMs 在硬件描述语言中生成 RTL 设计并非易事,因为硬件设计本身具有复杂性,且生成的设计必须满足时序和物理约束。我们提出了 VeriAssist,一个由 LLM 驱动的、用于 Verilog RTL 设计工作流的编程助手。VeriAssist 将 RTL 设计描述作为输入,并生成高质量的 RTL 代码及相应的测试平台(test benches)。VeriAssist 通过采用自动提示系统并将 RTL 模拟器集成到代码生成循环中,使 LLM 能够对生成的代码进行自校正和自验证。为了生成 RTL 设计,VeriAssist 首先生成初始 RTL 代码和相应的测试平台,接着进行自验证步骤,通过测试用例遍历代码以推理其在不同时间步的行为,最后通过读取编译和仿真结果进行自校正,生成修复了编译和仿真错误的最终 RTL 代码。该设计充分利用了 LLMs 在多轮交互和思维链推理方面的能力,以提高生成代码的质量。我们使用各种基准测试套件对 VeriAssist 进行了评估,发现它显著提升了现有 LLM 实现在语法和功能正确性方面的表现,从而最大程度地减少了人工干预,并使新手开发者也能轻松进行 RTL 设计。
英文摘要:
We explore the use of Large Language Models (LLMs) to generate high-quality Register-Transfer Level (RTL) code with minimal human interference. The traditional RTL design workflow requires human experts to manually write high-quality RTL code, which is time-consuming and error-prone. With the help of emerging LLMs, developers can describe their requirements to LLMs which then generate corresponding code in Python, C, Java, and more. Adopting LLMs to generate RTL design in hardware description languages is not trivial, given the complex nature of hardware design and the generated design has to meet the timing and physical constraints. We propose VeriAssist, an LLM-powered programming assistant for Verilog RTL design workflow. VeriAssist takes RTL design descriptions as input and generates high-quality RTL code with corresponding test benches. VeriAssist enables the LLM to self-correct and self-verify the generated code by adopting an automatic prompting system and integrating RTL simulator in the code generation loop. To generate an RTL design, VeriAssist first generates the initial RTL code and corresponding test benches, followed by a self-verification step that walks through the code with test cases to reason the code behavior at different time steps, and finally it self-corrects the code by reading the compilation and simulation results and generating final RTL code that fixes errors in compilation and simulation. This design fully leverages the LLMs' capabilities on multi-turn interaction and chain-of-thought reasoning to improve the quality of the generated code. We evaluate VeriAssist with various benchmark suites and find it significantly improves both syntax and functionality correctness over existing LLM implementations, thus minimizing human intervention and making RTL design more accessible to novice designers.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。