跳转到主要内容
瑞苏盈科专栏
我与瑞苏盈科板卡的开发故事

基于VSCode使用Codebuddy调用Vivado MCP进行逻辑工程开发指南

作者:Albert Wei;文章来源:FPGA FAE技术分享选集

1. Vivado MCP 概述

1.1 什么是 Vivado MCP

Vivado MCP(Model Context Protocol)是 AMD 提供的一座桥梁,将 AI Agent 的自然语言请求翻译为 Vivado Tcl 命令,从而实现 "用自然语言驱动 Vivado" 的 FPGA 开发体验。

核心能力包括:

·   会话管理:启动\停止\重连 Vivado 会话

·   Tcl 执行:在活动Vivado会话中运行任意 Tcl 命令

·   文档搜索:通过 RAG 检索 AMD 官方文档(User Guide、App Note、KBA 等)

·   GUI 操作:管理 Vivado 显示与截图

·   远程部署:支持通过 SSH/LSF 在远程机器上运行Vivado

1.2 架构总览

1.3 数据流与安全

安全要点:设计数据(RTL、约束、网表等)始终留在本地,只有自然语言查询发送给 LLM。MCP Server 和 Vivado 完全在本地运行。

2. 环境准备

以下条件在所有方案中均需满足:

2.1 Vivado 安装

2.2 Vivado MCP Server

从AMD Vivado AI Assistant EA页面的Downloads页面可获取以下文件,由于 有NDA限制使用需要联系自己的FAE:

2.3 推荐硬件

标准开发笔记本/工作站即可,无额外特殊要求。Vivado 本身的资源需求不变。

3. CodeBuddy 配置

CodeBuddy支持 MCP 协议,接入Vivado MCP Server :

3.1 方案架构

用户 → CodeBuddy(WorkBuddy)

         │

         ├─→ LLM 后端(内置或自定义API)

         │

         ├─→ MCP 协议通信

         │   ↓

         │ Vivado MCP Server(本地 stdio)

         │   ↓

         │ Vivado 工具链(本地)

         │

         └─→ Skills 技能库

               • ~/.workbuddy/skills/          (用户级)

               • {workspace}/.workbuddy/skills/ (项目级)

3.1.1CodeBuddy 安装步骤

• 打开扩展侧栏(Ctrl+Shift+X)搜索CodeBuddy并点击安装

• 用手机号登陆

3.2 VSIX 扩展安装(CodeBuddy IDE / VS Code 系编辑器)

3.2.1 VSIX 安装步骤

• 打开CodeBuddy,进入扩展侧栏(Ctrl+Shift+X)

• 点击扩展面板右上角 ⋯(Views and More Actions)→ Install from VSIX...

• 选择下载的 .vsix 文件,等待安装完成

命令行安装:

code --install-extension vivado-ai-extension.vsix

图 3-1  CodeBuddy 扩展面板 → 菜单 → 从 VSIX 安装(Install from VSIX)

3.2.2 配置 Vivado 路径

3.2.3 验证 VSIX 接入

• 打开 AI 聊天面板,切换到 Agent 模式

• 发送测试指令:

List the available MCP tools

应看到 vivado_execute、vivado_start、vivado_connect 等 MCP 工具。

若工具缺失:点击模型选择器旁的 Configure tools → Update tools → 勾选 Vivado MCP 工具;必要时执行 Developer: Reload Window。

3.3 配置 Vivado MCP(mcp.json)

CodeBuddy的MCP配置文件位于 ~/.workbuddy/mcp.json。

3.3.1 编辑 mcp.json

{

 "mcpServers": {

    "vivado-mcp": {

      "command": "/home/amd/work/Vivado_MCP/vivado-mcp-server-linux-amd64-0.6.9",

      "args": [

        "--stdio-bridge",

        "--vivado-path",

       "/home/amd/tools/2025.2/Vivado/bin/vivado"

      ],

      "type": "stdio",

      "disabled": false

    }

 }

}

图 3-2  CodeBuddy 中编辑 ~/.workbuddy/mcp.json 接入 Vivado MCP Server

3.3.2 配置项对照

3.4验证

• 在 CodeBuddy 对话中发送测试指令:

vivado的版本?

如果Agent成功启动/连接 Vivado 会话并确认访问,说明配置完成。

