[论文解读] CodeV: Empowering LLMs with HDL Generation through Multi-Level Summarization
CodeV 通过对 Verilog 代码进行反向提示以获得多级自然语言描述,在 VerilogEval 和 RTLLM 基准测试上实现 Verilog 生成任务的 SOTA。
The design flow of processors, particularly in hardware description languages (HDL) like Verilog and Chisel, is complex and costly. While recent advances in large language models (LLMs) have significantly improved coding tasks in software languages such as Python, their application in HDL generation remains limited due to the scarcity of high-quality HDL data. Traditional methods of adapting LLMs for hardware design rely on synthetic HDL datasets, which often suffer from low quality because even advanced LLMs like GPT perform poorly in the HDL domain. Moreover, these methods focus solely on chat tasks and the Verilog language, limiting their application scenarios. In this paper, we observe that: (1) HDL code collected from the real world is of higher quality than code generated by LLMs. (2) LLMs like GPT-3.5 excel in summarizing HDL code rather than generating it. (3) An explicit language tag can help LLMs better adapt to the target language when there is insufficient data. Based on these observations, we propose an efficient LLM fine-tuning pipeline for HDL generation that integrates a multi-level summarization data synthesis process with a novel Chat-FIM-Tag supervised fine-tuning method. The pipeline enhances the generation of HDL code from natural language descriptions and enables the handling of various tasks such as chat and infilling incomplete code. Utilizing this pipeline, we introduce CodeV, a series of HDL generation LLMs. Among them, CodeV-All not only possesses a more diverse range of language abilities, i.e. Verilog and Chisel, and a broader scope of tasks, i.e. Chat and fill-in-middle (FIM), but it also achieves performance on VerilogEval that is comparable to or even surpasses that of CodeV-Verilog fine-tuned on Verilog only, making them the first series of open-source LLMs designed for multi-scenario HDL generation.
研究动机与目标
- Motivate automated Verilog/HDL code generation to reduce hardware design costs.
- Overcome data scarcity by constructing a high-quality, Verilog-focused instruction-tuning dataset from real-world code.
- Demonstrate that multi-level summarization improves description-code alignment for HDL tasks.
- Show that fine-tuning open-source LLMs on CodeV data yields SOTA Verilog generation performance.
提出的方法
- Collect high-quality real-world Verilog modules from GitHub and filter for self-contained syntax-correct code.
- Apply multi-level summarization by prompting GPT-3.5 to generate fine-grained functional descriptions and high-level requirements from Verilog code.
- Construct a description-code dataset using reverse instruction generation and decontaminate via Rouge-L based filtering.
- Fine-tune base LLMs (CodeLlama, DeepSeekCoder, CodeQwen) on the CodeV dataset with supervised objective (negative log-likelihood).
- Evaluate on VerilogEval and RTLLM benchmarks using pass@k and syntax/functional checks.

实验结果
研究问题
- RQ1Can multi-level summarization bridge the semantic gap between Verilog code and natural language descriptions for data-efficient instruction tuning?
- RQ2Does reverse instruction generation improve the quality of Verilog description-code pairs compared to traditional description-first approaches?
- RQ3How do CodeV-tuned models compare to existing open-source and commercial SOTA models on Verilog generation benchmarks?
- RQ4What is the impact of dataset size and MLS (multi-level summarization) on Verilog generation performance?
主要发现
- CodeV models achieve state-of-the-art results on VerilogEval and RTLLM benchmarks, outperforming prior open-source SOTA and GPT-4 in Verilog generation tasks.
- Multi-level summarization significantly improves reasoning about Verilog functionality, yielding better pass@k and syntax/functional correctness.
- CodeV-CodeLlama and CodeV-CodeQwen variants reach notable pass@1 and syntax/functional scores, with strong performance on machine-human evaluation gaps.
- Dataset size scaling shows performance improves with more data but with diminishing returns, highlighting the importance of data quality over sheer quantity.
- The approach yields a 22.1% relative improvement over GPT-4 on VerilogEval in aggregate measures.
![Figure 2: GPT-generated Verilog dataset contains unrealistic code. (a) A synthetic description obtained from [ 26 ] , which is unrealistic. (b) The circuit’s block diagram according to the description, contains illegal loops in the circuit. (c) The corresponding incorrect Verilog code in the dataset](https://ar5iv.labs.arxiv.org/html/2407.10424/assets/x2.png)
阅读本论文
在 Nubint 阅读器中打开原文,边读边就任意段落提问。
在 Nubint 中阅读本论文本解读由 AI 根据论文原文生成,引用前请核对原文。