LLM-Assisted RTL Optimization and Specification-to-RTL Generation: Methods and Evaluation
Large language models are increasingly used in chip design, both for rewriting existing RTL to improve area, power, or timing, and for generating new RTL from functional specifications. This article outlines a verification-driven workflow for both tasks, covering equivalence checking with Yosys, a four-step specification-to-RTL process with differential testing against reference models, evaluation metrics using benchmarks such as VerilogEval and RTLLM, and a practical risk checklist for adopting AI-generated RTL.
Scope of the Problem
When LLMs participate in chip design, their output is hardware description that will be synthesized, place-and-routed, and eventually taped out. A single logic error may not surface until late-stage simulation or even after tape-out, so every AI-generated result must be machine-checkable.
This article covers two tasks. The first is rewriting existing RTL to improve area, power, or timing while preserving functionality. The second is generating new RTL from functional specifications. The first task has a golden reference (the original design) to compare against, making verification relatively straightforward. The second task can only be validated indirectly through testing and reference models, making it considerably harder.
All tools and benchmarks mentioned in this article are publicly available projects. No speedup figures are cited that have not been independently reproduced.
RTL Optimization and Equivalence Checking
The goal of RTL optimization is to make a functionally identical circuit better in terms of area, power, or critical path. LLMs are well suited to proposing candidate rewrites, such as merging duplicate logic, splitting long combinational paths into pipeline stages, or sharing computational resources. Every candidate must pass through the following verification chain.
Inputs and constraints should be fixed in file form:
Inputsrtl: alu.v Original RTL, serving as golden referencesdc: alu.sdc Timing constraintsarea_budget: 1200 um^2 Area budgettb: alu_tb.sv Regression test stimulusExample constraint (alu.sdc)create_clock -name clk -period 2.5 [get_ports clk]Process1. Run regression on the original design and record baseline outputs2. Generate candidate RTL, requiring top-level ports and protocols to remain unchanged3. Syntax check: yosys -p "read_verilog cand.v; hierarchy -check -top alu"4. Functional simulation: cycle-by-cycle output comparison under the same stimulus5. Formal equivalence checking (see below)6. Synthesis: compare area and critical path on the target technology library7. If any step fails, discard the candidate, keep the original RTL, and log the failure reasonOutputsAccepted candidate RTL, area and timing comparison table, failure log
Formal equivalence checking proves that the candidate RTL behaves identically to the original design for all inputs. Equivalence of combinational logic can be proven directly using methods such as SAT or BDD. The open-source tool Yosys provides corresponding equivalence checking commands, while commercial flows commonly use Synopsys Formality or Cadence Conformal.
Timing-related rewrites require an extra step. Pipeline splitting increases output latency, and a direct combinational equivalence check would incorrectly flag a valid rewrite as non-equivalent. The correct approach is to first specify the alignment relation explicitly—for example, “the candidate design’s outputs arrive two cycles later than the reference design but carry the same values”—and then perform sequential equivalence checking under this alignment. The alignment relation must be determined by engineers and documented; the model should not assume it on its own.
Specification to RTL: A Four-Step Process and Evaluation
Generating complete processor RTL from a specification is far harder than rewriting existing modules. The process can be broken into four steps, each producing verifiable artifacts.
- Specification parsing. Organize the natural-language specification into three tables: an interface table (signal names, widths, directions, reset values), an instruction semantics table (inputs, outputs, and exception behavior for each instruction), and a timing requirements table (latency, throughput, clock frequency targets). Missing items are listed as open questions.
- Ambiguity resolution. Specifications often lack details on reset states, illegal instruction handling, and unaligned accesses. These items must be confirmed by the design lead and written into the specification; the model should not make these choices on the engineer’s behalf.
- Architecture constraints. Fix parameters such as the instruction set subset, pipeline depth, and cache capacity as fixed inputs for generation. If the architecture is not fixed, the same specification may produce different structures on each run, making results incomparable.
- Module-by-module generation and differential verification. Generate RTL module by module, with each module’s interface strictly matching the interface table. For verification, use an instruction set simulator as the reference. Taking RISC-V as an example, Spike can serve as the reference model: run test programs from riscv-tests and compare the register and memory write-back traces of the processor under test against the reference model.
For evaluation, commonly used public benchmarks include VerilogEval and RTLLM. VerilogEval measures the proportion of generated code that passes functional tests using pass@k. RTLLM targets more complete circuit design tasks and checks both syntax correctness and functional correctness. The problems in both benchmarks are mostly small-to-medium modules and do not directly represent the ability to generate complete processors.
For specification-to-RTL tasks, the following metrics should also be recorded:
- Syntax pass rate: whether generated code passes compilation and syntax checks
- Functional pass rate: the proportion passing all simulation test cases
- Equivalence pass rate: the proportion passing formal equivalence checking or differential testing
- Area and maximum frequency: post-synthesis results, with the technology library and synthesis script version noted
- Iteration count and token consumption: the number of generation rounds and compute cost required to reach a pass
When comparing different models, fix the token budget, sampling count, and prompts, and report the variance across multiple runs. Reporting only the best single result does not reflect a model’s stability.
Risks and a Deployment Checklist
| Risk | Typical Manifestation | Check Method | Mitigation |
|---|---|---|---|
| Boundary condition errors | Regular simulation passes, but errors appear under specific timing or data boundaries | Add boundary test cases and random stimulus | Apply formal verification to critical modules |
| Specification misreading | Functionally correct but inconsistent with the specification | Item-by-item cross-check against the interface and instruction tables | Freeze the specification version after confirmation |
| Incorrect alignment relation | False positives or false negatives in equivalence checking | Manually review the alignment relation | Document it in the design documentation |
| Data leakage | Unpublished specifications or RTL sent to external services | Audit data flows | Use local deployment or sign confidentiality agreements |
| Non-reproducible results | Large variation across multiple runs with the same prompt | Fix sampling parameters and take statistics over multiple runs | Record model version and parameters |
Before adopting AI-generated RTL, verify the following:
- Every candidate RTL has regression test and equivalence checking records
- All open questions in the specification have been closed
- Area and frequency results are accompanied by the technology library and synthesis script version
- Rejected candidates and their failure reasons have been archived
- Engineers have manually reviewed critical paths and reset logic
