Wrong Code, Right Structure: Learning Netlist Representations from Imperfect LLM-Generated RTL
Authors: Siyang Cai, Cangyuan Li, Haoyu Gao, Kun Wang, Yinhe Han, Ying Wang
Organizations: School of Advanced Interdisciplinary Sciences, University of Chinese Academy of Sciences, Beijing, China · CICS, Institute of Computing Technology, Chinese Academy of Sciences, Beijing, China · Hangzhou Institute for Advanced Study, University of Chinese Academy of Sciences, Hangzhou, China
Learning effective netlist representations is fundamentally constrained by the scarcity of labeled datasets, as real designs are protected by Intellectual Property (IP) and costly to annotate. Existing work therefore focuses on small-scale circuits with clean labels, limiting scalability to realistic designs. Meanwhile, Large Language Models (LLMs) can generate Register-Transfer-Level (RTL) at scale, but their functional incorrectness has hindered their use in circuit analysis. In this work, we make a key observation: even when LLM-Generated RTL is functionally imperfect, the synthesized netlists still preserve structural patterns that are strongly indicative of the intended functionality. Building on this insight, we propose a cost-effective data augmentation and training framework that systematically exploits imperfect LLM-Generated RTL as training data for netlist representation learning, forming an end-to-end pipeline from automated code generation to downstream tasks. We conduct evaluations on circuit functional understanding tasks, including sub-circuit boundary identification and component classification, across benchmarks of increasing scales, extending the task scope from operator-level to IP-level. The evaluations demonstrate that models trained on our noisy synthetic corpus generalize well to real-world netlists, matching or even surpassing methods trained on scarce high-quality data and effectively breaking the data bottleneck in circuit representation learning.
Figures & tables
Figure 1. Functionally incorrect LLM-Generated RTL can retain structural features of the golden design after synthesis. An example of functionally imperfect LLM-Generated RTL whose synthesized netlist retains structural similarity to the golden netlist.
Figure 2. An overview of our proposed framework. The framework generates RTL variants, synthesizes and filters their netlists, constructs graph datasets, learns netlist representations, and evaluates them on downstream classification tasks.
Figure 3. Netlist-to-graph transformation and feature extraction. Blue nodes mark gate v ’s two-hop neighborhood. A netlist is transformed into a graph with connectivity, local functional, and structural node features; blue nodes mark gate v's two-hop neighborhood.
Dataset
Circuits
Training Nodes
F1-Micro (%)
F1-Macro (%)
Baseline
22
58,036
97.10
90.15
LLMstat *
22
75,020–177,399
96.87 ± 1.57
89.92 ± 3.49
LLMbest †
22
75,020
98.23
93.79
* Mean ± std.; nodes show the five-dataset range. † Best observed batch.
Table 1. Performance comparison on operator-level subcircuit identification: baseline vs. LLM-Augmented datasets.
Dataset
Circuits
Training Nodes
F1-Micro (%)
F1-Macro (%)
Baseline
22
58,036
92.78
89.63
LLM-Raw
22
80,369
92.47
91.72
Voting
22
92,023
94.45
93.79
Table 2. Effect of architecture voting on cross-architecture operator-level generalization.
Dataset
Circuits
Training Nodes
F1-Micro (%)
F1-Macro (%)
Original
22
58,036
45.99±0.75
35.31±0.91
LLM-Raw
110
496,448
40.47±1.41
39.32±0.48
LLM-Filtered
22
64,679
48.49±0.21
42.82±0.14
Table 3. Effect of structural curation under a frozen DeepGate4 encoder.
Dataset
τ
Training Nodes
F1-Micro (%)
F1-Macro (%)
Rule-Based
–
735,800
63.28
43.57
Random selection
–
639,575
56.90
46.38
Similarity filtering
0.50
641,069
66.50
42.80
0.70
641,056
59.24
40.99
0.85
641,204
83.71
53.58
0.95
641,256
84.46
54.96
Table 4. Sensitivity of zero-shot IP-level transfer to the structure-aware filtering threshold.
Metric (Mean)
vs. Source *
vs. Target †
Source–Target ( Δ )
Text-level (MinHash)
0.1375
0.0002
+0.1373
Netlist-level (Cosine)
0.8446
0.7720
+0.0726
* PicoSoC (Verilog), † NEORV32 SoC (VHDL)
Table 5. Similarity analysis across LLM-Generated variants.
Training large language models (LLMs) to write register-transfer level (RTL) requires large corpora of paired specifications and code, and such data is scarce enough that most public corpora are now synthesized. Synthesis provides scale but not correctness, and in two widely used RTL datasets only 24.4% and 53.5% of pairs pass generated functional tests. This raises the question of how much of such a corpus to keep and which part of it. Correctness alone is a poor answer. A pair that misbehaves in one corner case still shows valid syntax and interface conventions, and complex sequential designs are both harder to generate and harder to validate, so filtering by correctness leaves a corpus of short and simple modules. Correctness is also hard to obtain, since behavior leaves little trace on the surface in RTL, and validating an entire corpus only sorts pairs into passed and failed. We present RTLCurator, which learns a behavior-aware compatibility prior by contrasting each specification with implementations that fail simulation, and calibrates it to a new corpus using a small number of validated pairs. It then constructs the retained subset by balancing alignment, representation coverage, and RTL structural richness. On CodeV and RTLCoder, keeping 80% of the corpus this way improves on training with the full corpus across all reported metrics while validating only 10% of the pool, whereas ranking by the score alone falls below random selection and filtering the whole pool by simulation does no better.
Siyang Cai, Cangyuan Li, Wenjing Chang +4
School of Advanced Interdisciplinary Sciences, University of Chinese Academy of Sciences, Beijing, China · CICS, Institute of Computing Technology, Chinese Academy of Sciences, Beijing, China · Computer Network Information Center, Chinese Academy of Sciences, Beijing, China +1
Recent advances in large language models (LLMs) have enabled the automatic synthesis (generation) of register-transfer level (RTL) code from natural language instructions, offering a promising pathway to accelerate chip design. Unlike typical natural language (and software coding) tasks, LLM-based RTL code generation demands strict cycle accuracy with concurrency, where minor logical errors can render a circuit unusable or insecure. While prior work has explored hallucination mitigation via external verification, self-evaluation prompts, retrieval-augmented prompting, domain specific fine-tuning, agentic solutions, and reasoning, these approaches largely overlook the attention-oriented internal mechanisms of LLMs that may inherently correlate with RTL correctness. This work proposes CASS-RTL, a first-of-its-kind framework for discovering and leveraging LLMs' correctness-aware components to guide RTL generation toward functionally accurate outputs. We (i) identify attention heads whose activation patterns consistently differentiate correct from incorrect RTL; (ii) construct a low-dimensional subspace capturing correctness-relevant signals; and (iii) design a lightweight, geometry-aware intervention that steers the model at inference time. CASS-RTL is fully model-agnostic, requires no additional supervision or retraining, and readily integrates into existing models. Empirically, we evaluate CASS-RTL on multiple models and observe 10%-20% improvement in pass@1/5/10 accuracy on VerilogEval and 5% improvement on CVDP, demonstrating the effectiveness of our method in enhancing reliability without sacrificing model efficiency or requiring a large labeled dataset for fine-tuning.
Mohammad Akyash, Nowfel Mashnoor, Kimia Azar +1
Department of Electrical and Computer Engineering (ECE), University of Central Florida, Orlando, FL 32816, USA
Large Language Models (LLMs) are increasingly used in circuit design workflows, yet their reliability on simulator-facing SPICE netlist recognition and manipulation remains poorly understood and is rarely separated from high-level design reasoning. Although netlists are textual, they encode structured circuit objects through topology and parameters. We present NetlistBench, a structure-verified benchmark for SPICE netlist recognition and manipulation. NetlistBench contains 2,342 cases across 24 task families, covering parameter and connectivity recognition and edits, hierarchical operations, equivalence judgment, and long-horizon compound editing. Model outputs are evaluated by a deterministic structure-aware oracle. Across six non-thinking LLMs, performance varies substantially with operation-level structural complexity. Simple local edits reach 96%--100% accuracy, while device addition drops to 41%--83% and equivalence judgment to 49%--90%. Enabling reasoning substantially improves weaker models but does not eliminate structure-preservation failures, with performance still degrading sharply as the edit horizon increases. NetlistBench identifies netlist reliability as a distinct bottleneck for trustworthy LLM-based circuit design automation.
Jiarui Ma, Jianghan Wang, Yuheng Ma +2
Southern University of Science and Technology School of Microelectronics Shenzhen, China