Spec2RTL-Agent: Automated Hardware Code Generation from Complex Specifications Using LLM Agent Systems

Zhongzhi Yu, Mingjie Liu, Michael Zimmer, Yingyan Celine Lin, Yong Liu, Haoxing RenarXiv 2025 · OpenReview

Abstract

Despite recent progress in generating hardware RTL code with LLMs, existing solutions still suffer from a substantial gap between practical application scenarios and the requirements of real-world RTL code development. Prior approaches either focus on overly simplified hardware descriptions or depend on extensive human guidance to process complex specifications, limiting their scalability and automation potential. In this paper, we address this gap by proposing an LLM agent system, termed Spec2RTL-Agent, designed to directly process complex specification documentation and generate corresponding RTL code implementations, advancing LLM-based RTL code generation toward more realistic application settings. To achieve this goal, Spec2RTL-Agent introduces a novel multi-agent collaboration framework that integrates three key enablers: (1) a reasoning and understanding module that translates specifications into structured, step-by-step implementation plans; (2) a progressive coding and prompt optimization module that iteratively refines the code across multiple representations to enhance correctness and synthesisability for RTL conversion; and (3) an adaptive reflection module that identifies and traces the source of errors during generation, ensuring a more robust code generation flow. Instead of directly generating RTL from natural language, our system strategically generates synthesizable C++ code, which is then optimized for HLS. This agent-driven refinement ensures greater correctness and compatibility compared to naive direct RTL generation approaches. We evaluate Spec2RTL-Agent on three specification documents, showing it generates accurate RTL code with up to 75% fewer human interventions than existing methods. This highlights its role as the first fully automated multi-agent system for RTL generation from unstructured specs, reducing reliance on human effort in hardware design.

Introduction

The generation of Register Transfer Level (RTL) code is a critical yet labor-intensive stage in hardware design. While Large Language Models (LLMs) have demonstrated proficiency in software coding, their application to hardware design has been limited by the complexity of real-world specifications. These documents are often lengthy (tens of pages), multi-modal (containing tables, equations, and diagrams), and lack a rigid structure, as seen in NIST-standard documentation.

Existing LLM-based solutions typically focus on isolated modules or require significant human intervention to decompose specifications into manageable prompts. Spec2RTL-Agent addresses these limitations by providing an end-to-end automated framework that handles the entire pipeline from unstructured specification to final implementation, automating the understanding, coding, and reflection stages.

Comparison of Spec2RTL-Agent with existing automated RTL generation workflows.

The Spec2RTL-Agent Framework

Spec2RTL-Agent employs a multi-agent collaboration framework designed to mimic the workflow of a human hardware engineer. The system is partitioned into three primary modules:

  1. Iterative Understanding and Reasoning: A team of agents (Understanding, Decomposer, and Description agents) processes the raw specification document. They extract critical information into a structured "Information Dictionary," which includes inputs, outputs, functional steps, and references. This dictionary serves as a clear implementation plan, mitigating the "noise" inherent in long documents.
  2. Progressive Coding and Prompt Optimization: To ensure logical correctness, the system avoids direct RTL generation. Instead, it follows a path of increasing abstraction: Pseudocode $\rightarrow$ Python $\rightarrow$ C++. By verifying logic in high-level languages first, the system leverages the LLM's superior performance in these domains. A "Prompt Optimizer" iteratively refines instructions based on verification failures.
  3. Adaptive Reflection: When a test fails, an Analysis Agent traces the error back to its source—whether it be a coding error, a faulty instruction, or a misunderstanding of a previous module. This allows for structured backtracking and root-cause correction through candidate actions like regenerating instructions or reverting to a previous state.

Finally, the system uses High-Level Synthesis (HLS) tools to convert the verified, synthesizable C++ code into the final RTL implementation.

The multi-agent architecture of Spec2RTL-Agent, illustrating the iterative understanding, progressive coding, and adaptive reflection modules.

Evaluation and Results

The framework was evaluated using three complex NIST specifications: AES (Advanced Encryption Standard), DSS (Digital Signature Standard), and HMAC (Keyed-Hash Message Authentication Code). These benchmarks represent significant challenges due to their mathematical complexity and multi-stage design requirements.

Spec2RTL-Agent achieved 100% functional correctness across all benchmarks. Notably, it reduced human intervention by 75% compared to traditional human-in-the-loop LLM workflows. In contrast, "single-shot" LLM prompts failed to produce functional code for any of these complex tasks, highlighting the necessity of the agentic, iterative approach. The system demonstrated strong resilience in "noise" tests, where it successfully identified and corrected intentionally introduced logical flaws.

Key Insights and Discussion

The success of Spec2RTL-Agent stems from several key design choices:

  • Abstraction as a Proxy for Correctness: Verifying logic in Python/C++ before moving to hardware-specific syntax significantly reduces logic-syntax confusion.
  • Structured Backtracking: The ability to identify where in the pipeline an error originated allows the system to fix fundamental misunderstandings rather than just patching code symptoms.
  • Information Distillation: The "Information Dictionary" acts as a crucial bridge between unstructured natural language and structured code generation.

While highly effective, future work will focus on improving token efficiency (currently requiring approximately 10 iterations per sub-function) and optimizing the generated code for Power, Performance, and Area (PPA) to ensure the automated code is as efficient as expert hand-written RTL.

Summary updated

BibTeX
@misc{yu2025spec,
  author = {Zhongzhi Yu and Mingjie Liu and Michael Zimmer and Yingyan Celine Lin and Yong Liu and Haoxing Ren},
  title = {{Spec2RTL-Agent: Automated Hardware Code Generation from Complex Specifications Using LLM Agent Systems}},
  year = {2025},
  eprint = {2506.13905},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2506.13905},
}
Figure