Agent应调用vivado_execute返回版本号。

4. 使用工程验证

4.1 基础测试

完成任一方案配置后,依次执行以下自然语言指令验证:

4.2 完整设计验证

以下步骤创建一个完整 Vivado 设计,验证端到端工作流:

提示1 — 创建项目与 RTL

In GUI mode, create a Vivado project targeting the vck190 and name the project

Test_MCP. Create a simple Verilog file that has 2 inputs that are XOR,

and output a registered Y. Ensure the design has a reset.

提示2 — 打开展开设计

open the elaborated design

提示3 — 添加流水线级

Add an additional pipeline stage on Y

提示4 — 创建 IP Integrator Block Design

Create an IP Integrator block design called atg_bram_bd that exercises the

Versal NoC:

- Add an axi_tg (Performance AXI Traffic Generator) in NoC mode with SRC_ID = 1,

 driving S00_AXI of an axi_noc.

- Connect axi_noc M00_AXI to an axi_bram_ctrl backed by an emb_mem_gen BRAM.

- Use clk_gen_sim + sim_clk_gen for the AXI clock/reset, and sim_trig to drive

 axi_tg_start and consume axi_tg_done / trigger handshakes.

- Auto-assign addresses (BRAM at 0x201_0000_0000, 8 KB), validate the design,

 and regenerate the layout.

4.3 常用开发工作流

5. Agent Skills 技能系统

5.1 什么是 Skills

Skills是Markdown 文件(SKILL.md),将专家级 FPGA 方法论编码为可重复、自动化的工作流。它们告诉 AI Agent:

·   要运行哪些命令

·   如何解析输出

·   发现问题如何修复

·   需要遵守哪些规则和边界

5.2 目录结构

Skills兼容.claude/skills/ 格式,在CodeBuddy和Claude Code中均可用:

your-workspace/

├── .claude/

│   └── skills/

│       └── my-custom-skill/

│           ├── SKILL.md          # 技能定义

│           ├── REFERENCE.md      # 可选 — 详细参考资料

│           └── tcl/              # 可选 — 内置 Tcl 脚本

│               └── helper.tcl

└── your-design-files/

在CodeBuddy中,还支持以下替代路径:

·   用户级:~/.workbuddy/skills/

·   项目级:

              {workspace}/.workbuddy/skills/

5.3 SKILL.md 结构

5.4 创建自定义技能的推荐流程

• 交互式探索:先在对话中手动走通工作流(启动会话 → 运行分析 → 解析报告 → 修复问题)

• 让 Agent 创建技能:安装 Skill Creator 后,输入 "Create a Vivado skill based on the workflow we just went through"

• 测试迭代:用新技能跑真实设计,审查输出并精炼

5.5 最小技能模板

# My Custom Analysis Skill

## Description

Runs [analysis type] on the current design and generates a summary report.

## Trigger

"Run my custom analysis" or "Analyze [specific aspect]"

## Efficiency Guidelines

- Pass `session_id` to ALL `vivado_execute` calls

- Execute steps SEQUENTIALLY — wait for each to complete

- Use semicolon-chained Tcl for atomic operations

- Do NOT retry failed Tcl commands with different syntax

## Workflow

### Step 1: Open Design and Run Report

```tcl

set dcp [lindex [glob -nocomplain *.dcp] 0]

if {$dcp != ""} { open_checkpoint $dcp }

elseif {[catch {current_design}]} { open_run synth_1 }

file mkdir vivado_agentic_ai_reports/my-analysis

report_methodology -file vivado_agentic_ai_reports/my-analysis/methodology.rpt

```

### Step 2: Parse Report and Extract Findings

- Use `grep` or `read_file` to extract violations from the report

- Extract ACTUAL cell names, clock names, and net paths — no placeholders

### Step 3: Generate REPORT.md

- Write `vivado_agentic_ai_reports/my-analysis/REPORT.md` with findings and fixes

- Call the write tool FIRST, then summarize in chat

## Progress

- [ ] Step 1: Open design, run report

- [ ] Step 2: Parse report, extract findings

- [ ] Step 3: Generate REPORT.md

如果您在Vivado MCP方面有问题,欢迎联系:

simonyang@comtech.cn

charlesxu@comtech.cn