Using LLM such as ChatGPT for Designing and Implementing a RISC Processor: Execution,Challenges and Limitations

Shadeeb Hossain, Aayush Gohil, Yizhou WangarXiv 2024 · DOI

TL;DR

This paper explores whether ChatGPT 3.5 can autonomously design a RISC-V (RV32I) processor using VHDL. While the LLM is excellent at generating "code skeletons," the study reveals that it cannot yet produce bug-free hardware; every single component required human intervention and multiple iterations to function correctly on an FPGA.

What Problem Does This Paper Address?

Designing microprocessors is a complex, time-consuming task that traditionally requires deep expertise in Hardware Description Languages (HDLs) like VHDL or Verilog. While Large Language Models (LLMs) have shown remarkable success in generating software (like Python or C++), their utility in the specialized world of hardware engineering is less understood.

The authors aim to determine if an LLM can bridge the gap between natural language requirements and a working physical processor. Specifically, they test if ChatGPT can handle the rigid constraints of a RISC-V architecture—where a single bit error in a Control Unit or ALU can render an entire system useless—and identify the specific "bottlenecks" where the AI fails.

Methods

The researchers used ChatGPT 3.5 to generate VHDL code for the core components of an RV32I processor, including:

  • Program Counter (PC): The 32-bit register pointing to the next instruction.
  • Register File: The internal storage for data processing.
  • Arithmetic Logic Unit (ALU): The "math engine" of the chip.
  • Control Unit (CU): The brain that decodes instructions.
  • Memory Modules: Both Instruction and Data memory.

The workflow followed a standard LLM pipeline: Parsing (extracting keywords from prompts), Tokenization, and Attention-based generation. To verify the results, the authors used the Vivado Design Suite for RTL analysis and timing simulations. Finally, they implemented the design on physical hardware using a Basys 3 FPGA board (Xilinx Artix-7) to ensure the code wasn't just syntactically correct, but electrically functional.

Datasets

The paper does not introduce a new training dataset. Instead, it relies on the pre-trained knowledge of ChatGPT 3.5 (trained on massive corpora like GitHub) and evaluates its performance against the RV32I Instruction Set Architecture (ISA) standards. The "evaluation dataset" consists of the specific prompts and the resulting VHDL code generated for the six processor components.

Key Insights and Ideas

  • The "Skeleton" Strength: LLMs are highly effective at creating the initial structure of a hardware module. They can quickly map out entity declarations and basic logic based on natural language descriptions.
  • Complexity Correlates with Failure: The more complex the logic, the more the LLM struggled. The Control Unit, which manages the Finite State Machine (FSM) for 40 different instructions, was the most difficult for the AI to get right.
  • Prompt Sensitivity: The authors noted that "missing information" in a prompt often led the LLM to ignore essential features. Hardware design requires much more explicit prompting than general-purpose software.
  • Human-in-the-Loop is Mandatory: The study concludes that LLMs should be viewed as a "complement" to engineers, not a replacement. The AI provides the "preliminary sketch," but the human provides the "ground truth" through debugging.

Key Results

The authors evaluated the LLM using a 4-point metric system. The results were a reality check for AI-driven hardware design:

  • First-Iteration Success: 0%. Not a single component worked correctly on the first try.
  • Error Density: The ALU had the highest number of embedded errors (8), while the Program Counter had the fewest (1).
  • Trial Count: Most components required more than 3 or 4 trials to reach a functional state. The Control Unit required more than 10 trials and assistance from "senior consultants" to fix.
  • Hardware Verification: Once debugged by humans, the code successfully ran on the Basys 3 FPGA. The final synthesized design utilized 5 cells and 122 I/O ports, with a total power consumption of approximately 121 mW.

Limitations and Future Work

The primary limitation identified is the LLM's tendency to produce syntax errors and logic that is "not complicit with the requirements of the system." ChatGPT 3.5 often struggled with the strict concurrency and timing requirements inherent in VHDL.

Future Directions: 1. Self-Correcting Loops: Developing systems where the LLM can receive error logs from simulation tools (like Vivado) and automatically iterate on the code. 2. Optimization: Moving beyond "just making it work" to using LLMs to optimize for power consumption and timing delays. 3. Specialized Models: Testing if models specifically fine-tuned on HDL (like Verilog-specific LLMs) perform better than general-purpose models like ChatGPT.

Summary updated

BibTeX
@misc{hossain2024using,
  author = {Shadeeb Hossain and Aayush Gohil and Yizhou Wang},
  title = {{Using LLM such as ChatGPT for Designing and Implementing a RISC Processor: Execution,Challenges and Limitations}},
  year = {2024},
  eprint = {2401.10364},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2401.10364},
}
Figure