UniRTL: Unifying Code and Graph for Robust RTL Representation Learning

Yi Liu, Hongji Zhang, Lei Chen, Mingxuan Yuan, Qiang Xu

In modern chip design, accelerating the Electronic Design Automation (EDA) workflow is paramount. Traditionally, hardware engineers must wait hours for logic synthesis—the translation of high-level code into a physical circuit map—before evaluating critical metrics like area and delay.

Machine learning offers a compelling shortcut: predicting performance metrics instantly. However, existing models suffer from a fundamental blind spot. They typically analyze either the code (capturing semantic intent) or the circuit graph (capturing physical structure), but rarely both. A new framework, UniRTL, developed by researchers at The Chinese University of Hong Kong and Huawei's Noah’s Ark Lab, bridges this gap by teaching AI to simultaneously "read" hardware blueprints and structural manuals.

The Alignment Challenge in Hardware ML

Hardware is predominantly written in Register Transfer Level (RTL) languages such as Verilog. For machine learning models, this data presents itself in two distinct modalities:

  1. The Code Modality: Explicitly describes the function and logic of the hardware but obscures the complex physical relationships between components.
  2. The Graph Modality: Specifically, the Control Data Flow Graph (CDFG) captures the structural "skeleton" of the hardware—detailing how data flows through gates and registers—but lacks high-level semantic context.

Historically, tools have forced a choice between the two. Large Language Model (LLM)-based approaches treat Verilog like standard software code, missing the structural nuances that dictate physical performance. Conversely, graph-based tools understand the structure but miss the functional intent. The core challenge UniRTL solves is alignment: teaching a model that a specific line of code and a specific cluster of nodes in a graph represent the exact same hardware logic.

The UniRTL Methodology

UniRTL employs a hierarchical, multimodal architecture built on a unified Transformer backbone. It introduces several key innovations to effectively merge code and graph data:

Graph-Aware Tokenizer

Instead of flattening a graph into a simple list of nodes, UniRTL utilizes a Graph Isomorphism Network (GIN) combined with a lightweight Transformer. This module "pre-digests" the circuit's local and global structural information before passing it to the main model.

Hierarchical Training Strategy

The framework is trained in three distinct stages to ensure robust multimodal alignment:

  • Stage 1 (Graph Pretraining): The graph tokenizer is pretrained to understand structural representations.
  • Stage 2 (Text-Code Alignment): A warm-up phase utilizing natural language summaries and Verilog code. Because text-code pairs are abundant, this stage builds a strong semantic foundation.
  • Stage 3 (Graph Incorporation): The final stage employs Mutual Masked Modeling. The model is presented with a graph containing missing nodes and must predict them using the corresponding code (and vice versa). This forces the model to learn a deep, fine-grained mapping between the two modalities.

Datasets and Evaluation

To train UniRTL, the researchers curated a massive dataset of 132,008 RTL designs from sources like RTLCoder and MG-Verilog. From this, a high-quality subset of 38,888 designs was successfully converted into CDFGs using the Yosys synthesis suite.

The model was evaluated on two primary benchmarks: the StructRTL dataset for performance prediction (area and delay) and the DeepRTL2 benchmark for code retrieval and functionality equivalence checking.

Key Insights and Results

UniRTL establishes a new state-of-the-art across multiple hardware design tasks, driven by several core insights:

  • CDFGs are "Lossless": Unlike the simplified data flow graphs used in software AI, the CDFGs utilized in UniRTL preserve complete structural information. This completeness allows UniRTL to understand hardware structure far better than its predecessors.
  • Align Before Fuse: Training on text and code before integrating the graph significantly boosts performance. Establishing semantic understanding first makes structural mapping much more effective.
  • Structure Dictates Physics: Ablation studies revealed that removing the graph component caused a massive drop in performance for area and delay prediction. Code alone is insufficient to model the physical constraints of a chip.

Performance Highlights

  • Performance Prediction: In predicting circuit delay prior to final netlist generation, UniRTL achieved a Mean Absolute Error (MAE) of 0.3384, vastly outperforming the previous best graph-based model (StructRTL at 0.5414) and standard Graph Attention Networks (0.7327).
  • Code Retrieval: On natural language code search tasks, UniRTL achieved an F1 score of 0.662, beating specialized RTL models and even general-purpose heavyweights like OpenAI’s text-embedding-3-large.
  • Efficiency: Despite its multimodal capabilities, UniRTL is highly efficient. It requires only about 300 MB of memory during inference—roughly 50x smaller than typical 7B-parameter LLMs—while providing highly accurate, hardware-specific embeddings.

Limitations and Future Directions

While UniRTL represents a significant leap forward, the authors note a few areas for future development. Currently, the implementation is focused exclusively on Verilog; expanding support to VHDL or SystemVerilog is a logical next step. Additionally, the model relies on code being "synthesizable" to generate the necessary graph modality. If the input code contains syntax errors—a common issue with LLM-generated code—the graph cannot be utilized. Finally, while UniRTL excels at the module level, scaling the framework to handle massive, multi-million-gate industrial System-on-Chip (SoC) designs remains an exciting challenge for future research.

Summary updated

BibTeX
@inproceedings{liu2026unirtl,
  author = {Yi Liu and Hongji Zhang and Lei Chen and Mingxuan Yuan and Qiang Xu},
  title = {{UniRTL: Unifying Code and Graph for Robust RTL Representation Learning}},
  booktitle = {International Conference on Machine Learning},
  year = {2026},
  url = {https://openreview.net/forum?id=hzYEWSTOEA},
}
Figure