PrefixAgent: An LLM-Powered Design Framework for Efficient Prefix Adder Optimization

Dongsheng Zuo, Jiadong Zhu, Yang Luo, Yuzhe MaarXiv 2025 · DOI

Abstract

Prefix adders are fundamental components in digital processors, yet their design space is vast and complex. Traditional optimization methods often struggle with scalability and non-uniform input arrival times. This paper presents PrefixAgent, an LLM-powered framework that decomposes prefix adder design into high-level reasoning and low-level tool execution. By utilizing E-graphs to generate high-quality reasoning traces for fine-tuning, PrefixAgent achieves significant scalability, reaching 64-bit designs. Experimental results demonstrate that PrefixAgent consistently outperforms commercial EDA tools and previous reinforcement learning methods, achieving up to an 11.4% area reduction and a 10x speedup in optimization runtime.

Introduction

Prefix adders serve as the "heart" of arithmetic circuits in modern CPUs and AI accelerators. However, designing these components is a monumental task due to the sheer size of the design space; for a 16-bit adder, there are approximately $10^{48}$ possible configurations. While standard "regular" structures like Kogge-Stone or Brent-Kung are common, they are often sub-optimal for real-world applications where input signals arrive at different times.

Existing automated approaches, such as Reinforcement Learning (RL) or Monte Carlo Tree Search (MCTS), struggle with scalability, often requiring weeks of training for 64-bit designs. While Large Language Models (LLMs) show promise in reasoning, they typically fail when handling complex graph structures exceeding 20 nodes. Furthermore, the lack of high-quality "reasoning traces" for hardware synthesis has hindered the application of LLMs in this domain.

Methods

PrefixAgent addresses these challenges through a "divide and conquer" strategy combined with Tool-Integrated Reasoning (TIR). The framework consists of three core innovations:

Two-Phase Optimization

Instead of attempting to synthesize the entire circuit at once, PrefixAgent splits the task into two manageable phases:

  1. Phase I: Backbone Optimization: The agent focuses on the "backbone"—the critical path for the most significant bit. This reduces the search space for a 16-bit adder from $10^{48}$ to roughly $10^6$.
  2. Phase II: Local Structure Refinement: Once the backbone is established, the agent performs local refinements to address timing and fanout constraints across the rest of the structure.
Overview of the PrefixAgent framework, illustrating the E-graph based data generation and the two-phase optimization loop.

E-graph Based Data Generation

To train the underlying LLM (a fine-tuned QwQ-32B), the authors leveraged E-graphs (Equality Graphs) to find optimal designs and extract "rewrite traces." These raw mathematical transformations were then "translated" into natural language Chain-of-Thought (CoT) reasoning steps using commercial Large Reasoning Models (LRMs) like GPT-o1. This process created a high-quality dataset of optimization sequences that teach the model how to reason about hardware design.

The Agentic Loop and Specialized Representations

PrefixAgent acts as a controller that analyzes the circuit state and calls external tools (e.g., regroup, level-opt, node clone) to modify the design. To facilitate this, the authors developed BackboneLang (an S-expression format) and Enhanced Prefix Representation (EPR), which allow the LLM to perceive hierarchy, timing, and fanout constraints more effectively than raw netlists.

Detailed view of the two-phase optimization process, showing the interaction between the LRM and specialized tools in Phase I and Phase II.

Results

PrefixAgent was evaluated on 16-bit, 32-bit, and 64-bit prefix adders under various input arrival conditions. Key findings include:

  • Superior Area Efficiency: PrefixAgent consistently produced adders with smaller areas than MCTS, RL, and VAE baselines. In 64-bit configurations, it achieved an 11.4% area reduction over the strongest baseline.
  • Outperforming Commercial Tools: In a commercial 32nm industrial flow, PrefixAgent synthesized designs with smaller areas than the default outputs of commercial synthesis tools (CST).
  • Significant Speedup: By making informed decisions rather than performing random searches, the framework achieved a 10x speedup in runtime compared to previous search-based methods.
  • Scalability: PrefixAgent is the first LLM-based approach to scale successfully to 64-bit designs, whereas previous attempts typically failed beyond 8-bit.

Conclusion

PrefixAgent demonstrates that combining LLM-based reasoning with formal methods like E-graphs can overcome the scalability and complexity barriers in hardware design. By focusing on high-level strategy and delegating low-level tasks to specialized tools, the framework achieves state-of-the-art results in prefix adder optimization. Future work will explore extending this agentic approach to more complex arithmetic units, such as multipliers and general datapath synthesis.

Summary updated

BibTeX
@misc{zuo2025prefixagent,
  author = {Dongsheng Zuo and Jiadong Zhu and Yang Luo and Yuzhe Ma},
  title = {{PrefixAgent: An LLM-Powered Design Framework for Efficient Prefix Adder Optimization}},
  year = {2025},
  eprint = {2507.06127},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2507.06127},
}
Figure