[论文解读] Revisiting VerilogEval: A Year of Improvements in Large-Language Models for Hardware Code Generation
该论文将VerilogEval基准扩展以支持规范到RTL任务、上下文学习(ICL)示例以及详细的失败分类。它评估了较新的大语言模型(包括GPT-4 Turbo和Llama 3.1 405B),在规范到RTL任务上实现了59%的通过率,且性能高度依赖于提示工程和模型特定调优。
The application of large-language models (LLMs) to digital hardware code generation is an emerging field, with most LLMs primarily trained on natural language and software code. Hardware code like Verilog constitutes a small portion of training data, and few hardware benchmarks exist. The open-source VerilogEval benchmark, released in November 2023, provided a consistent evaluation framework for LLMs on code completion tasks. Since then, both commercial and open models have seen significant development. In this work, we evaluate new commercial and open models since VerilogEval's original release-including GPT-4o, GPT-4 Turbo, Llama3.1 (8B/70B/405B), Llama3 70B, Mistral Large, DeepSeek Coder (33B and 6.7B), CodeGemma 7B, and RTL-Coder-against an improved VerilogEval benchmark suite. We find measurable improvements in state-of-the-art models: GPT-4o achieves a 63% pass rate on specification-to-RTL tasks. The recently released and open Llama3.1 405B achieves a 58% pass rate, almost matching GPT-4o, while the smaller domain-specific RTL-Coder 6.7B models achieve an impressive 34% pass rate. Additionally, we enhance VerilogEval's infrastructure by automatically classifying failures, introducing in-context learning support, and extending the tasks to specification-to-RTL translation. We find that prompt engineering remains crucial for achieving good pass rates and varies widely with model and task. A benchmark infrastructure that allows for prompt engineering and failure analysis is essential for continued model development and deployment.
研究动机与目标
- 为解决现有Verilog代码生成基准的局限性,例如缺乏对上下文学习(ICL)的支持和失败分析能力。
- 将VerilogEval基准扩展以包含规范到RTL转换任务,与指令微调的大语言模型对齐。
- 评估较新商业及开源大语言模型(包括GPT-4 Turbo和Llama 3.1)在代码补全与规范到RTL任务上的表现。
- 引入一种失败分类系统,实现对模型与提示策略下编译器错误与运行时错误的细粒度分析。
- 证明提示工程显著影响模型性能,且其影响在不同模型与任务间存在差异。
提出的方法
- 将原始VerilogEval基准扩展为支持使用聊天式格式(含[BEGIN]和[DONE]标签)的规范到RTL提示,类似MBPP。
- 通过在提示中注入最多四个问题-解决方案对,集成上下文学习(ICL),适用于代码补全与规范到RTL任务。
- 开发基于Makefile的评估环境,将数据集管理与评估逻辑解耦,实现跨模型的可扩展且可复现的测试。
- 实现失败分类流水线,将模型输出分类为编译错误、运行时错误与逻辑错误,并通过颜色编码提供可视化反馈。
- 通过静态与动态分析自动化失败分类,报告不同模型与提示配置下的通过率与错误类型分布。
- 在https://github.com/NVlabs/verilog-eval公开发布增强版基准,以支持持续研究与模型开发。

实验结果
研究问题
- RQ1相较于旧模型,较新的大语言模型(包括GPT-4 Turbo与Llama 3.1)在规范到RTL硬件代码生成任务上的表现如何?
- RQ2上下文学习(ICL)在不同大语言模型与任务上对通过率的提升程度如何?其影响如何随模型架构而变化?
- RQ3大语言模型生成的Verilog代码中最常见的错误类型(如编译错误、运行时错误、逻辑错误)是什么?这些错误在不同模型与提示策略下如何变化?
- RQ4开源模型与领域特定大语言模型能否在硬件代码生成任务中达到与闭源最先进模型相当的性能?
- RQ5提示工程如何影响模型行为?失败分类在指导有效提示调优中扮演何种角色?
主要发现
- GPT-4 Turbo在规范到RTL任务上实现了59%的通过率,显著优于以往模型,展现出对指令微调提示的强大泛化能力。
- Llama 3.1 405B在规范到RTL任务上实现了58%的通过率,与GPT-4 Turbo表现相当,表明开源模型如今已能与商业模型比肩。
- RTL-Coder 6.7B模型在规范到RTL任务上实现了37%的通过率,展现出小型领域专用模型的强劲性能。
- 上下文学习(ICL)提升了GPT-4 Turbo与Llama 3.1 405B在代码补全任务上的表现,但对其他模型效果不一,部分模型因提示引入的错误而出现性能下降。
- 失败分类分析显示,在零样本设置下,编译错误是最主要的失败模式,尤其在Llama 3.1 70B上频繁出现缺少endmodule语句的情况,表明需要针对性的提示调优。
- 性能在不同模型与任务间差异显著,Llama 3.1 70B在ICL提示下代码补全任务性能下降,主要因endmodule错误;而GPT-4 Turbo在规范到RTL任务中使用更多ICL示例时出现轻微性能下降。

更好的研究,从现在开始
从阅读论文到最终审阅,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。