Abstract: Large Language Models (LLMs) have demonstrated potential in automating hardware design, yet they frequently produce code with syntactic hallucinations and logical inconsistencies. This paper presents Veritas, a framework that bypasses direct Verilog generation in favor of producing formal logic specifications. By fine-tuning a 3B-parameter LLM to generate Conjunctive Normal Form (CNF) and Propositional Logic Formulas (PLF), Veritas enables deterministic synthesis of functionally perfect Verilog code. Our results show a 100% success rate on standard digital components, significantly outperforming state-of-the-art models like GPT-4.
Introduction
Designing hardware using Verilog is notoriously difficult and prone to bugs. While Large Language Models (LLMs) like GPT-4 have shown promise in automating this, they suffer from two major flaws: syntactic errors, where they hallucinate non-compiling syntax, and logical errors, where the compiled code fails to meet functional requirements. Currently, engineers rely on a "generate-then-verify" approach that is slow, expensive, and often fails on complex designs. Veritas addresses this by shifting the LLM's role from code generation to formal logic description.
Methodology
The core innovation of Veritas is using Conjunctive Normal Form (CNF)—a standardized logical format used in formal verification—as an intermediate representation.
The workflow follows a structured path:
- The Prompt: A user requests a specific circuit implementation.
- Logic Generation: A fine-tuned LLM generates Propositional Logic Formulas (PLF) or CNF clauses describing the circuit's truth table.
- Deterministic Synthesis: These logical clauses are processed by the traditional
ABClogic synthesis tool. - Verilog Output: The tool converts the logic into synthesizable, perfectly formatted Verilog.
By utilizing a deterministic tool for the final synthesis, Veritas ensures that if the underlying logic is correct, the resulting code is guaranteed to be syntactically perfect.
Experimental Evaluation
The researchers fine-tuned a Llama-3.2-3B-Instruct model using a custom RTL dataset containing standard components such as adders, subtractors, multiplexers, and decoders. This model was compared against state-of-the-art open-source models like Verigen-2B and RTLCoder.
Veritas significantly outperformed much larger models in functional accuracy, achieving a pass@1 score of 1.0 across all test cases. In comparative studies, Veritas produced correct logic 100% of the time, while GPT-4 struggled with XOR gates and RTLCoder failed on simple 4-bit subtractors, often mismanaging carry logic. The authors even successfully synthesized a fully functional Arithmetic Logic Unit (ALU) from scratch on the first attempt.
Discussion and Key Insights
Veritas succeeds by narrowing the LLM's task to logic generation, playing to the model's strengths in reasoning through logical structures rather than struggling with rigid HDL syntax. Furthermore, by using PLF instead of standard CNF, the authors reduced the token count by nearly 3x for complex designs, allowing a lightweight 3B model to outperform much larger counterparts.
A critical advantage of this approach is "correctness by construction." Because the LLM outputs a formal specification, verification is inherent to the process. If the CNF is satisfiable and matches the requirement, the resulting hardware is mathematically guaranteed to be correct, as illustrated by the use of SAT solvers in equivalence checking.
Conclusion
While Veritas represents a major advancement, it currently focuses on combinational logic. Future work will extend the framework to sequential logic (including registers and clocks) and explore scaling to massive, non-standardized architectural blocks. The authors plan to open-source the method and data to provide a new baseline for the Electronic Design Automation (EDA) community.
Summary updated