fpv-mcp
# AI4FPV (`v1.0.0-rc2`) — Thin MCP + Strong Skill for RTL Formal Verification
**AI4FPV** lets an AI coding agent (Claude Code, GitHub Copilot CLI) run RTL formal verification with the open-source **OSS CAD Suite** (`SymbiYosys`, `Yosys/Slang`, `ABC`, `Bitwuzla`, `Boolector`, `Yices`, `Z3`, `Pono`). It has two parts:
- an **MCP server** (`fpv-mcp`, 13 tools) that runs `sby` and friends in isolated work directories and returns structured results plus the exact script it executed;
- a **skill** (`rtl-fpv-workflow`) that tells the agent how to use those tools without drawing wrong conclusions: cover before BMC, induction counterexamples are not bugs, and so on.
It is a transparent helper around mature upstream tools, not an automated sign-off platform.
Released under the MIT License, see `LICENSE`.
## Prerequisites
| Need | Notes |
|---|---|
| Windows 10/11 | The only platform it has been tested on. Process-tree cleanup uses Windows facilities; Linux is untested. |
| Python 3.10 or newer | Developed and tested with 3.12. |
| OSS CAD Suite | Download a Windows release from <https://github.com/YosysHQ/oss-cad-suite-build/releases> and unpack it anywhere. Tested with the 2026-10-19 build. The suite must include the `slang` Yosys plugin for full SystemVerilog support (`fv_env_check` tells you). |
| Python packages `mcp>=2.1`, `anyio>=4.1`, `pydantic>=2` | Installed for you by `--install-editable`. |
## Install
Unpack or clone this folder somewhere permanent (the agent's configuration will point at it), then from that folder:
```powershell
# Claude Code: installs dependencies, links the skill into ~/.claude/skills, registers fpv-mcp in ~/.claude.json, verifies
.\scripts\install_ai4fpv.cmd --target claude --install-editable --verify
# GitHub Copilot CLI
.\scripts\install_ai4fpv.cmd --target copilot --install-editable --verify
# One RTL project only (.github/skills and .mcp.json inside that project)
.\scripts\install_ai4fpv.cmd --target project --project-dir <your-rtl-project> --install-editable --verify
```
- **Where is the OSS CAD Suite?** It is found automatically if `yosys` is on `PATH`, or the suite sits under `D:\oss-cad`, `C:\oss-cad`, `C:\oss-cad-suite` or `%USERPROFILE%\oss-cad-suite`. Anywhere else, add `--oss-cad-dir <folder containing bin\yosys.exe>`.
- **Which Python?** The one that runs the installer is the one the MCP server will use. Use `--python <path>` to choose another.
- `--verify` starts the server the way the agent will, asks it for its tool list and its view of the toolchain, and exits non-zero with the reason if anything is missing. `--dry-run` shows what would change without touching anything. `--uninstall` removes the skill link and the MCP entry.
- Restart the agent (or reconnect its MCP servers) after installing.
PowerShell wrapper and direct call are equivalent:
```powershell
powershell -ExecutionPolicy Bypass -File .\scripts\install_ai4fpv.ps1 -Target claude -InstallEditable -Verify
python -m fpv_mcp.installer --target claude --install-editable --verify
```
The skill is installed as a link to this folder, so updating the folder updates the skill. Do not move or delete the folder after installing; re-run the installer if you do.
## First Use
Ask the agent, for example: *"Formally verify `examples/demo_fifo/sync_fifo.sv` with the harness `fv_sync_fifo.sv`."* It should load the `rtl-fpv-workflow` skill, call `fv_env_check`, then run cover, BMC and a per-property proof. `examples/demo_fifo` also contains a refactored FIFO for RTL-vs-RTL equivalence checking.
To check the installation yourself, without an agent:
```powershell
python -m unittest discover -s tests
```
About one minute; needs only the OSS CAD Suite.
## Tools (13)
| Tool | Purpose |
|---|---|
| `fv_env_check` | Is the toolchain usable (`ready`, `problems`), which tools and versions |
| `fv_list_models` | Built-in formal models and SEC primitive models included in this edition, if any |
| `fv_analyze_design` | Elaborate RTL: FF/memory sizes, assert/cover inventory, missing modules, semantic-hazard lint |
| `fv_run_sby` | Isolated SBY run (existing `.sby`, or files + probes/cutpoints, `skip`, `extra_options`); `background=True` for long runs; reports `expectation_met` for `expect fail` tasks |
| `fv_job_status` | Poll a background job: step reached so far, or the final result (`wait_sec` to block) |
| `fv_job_cancel` | Cancel a background job and kill its process tree |
| `fv_prove_per_property` | One elaboration, then each assertion proved separately (ABC PDR, fallback `abc dprove` / `pono`); each result carries `src` (`file:line`) |
| `fv_inspect_cex` | Counterexample VCD as a Markdown table: one row per clock cycle, caller-ordered columns, step windows |
| `fv_run_sec_rtl` | RTL-vs-RTL sequential equivalence (multi-clock/reset, `valid_qualified_outputs`, counterexample VCD) |
| `fv_run_sec_netlist` | RTL-vs-Synplify `.vm` equivalence with primitive audit; refuses unmodelled hard macros |
| `fv_check_mutation` | Targeted or random mutation check: can the assertions fail at all? |
| `fv_export_yosys_netlist` | Yosys netlist for simulation bridging |
| `fv_generate_report` | Sign-off report filled in from the server's run records |
Every proving tool returns `generated_sby` / `generated_ys`, the script it ran, so results can be reproduced with plain `sby` / `yosys`.
## Known Limits
- **Netlist SEC needs behavioural models of the netlist's primitives.** Pass them with `extra_prim_files` unless this edition includes built-in ones (`fv_list_models` shows what is installed).
- **SEC ties all clocks to one miter clock.** Asynchronous phase relationships are not modelled, so SEC results say nothing about CDC.
- **`abc bmc3` may find a failure but give no trace.** A defect in upstream `yosys-witness aiw2yw` can crash the witness conversion; `fv_run_sby` then reports `FAIL` with `cex_step` only. Re-run with `smtbmc` for the waveform.
- **Assertions generated by a macro have no source location under the `slang` frontend** (`src` is null). `frontend="yosys_sv"` locates them.
- **Client cancel stops `fv_run_sby` and the two SEC tools only.** `fv_prove_per_property` and `fv_check_mutation` run to their own timeouts.
- **Background jobs and run records are in memory.** Both are lost when the MCP server restarts.
- **The report is not tamper-evident.** It is filled in from the server's run records, which keeps an honest report consistent with what the tools returned; records vanish on restart, the Markdown can be edited, and only the runs the caller lists are shown.
- **A call that stays silent for about 30 minutes is aborted by the MCP client.** Use `background=True` for long runs.
- **Hard datapath proofs can exceed what the open-source engines converge on** (for example Reed-Solomon decoder properties); expect partial results and plan decomposition.
## Configuration (Environment Variables)
Set these in the `env` block of the `fpv-mcp` entry in the agent's MCP configuration (the installer writes `FPV_OSS_CAD_DIR` there when you pass `--oss-cad-dir`).
| Variable | Default | Purpose |
|---|---|---|
| `FPV_OSS_CAD_DIR` | Auto: `yosys` on `PATH`, then `D:\oss-cad`, `C:\oss-cad`, `C:\oss-cad-suite`, `%USERPROFILE%\oss-cad-suite` | OSS CAD Suite root. If set, it must be right: a wrong value is reported, not silently replaced. |
| `FPV_DEFAULT_TIMEOUT` | `600` | Default solver timeout in seconds |
| `FPV_MAX_WORKERS` | `max(1, min(4, cpu_count // 2))` | Parallel workers for per-property proofs and background jobs |
| `FPV_SSH_HOST` / `FPV_REMOTE_ENV` / `FPV_REMOTE_TMP` | `testhost` / `~/fv-tools/env.sh` / `/tmp/ai4fpv_jobs` | Optional SSH offload to a Linux host you configure yourself; unused unless a tool is called with `target="testhost"` |
## Manual Registration (if you do not use the installer)
```json
{
"mcpServers": {
"fpv-mcp": {
"type": "stdio",
"command": "<path to python.exe>",
"args": ["-m", "fpv_mcp.server"],
"env": {
"PYTHONPATH": "<this folder>",
"FPV_OSS_CAD_DIR": "<folder containing bin\\yosys.exe>"
}
}
}
}
```
Copy or link `skills\rtl-fpv-workflow` into the agent's skills directory (`~/.claude/skills`, `~/.copilot/skills` or `<project>/.github/skills`).
## Folder Layout
| Path | Contents |
|---|---|
| `fpv_mcp\` | MCP server and engines (server, sby, sec, mutation, vcd, installer, ...) |
| `skills\rtl-fpv-workflow\` | `SKILL.md` (rules + workflow) and 4 reference guides (patterns, solvers, SEC, sign-off) |
| `examples\demo_fifo\` | Self-contained formal verification and equivalence-checking demo |
| `scripts\` | `install_ai4fpv.cmd` / `.ps1` |
| `tests\test_fpv_mcp.py` | 15 end-to-end suites; also the installation self-check |
| `FEEDBACK_TEMPLATE.md` | How to report a problem |
| `LICENSE` | MIT License |
## Reporting Problems
This toolkit has had few users so far, and their reports are what improves it. When something goes wrong or is awkward, fill in `FEEDBACK_TEMPLATE.md`.
Open an issue in the repository and paste it there; remove anything confidential about your design first.
The `generated_sby` / `generated_ys` from the failing call and the `log_file` it names are the most useful attachments.
TDQS
Scored across 13 tools
The 13 tools mostly map to clearly distinct actions (environment check, model listing, design analysis, job management, report generation). The family of proving tools (fv_run_sby, fv_prove_per_property, fv_run_sec_rtl, fv_run_sec_netlist, fv_check_mutation) has some conceptual overlap in 'run a proof,' but descriptions make the boundaries reasonably clear (general SBY vs per-assertion ABC vs RTL/RTL SEC vs RTL/netlist SEC vs mutation).
All tools share a consistent fv_ prefix and snake_case, which is strong. Minor inconsistency exists between verb-first names (fv_run_sby, fv_prove_per_property, fv_generate_report) and noun-first names (fv_env_check, fv_job_status, fv_job_cancel), but the pattern is still readable.
13 tools is well within the ideal 3-15 range and each tool earns its place in a formal verification flow. No redundant entries; job status/cancel are a natural pair supporting the background-run capability.
The surface covers the full flow: environment, models, analysis, multiple proof engines (BMC/PDR, per-property, SEC RTL/netlist), mutation, counterexample inspection, netlist export, job control, and sign-off reporting. Minor gaps remain, such as no dedicated cover/coverage-depth command or a way to list past runs for re-reporting, but agents can work around these via fv_run_sby and fv_job_status.