用类型系统让大模型生成的电路代码自动通过硬件验证,减少失败率。
CktFormalizer: Autoformalization of Natural Language into Circuit Representations

- 用依赖类型语言Lean 4约束电路位宽、覆盖和环路,编译时即发现错误
- 在多个数据集上实现95%-100%的后端可实现率,远超基线的80%
- 适合想用大模型设计可靠芯片的工程师或研究者
大模型可从自然语言生成硬件描述,但生成的Verilog常含位宽不匹配、组合环和不完整分支逻辑,虽通过语法检查却在综合或流片时失败。我们提出CktFormalizer,一个基于Lean 4的依赖类型硬件描述语言框架。Lean作为类型检查器:编码位宽、分支覆盖与无环性约束,将硬件缺陷转为编译时错误,支持迭代修复;作为正确性防火墙:编译后设计结构上无导致隐性后端失败的缺陷(基线在综合与布局布线阶段丢失20%正确设计;CktFormalizer保留全部);作为证明助手:代理可构建针对任意输入序列与参数化位宽的机器可验证等价性证明,超出有界SMT检查范围。在VerilogEval(156题)、RTLLM(50题)和ResBench(56题)上,CktFormalizer仿真通过率与直接生成Verilog相当,但后端可实现率高达95%-100%,所有设计均完成综合、布局布线、DRC与LVS流程。闭环的PPA优化阶段实现最高35%面积缩减与30%功耗降低,且每版优化均经自动化定理证明确保功能等价于形式规范。
原文摘要 · Abstract (English)
LLMs can generate hardware descriptions from natural language specifications, but the resulting Verilog often contains width mismatches, combinational loops, and incomplete case logic that pass syntax checks yet fail in synthesis or silicon. We present CktFormalizer, a framework that redirects LLM-driven hardware generation through a dependently-typed HDL embedded in Lean 4. Lean serves three roles: (i) type checker:dependent types encode bit-width constraints, case coverage, and acyclicity, turning hardware defects into compile-time errors that guide iterative repair; (ii) correctness firewall:compiled designs are structurally free of defects that cause silent backend failures (the baseline loses 20% of correct designs during synthesis and routing; CktFormalizer preserves all of them); (iii) proof assistant:the agent constructs machine-checked equivalence proofs over arbitrary input sequences and parameterized widths, beyond the reach of bounded SMT-based checking. On VerilogEval (156 problems), RTLLM (50 problems), and ResBench (56 problems), CktFormalizer achieves simulation pass rates competitive with direct Verilog generation while delivering substantially higher backend realizability: 95--100% of compiled designs complete the full synthesis, place-and-route, DRC, and LVS flow. A closed-loop PPA optimization stage yields up to 35% area reduction and 30% power reduction through validated architecture exploration, with automated theorem proof ensuring that each optimized variant remains functionally equivalent to its formal specification.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。