Skip to main content
QUICK REVIEW

[Paper Review] Make Every Move Count: LLM-based High-Quality RTL Code Generation Using MCTS

Matthew DeLorenzo, Animesh Basak Chowdhury|arXiv (Cornell University)|Feb 5, 2024
Advanced Wireless Communication TechniquesEngineering6 citations
TL;DR

The paper introduces an MCTS-guided decoding framework (VeriGen+MCTS) that uses a transformer-based LLM to generate Verilog RTL code that is compilable, functionally correct, and optimized for PPA. It reports significant ADP improvements over prior LLM-only approaches, including up to 31.8% for a 16-bit adder.

ABSTRACT

Existing large language models (LLMs) for register transfer level code generation face challenges like compilation failures and suboptimal power, performance, and area (PPA) efficiency. This is due to the lack of PPA awareness in conventional transformer decoding algorithms. In response, we present an automated transformer decoding algorithm that integrates Monte Carlo tree-search for lookahead, guiding the transformer to produce compilable, functionally correct, and PPA-optimized code. Empirical evaluation with a fine-tuned language model on RTL codesets shows that our proposed technique consistently generates functionally correct code compared to prompting-only methods and effectively addresses the PPA-unawareness drawback of naive large language models. For the largest design generated by the state-of-the-art LLM (16-bit adder), our technique can achieve a 31.8% improvement in the area-delay product.

Motivation & Objective

  • Address compilation and functional correctness gaps in LLM-generated RTL code.
  • Enable PPA-aware RTL generation by guiding LLM decoding with search.
  • Handle practical designs (adders, multipliers, MACs) and optimize for area and delay.
  • Utilize modularity to reuse optimized sub-modules for large designs.
  • Demonstrate performance gains over prompting-only strategies across multiple bit widths.

Proposed method

  • Formulate Verilog RTL generation as a Markov decision process (MDP) over LLM tokens.
  • Apply Monte Carlo Tree Search (MCTS) with a policy that combines MCTS statistics and LLM priors (UCT-based exploration).
  • Define a reward function that penalizes non-compilable or non-functional code and emphasizes area-delay product (ADP).
  • Prune non-functional tokens (e.g., comments) to reduce search space.
  • Use modularity by reusing optimized sub-modules to scale to large designs (e.g., 64-bit adders).
  • Evaluate on adders, multipliers, and MAC units using VeriGen-2B as the base LLM and standard synthesis tools to derive PPA.

Experimental results

Research questions

  • RQ1Can an MCTS-guided decoding framework produce functionally correct Verilog RTL when used with an LLM?
  • RQ2Does incorporating PPA-aware rewards yield optimized RTL (lower area, delay, or ADP) compared to prompting-only methods?
  • RQ3How does token pruning (e.g., removing non-functional tokens) affect search efficiency and code quality?
  • RQ4Can modular reuse of sub-modules enable scalable generation for large bit-width designs?
  • RQ5How does VeriGen+MCTS compare to VeriGen with beam search or greedy decoding across various modules and sizes?

Key findings

  • VeriGen+MCTS yields functionally correct Verilog codes for all tested modules, while VeriGen and VeriGen+Beam Search fail on many modules.
  • ADP improvements with VeriGen+MCTS average 5.69% over VeriGen and 14.27% over VeriGen+Beam for modules with functional codes.
  • For the largest design (16-bit adder), VeriGen+MCTS achieves up to 31.8% ADP improvement over a baseline (state-of-the-art prompting approach).
  • Modularity and sub-module reuse substantially improve MCTS iteration rates for large designs (e.g., 3x faster for 64-bit adders).
  • A higher baseline reward increases exploitation and functional-code proportions, while intermediate values balance exploration and exploitation in the MCTS process.

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.