A Formally Verified Procedure for Width Inference in FIRRTL

📅 2026-01-19
📈 Citations: 0
Influential: 0
📄 PDF
🤖 AI Summary
This work addresses the incompleteness of existing FIRRTL compilers, such as firtool, which may fail to infer bit widths even for simple programs. We propose a complete width inference method that guarantees a unique minimal solution whenever the underlying constraints are satisfiable, and we formalize this inference procedure accordingly. For the first time, we implement and formally verify the InferWidths compiler pass within the interactive theorem prover Rocq, from which we extract correct-by-construction OCaml executable code. Experimental evaluation demonstrates that our approach handles a strictly larger set of benchmarks than firtool while maintaining high performance.

Technology Category

Application Category

📝 Abstract
FIRRTL is an intermediate representation language for Register Transfer Level (RTL) hardware designs. In FIRRTL programs, the bit widths of many components are not specified explicitly and must be inferred during compilation. In mainstream FIRRTL compilers, such as the official compiler firtool, width inference is conducted by a compilation pass referred to as InferWidths, which may fail even for simple FIRRTL programs. In this paper, we thoroughly investigate the width inference problem for FIRRTL programs. We show that, if the constraints obtained from a FIRRTL program are satisfiable, there exists a unique least solution. Based on this result, we propose a complete procedure for solving the width inference problem. We implement it in the interactive theorem prover Rocq and prove its functional correctness. From the Rocq implementation, we extract an OCaml implementation, which is the first formally verified implementation of the InferWidths pass. Extensive experiments demonstrate that our approach can solve more instances than the official InferWidths pass in firtool, normally with high efficiency.
Problem

Research questions and friction points this paper is trying to address.

FIRRTL
width inference
RTL
bit width
compiler
Innovation

Methods, ideas, or system contributions that make the work stand out.

FIRRTL
width inference
formal verification
constraint solving
compiler pass
🔎 Similar Papers
No similar papers found.
K
Keyin Wang
Key Laboratory of System Software (Chinese Academy of Sciences), Institute of Software, Chinese Academy of Sciences, University of Chinese Academy of Sciences
X
Xiaomu Shi
Key Laboratory of System Software (Chinese Academy of Sciences), Institute of Software, Chinese Academy of Sciences, University of Chinese Academy of Sciences
Jiaxiang Liu
Jiaxiang Liu
Zhejiang University
Multimodal FusionMedical Image Analysis
Zhilin Wu
Zhilin Wu
State Key Laboratory of Computer Science
Computational LogicProgram Analysis and VerificationAutomata Theory
F
Fu Song
Key Laboratory of System Software (Chinese Academy of Sciences), Institute of Software, Chinese Academy of Sciences, University of Chinese Academy of Sciences, Nanjing Institute of Software Technology
Taolue Chen
Taolue Chen
School of Computing and Mathematical Sciences, Birkbeck, University of London
Software EngineeringProgram Analysis and VerificationMachine learning
David N. Jansen
David N. Jansen
Radboud Universiteit Nijmegen
Computer Science: Model checking