TL;DR
CPPL (Circuit Prompt Programming Language) is a compiler-mediated framework that transforms LLM-based hardware generation from an unconstrained text-generation task into a statically checkable frontend problem. By combining a Python DSL for structural hierarchy with an LLM-friendly JSON intermediate representation, CPPL significantly improves the functional correctness of AI-generated circuits while unlocking automated backend compiler optimizations.
What Problem Does This Paper Address?
Using Large Language Models (LLMs) to automate register-transfer level (RTL) hardware design is a double-edged sword. While natural-language-to-Verilog generation lowers the barrier to entry, the traditional end-to-end text generation approach frequently produces code with syntax errors, tool-compatibility issues, or functional bugs. This happens because the LLM must simultaneously reason about high-level behavior, strict bitwidth consistency, and complex structural hierarchies.
An alternative approach would be to have LLMs generate strongly typed compiler Intermediate Representations (IRs), such as CIRCT, which can catch errors early and optimize designs. However, the authors reveal a massive performance gap here: current LLMs struggle immensely with raw compiler IR due to its complex Multi-Level IR (MLIR) syntax, Static Single Assignment (SSA) discipline, and strict type constraints.
Methods
CPPL introduces a hybrid, compiler-mediated workflow that bridges the gap between flexible LLM generation and rigid hardware compiler requirements:
- Python Frontend DSL: Users explicitly declare module boundaries, input/output ports, bitwidths, and high-level structural hierarchy using a clean, function-oriented Python syntax. This prevents the LLM from hallucinating or inventing incompatible interfaces.
- JSON-based Intermediate Representation (CPPL IR): Instead of forcing the LLM to write raw MLIR text, CPPL prompts the model to generate circuit logic using a structured, regular JSON schema. This keeps the target format highly accessible to the LLM while preserving compiler-visible operations.
- Compiler-Driven Refinement Loop: The CPPL compiler parses the frontend DSL, establishes the structural skeleton, and prompts the LLM to fill in the behavioral implementation details. The compiler then statically validates the LLM's JSON output (checking for syntax errors, dead code, and combinational loops), infers operation bitwidths, and automatically feeds descriptive error messages back to the LLM if any checks fail.
- Deterministic Lowering & Optimization: Once validated, the CPPL IR is deterministically lowered to CIRCT IR. Standard hardware compiler optimization passes (such as common subexpression elimination and constant folding) are applied before emitting the final synthesizable Verilog.
Datasets
The framework was evaluated using the RTLLM benchmark, an open-source benchmark consisting of 29 distinct hardware design problems. These tasks cover a diverse range of design complexities, including combinational logic, sequential logic, and memory designs (e.g., ALUs, multi-bit adders, digital clock components, and finite state machines).
Key Insights and Ideas
- The Separation of Concerns: By offloading interface declaration and structural hierarchy to a deterministic Python frontend, the LLM can focus entirely on expressing behavioral implementation intent. This drastically reduces the model's cognitive load.
- Insulating LLMs from Evolving IRs: Hardware compiler infrastructures like CIRCT are actively developing, meaning their syntax and dialect definitions constantly change. Using a stable, regular JSON schema (CPPL IR) insulates the LLM from version-specific compiler syntax shifts.
- "Free" Hardware Optimization: Because the LLM outputs a structured IR rather than raw Verilog text, the framework can seamlessly hook into existing hardware compiler optimization pipelines. The final circuit can be automatically optimized for size and efficiency without requiring the LLM to explicitly understand hardware optimization passes.
Key Results
- Functional Correctness Boost: Across all evaluated commercial and open-source LLMs, CPPL significantly outperformed direct Verilog and direct CIRCT generation. Notably, Qwen-3.6-plus—which performs poorly when generating raw CIRCT IR directly—achieved a functional
pass@1score of 0.768 when mediated by CPPL (compared to just 0.082 for direct CIRCT generation). - Area and Node Reduction: By leveraging CIRCT's backend optimization pipeline, CPPL reduced the post-synthesis And-Inverter Graph (AIG) node count by a geometric average of 16.3% (dropping from 439.88 to 368.16 nodes) compared to unoptimized baselines, yielding significantly more compact hardware layouts.
Limitations and Future Work
The authors note that the compiler-driven refinement loop currently caps correction attempts at a fixed maximum ($N_{max} = 3$). Future iterations could explore more dynamic, multi-agent debugging strategies to resolve complex edge cases. Additionally, while CPPL handles standard sequential and combinational blocks effectively, extending the DSL and IR to seamlessly support highly complex, custom memory architectures and large-scale industrial SoC hierarchies remains an open direction for future development.
Summary updated