Skip to main content
QUICK REVIEW

[Paper Review] CodeV: Empowering LLMs with HDL Generation through Multi-Level Summarization

Yang Zhao, Di Huang|arXiv (Cornell University)|Jul 15, 2024
Natural Language Processing TechniquesComputer Science5 citations
TL;DR

CodeV trains instruction-tuned Verilog-generation LLMs by reverse prompting Verilog code to obtain multi-level natural language descriptions, achieving SOTA results on VerilogEval and RTLLM benchmarks.

ABSTRACT

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.

Motivation & Objective

  • 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.

Proposed method

  • 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.
Figure 1: The CodeV framework overview. We first collect and filter high-quality Verilog modules from open-source codebases. The modules are then sent to GPT-3.5 to request multi-level summaries. Pairing high-level descriptions with corresponding modules, the high-quality dataset is utilized to fine
Figure 1: The CodeV framework overview. We first collect and filter high-quality Verilog modules from open-source codebases. The modules are then sent to GPT-3.5 to request multi-level summaries. Pairing high-level descriptions with corresponding modules, the high-quality dataset is utilized to fine

Experimental results

Research questions

  • 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?

Key findings

  • 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
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

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.