TL;DR
CktFormalizer is a novel framework that pairs Large Language Models (LLMs) with Lean 4 to automate trustworthy hardware design. By redirecting LLM generation through a dependently-typed Hardware Description Language (HDL) embedded in Lean, it catches subtle hardware defects at compile time and generates machine-checked equivalence proofs. The result is a dramatic boost in backend realizability, ensuring that 95–100% of compiled designs successfully navigate the entire physical design pipeline down to synthesizable silicon.
What Problem Does This Paper Address?
While LLMs have shown impressive capabilities in generating hardware descriptions (like Verilog) from natural language, the code they produce is notoriously fragile. Directly generated Verilog frequently suffers from subtle semantic defects—such as bit-width mismatches, combinational loops, and incomplete case logic.
These bugs often slip past standard syntax checkers, only to cause silent failures hours later during logic synthesis, place-and-route, or worse, as multi-million-dollar silicon bugs post-fabrication. Traditional Electronic Design Automation (EDA) tools lack the static, compile-time guarantees common in modern software engineering, leaving LLM agents to stochastically guess solutions based on cryptic linter warnings.
Methods
CktFormalizer introduces a paradigm shift: the compiler is the verifier. Instead of generating Verilog directly, the LLM coding agent targets a dependently-typed HDL embedded within the Lean 4 theorem prover.
The framework operates via three core pillars:
- Type-Guided Compile-Fix Loop: Lean’s dependent type system explicitly encodes bit-width constraints, case exhaustiveness, and acyclicity. When the LLM makes a mistake, Lean generates immediate, highly structured type errors that guide the agent through iterative repairs.
- Correctness Firewall & Extraction: Once the Lean code compiles, it is structurally guaranteed to be free of major hardware defects. A custom metaprogram (
#synthesizeVerilog) then automatically extracts this clean representation into synthesizable SystemVerilog. - Closed-Loop PPA Optimization: For designs that pass simulation, CktFormalizer passes the Verilog through an automated physical design pipeline (using Yosys, OpenROAD, and the SkyWater 130nm PDK). It feeds physical Power, Performance, and Area (PPA) metrics back to the agent. The agent can then safely explore alternative architectures because it uses Lean to construct automated theorem equivalence proofs, ensuring the optimized circuit behaves identically to the original specification.
Datasets
The authors evaluated CktFormalizer across three distinct hardware generation benchmarks to test its generalizability:
- VerilogEval (156 problems): A benchmark derived from HDLBits, covering everything from simple wire assignments to complex Finite State Machines (FSMs).
- RTLLM (50 problems): A dataset containing natural-language RTL design tasks focusing on arithmetic, memory, and control modules.
- ResBench (56 problems): A resource-aware benchmark spanning signal processing, arithmetic, and application-level datapaths.
- AXI4-Lite Interface: The authors also tested the framework on an industry-standard AMBA AXI4-Lite bus interface to demonstrate its scalability to multi-channel handshake protocols.
Key Insights and Ideas
- Shifting Error Detection Left: By moving verification from the end of the EDA pipeline (hours of simulation/synthesis) to compile time (milliseconds in Lean), the LLM receives actionable feedback fast enough to systematically narrow its search space.
- Eliminating Silent Backend Failures: Traditional LLM-generated Verilog often breaks during physical design due to implicit latches or redundant logic optimization. Lean's structural guarantees act as a "firewall," meaning if it compiles, it will almost certainly realize into physical layout.
- Stepwise Proofs Beat One-Shot Generation: Allowing the LLM to interactively query Lean's proof states and iteratively refine theorems drastically improves proof completion rates compared to asking the model to output the code and proof all at once.
Key Results
CktFormalizer achieves simulation pass rates competitive with state-of-the-art direct Verilog generation models (like CodeV and RTLCoder) while delivering vastly superior backend reliability:
- 100% Backend Survival: While the direct Verilog baseline lost up to 20% of its functionally correct designs during synthesis and routing due to fragile constructs, CktFormalizer preserved every single one.
- 95–100% Realizability: Across all benchmarks, 95–100% of compiled designs successfully completed the full synthesis, place-and-route, Design Rule Checking (DRC), and Layout Versus Schematic (LVS) flow without manual intervention.
- Significant PPA Gains: The closed-loop optimization stage successfully discovered structurally distinct architectures, yielding up to a 35% reduction in area and a 30% reduction in power while maintaining machine-checked functional equivalence.
Limitations and Future Work
Despite its strengths, the authors note a few areas for improvement:
- Single Clock Domain Restriction: Lean HDL currently models signals under a single synchronous clock domain. It lacks formal semantics for multi-clock interactions or asynchronous reset release timing, meaning these must still rely on traditional simulation and static clock-domain crossing (CDC) tools.
- Tactic Automation Bottlenecks: While Lean's automated tactics (
simp,decide) easily handle combinational logic, complex sequential logic and intricate FSMs still occasionally require manual lemmas that challenge the LLM, causing it to fall back onsorryplaceholders during proof generation. - Abstraction Gaps: Lean proofs operate at the RTL level; they cannot see post-synthesis netlist transformations or physical layout parasitics, leaving gate-level timing sign-off to traditional gate-level simulations.
Summary updated