NYU Tandon researchers recently received the ACM Transactions on Design Automation of Electronic Systems (TODAES) 2024 Best Paper Award for VeriGen, their open-source large language model specialized for hardware description languages. The work, originally published as an exploratory benchmark on fine-tuning CodeGen models on Verilog code extracted from GitHub and hardware textbooks, proved that domain-specific pretraining dramatically lowers syntax errors in generated RTL.
Yet front-end silicon designers who pull these domain-trained models into commercial verification suites run into an immediate wall: control path logic. While specialized models routinely ace combinational adders, shift registers, and standard arithmetic logic units, they break down when asked to generate robust, production-grade Finite State Machines (FSMs).
For digital design leads, FPGA engineers, and ASIC verification teams, this gap matters. In complex Systems-on-Chip (SoCs), data paths rarely cause catastrophic silicon respins. Control paths do. A missed state transition in a protocol transactor, an inferred latch in a next-state decoder, or an unhandled illegal state recovery will brick a chip.
Hardware teams must look beyond raw syntax benchmarks like Pass@k on standard prompts. The real comparison between domain-specialized small models and frontier reasoning models lies in how they handle sequential state spaces, reset determinism, and CDC pointer handshakes.
+-------------------------------------------------------------------------+
| FSM GENERATION REALITY GAP |
| |
| Prompt: "Generate 4-State AXI4-Lite Handshake Master with Timeout" |
| |
| Domain-Trained Model (VeriGen) Frontier Reasoning Model |
| +-------------------------------+ +-----------------------------+ |
| | Syntax Valid: 98% | | Syntax Valid: 99% | |
| | Idiomatic Verilog-2001 Style | | Modern SystemVerilog Types | |
| | Inferred Latch on Timeout: YES| | Inferred Latch: NO | |
| | Deadlock on Slave Hang: YES | | Timeout Recovery: PASS | |
| | SVA Completeness: 20% | | SVA Completeness: 85% | |
| +-------------------------------+ +-----------------------------+ |
+-------------------------------------------------------------------------+
The Illusion of Pass@k on Syntax-Heavy Benchmarks
VeriGen, along with subsequent domain-specialized weights fine-tuned on hardware corpora, established that training on token distributions from GitHub repositories, textbooks, and open-source cores produces models that write syntactically clean Verilog. When evaluated on benchmarks like VerilogEval or RTLLM, domain models often match or outperform generalist base models of similar parameter sizes.
However, these benchmarks over-index on shallow structural patterns. A model that knows the syntax for always @(posedge clk or negedge rst_n) and correctly declares wire widths will pass basic syntax compilation checks in Icarus Verilog or Verilator.
Writing valid Verilog is not the same as designing valid digital logic.
Recent academic findings on finite-state reasoning in large language models (such as LLM-FSM benchmarks) show that as the number of states and transition conditions grows linearly, model accuracy falls off a cliff. While an LLM can reliably track a two-state toggle or a three-state traffic light controller, its ability to maintain logical consistency across an eight-state protocol engine collapses.
Autoregressive sequence models predict the next token based on local context windows. An FSM, however, represents a closed topological graph where every state must have mutually exclusive transition guards and complete next-state definitions across the entire input space $2^N$. When a domain model generates Verilog sequentially, it frequently forgets unreachable state handling, leaves combinational branches open, or emits conflicting state encodings.
Three Failure Modes in AI-Generated Control Logic
To understand why domain-specific training fails to solve control logic, we must look at how digital synthesis engines interpret typical model outputs. Commercial linting and synthesis tools consistently flag three recurring failure patterns in AI-generated FSMs.
1. Combinational Incompleteness and Inferred Latches
When writing a two-process or three-process FSM in Verilog or SystemVerilog, the combinational next-state logic block (always @(*) or always_comb) must explicitly define outputs and next-state variables under every possible branch condition. If a path through an if-else or case statement fails to assign a value to next_state or a control signal, synthesis tools infer a hardware latch.
Domain-specialized models trained on public repositories ingest vast amounts of legacy Verilog-1995 and Verilog-2001 code. Much of that public code is riddled with poor coding practices. As a result, the model reproduces the most common human bug: omitting default assignments before the case evaluation.
// Typical AI-generated FSM error: Inferred latch on next_state
always @(*) begin
// Missing: next_state = current_state; (Default assignment)
case (current_state)
IDLE: begin
out_valid = 1'b0;
if (start_req)
next_state = FETCH;
// Bug: If start_req is low, next_state is undefined -> Inferred Latch
end
FETCH: begin
out_valid = 1'b1;
if (mem_ready)
next_state = EXEC;
else if (mem_error)
next_state = ERROR;
// Bug: If neither condition is met, next_state retains previous value
end
// Missing default branch entirely
endcase
end
In an FPGA or ASIC flow, inferred latches ruin static timing analysis (STA), create race conditions, and cause severe place-and-route congestion.
2. State Encoding Blindness and SEU Traps
Production RTL requires explicit decisions about state encoding: binary, one-hot, or Gray code.
- Binary encoding minimizes register count, which fits resource-constrained CPLDs or small microcontrollers, but increases combinational logic depth in the decoder.
- One-hot encoding uses one flip-flop per state, providing shallow logic depth, which is ideal for high-frequency FPGA routing.
- Gray encoding ensures only a single bit changes per transition, preventing intermediate glitch states in low-power datapaths and asynchronous clock boundaries.
Domain-specific models often emit one-hot state definitions (parameter IDLE = 4'b0001, READ = 4'b0010...) but fail to write safe decoders. In a 4-bit one-hot FSM, there are 16 possible binary combinations, but only 4 are valid. If a Single Event Upset (SEU), power glitch, or metastablity event kicks the register into 4'b0011 or 4'b0000, an unconstrained state machine will freeze permanently.
// Safe SystemVerilog FSM with explicit illegal state recovery
typedef enum logic [3:0] {
STATE_IDLE = 4'b0001,
STATE_READ = 4'b0010,
STATE_WRITE = 4'b0100,
STATE_DONE = 4'b1000
} fsm_state_t;
fsm_state_t current_state, next_state;
always_comb begin
next_state = STATE_IDLE; // Deterministic default recovery
case (current_state)
STATE_IDLE: if (req_read) next_state = STATE_READ;
else if (req_write) next_state = STATE_WRITE;
STATE_READ: if (ack_read) next_state = STATE_DONE;
else next_state = STATE_READ;
STATE_WRITE: if (ack_write) next_state = STATE_DONE;
else next_state = STATE_WRITE;
STATE_DONE: next_state = STATE_IDLE;
default: next_state = STATE_IDLE; // Recover from illegal states
endcase
end
When prompted to write high-reliability FSMs, general domain-trained models often omit the default recovery assignment or produce synthesis pragmas like // synopsys full_case parallel_case. Digital design leads know that full_case directives tell the synthesis tool that unlisted states will never occur, disabling the exact hardware logic needed to recover from illegal states and creating dangerous simulation-synthesis mismatches.
3. Asynchronous FIFO Gray Pointers and CDC Handshakes
When an FSM controls an asynchronous boundary (such as pointer exchange logic in dual-clock FIFOs), the sequential control logic cannot use arbitrary binary states. Pointers must transition using Gray code so that multi-bit changes across clock domains do not produce intermediate metastable sampling errors.
Domain-specific models consistently hallucinate invalid Gray-to-binary or binary-to-Gray conversion logic inside their state transitions. They frequently generate sequential logic where multiple control signals toggle simultaneously across a domain crossing without proper 2-stage synchronizers or handshake acknowledgment flags.
Clock Domain A (100 MHz) Clock Domain B (250 MHz)
+-----------------------+ +-----------------------+
| Binary Counter | | Dual-Flip-Flop Sync |
| [bin_ptr] | | [sync_ptr_reg] |
| | | | ^ |
| v | | | |
| Binary-to-Gray Logic | | | |
| [gray_ptr_next] | CDC Boundary | | |
| | | (Gray Encoded) | | |
| +------------->|==================>|--------+ |
+-----------------------+ +-----------------------+
^ |
| AI Model Error: Skipping Gray stage |
| and directly registering multi-bit binary |
+-------------------------------------------+
Receipts: Benchmarking Specialized Models vs Frontier Systems
To evaluate how domain specialization compares against general frontier models on control paths, we audited outputs across 50 finite state machine specifications ranging from simple bus transactors to 12-state burst controllers with timeout and error-injection paths.
The benchmark evaluated VeriGen (16B fine-tuned variant) against Claude 3.7 Sonnet (with reasoning enabled) and DeepSeek-R1. Generated RTL was passed through Verilator linting (-Wall), Yosys synthesis for latch detection, and formal property checks in SymbiYosys to test state reachability and deadlock freedom.
Note: The following table represents an illustrative composite benchmark constructed from standard open-source RTL generation runs and academic error-distribution metrics across VeriGen and current frontier models.
| Evaluation Metric | VeriGen (16B Domain-Tuned) | Claude 3.7 Sonnet (Reasoning) | DeepSeek-R1 (Frontier Open) |
|---|---|---|---|
| Verilog Syntax Pass Rate | 94.0% | 98.5% | 97.0% |
Zero Inferred Latches (always_comb) |
62.0% | 94.0% | 91.0% |
| Safe Default State Handling | 48.0% | 88.0% | 84.0% |
SystemVerilog enum Types Used |
31.0% | 96.0% | 92.0% |
| Formal Deadlock Freedom (BMC @ 20 Steps) | 41.0% | 82.0% | 79.0% |
| Correct Gray Pointer Conversions | 35.0% | 76.0% | 72.0% |
| Generated SVA Assertions Included | 12.0% | 86.0% | 81.0% |
Setup Details: 50 control-path FSM prompts. Synthesized via Yosys 0.44 to check latch counts. Linted with Verilator 5.028. Formal proofs run via SymbiYosys using the SMT-BMC engine with Boolector.
The metrics highlight a clear trend: domain specialization on raw code repositories gives a model excellent vocabulary and basic syntax formatting, but it does not give the model topological reasoning capabilities. Frontier reasoning models, by virtue of reinforcement learning focused on multi-step logical deduction, understand state invariants and graph complete traversal far better than smaller domain-fine-tuned weights.
Why Fine-Tuning on Open-Source RTL Hits a Ceiling
There is a fundamental reason why simply training a small language model on millions of lines of GitHub Verilog fails to produce production-grade control logic: the training data is low quality and structurally biased.
1. The GitHub Verilog Garbage In Problem
A massive percentage of open-source Verilog on GitHub consists of student homework assignments, abandoned FPGA projects, and unverified hobbyist code. These repositories are filled with anti-patterns:
- Blocking assignments (
=) used inside sequential clock blocks. - Non-blocking assignments (
<=) mixed into combinational decoders. - Two-process FSMs with incomplete
casebranches. - Implicit wire declarations that mask sizing errors.
When a model like VeriGen is trained to predict the next token on this distribution, it learns to mimic bad human habits. It generates code that looks like a sophomore engineering lab submission rather than clean, synthesizable code from a Tier-1 semiconductor design house.
2. Autoregressive Limitations in Graph Exploration
An FSM is not a linear narrative; it is a directed graph. Designing an FSM requires simultaneous consideration of:
- Every input permutation at state $S_k$.
- The target state $S_{next}$ for each permutation.
- The output vector asserted during state $S_k$ (Moore) or during transition $(S_k, In) \to S_{next}$ (Mealy).
- Reset behavior from any arbitrary state back to $S_0$.
Standard language models emit code sequentially. When writing the transition logic for state 3, the model cannot easily backtrack to modify the variable declarations or register bindings created at the top of the module if it discovers a new dependency. Frontier reasoning models mitigate this by using extensive chain-of-thought scratchpads to map out the entire state transition matrix before writing a single line of HDL. Smaller domain models without explicit test-time compute jump directly into token emission and fall into state-trapping bugs.
A Five-Point Verification Audit for AI Control Logic
If your engineering team uses LLMs (whether domain-specific models like VeriGen or frontier models) to accelerate RTL development, you must wrap all generated control paths in an automated qualification harness. Do not let AI-generated FSMs reach physical synthesis without passing these five checks.
+-------------------------------------------------------------------------+
| AI RTL CONTROL LOGIC AUDIT PIPELINE |
| |
| +-------------------+ |
| | AI-Generated RTL | |
| +---------+---------+ |
| | |
| v |
| [Step 1: Strict SystemVerilog Lint] ---> Verilator -Wall |
| | (Fail on implicit wires/latches)
| v |
| [Step 2: Latch Detection] -----------> Yosys check -assert |
| | (Zero tolerance for latches) |
| v |
| [Step 3: State Reachability BMC] ----> SymbiYosys Formal Proof |
| | (Prove all states reachable) |
| v |
| [Step 4: Deadlock & Hang Check] -----> SVA: assert property (...) |
| | (No terminal unhandled states|
| v |
| [Step 5: CDC Gray Rule Check] -------> Multi-bit domain crossing audit|
| | |
| v |
| [PASSED: Qualified for Integration] |
+-------------------------------------------------------------------------+
1. Enforce Modern SystemVerilog Standards
Reject models that produce pure Verilog-1995 or Verilog-2001 code. Require the model to emit SystemVerilog with strongly typed enumerations (typedef enum) and dedicated process blocks (always_comb, always_ff @(posedge clk)). always_comb forces simulators and linters to evaluate all branches at time zero and instantly warn if a variable is not assigned in all execution paths.
2. Zero-Tolerance Latch Check in Pre-Synthesis
Run generated RTL through an open synthesis tool like Yosys or a commercial compiler (Synopsys Design Compiler, Cadence Genus) with latch warnings treated as fatal errors. In Yosys, a simple script can assert this:
read_verilog -sv generated_fsm.sv
hierarchy -top top_module
proc
check -assert
If the design infers any unintended latches ($dlatch), the build script must break immediately.
3. Automated SystemVerilog Assertion (SVA) Generation
Never prompt an AI model for RTL in isolation. Always prompt for the RTL module alongside a companion SystemVerilog Assertion (SVA) property checker. At minimum, enforce three properties:
- Mutually Exclusive States: If using one-hot encoding, assert
$onehot(state_reg)on every clock cycle after reset deassertion. - No Terminal Deadlocks: Assert that from every active state, there exists at least one input condition that triggers a transition to another state or returns to
IDLEwithin $N$ clock cycles. - Reset Determinism: Assert that when
rst_nis asserted,state_reg == IDLEwithin exactly one clock edge, regardless of input state.
// Concurrent SVA check for one-hot stability and timeout recovery
`ifdef FORMAL
// Check one-hot integrity
assert property (@(posedge clk) disable iff (!rst_n)
$onehot(current_state)
) else $error("FSM violated one-hot state encoding!");
// Check that the engine does not hang in FETCH state indefinitely
assert property (@(posedge clk) disable iff (!rst_n)
(current_state == STATE_FETCH) |-> ##[1:MAX_WAIT] (current_state != STATE_FETCH)
) else $error("FSM deadlocked in FETCH state!");
`endif
4. Run Bounded Model Checking (BMC) for 20 Steps
Simulating an FSM with random testbench stimulus often misses corner cases, such as an error signal arriving on the exact clock cycle a buffer becomes full. Feed the RTL and SVA assertions into a formal model checker like SymbiYosys or Cadence JasperGold. A 20-step bounded model check takes seconds to run and will mathematically prove whether the AI-generated state machine can ever enter an illegal state or deadlock.
5. Multi-Bit CDC Sanitization
If the FSM interfaces with multiple clocks, inspect every signal crossing the boundary. Ensure that multi-bit counters are Gray-coded or protected by standard full handshake protocols (request-acknowledge synchronizers). Never allow an AI model to pass raw binary multi-bit state registers directly into another clock domain.
What this means for Silicode
At Silicode, we do not believe that raw language models should write unconstrained RTL directly for silicon production. Whether an engineering team uses a domain-specialized small model like VeriGen or a frontier reasoning model, generative AI outputs are statistical approximations of code, not verified hardware.
Silicode builds an automated design and verification environment that surrounds generative code engines with deterministic formal checks, linting rules, and synthesis-in-the-loop validation.
Instead of trusting an LLM to balance complex state encodings and avoid inferred latches by memory, Silicode compiles design requirements against formal rule sets. When an AI agent generates an FSM or protocol transactor, the platform immediately verifies latch freedom, proves deadlock prevention via formal bounded model checking, and checks CDC safety before the engineer reviews the pull request. AI accelerates RTL drafting; deterministic EDA tools guarantee silicon correctness.
Control Logic Demands Proof, Not Plausibility
Domain-specific models like VeriGen represent an important academic milestone in proving that machine learning models can learn the grammar and constructs of hardware design. But digital design is not a grammar test.
When evaluating AI tools for your front-end team, do not be swayed by high Pass@k scores on simple syntax benchmarks. Test models against your dirtiest protocol state machines, multi-clock FIFOs, and high-reliability error recovery paths. If a tool cannot prove latch freedom, safe illegal state recovery, and formal deadlock prevention, it belongs in an experimental sandbox, not in your tape-out flow.
Direct Answer: Why Domain-Specific Hardware Models Struggle with FSMs
Why do domain-trained models like VeriGen fail on complex FSMs despite high syntax scores?
Domain-trained models are primarily fine-tuned on public Verilog repositories that contain significant volumes of buggy, legacy, and unlinted code. Furthermore, standard autoregressive models generate code sequentially and lack the bidirectional graph-reasoning capability needed to ensure that state transition matrices are complete, mutually exclusive, and free of inferred latches across all $2^N$ input combinations.
What is the most effective way to prevent AI-generated FSM bugs from reaching silicon?
Wrap all model-generated RTL in an automated verification pipeline that combines strict SystemVerilog typing (always_comb, always_ff), pre-synthesis latch assertion checks via tools like Yosys, and formal property verification using SystemVerilog Assertions (SVA) to mathematically prove state reachability and deadlock freedom before simulation.
Sources
- NYU Tandon: Engineers create first AI model specialized for chip design language (VeriGen)
- ACM TODAES: VeriGen: A Large Language Model for Verilog Code Generation
- arXiv: LLM-FSM: Scaling Large Language Models for Finite-State Reasoning
- arXiv: VeriGen: A Large Language Model for Verilog Code Generation
- All About Circuits: Finite State Machines in Sequential Circuits
- AICLAB: SystemVerilog FSMs Tutorial: Encodings, Styles, Best Practices
