Abstract
DeepRTL2 is a unified Large Language Model (LLM) framework designed for both generative and embedding-based Register Transfer Level (RTL) tasks. By integrating Generative Representational Instruction Tuning (GRIT) and a two-stage training pipeline, DeepRTL2 excels in code generation, natural language code search, functional equivalence checking, and performance prediction. Experimental results demonstrate that DeepRTL2 achieves state-of-the-art performance, outperforming general-purpose models like GPT-4o in hardware-specific logic understanding.
Introduction
Large Language Models (LLMs) have demonstrated significant potential in Verilog code generation. However, modern hardware design requires more than just code synthesis; it demands tools capable of searching massive codebases, verifying functional identity, and predicting performance metrics like area and delay before synthesis. DeepRTL2, developed by researchers at The Chinese University of Hong Kong, addresses these needs by unifying generative and embedding-based tasks into a single "Swiss Army Knife" for Electronic Design Automation (EDA).
Methods
DeepRTL2 is built upon base models such as Llama-3.1-8B and DeepSeek-Coder-6.7B. The core innovation is the adoption of the Generative Representational Instruction Tuning (GRIT) framework, which enables a decoder-only model to function as both a generator and an encoder.
The training follows a two-stage pipeline:
- Curriculum Learning: Progressive training from line-level comments to high-level functional descriptions.
- Contrastive Learning with Hard Negatives: To improve equivalence checking, the model is trained to distinguish between code snippets that are syntactically similar but logically different, using feedback from the Yosys synthesis tool.
Datasets
The researchers curated a comprehensive dataset including over 400k RTL samples annotated via GPT-4o with Chain-of-Thought (CoT) strategies, 59,700 pairs for natural language code search, and 18,766 samples mapped to real area and delay metrics using the SkyWater 130nm library.
Key Results and Insights
DeepRTL2 sets new benchmarks across various RTL tasks. A critical finding was the importance of "hard negatives"—intentionally generating code with subtle logic errors significantly boosted verification capabilities. Furthermore, hardware-specific fine-tuning proved mandatory, as general-purpose embedding models like OpenAI’s text-embedding-3-large failed to capture the nuances of hardware logic.
In RTL understanding, DeepRTL2 outperformed GPT-4o in metrics such as BLEU and METEOR. In code search, it achieved an F1 score of 0.463, nearly doubling the performance of OpenAI’s best embedding models. For performance prediction, the model achieved an $R^2$ score of 0.805 for area, indicating that its embeddings successfully capture structural hardware complexity.
Conclusion
DeepRTL2 represents a significant advancement in bridging the gap between hardware description and analysis. While challenges remain in bridging the "physical gap" to post-layout metrics, future work will focus on incorporating Control Data Flow Graphs (CDFG) to provide a more structured representation of hardware logic.
Summary updated