Automated CPU Design by Learning from Input-Output Examples

Shuyao Cheng, Pengwei Jin, Qi Guo, Zidong Du, Rui Zhang, Xing Hu, Yongwei Zhao, Yifan Hao, Xiangtao Guan, Husheng Han, Zhengyue Zhao, Ximing Liu, Xishan Zhang, Yuejie Chu, Weilong Mao, Tianshi Chen, Yunji Chen

Abstract

Designing a central processing unit (CPU) requires intensive manual work of talented experts to implement the circuit logic from design specifications. Although considerable progress has been made in electronic design automation (EDA) to relieve human efforts, all existing EDA tools require hand-crafted formal program codes (e.g., Verilog, Chisel, or C) as the input. To automate the CPU design without human programming, we are motivated to learn the CPU design from only input-output (IO) examples. The key challenge is that the learned CPU design should have almost zero tolerance for inaccuracy, which makes well-known approximate algorithms such as neural networks ineffective. We propose a new AI approach to generate the CPU design in the form of a large-scale Boolean function, from only external IO examples instead of formal program code. This approach employs a novel graph structure called Binary Speculative Diagram (BSD) to approximate the CPU-scale Boolean function accurately. We propose an efficient BSD expansion method based on Boolean Distance, a new metric to quantitatively measure the structural similarity between Boolean functions, gradually increasing the design accuracy up to 100%. Our approach generates an industrial-scale RISC-V CPU design within 5 hours, reducing the design cycle by about 1000x without human involvement. The taped-out chip, Enlightenment-1, the world's first CPU designed by AI, successfully runs the Linux operating system and performs comparably against the human-design Intel 80486SX CPU. Our approach even autonomously discovers human knowledge of the von Neumann architecture.

Introduction

Designing a Central Processing Unit (CPU) is often cited as one of the most complex engineering feats humans undertake. A modern processor involves billions of transistors and requires thousands of engineers years of manual labor to verify and implement. While Electronic Design Automation (EDA) tools exist, they still require humans to write formal code (like Verilog or Chisel).

A new paper from the Chinese Academy of Sciences, presented at IJCAI-24, asks a radical question: Can we skip the programming entirely and learn a CPU's logic directly from input-output (IO) examples?

The Challenge: Moving Beyond Manual Programming

Traditional CPU design is an iterative, manual nightmare. Engineers translate specifications into formal code, which is then subjected to billions of test cases. If a bug is found, the code is manually debugged and the process repeats.

Existing AI methods like Neural Networks (NNs) or Large Language Models (LLMs) struggle here for two reasons:

  1. Zero Tolerance for Error: A CPU requires essentially 100% accuracy. Probabilistic models like NNs are inherently "fuzzy" and cannot guarantee this.
  2. Scale: Previous AI-based logic synthesis could only handle a few hundred gates. A real CPU requires millions.
Comparison between traditional human-led design flow (a) and the proposed automated AI design flow (b).

The authors sought a way to automate the entire flow—programming, debugging, and verification—using only external IO examples as the "ground truth."

Methods: The Binary Speculative Diagram

The researchers moved away from traditional deep learning and instead innovated on formal logic structures.

1. Binary Speculative Diagram (BSD)

The core innovation is the BSD, an evolution of the well-known Binary Decision Diagram (BDD). While a BDD represents a Boolean function exactly, it can become exponentially large. A BSD starts as an approximation. It uses "speculation nodes" that guess a sub-function's output (0 or 1) based on IO samples.

Visualization of BDD (100% accurate) versus BSDs at varying levels of accuracy (62.75% and 75%).

2. BSD Expansion and Boolean Distance

To reach 100% accuracy, the system iteratively expands these speculation nodes using Boole’s Expansion Theorem. To prevent the graph from exploding in size, the authors introduced a metric called Boolean Distance. This metric measures how structurally similar two Boolean functions are. By clustering similar nodes, the AI can reuse logic structures, keeping the design compact and manageable.

3. Monte Carlo Estimation

Since calculating the exact complexity of a Boolean function is NP-hard, the team used Monte Carlo sampling to estimate Boolean Distance and functional equivalence, allowing the algorithm to scale to millions of gates.

Key Insights and Results

  • Accuracy through Iteration: By treating CPU design as a "coarse-to-fine" optimization problem, the BSD can start with a simple guess and refine it only where the IO examples prove it wrong.
  • Autonomous Discovery: Most surprisingly, the AI autonomously discovered the von Neumann architecture. Without being told how a CPU should be structured, the BSD expansion naturally formed a "control unit" and an "arithmetic unit" to represent the logic efficiently.
  • Design Speed: The AI generated the RISC-V design in under 5 hours. For comparison, a human team would take roughly 5,000 man-hours to complete a similar task.
  • Physical Success: The design was taped out using 65nm technology. The physical chip, Enlightenment-1, reached a frequency of 300 MHz and successfully booted the Linux kernel 5.15. On the Dhrystone benchmark, it performed on par with the Intel 80486SX.

Limitations and Future Work

While a breakthrough, Enlightenment-1 is comparable to a 1991-era processor. It lacks the advanced out-of-order execution and multi-level caching of modern high-performance CPUs. Future work is needed to optimize for PPA (Power, Performance, and Area) to make the AI-generated designs as efficient as those hand-tuned by human experts. Furthermore, scaling to more complex instruction sets like x86 will require further refinements to the BSD clustering algorithms.

Summary updated

BibTeX
@inproceedings{cheng2024automated,
  author = {Shuyao Cheng and Pengwei Jin and Qi Guo and Zidong Du and Rui Zhang and Xing Hu and Yongwei Zhao and Yifan Hao and Xiangtao Guan and Husheng Han and Zhengyue Zhao and Ximing Liu and Xishan Zhang and Yuejie Chu and Weilong Mao and Tianshi Chen and Yunji Chen},
  title = {{Automated CPU Design by Learning from Input-Output Examples}},
  booktitle = {International Joint Conference on Artificial Intelligence},
  year = {2024},
  url = {https://openreview.net/forum?id=dABQFwQK9V},
}
Figure