Skip to main content
QUICK REVIEW

[Paper Review] VeriGen: A Large Language Model for Verilog Code Generation

Shailja Thakur, Baleegh Ahmad|arXiv (Cornell University)|Jul 28, 2023
Ferroelectric and Negative Capacitance DevicesEngineering9 citations
TL;DR

The paper fine-tunes open-source LLMs on Verilog data to generate Verilog code, showing that fine-tuned CodeGen-16B rivals or surpasses GPT-3.5-turbo in functional Verilog generation and achieves significant gains over pre-trained models.

ABSTRACT

In this study, we explore the capability of Large Language Models (LLMs) to automate hardware design by generating high-quality Verilog code, a common language for designing and modeling digital systems. We fine-tune pre-existing LLMs on Verilog datasets compiled from GitHub and Verilog textbooks. We evaluate the functional correctness of the generated Verilog code using a specially designed test suite, featuring a custom problem set and testing benches. Here, our fine-tuned open-source CodeGen-16B model outperforms the commercial state-of-the-art GPT-3.5-turbo model with a 1.1% overall increase. Upon testing with a more diverse and complex problem set, we find that the fine-tuned model shows competitive performance against state-of-the-art gpt-3.5-turbo, excelling in certain scenarios. Notably, it demonstrates a 41% improvement in generating syntactically correct Verilog code across various problem categories compared to its pre-trained counterpart, highlighting the potential of smaller, in-house LLMs in hardware design automation.

Motivation & Objective

  • Motivate automating hardware design by generating Verilog code with LLMs.
  • Create a large Verilog-focused training corpus from GitHub and Verilog textbooks.
  • Fine-tune multiple open-source LLMs on the Verilog corpus and evaluate their code generation quality.
  • Develop an automated evaluation pipeline with Verilog compilation and unit-test checks.
  • Release training/evaluation scripts and checkpoints as open-source resources.

Proposed method

  • Curate a Verilog training corpus from GitHub (~50k files) and Verilog textbooks (PDFs) to form a 400 MB Verilog dataset.
  • Fine-tune five pre-trained LLMs ranging from 345M to 16B parameters on the Verilog corpus using multi-GPU training with DeepSpeed/ZeRO-3 strategies.
  • Evaluate models with two problem sets: Set I (hand-designed Verilog challenges) and Set II (extended HDLBits-derived problems) plus custom test benches.
  • Compile-generated Verilog with Icarus Verilog and verify functional correctness via unit tests and HDLBits-based simulations.
  • Compare fine-tuned models against large commercial LLMs (GPT-3.5-turbo, GPT-4, PALM2) and against an open-source baseline, analyzing temperature and prompt effects.
  • Report that fine-tuned CodeGen-16B achieves the best performance among evaluated models and is competitive with larger, commercial LLMs.

Experimental results

Research questions

  • RQ1RQ1: How well do base LLMs perform on the Verilog generation sets?
  • RQ2RQ2: Does fine-tuning improve Verilog generation performance?
  • RQ3RQ3: Are larger LLMs with more parameters better for Verilog generation?
  • RQ4RQ4: How does variation in problem description affect quality and correct completions?
  • RQ5RQ5: How does Fine-Tuned LLM performance stack up against GPT-3.5-turbo, GPT-4, PALM2, and Claude for different problem complexities?
  • RQ6RQ6: At what difficulty levels do large LLMs excel or need enhancement to meet the best performing models?
  • RQ7RQ7: Does incorporating diverse training data (e.g., textbooks) boost model performance?

Key findings

  • Fine-tuned LLMs outperform their pre-trained counterparts across datasets.
  • Fine-tuned CodeGen-16B MSV outperforms other evaluated LLMs, including some larger models.
  • The fine-tuned model shows a 41% improvement in generating syntactically correct Verilog code over its pre-trained version.
  • The 1.1% overall improvement of fine-tuned models over GPT-3.5-turbo is reported for the best-performing configurations.
  • Evaluation reveals that larger parameter counts generally correlate with more completions passing test benches and synthesis checks.
  • Prompt detail and temperature negatively impact performance, with lower temperatures and more completions per prompt yielding better results.

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.