Classification-Based Automatic HDL Code Generation Using LLMs
Wenhao Sun, Bing Li, Grace Li Zhang, Xunzhao Yin, Cheng Zhuo, Ulf Schlichtmann
TL;DR
This paper addresses hallucinations in HDL code generation by introducing a human-expert-inspired, training-free workflow for LLM-based HDL synthesis. The method starts with circuit-type classification, then extracts explicit information lists, and applies type-specific (SEQU/COMB) or general BEHAV generation, guided by a verification-driven search over code candidates. It demonstrates substantial improvements in functional correctness on VerilogEval-human and VerilogEval-machine datasets, highlighting the value of structured task decomposition, explicit information modeling, and budgeted verification over naive one-shot generation. The work offers a practical pathway to more reliable HDL generation with LLMs, reducing reliance on fine-tuning, large databases, or testbench-only feedback loops, and suggesting avenues for further refinement of information-list quality and budget strategies.
Abstract
While large language models (LLMs) have demonstrated the ability to generate hardware description language (HDL) code for digital circuits, they still suffer from the hallucination problem, which leads to the generation of incorrect HDL code or misunderstanding of specifications. In this work, we introduce a human-expert-inspired method to mitigate the hallucination of LLMs and improve the performance in HDL code generation. We first let LLMs classify the type of the circuit based on the specifications. Then, according to the type of the circuit, we split the tasks into several sub-procedures, including information extraction and human-like design flow using Electronic Design Automation (EDA) tools. Besides, we also use a search method to mitigate the variation in code generation. Experimental results show that our method can significantly improve the functional correctness of the generated Verilog and reduce the hallucination of LLMs.
