fpgaZeroMCP
fpgaZeroMCP
一个开源的 Model Context Protocol 服务器,为 AI 助手提供完整的 FPGA 工具链——lint、仿真、综合、布局布线、烧录比特流,以及一个由 GitHub 驱动的实时 IP 核注册表。
你可以让 AI 搜索 IP 核、拉取它们、lint HDL、综合磁盘上的多文件 VHDL 或 Verilog 工程、运行仿真,然后把比特流烧录到你的开发板上——全程无需离开聊天窗口。
功能特性
多语言支持:Verilog、SystemVerilog 和 VHDL(通过 ghdl-yosys-plugin)
三种输入模式:内联
code字符串、多文件files字典,或磁盘上的project_dir路径文件列表支持:
files.f/sources.f,支持+incdir+、+define+和嵌套的-f指令开发板预设:11 块内置开发板(iCEBreaker、ULX3S、TinyFPGA BX、Tang Nano 等)——自动设置 target/device/package/clock
约束自动检测:在工程目录中自动查找
.pcf/.lpf/.pdc/.cst比特流烧录:通过
iceprog(iCE40)或openFPGALoader(ECP5/Gowin/Nexus/Xilinx)烧录Vivado:通过
start_build批量运行,Xilinx 构建通过 LiteX,build_status中结构化解析 Vivado 日志仿真结果判定:PASS/FAIL/UVM 模式检测,附带 VCD 信号摘要
后台构建:长时间运行的综合/布局布线,支持状态轮询和严格的仅 EDA 命令白名单
并发请求:在慢速工具调用仍在运行时响应 ping、构建状态和取消请求;
notifications/cancelled可中止正在进行的调用机器可读结果:工具结果上的
structuredContent(MCP 2025-06-18),以及用于重试/回退决策的统一error_code分类进度通知:当客户端发送
progressToken时,在综合、布局布线和 LiteX 运行的阶段边界发送notifications/progressIP 核注册表:从 GitHub 实时搜索和导入,支持 FuseSoC CAPI2 元数据
健康检查:发现 OSS CAD Suite 中已安装且可访问的工具
Related MCP server: vivado-mcp-agent
目录
工作原理
MCP 服务器作为本地子进程运行。你的 AI 通过 JSON-RPC(stdio)调用其上的工具。服务器会调用 OSS CAD Suite 中的 Yosys、nextpnr、iverilog、Verilator 等工具——并且可以直接从 GitHub 拉取开源 FPGA IP 核。
Your AI assistant <--> fpgaZeroMCP (stdio MCP server) <--> OSS tools
|
cores/ registry on GitHub
(uart_tx, fifo + any imported)前提条件
要求 | 说明 |
Python 3.11+ | |
一次性打包下载 iverilog、Yosys、nextpnr、Verilator、Verible、GHDL | |
可选——仅在使用 LiteX 工具时需要 |
安装后,将 OSS CAD Suite 添加到你的 PATH。如果某个工具缺失,所有工具包装器都会优雅降级。
GitHub API 访问
默认情况下,GitHub API 请求未经过身份验证,并受速率限制。设置个人访问令牌可提高限额:
# Linux/macOS
export GITHUB_TOKEN=ghp_...# Windows (PowerShell)
$env:GITHUB_TOKEN = "ghp_..."安装
git clone https://github.com/lcapossio/fpgaZeroMCP
cd fpgaZeroMCP
pip install -e .MCP 客户端配置
Claude Desktop
添加到 claude_desktop_config.json:
{
"mcpServers": {
"fpgaZeroMCP": {
"command": "python",
"args": ["/path/to/fpgaZeroMCP/server.py"],
"env": { "PYTHONPATH": "/path/to/fpgaZeroMCP" }
}
}
}VS Code (GitHub Copilot)
添加到工作区中的 .vscode/mcp.json:
{
"servers": {
"fpgaZeroMCP": {
"type": "stdio",
"command": "python",
"args": ["/path/to/fpgaZeroMCP/server.py"],
"env": { "PYTHONPATH": "/path/to/fpgaZeroMCP" }
}
}
}Cursor / Windsurf
添加到你的 MCP 设置(Settings → MCP Servers):
{
"fpgaZeroMCP": {
"command": "python",
"args": ["/path/to/fpgaZeroMCP/server.py"],
"env": { "PYTHONPATH": "/path/to/fpgaZeroMCP" }
}
}示例提示词
"帮我找一个 I2C 主机 IP 核并导入。"
"综合 ~/projects/my_fpga 中的 VHDL 文件,并告诉我 LUT 数量。"
"对我的工程执行面向 iCEBreaker 开发板的布局布线,然后烧录。"
"使用 seed 42 运行布局布线,尝试获得更好的时序。"
"对这个 Verilog 执行 lint 并修复所有错误。"
"仿真这个 FIFO,并告诉我测试平台是否通过。"
"格式化这个 SystemVerilog 文件。"
"我安装了哪些 OSS CAD Suite 工具?"
工具
HDL 质量
工具 | 说明 |
| 通过 iverilog(V/SV)或 GHDL(VHDL)进行语法/错误检查——单文件 |
| 同时 lint 多个文件,使跨模块引用能够解析 |
| 结构化的逐行诊断——Verilator → verible 回退(V/SV),GHDL(VHDL) |
| 通过 verible-verilog-format(V/SV)或 vsg(VHDL)自动格式化 |
设计流程
工具 | 说明 |
| 编译并运行测试平台——iverilog(V/SV)或 GHDL(VHDL)。接受 |
| 使用 Yosys 综合并给出资源统计。接受 |
| 一步完成 Yosys + nextpnr。开发板预设、约束自动检测,比特流写入磁盘( |
| 通过 |
| 枚举内置开发板预设(target/device/package/clock) |
IP 核注册表
工具 | 说明 |
| 浏览本地注册表,按类别筛选 |
| 获取某个 IP 核的清单和 HDL 源码 |
| 获取参数化实例化片段 + 源文件 |
| 在 GitHub 上搜索 MIT 许可的 FPGA IP 仓库 |
| 将 GitHub 仓库下载到本地注册表 |
| 导入本地 FuseSoC CAPI2 |
LiteX
工具 | 说明 |
| 使用 |
| 生成 LiteX SoC,不构建 gateware |
| 使用完全自定义的参数运行 LiteX 开发板目标 |
构建管理
工具 | 说明 |
| 在后台启动长时间运行的命令(仅限白名单中的 EDA 工具) |
| 检查进度——状态、已用时间、解析出的阶段/资源利用率/时序 |
| 列出所有被跟踪的构建(运行中和已完成) |
| 终止正在运行的后台构建 |
| 按年龄和总大小删除旧的构建日志 |
服务器 / 注册表
工具 | 说明 |
| 报告哪些 OSS CAD Suite 工具已安装,含路径和版本 |
| 无需重启服务器即可重新扫描 IP 核目录 |
IP 核注册表
IP 核存放在 cores/<name>/ 中——包含一个 core.json 清单和一个或多个 HDL 文件。服务器在启动时自动发现它们,并在任何导入后重新加载。
内置两个参考 IP 核(uart_tx、fifo)以演示该格式。注册表并非要在这里增长——它由 GitHub 驱动。
在运行时获取 IP 核
# Find a RISC-V softcore
search_github_cores("riscv softcore", language="verilog")
# Pull it in
import_github_core("YosysHQ/picorv32")
# It is now in the local registry
get_ip_core("picorv32")
generate_ip("picorv32", {"COMPRESSED_ISA": 1})当仓库中存在 FuseSoC CAPI2 元数据(.core 文件)时,服务器会自动使用它,从而获得更丰富的参数和端口信息。只有具有允许的许可证的仓库才会被接受。
贡献 IP 核
请不要为此仓库提交添加 IP 核的 PR。 而是:
在 GitHub 上发布你的 HDL 仓库,带上
fpga主题和 MIT 许可证可选:添加 FuseSoC CAPI2
.core文件以获得更丰富的元数据然后任何人都可以直接
import_github_core("you/your-core")
这样可以让服务器保持精简,并让社区在 GitHub 上有机地成长。
综合目标
目标 | 供应商 / 系列 | 完整的开源 P&R |
| Lattice iCE40 | 是——nextpnr-ice40 |
| Lattice ECP5 | 是——nextpnr-ecp5 |
| Lattice Nexus (CrossLink-NX, CertusPro-NX) | 是——nextpnr-nexus |
| Gowin | 是——nextpnr-gowin |
| Xilinx / AMD | 仅综合 |
| Intel / Altera | 仅综合 |
| 与技术无关 | 仅网表 |
用于 place_and_route 的常用 device/package 值:
目标 | device | package |
ice40 |
|
|
ecp5 |
|
|
nexus |
| (内嵌在设备字符串中) |
gowin |
| (内嵌在设备字符串中) |
LiteX
LiteX 是一个基于 Python 的 SoC 框架,可以面向许多 FPGA 开发板。fpgaZeroMCP 提供了三个专用的 LiteX 工具,并且在 synthesize 和 place_and_route 中也接受 backend="litex"。
# Dedicated tools
litex_build(board="arty", args=["--build"])
litex_soc(board="arty", args=["--no-compile"])
litex_flow(board="arty", args=["--build", "--output-dir", "build_arty"])
# As a backend in existing flow tools
synthesize(code="...", top_module="top", backend="litex", litex_board="arty")
place_and_route(code="...", top_module="top", target="ice40", device="hx1k",
backend="litex", litex_board="arty", litex_args=["--build"])本地 IP 核仓库
你可以通过两种方式将注册表指向你自己的本地 HDL 目录:
环境变量:
Linux/macOS(冒号分隔):
export USERCORES_PATH=/home/you/my-cores:/home/you/work-coresWindows(分号分隔,PowerShell):
$env:USERCORES_PATH = "C:\Users\you\my-cores;C:\Users\you\work-cores"配置文件(~/.fpgazero_mcp/config.json):
{
"core_paths": [
"/home/you/my-cores",
"/home/you/work-cores"
]
}允许的许可证
默认情况下,import_github_core 接受以下任一 SPDX 许可证的仓库:
MIT, BSD-2-Clause, BSD-3-Clause, Apache-2.0, ISC, GPL-2.0, GPL-3.0, LGPL-2.1, LGPL-3.0通过 FPGA_ZERO_ALLOWED_LICENSES 环境变量覆盖(逗号分隔的 SPDX ID):
# Linux/macOS
export FPGAZERO_ALLOWED_LICENSES=MIT
export FPGAZERO_ALLOWED_LICENSES=MIT,Apache-2.0# Windows (PowerShell)
$env:FPGAZERO_ALLOWED_LICENSES = "MIT"
$env:FPGAZERO_ALLOWED_LICENSES = "MIT,Apache-2.0"许可证 ID 遵循 SPDX 表示法。检查是在导入时进行的;search_github_core 返回结果时不受许可证影响,因此你可以在导入前进行审查。
测试
pip install -e ".[dev]"
python -m pytest tests/ -v某些测试需要 PATH 中包含 OSS CAD 工具。缺少所需工具的测试会自动跳过。
减小内存占用
服务器通过 stdio 传输以 1 进程/会话 的子进程运行(这就是 MCP 客户端如 Claude Desktop 启动它的方式)。每个会话在 Linux 上闲置时占用约 60-90 MB RSS,主要来自 Python 解释器及依赖库。
如果你运行许多并发 MCP 会话,请在启动 MCP 客户端之前设置以下环境变量:
# Linux — reduces glibc malloc arena fragmentation (can save 10-20 MB per session)
export MALLOC_ARENA_MAX=2
# Strip bytecode position annotations from tracebacks (saves a few MB)
export PYTHONNODEBUGRANGES=1
# Skip .pyc cache files (no memory impact, avoids disk writes)
export PYTHONDONTWRITEBYTECODE=1这些是零代码更改,并且完全透明。
环境变量
变量 | 描述 |
| GitHub 个人访问令牌 — 提高 API 速率限制 |
| 额外的内核搜索目录(操作系统路径分隔符分隔) |
| 用于 |
| 覆盖临时工作区根目录 |
| 持久服务器工件(构建日志、XYZ 输出、临时工作区)的根目录(默认: |
| OS pathsep 分隔的额外目录列表, |
独立 / 脚本模式
Python API 可以直接使用,无需 MCP 客户端:
from registry.resolver import CoreRegistry
from tools.lint import lint_hdl
reg = CoreRegistry()
# Import a core from GitHub
reg.import_github_core("ben-marshall/uart")
# Generate a parameterized instantiation
result = reg.generate_ip("uart", {"CLKS_PER_BIT": 868})
print(result["instantiation"])
# Lint some HDL
lint_hdl(open("my_design.v").read())python example.py # runs the built-in democore.json schema
{
"name": "my_core",
"version": "1.0.0",
"description": "...",
"author": "you",
"license": "MIT",
"language": "verilog",
"category": "communication",
"tags": ["spi", "serial"],
"parameters": {
"DATA_WIDTH": { "type": "integer", "default": 8, "description": "..." }
},
"ports": {
"clk": { "direction": "input", "width": 1, "description": "System clock" }
},
"files": ["my_core.v"]
}作者
Leonardo Capo (bard0) — hello@bard0.com
许可证
MIT — 参见 LICENSE。
Available Tools
25 toolsbuild_statusA
Check the progress of a background build. Returns status (running/success/failed), elapsed time, and recent log output.
Inputs: build_id (required), tail_lines, parse.
cancel_buildB
Cancel a running background build.
Inputs: build_id (required).
check_toolsA
Check which EDA tools are installed and reachable. Returns tool name, path, and version for each detected binary.
Inputs: no named parameters.
cleanup_build_logsA
Delete old build logs to reclaim disk space. Removes logs older than max_age_days, then trims oldest until under max_total_mb.
Inputs: max_age_days, max_total_mb.
format_hdlA
Format HDL source code and return the result. Verilog/SystemVerilog: uses verible-verilog-format. VHDL: uses vsg (pip install vsg). Returns the formatted code and whether it changed.
Inputs: code (required), language.
generate_ipB
Generate a parameterized instance of an IP core. Returns the HDL source files and a ready-to-paste Verilog instantiation snippet with the requested parameter values applied.
Inputs: name (required), parameters, instance_name.
get_diagnosticsB
Return structured lint diagnostics (line, column, severity, message) for HDL source. Verilog/SystemVerilog: uses Verilator (primary) with verible-verilog-lint as fallback. VHDL: uses GHDL. All tools are part of OSS CAD Suite.
Inputs: code (required), language.
get_ip_coreB
Fetch the full manifest and HDL source files for a named IP core.
Inputs: name (required).
import_fusesoc_coreA
Import a local FuseSoC CAPI2 .core file into the registry. HDL files referenced in the .core file must exist in the same directory. Useful when you already have FuseSoC cores checked out locally.
Inputs: path (required).
import_github_coreA
Download an open-source GitHub repository and add it to the local IP core registry. Automatically uses FuseSoC CAPI2 metadata (.core file) if one exists in the repo. After import, the core is immediately available via get_ip_core and generate_ip.
Inputs: repo (required), subdir, ref.
lint_hdlA
Lint HDL source code using iverilog/verilator (Verilog/SystemVerilog) or ghdl (VHDL). Use linter='verilator' to enable -Wall checks including multidriven net detection.
Inputs: code (required), language, top_module, linter.
lint_projectA
Lint multiple HDL files together so cross-module references resolve. Pass a dict of filename-to-source pairs. All files are compiled in one invocation of iverilog/verilator (Verilog/SystemVerilog) or ghdl (VHDL). Use linter='verilator' to enable -Wall checks including multidriven net detection.
Inputs: files (required), language, top_module, timeout, +1 more.
list_boardsA
List all known FPGA board presets with target, device, package, and clock frequency.
Inputs: no named parameters.
list_buildsA
List all tracked builds (running and finished) with status summary.
Inputs: no named parameters.
list_ip_coresA
List all available IP cores in the registry. Optionally filter by category.
Inputs: category.
litex_buildC
Run LiteX board target with --build. Returns logs and output directory.
Inputs: board (required), args, output_dir, timeout.
litex_flowA
Run a generic LiteX board target with caller-provided args.
Inputs: board (required), args, timeout.
litex_socA
Generate LiteX SoC without building gateware. Returns logs and output directory.
Inputs: board (required), args, output_dir, timeout.
place_and_routeA
Synthesize HDL with Yosys then place-and-route with nextpnr in one step. Provide source as: code (single string), files (dict of filename→source), or project_dir (path to HDL files on disk). If backend=litex, runs LiteX build and ignores HDL inputs. Returns max frequency, critical path, resource utilization, bitstream, and full logs. Supported targets: ice40, ecp5, nexus, gowin. Common device/package values: ice40: device=hx1k|hx8k|up5k|lp1k package=tq144|qn84|sg48|cm81 ecp5: device=25k|45k|85k package=CABGA256|CABGA381 nexus: device=LIFCL-40-9BG400C (package embedded in device string) gowin: device=GW1N-UV4LQ144C6/I5 (package embedded in device string)
Inputs: top_module (required), code, files, project_dir, +12 more.
program_fpgaA
Flash a bitstream to an FPGA board using iceprog (ice40) or openFPGALoader (ecp5/gowin/nexus). Provide bitstream as base64 (from place_and_route output) or a file path on disk.
Inputs: target (required), bitstream_b64, bitstream_path, programmer, +2 more.
reload_registryA
Re-scan all core directories and rebuild the IP core cache. Call after adding cores to disk or editing config.json.
Inputs: no named parameters.
search_github_coresA
Search GitHub for open-source FPGA IP cores (MIT, BSD, Apache, GPL, etc). Returns repo names, star counts, descriptions and topics. Use import_github_core to download a result into the local registry.
Inputs: query (required), language, max_results.
simulateA
Compile and simulate HDL using Icarus Verilog (iverilog + vvp) or GHDL (VHDL). Provide the design source and a separate testbench. Returns all $display/$monitor output (Verilog) or report output (VHDL) and any runtime errors.
Inputs: code (required), testbench (required), language, timeout.
start_buildA
Start a long-running build command in the background. Returns a build_id to check progress with build_status. Use for synthesis, place-and-route, LiteX builds, or any command that takes minutes.
Inputs: cmd (required), label, work_dir.
synthesizeA
Synthesize HDL (Verilog, SystemVerilog, or VHDL) using Yosys or run LiteX backend. Provide source as: code (single string), files (dict of filename→source), or project_dir (path to HDL files on disk). Returns resource statistics and the list of inferred modules. Supported targets: generic, ice40, ecp5, gowin, xilinx, intel.
Inputs: top_module (required), code, files, project_dir, +6 more.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 25 tools
Each tool targets a distinct operation: build management, IP core management, HDL linting/simulation, synthesis/P&R, and LiteX flows. Overlaps like lint_hdl vs lint_project are clearly differentiated by single vs multi-file scope, so agents can reliably select the correct tool.
All tool names follow consistent snake_case with a verb_noun pattern (e.g., list_boards, generate_ip, cancel_build). No camelCase or mixed styles, making naming predictable and easy to remember.
25 tools cover a broad FPGA development workflow without being excessive. Each sub-domain (builds, IP cores, linting, synthesis, LiteX) is adequately represented, though the count is at the upper end of typical scopes.
The tool set covers the main FPGA flow: HDL linting, simulation, synthesis, place-and-route, and programming, plus build management and IP core discovery/import. Minor omissions like constraint file generation or waveform viewing exist, but core operations are well-supported.
Related MCP Connectors
A MCP server built for developers enabling Git based project management with project and personal…
Create, deploy, and operate MCP servers directly from your GitHub repositories.
One MCP server for all your MCP servers: code mode, per-tool permissions, approvals and audit.
MCP server for progressive tool usage at any scale (see https://klavis.ai)
Related MCP Servers
- AlicenseAqualityDmaintenanceProvides AI assistants with a complete FPGA toolchain for HDL linting, simulation, synthesis, and place-and-route across various hardware targets. It features a GitHub-backed IP core registry that enables users to search for and import MIT-licensed cores directly through their chat interface.151MIT
- AlicenseNot gradedqualityDmaintenanceMCP server for deterministic Vivado FPGA automation including project scaffolding, simulation, synthesis, implementation, and gated bitstream generation.4MIT
- AlicenseAqualityBmaintenanceA minimal MCP server that provides 25 tools and 5 hooks to control Xilinx Vivado EDA for FPGA development, including session management, Tcl execution, smart diagnostics, and IP debugging.32166 PyPI181Apache 2.0
- AlicenseBqualityDmaintenanceA Model Context Protocol (MCP) server that enables AI assistants like Claude to directly interact with AMD/Xilinx Vivado FPGA development tools.4074MIT