Bridging the Semantic Gap from Natural Language Specifications to RTL with Layered Formal Guidance

Yan Tan, Xiangchen Meng, Yangdi LyuarXiv 2026

TL;DR

Large Language Models (LLMs) are surprisingly good at writing code, but they often stumble over the rigid, cycle-accurate requirements of hardware design (RTL). This paper introduces Layered Formal Guidance, a framework that uses mathematical assertions as a "semantic middleman" to tighten vague human instructions and automatically refine buggy hardware designs until they actually work.

What Problem Does This Paper Address?

If you ask an LLM to "write a Python script to sort a list," the requirements are straightforward. But if you ask it to "design a 16-bit divider in Verilog," you’ve entered a world of pain. Hardware description language (RTL) requires absolute precision: what happens on clock cycle 5? How do we handle a reset? What if the input is zero?

The authors identify a semantic gap. Human specifications are often high-level and "underspecified," leaving the LLM to guess the implementation details. As shown in Figure 1, a single vague prompt can lead to multiple "syntactically correct" designs that behave completely differently—and incorrectly—under simulation.

Fig. 1: Underspecified prompts can lead to syntactically valid but behaviorally divergent RTL candidates.

Existing methods try to fix code after it's written (like a compiler error), but they can't fix a design if the original instructions were fundamentally ambiguous.

Methods

The authors propose a three-layer "Formal Guidance" sandwich to bridge this gap:

  1. Layer 1: Specification Augmentation (The Pre-game): Before the LLM writes a single line of Verilog, the framework extracts SystemVerilog Assertions (SVAs)—formal mathematical rules—from the natural language spec. It then translates these rules back into structured natural language constraints and appends them to the prompt. This "primes" the LLM with explicit implementation requirements it might have otherwise ignored.
  2. Layer 2: Model Checking (The Check-up): Once the RTL is generated, it’s fed into a formal verification tool (like Yosys). The tool checks if the code actually obeys the SVAs generated in Layer 1. If a rule is broken, the tool generates a Counterexample (CEX)—a specific trace of inputs and states that triggered the failure.
  3. Layer 3: CEX-Guided Refinement (The Deep Dive): This is the clever bit. The framework analyzes the failure to determine the root cause:
  4. Is it an RTL Bug? (Fix the code).
  5. Is it a Specification Gap? (The prompt was too vague; clarify it and regenerate).
  6. Is it a Property Issue? (The mathematical rule itself was wrong; fix the rule).
Fig. 2: Overview of the Layered Formal Guidance framework.

Datasets

The framework was put to the test across four major benchmarks:

  • RTLLM: A benchmark for natural language to RTL generation.
  • VerilogEval: Evaluates Verilog code generation quality.
  • CVDP: Focuses on general RTL code generation tasks.
  • ChipVerilog: A large-scale benchmark derived from open-source IP (Intellectual Property) designs.

They tested this across a "who's who" of models, including DeepSeek-V4, Qwen 3.6, and GPT-4o/5.4.

Key Insights and Ideas

  • Formal as a Language: The most powerful idea here is using formal properties (SVAs) not just as a "pass/fail" test at the end, but as a translation layer to make human intent readable for a machine.
  • Reducing "Behavioral Divergence": By adding explicit constraints, the authors drastically reduced the "randomness" of LLM outputs. Instead of getting 9 different buggy behaviors from one prompt, the augmented prompts steered the models toward a single, correct implementation (see Figure 5).
  • Multi-Artifact Repair: Most "self-repair" loops only look at the code. This framework realizes that sometimes the instructions are the problem. By refining the specification alongside the code, it solves the root cause of the ambiguity.

Key Results

The results are a significant step up from "vanilla" LLM generation:

  • Accuracy Boost: On the complex OR1200 benchmark, using Layered Formal Guidance improved the pass@1 rate (the chance of getting it right on the first try) from 12.2% to 40.2% when using DeepSeek-V4.
  • Consistency: Across all models, the framework provided a mean paired gain of up to 19.01 percentage points on the RTLLM 2.0 benchmark.
  • IP-Level Success: The method proved effective even on larger, more complex designs like Floating Point Units (FPUs), where standard LLMs almost always fail due to the intricate control logic.

Limitations and Future Work

  • The "SVA Quality" Ceiling: The framework relies on the LLM's ability to generate accurate SVAs in Layer 1. If the model fails to capture a critical requirement in the formal properties, the subsequent checking layers won't catch the resulting bugs.
  • Iteration Limits: In this study, refinement was limited to one iteration per candidate. Real-world complex designs might require deeper "conversations" between the formal checker and the generator.
  • Computational Cost: Running a formal model checker (Yosys/VCS) in the loop adds time and compute overhead compared to simple text generation.

In short, if we want LLMs to design the chips of the future, we can't just give them a "vibe" and hope for the best. We need to give them a mathematical map—and this paper provides the compass.

Summary updated

Abstract

While large language models (LLMs) have shown promise in generating register-transfer level (RTL) code from natural-language specifications, their reliability remains limited on designs with complex control logic and temporal behavior. This stems from a fundamental semantic gap: high-level natural language often leaves implementation-critical details underspecified, forcing LLMs to infer unstated assumptions. This paper presents Layered Formal Guidance, a novel framework that bridges this semantic gap by using formal properties as an intermediate semantic layer between natural-language specifications and RTL generation. Our framework applies formal guidance across three layers: property-driven specification augmentation before generation, property-consistency checking after generation, and counterexample-guided refinement after checking. Experiments on RTLLM benchmarks and various open-source IP designs demonstrate that our framework achieves higher functional correctness and lower sampled output-trace diversity. Furthermore, we show that Layered Formal Guidance can flexibly augment both general-purpose LLMs and domain-specific models to substantially improve their generation reliability.
BibTeX
@misc{tan2026bridging,
  author = {Yan Tan and Xiangchen Meng and Yangdi Lyu},
  title = {{Bridging the Semantic Gap from Natural Language Specifications to RTL with Layered Formal Guidance}},
  year = {2026},
  eprint = {2611.30766},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2611.30766},
}
Figure