Merge branch 'feat/codeToChat' into feat/personalRules
This commit is contained in:
392
docs/EDA联动功能需求文档.md
Normal file
392
docs/EDA联动功能需求文档.md
Normal file
@ -0,0 +1,392 @@
|
||||
# Vivado 联动功能需求文档
|
||||
|
||||
## 1. 项目背景
|
||||
|
||||
### 1.1 当前状态
|
||||
|
||||
IC Coder Plugin 目前支持:
|
||||
|
||||
- iverilog 仿真(内置 Windows 版本)
|
||||
- VCD 波形查看
|
||||
- Verilog 代码生成和文件操作
|
||||
|
||||
### 1.2 需求来源
|
||||
|
||||
用户需要在 VS Code 中直接调用本地 Vivado 工具,并将产出文件自动导入到项目中,完成从仿真到 FPGA 部署的完整流程。
|
||||
|
||||
### 1.3 Vivado 是什么?
|
||||
|
||||
**Vivado** 是 Xilinx(现 AMD)的 FPGA 开发工具,用于将 Verilog 代码部署到 FPGA 硬件:
|
||||
|
||||
- **综合(Synthesis)**:将 RTL 代码转换为门级网表
|
||||
- **实现(Implementation)**:布局布线,映射到具体 FPGA 芯片
|
||||
- **生成比特流(Bitstream)**:生成 .bit 配置文件用于烧录
|
||||
|
||||
**与 iverilog 的区别**:
|
||||
|
||||
- iverilog:只做**仿真验证**(软件层面验证逻辑)
|
||||
- Vivado:做**综合+实现+生成配置文件**(真正部署到硬件)
|
||||
|
||||
**典型开发流程**:
|
||||
|
||||
```
|
||||
编写 Verilog → iverilog 仿真验证 → Vivado 综合 → Vivado 实现 → 生成 .bit 文件 → 烧录到 FPGA
|
||||
```
|
||||
|
||||
## 2. 功能目标
|
||||
|
||||
### 2.1 核心目标
|
||||
|
||||
- **前端工具封装**:在插件前端实现 Vivado 调用的完整逻辑
|
||||
- **后端简化调用**:后端只需调用一个工具接口
|
||||
- **文件自动导入**:Vivado 执行完成后,自动将产出文件导入到项目
|
||||
- **流程可视化**:执行进度、日志实时显示
|
||||
|
||||
### 2.2 非功能目标
|
||||
|
||||
- 配置简单,用户友好
|
||||
- 执行过程可视化(进度、日志)
|
||||
- 错误处理完善,提示清晰
|
||||
|
||||
## 3. 功能详细需求
|
||||
|
||||
### 3.1 Vivado 支持的操作
|
||||
|
||||
#### 3.1.1 综合(Synthesis)
|
||||
|
||||
- **输入**:Verilog/VHDL 源文件、约束文件(.xdc)
|
||||
- **输出**:设计检查点(.dcp)、综合报告(.rpt)
|
||||
- **用途**:将 RTL 代码转换为门级网表,检查资源使用情况
|
||||
|
||||
#### 3.1.2 实现(Implementation)
|
||||
|
||||
- **输入**:综合后的 .dcp 文件
|
||||
- **输出**:实现后的 .dcp 文件、时序报告、布局布线报告
|
||||
- **用途**:完成布局布线,检查时序是否满足要求
|
||||
|
||||
#### 3.1.3 生成比特流(Generate Bitstream)
|
||||
|
||||
- **输入**:实现后的 .dcp 文件
|
||||
- **输出**:比特流文件(.bit)
|
||||
- **用途**:生成可烧录到 FPGA 的配置文件
|
||||
|
||||
### 3.2 配置管理
|
||||
|
||||
#### 3.2.1 配置项
|
||||
|
||||
```json
|
||||
{
|
||||
"vivado": {
|
||||
"enabled": true,
|
||||
"executablePath": "C:/Xilinx/Vivado/2023.1/bin/vivado.bat",
|
||||
"workingDir": "${workspaceFolder}/vivado_project",
|
||||
"part": "xc7a35tcpg236-1", // FPGA 型号
|
||||
"commands": {
|
||||
"synthesis": "vivado -mode batch -source synth.tcl",
|
||||
"implementation": "vivado -mode batch -source impl.tcl",
|
||||
"bitstream": "vivado -mode batch -source bitstream.tcl"
|
||||
},
|
||||
"outputFiles": {
|
||||
"synthesis": ["*.dcp", "*_synth.rpt"],
|
||||
"implementation": ["*.dcp", "*_timing.rpt", "*_utilization.rpt"],
|
||||
"bitstream": ["*.bit"]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### 3.2.2 存储位置
|
||||
|
||||
- 全局配置:VS Code Settings(`settings.json`)
|
||||
- 项目配置:`.vscode/ic-coder-vivado.json`(优先级更高)
|
||||
|
||||
### 3.3 工具调用接口
|
||||
|
||||
#### 3.3.1 接口定义
|
||||
|
||||
```typescript
|
||||
interface VivadoToolRequest {
|
||||
command: string; // 命令类型:synthesis | implementation | bitstream
|
||||
parameters?: {
|
||||
topModule?: string; // 顶层模块名
|
||||
files?: string[]; // 输入文件列表
|
||||
part?: string; // FPGA 型号(可选,使用配置中的默认值)
|
||||
constraints?: string; // 约束文件路径(.xdc)
|
||||
outputDir?: string; // 输出目录
|
||||
};
|
||||
importOutput?: {
|
||||
enabled: boolean; // 是否自动导入
|
||||
targetDir: string; // 目标目录
|
||||
};
|
||||
}
|
||||
|
||||
interface VivadoToolResponse {
|
||||
success: boolean;
|
||||
command: string;
|
||||
executionTime: number; // 执行时间(毫秒)
|
||||
output: string; // 标准输出
|
||||
error?: string; // 错误信息
|
||||
importedFiles?: string[]; // 已导入的文件列表
|
||||
reports?: {
|
||||
// 报告摘要
|
||||
resources?: string; // 资源使用情况
|
||||
timing?: string; // 时序信息
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
### 3.4 执行流程
|
||||
|
||||
#### 3.4.1 参数验证
|
||||
|
||||
- 检查 Vivado 是否已配置
|
||||
- 检查可执行文件是否存在
|
||||
- 检查输入文件是否存在
|
||||
- 检查工作目录是否存在
|
||||
|
||||
#### 3.4.2 TCL 脚本生成
|
||||
|
||||
根据命令类型自动生成 TCL 脚本:
|
||||
|
||||
**综合脚本示例(synth.tcl)**:
|
||||
|
||||
```tcl
|
||||
# 读取源文件
|
||||
read_verilog counter.v
|
||||
read_xdc constraints.xdc
|
||||
|
||||
# 设置顶层模块
|
||||
set_property top counter [current_fileset]
|
||||
|
||||
# 综合
|
||||
synth_design -part xc7a35tcpg236-1 -top counter
|
||||
|
||||
# 生成报告
|
||||
report_utilization -file utilization_synth.rpt
|
||||
report_timing -file timing_synth.rpt
|
||||
|
||||
# 保存检查点
|
||||
write_checkpoint -force counter_synth.dcp
|
||||
```
|
||||
|
||||
#### 3.4.3 命令执行
|
||||
|
||||
- 启动子进程执行 Vivado 命令
|
||||
- 实时捕获标准输出和错误输出
|
||||
- 向前端推送进度信息(解析日志中的进度标记)
|
||||
|
||||
#### 3.4.4 结果处理
|
||||
|
||||
- 检查执行结果(退出码)
|
||||
- 解析报告文件,提取关键信息(资源使用、时序)
|
||||
- 查找产出文件
|
||||
|
||||
#### 3.4.5 文件导入
|
||||
|
||||
- 根据配置的文件模式查找产出文件
|
||||
- 复制文件到目标目录
|
||||
- 通知用户导入结果
|
||||
|
||||
### 3.5 UI 交互
|
||||
|
||||
#### 3.5.1 配置界面
|
||||
|
||||
- 在设置页面添加 "Vivado 配置" 选项
|
||||
- 支持配置 Vivado 路径、FPGA 型号
|
||||
- 支持测试 Vivado 可用性(点击按钮测试)
|
||||
|
||||
#### 3.5.2 调用界面
|
||||
|
||||
- 在聊天面板中,AI 可以建议使用 Vivado
|
||||
- 用户确认后,显示执行进度对话框
|
||||
- 实时显示日志输出(可折叠)
|
||||
- 显示执行状态:准备中 → 执行中 → 完成/失败
|
||||
|
||||
#### 3.5.3 结果展示
|
||||
|
||||
- 执行成功:显示执行时间、资源使用、时序信息
|
||||
- 执行失败:显示错误信息、建议解决方案
|
||||
- 导入文件:高亮显示已导入的文件,支持点击打开报告
|
||||
|
||||
### 3.6 后端集成
|
||||
|
||||
#### 3.6.1 工具定义
|
||||
|
||||
后端在工具列表中添加 Vivado 工具:
|
||||
|
||||
```json
|
||||
{
|
||||
"name": "runVivado",
|
||||
"description": "调用 Vivado 执行综合、实现或生成比特流。使用前必须先询问用户芯片型号等必要参数。",
|
||||
"parameters": {
|
||||
"command": "命令类型(synthesis/implementation/bitstream)",
|
||||
"topModule": "顶层模块名",
|
||||
"files": "输入文件列表",
|
||||
"part": "FPGA 芯片型号(必须从用户获取)",
|
||||
"constraints": "约束文件路径(可选)"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### 3.6.2 后端交互流程
|
||||
|
||||
**关键点**:后端必须先收集必要参数,再调用工具
|
||||
|
||||
1. **用户发起请求**:"打开 Vivado" 或 "用 Vivado 综合"
|
||||
2. **后端识别意图**:需要调用 runVivado 工具
|
||||
3. **后端询问参数**:
|
||||
- FPGA 芯片型号(必须)
|
||||
- 约束文件(可选)
|
||||
- 确认顶层模块名
|
||||
4. **用户提供参数**
|
||||
5. **后端调用工具**:传递完整参数给前端
|
||||
6. **前端执行**:VivadoRunner 执行命令
|
||||
7. **返回结果**:后端接收结果并展示给用户
|
||||
|
||||
#### 3.6.3 调用示例(完整交互)
|
||||
|
||||
```
|
||||
用户:帮我用 Vivado 综合一下 counter.v
|
||||
|
||||
AI:好的,我将使用 Vivado 进行综合。请提供以下信息:
|
||||
1. FPGA 芯片型号(例如:xc7a35tcpg236-1)
|
||||
2. 是否有约束文件(.xdc)?
|
||||
|
||||
用户:xc7a35tcpg236-1,没有约束文件
|
||||
|
||||
AI:收到,开始综合...
|
||||
[调用工具] runVivado
|
||||
参数:
|
||||
- command: synthesis
|
||||
- topModule: counter
|
||||
- files: ["counter.v"]
|
||||
- part: "xc7a35tcpg236-1"
|
||||
|
||||
[执行中...]
|
||||
Vivado 综合完成!
|
||||
- 芯片型号:xc7a35tcpg236-1
|
||||
- 执行时间:45 秒
|
||||
- 资源使用:LUT: 32/20800 (0.15%), FF: 8/41600 (0.02%)
|
||||
- 产出文件:counter_synth.dcp, utilization_synth.rpt
|
||||
- 已自动导入到:vivado_output/
|
||||
```
|
||||
|
||||
## 4. 用户场景
|
||||
|
||||
### 4.1 场景一:单步综合
|
||||
|
||||
1. 用户编写完 Verilog 代码
|
||||
2. 在聊天中输入:"用 Vivado 综合一下 counter.v"
|
||||
3. AI 调用 `runVivado` 工具
|
||||
4. 插件执行 Vivado 综合
|
||||
5. 综合完成后,显示资源使用情况,自动导入报告文件
|
||||
|
||||
### 4.2 场景二:完整流程
|
||||
|
||||
1. 用户输入:"用 Vivado 跑完整个流程"
|
||||
2. AI 依次调用:
|
||||
- 综合(Synthesis)
|
||||
- 实现(Implementation)
|
||||
- 生成比特流(Bitstream)
|
||||
3. 每个步骤完成后显示结果
|
||||
4. 最终生成 .bit 文件,用户可以烧录到 FPGA
|
||||
|
||||
### 4.3 场景三:查看报告
|
||||
|
||||
1. Vivado 执行完成后
|
||||
2. 用户点击导入的报告文件
|
||||
3. 在编辑器中查看资源使用、时序分析等信息
|
||||
|
||||
## 5. 技术约束
|
||||
|
||||
### 5.1 平台兼容性
|
||||
|
||||
- Windows:支持 `.bat` 可执行文件
|
||||
- Linux:支持 shell 脚本
|
||||
- 路径分隔符自动适配
|
||||
|
||||
### 5.2 性能要求
|
||||
|
||||
- 命令执行不阻塞 UI
|
||||
- 综合时间可能较长(分钟级),需要进度提示
|
||||
- 日志输出实时更新,限制缓冲区大小
|
||||
|
||||
### 5.3 安全性
|
||||
|
||||
- 工作目录限制在项目范围内
|
||||
- 许可证路径不记录到日志
|
||||
|
||||
## 6. 验收标准
|
||||
|
||||
### 6.1 功能验收
|
||||
|
||||
- [ ] 用户可以配置 Vivado 路径和 FPGA 型号
|
||||
- [ ] AI 可以通过工具调用成功执行 Vivado 综合
|
||||
- [ ] 产出文件自动导入到指定目录
|
||||
- [ ] 执行过程有清晰的进度提示
|
||||
- [ ] 报告文件可以正常打开查看
|
||||
|
||||
### 6.2 性能验收
|
||||
|
||||
- [ ] 小型项目综合时间 < 1 分钟
|
||||
- [ ] UI 响应流畅,不卡顿
|
||||
- [ ] 日志输出实时更新(延迟 < 500ms)
|
||||
|
||||
### 6.3 用户体验验收
|
||||
|
||||
- [ ] 配置界面直观易用
|
||||
- [ ] 首次使用有引导提示
|
||||
- [ ] 错误提示清晰,有解决建议
|
||||
- [ ] 导入的文件可以直接打开查看
|
||||
|
||||
## 7. 风险和依赖
|
||||
|
||||
### 7.1 风险
|
||||
|
||||
- **Vivado 版本差异**:不同版本的命令行参数可能不同
|
||||
- **许可证问题**:Vivado 需要许可证才能运行
|
||||
- **路径问题**:Windows 路径中的空格和特殊字符
|
||||
- **执行时间长**:大型项目可能需要数十分钟
|
||||
|
||||
### 7.2 依赖
|
||||
|
||||
- 用户需要自行安装 Vivado
|
||||
- 用户需要配置正确的 Vivado 路径
|
||||
- 需要设置环境变量(如 `XILINX_VIVADO`)
|
||||
- 需要有效的 Vivado 许可证
|
||||
|
||||
## 8. 后续扩展
|
||||
|
||||
### 8.1 短期扩展
|
||||
|
||||
- 支持自定义 TCL 脚本模板
|
||||
- 支持批量处理多个设计
|
||||
- 支持时序约束编辑器
|
||||
|
||||
### 8.2 长期扩展
|
||||
|
||||
- 支持其他 FPGA 工具(Quartus)
|
||||
- 云端 Vivado 服务集成
|
||||
- 结果对比和版本管理
|
||||
- 性能分析和优化建议
|
||||
|
||||
---
|
||||
|
||||
## 附录
|
||||
|
||||
### A. Vivado 命令行参考
|
||||
|
||||
- 官方文档:https://docs.xilinx.com/
|
||||
- TCL 命令参考:UG835
|
||||
- 设计流程参考:UG892
|
||||
|
||||
### B. 术语表
|
||||
|
||||
- **RTL**:Register Transfer Level,寄存器传输级
|
||||
- **综合**:Synthesis,将 RTL 代码转换为门级网表
|
||||
- **实现**:Implementation,布局布线
|
||||
- **比特流**:Bitstream,FPGA 配置文件
|
||||
- **DCP**:Design Checkpoint,Vivado 设计检查点文件
|
||||
- **XDC**:Xilinx Design Constraints,约束文件
|
||||
- **LUT**:Look-Up Table,查找表(FPGA 基本逻辑单元)
|
||||
- **FF**:Flip-Flop,触发器
|
||||
284
docs/IVERILOG_INTEGRATION.md
Normal file
284
docs/IVERILOG_INTEGRATION.md
Normal file
@ -0,0 +1,284 @@
|
||||
# Iverilog 集成完成报告
|
||||
|
||||
## 概述
|
||||
|
||||
已成功将 Icarus Verilog (iverilog) 工具集成到 IC Coder 插件中,用户可以通过简单的命令生成 VCD 波形文件。
|
||||
|
||||
## 完成的功能
|
||||
|
||||
### 1. 核心功能模块
|
||||
|
||||
**文件**: `src/utils/iverilogRunner.ts`
|
||||
|
||||
实现了以下功能:
|
||||
- ✅ Verilog 项目文件完整性检查
|
||||
- ✅ 自动查找顶层模块和 testbench 文件
|
||||
- ✅ iverilog 编译功能
|
||||
- ✅ vvp 仿真运行
|
||||
- ✅ VCD 文件生成
|
||||
- ✅ 路径空格问题处理(使用 spawn 代替 exec)
|
||||
- ✅ 环境变量配置
|
||||
|
||||
### 2. 用户界面集成
|
||||
|
||||
**文件**: `src/utils/messageHandler.ts`
|
||||
|
||||
- ✅ 命令解析:支持多种 VCD 生成命令
|
||||
- "生成 VCD"
|
||||
- "创建 VCD"
|
||||
- "运行仿真"
|
||||
- "执行仿真"
|
||||
- "iverilog"
|
||||
- "生成波形"
|
||||
- "仿真生成"
|
||||
|
||||
- ✅ 实时反馈:
|
||||
- 项目检查进度
|
||||
- 编译状态
|
||||
- 仿真输出
|
||||
- 错误信息
|
||||
|
||||
- ✅ 用户交互:
|
||||
- 成功后提示打开 VCD 文件
|
||||
- 详细的错误提示和解决建议
|
||||
|
||||
### 3. Iverilog 工具打包
|
||||
|
||||
**目录**: `tools/iverilog/`
|
||||
|
||||
已成功复制以下文件到插件包:
|
||||
|
||||
**bin/ 目录** (10 个文件,约 4 MB):
|
||||
- `iverilog.exe` - Verilog 编译器
|
||||
- `vvp.exe` - Verilog 仿真器
|
||||
- 所有必需的 DLL 文件
|
||||
|
||||
**lib/ 目录** (44 个文件,约 21 MB):
|
||||
- 所有 `.vpi` 库文件
|
||||
- 所有 `.tgt` 目标文件
|
||||
- 所有 `.conf` 配置文件
|
||||
- `include/` 头文件目录
|
||||
|
||||
**总大小**: 约 25 MB
|
||||
|
||||
### 4. 文档和示例
|
||||
|
||||
创建了完整的文档:
|
||||
|
||||
1. **README.md** - 工具说明和使用指南
|
||||
2. **INSTALL.md** - 安装和配置说明
|
||||
3. **DOWNLOAD_INSTRUCTIONS.md** - 下载和部署指南
|
||||
4. **examples/** - 测试示例项目
|
||||
- `counter.v` - 4 位计数器模块
|
||||
- `counter_tb.v` - 测试平台
|
||||
- `README.md` - 示例说明
|
||||
|
||||
### 5. 自动化脚本
|
||||
|
||||
- ✅ `copy-iverilog.ps1` - PowerShell 自动复制脚本
|
||||
- ✅ `copy-iverilog.bat` - Windows 批处理启动器
|
||||
|
||||
## 技术实现细节
|
||||
|
||||
### 路径空格处理
|
||||
|
||||
使用 `child_process.spawn` 代替 `child_process.exec`,完美解决了路径中包含空格的问题:
|
||||
|
||||
```typescript
|
||||
function execCommand(
|
||||
command: string,
|
||||
args: string[],
|
||||
options: { cwd: string; env?: any }
|
||||
): Promise<{ stdout: string; stderr: string }>
|
||||
```
|
||||
|
||||
### 环境变量配置
|
||||
|
||||
设置 `IVERILOG_ROOT` 环境变量,确保 iverilog 能找到库文件:
|
||||
|
||||
```typescript
|
||||
const env = {
|
||||
...process.env,
|
||||
IVERILOG_ROOT: path.join(extensionPath, "tools", "iverilog"),
|
||||
};
|
||||
```
|
||||
|
||||
### 文件检查逻辑
|
||||
|
||||
智能识别项目文件:
|
||||
- 自动查找所有 `.v` 和 `.sv` 文件
|
||||
- 识别 testbench 文件(文件名包含 `tb` 或 `test`,或包含 `$dumpfile`)
|
||||
- 识别顶层模块(非 testbench 的 module 定义)
|
||||
|
||||
## 使用方法
|
||||
|
||||
### 1. 准备项目
|
||||
|
||||
确保项目包含:
|
||||
- 至少一个 Verilog 模块文件(`.v` 或 `.sv`)
|
||||
- 一个 testbench 文件,包含:
|
||||
```verilog
|
||||
initial begin
|
||||
$dumpfile("output.vcd");
|
||||
$dumpvars(0, module_name);
|
||||
// ... 测试代码 ...
|
||||
$finish;
|
||||
end
|
||||
```
|
||||
|
||||
### 2. 生成 VCD
|
||||
|
||||
在 IC Coder 插件中输入任一命令:
|
||||
- `生成 VCD`
|
||||
- `运行仿真`
|
||||
- `生成波形`
|
||||
|
||||
### 3. 查看结果
|
||||
|
||||
- VCD 文件保存在项目根目录:`output.vcd`
|
||||
- 可以使用 GTKWave 等工具查看波形
|
||||
|
||||
## 测试示例
|
||||
|
||||
提供了完整的测试示例:
|
||||
|
||||
**位置**: `tools/iverilog/examples/`
|
||||
|
||||
**运行测试**:
|
||||
1. 在 VS Code 中打开 `examples` 目录
|
||||
2. 打开 IC Coder 插件
|
||||
3. 输入 "生成 VCD"
|
||||
4. 查看生成的 `output.vcd` 文件
|
||||
|
||||
## 文件清单
|
||||
|
||||
### 新增文件
|
||||
|
||||
```
|
||||
src/utils/iverilogRunner.ts # 核心功能模块
|
||||
tools/iverilog/
|
||||
├── bin/ # 可执行文件 (10 个文件)
|
||||
│ ├── iverilog.exe
|
||||
│ ├── vvp.exe
|
||||
│ └── *.dll
|
||||
├── lib/ # 库文件 (44 个文件)
|
||||
│ ├── ivl/
|
||||
│ │ ├── *.vpi
|
||||
│ │ ├── *.tgt
|
||||
│ │ └── *.conf
|
||||
│ └── include/
|
||||
├── examples/ # 测试示例
|
||||
│ ├── counter.v
|
||||
│ ├── counter_tb.v
|
||||
│ └── README.md
|
||||
├── README.md # 使用说明
|
||||
├── INSTALL.md # 安装指南
|
||||
├── DOWNLOAD_INSTRUCTIONS.md # 下载说明
|
||||
├── copy-iverilog.ps1 # 自动复制脚本
|
||||
└── copy-iverilog.bat # 批处理启动器
|
||||
```
|
||||
|
||||
### 修改文件
|
||||
|
||||
```
|
||||
src/utils/messageHandler.ts # 添加 VCD 生成命令处理
|
||||
src/panels/ICHelperPanel.ts # 传递 extensionPath 参数
|
||||
package.json # 添加 tools 目录到打包列表
|
||||
```
|
||||
|
||||
## 版本信息
|
||||
|
||||
- **Icarus Verilog**: v12.0 (devel) (s20150603-1539-g2693dd32b)
|
||||
- **平台**: Windows x64
|
||||
- **许可证**: GPL v2+
|
||||
|
||||
## 已知问题和限制
|
||||
|
||||
### 1. 路径空格问题 ✅ 已解决
|
||||
- 使用 `spawn` 代替 `exec` 完美解决
|
||||
|
||||
### 2. 平台支持
|
||||
- 当前仅包含 Windows x64 版本的 iverilog
|
||||
- macOS 和 Linux 用户需要自行安装 iverilog
|
||||
|
||||
### 3. 文件大小
|
||||
- 插件包增加约 25 MB
|
||||
- 建议在发布时说明文件大小
|
||||
|
||||
## 后续优化建议
|
||||
|
||||
### 1. 多平台支持
|
||||
- 为 macOS 和 Linux 提供对应的 iverilog 二进制文件
|
||||
- 根据平台自动选择对应的可执行文件
|
||||
|
||||
### 2. 配置选项
|
||||
- 允许用户配置 VCD 文件输出路径
|
||||
- 允许用户配置仿真参数
|
||||
|
||||
### 3. 高级功能
|
||||
- 支持 SystemVerilog
|
||||
- 支持多个 testbench 选择
|
||||
- 集成波形查看器
|
||||
|
||||
### 4. 错误处理
|
||||
- 更详细的编译错误提示
|
||||
- 语法错误定位
|
||||
- 常见问题自动修复建议
|
||||
|
||||
## 测试清单
|
||||
|
||||
- ✅ 编译成功(无 TypeScript 错误)
|
||||
- ✅ iverilog 工具已打包(25 MB)
|
||||
- ✅ 路径空格问题已解决
|
||||
- ✅ 环境变量配置正确
|
||||
- ✅ 文档完整
|
||||
- ✅ 示例项目可用
|
||||
- ⏳ 实际运行测试(需要在 VS Code 中测试)
|
||||
|
||||
## 部署步骤
|
||||
|
||||
1. **确认文件完整**
|
||||
```bash
|
||||
ls -lh "D:/IC Coder Plugin/ic-coder/tools/iverilog/bin"
|
||||
ls -lh "D:/IC Coder Plugin/ic-coder/tools/iverilog/lib"
|
||||
```
|
||||
|
||||
2. **编译插件**
|
||||
```bash
|
||||
cd "D:/IC Coder Plugin/ic-coder"
|
||||
pnpm run compile
|
||||
```
|
||||
|
||||
3. **打包插件**
|
||||
```bash
|
||||
pnpm run package
|
||||
```
|
||||
|
||||
4. **测试插件**
|
||||
- 在 VS Code 中按 F5 启动调试
|
||||
- 打开 `tools/iverilog/examples` 目录
|
||||
- 测试 VCD 生成功能
|
||||
|
||||
5. **发布插件**
|
||||
- 确保 `package.json` 中的 `files` 字段包含 `tools`
|
||||
- 使用 `vsce package` 打包
|
||||
- 发布到 VS Code Marketplace
|
||||
|
||||
## 总结
|
||||
|
||||
✅ **所有功能已完成并集成**
|
||||
|
||||
- Iverilog 工具已成功打包到插件中(25 MB)
|
||||
- 用户下载插件后即可直接使用,无需额外安装
|
||||
- 支持多种命令触发 VCD 生成
|
||||
- 提供完整的文档和示例
|
||||
- 解决了路径空格等技术问题
|
||||
- 代码编译成功,无错误
|
||||
|
||||
**下一步**: 在 VS Code 中实际测试插件功能,验证 VCD 生成流程。
|
||||
|
||||
---
|
||||
|
||||
**创建时间**: 2025-12-15
|
||||
**版本**: 1.0
|
||||
**状态**: ✅ 完成
|
||||
409
docs/PUBLISH.md
Normal file
409
docs/PUBLISH.md
Normal file
@ -0,0 +1,409 @@
|
||||
# IC Coder 插件发布流程文档
|
||||
|
||||
本文档详细说明如何将 IC Coder 插件发布到 VS Code 插件市场进行测试和正式发布。
|
||||
|
||||
## 目录
|
||||
|
||||
- [前置准备](#前置准备)
|
||||
- [账号配置](#账号配置)
|
||||
- [插件信息完善](#插件信息完善)
|
||||
- [打包与发布](#打包与发布)
|
||||
- [版本更新](#版本更新)
|
||||
- [常见问题](#常见问题)
|
||||
|
||||
---
|
||||
|
||||
## 前置准备
|
||||
|
||||
### 环境要求
|
||||
|
||||
- Node.js 和 pnpm 已安装
|
||||
- VS Code 1.80.0 或更高版本
|
||||
- 已安装 `@vscode/vsce` 工具(项目已包含)
|
||||
|
||||
### 检查清单
|
||||
|
||||
在发布前,请确保以下文件和配置已准备就绪:
|
||||
|
||||
- [x] `package.json` - 插件配置文件
|
||||
- [x] `README.md` - 插件说明文档
|
||||
- [x] `dist/` - 编译后的代码
|
||||
- [x] `media/` - 图标和资源文件
|
||||
- [ ] `CHANGELOG.md` - 版本更新日志(建议添加)
|
||||
- [x] `LICENSE` - 开源许可证(建议添加)
|
||||
|
||||
---
|
||||
|
||||
## 账号配置
|
||||
|
||||
### 1. 创建 Azure DevOps 账号
|
||||
|
||||
1. 访问 [Azure DevOps](https://dev.azure.com)
|
||||
2. 使用 Microsoft 账号注册或登录
|
||||
3. 创建一个组织(如果还没有)
|
||||
|
||||
### 2. 生成 Personal Access Token (PAT)
|
||||
|
||||
这是发布插件的关键凭证,请妥善保管。
|
||||
|
||||
**步骤:**
|
||||
|
||||
1. 登录 Azure DevOps
|
||||
2. 点击右上角用户图标 → **User settings** → **Personal access tokens**
|
||||
3. 点击 **New Token** 按钮
|
||||
4. 配置 Token 信息:
|
||||
- **Name**: `vscode-publisher`(或其他易识别的名称)
|
||||
- **Organization**: 选择 **All accessible organizations**
|
||||
- **Expiration**: 建议选择较长期限(如 90 天或自定义)
|
||||
- **Scopes**: 选择 **Custom defined**
|
||||
- 展开 **Marketplace**
|
||||
- 勾选 **Manage**(包含发布和管理权限)
|
||||
5. 点击 **Create** 生成 Token
|
||||
6. **重要**: 立即复制并保存 Token,页面关闭后将无法再次查看
|
||||
|
||||
**Token 示例格式:**
|
||||
|
||||
```
|
||||
CO03l8nmFBBTNPDg7lN9a9fYwDdgsRIDVDwTrx6Esggi6HnzmrMTJQQJ99BLACAAAAAAAAAAAAAGAZDOVVyT
|
||||
```
|
||||
|
||||
```
|
||||
//蔡工的token
|
||||
6CB3tOZPiwNi6rrOuFHMe6QzrVWBnajW5fJsNgCWu8jtERUCCRnJJQQJ99CAACAAAAAAAAAAAAASAZDO3FnY
|
||||
```
|
||||
|
||||
### 3. 创建发布者账号
|
||||
|
||||
发布者账号是你在 VS Code 市场的身份标识。
|
||||
|
||||
**步骤:**
|
||||
|
||||
1. 访问 [VS Code Marketplace 管理页面](https://marketplace.visualstudio.com/manage)
|
||||
2. 使用 Azure DevOps 账号登录
|
||||
3. 点击 **Create publisher** 按钮
|
||||
4. 填写发布者信息:
|
||||
- **ID**: `ICCoder`(必须与 package.json 中的 `publisher` 字段一致)
|
||||
- **Name**: `IC Coder`(显示名称,可自定义)
|
||||
- **Email**: 你的联系邮箱
|
||||
5. 点击 **Create** 完成创建
|
||||
|
||||
**注意事项:**
|
||||
|
||||
- Publisher ID 一旦创建无法修改
|
||||
- Publisher ID 必须全局唯一
|
||||
- 建议使用有意义且专业的 ID
|
||||
|
||||
---
|
||||
|
||||
## 插件信息完善
|
||||
|
||||
### 1. 完善 package.json
|
||||
|
||||
建议在 `package.json` 中添加以下字段以提升插件质量:
|
||||
|
||||
```json
|
||||
{
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/your-org/ic-coder.git"
|
||||
},
|
||||
"homepage": "https://github.com/your-org/ic-coder#readme",
|
||||
"bugs": {
|
||||
"url": "https://github.com/your-org/ic-coder/issues"
|
||||
},
|
||||
"license": "MIT"
|
||||
}
|
||||
```
|
||||
|
||||
### 2. 创建 CHANGELOG.md
|
||||
|
||||
版本更新日志帮助用户了解每个版本的变化。
|
||||
|
||||
**示例内容:**
|
||||
|
||||
```markdown
|
||||
# 更新日志
|
||||
|
||||
## [0.0.2] - 2025-12-29
|
||||
|
||||
### 新增
|
||||
|
||||
- 添加发送和暂停按钮功能
|
||||
- 添加一键优化按钮组件
|
||||
- 添加 Plan 开关组件
|
||||
- 添加模式选择器组件
|
||||
- 添加上下文压缩功能
|
||||
|
||||
### 改进
|
||||
|
||||
- 优化用户界面交互体验
|
||||
|
||||
## [0.0.1] - 2025-12-XX
|
||||
|
||||
### 新增
|
||||
|
||||
- 初始版本发布
|
||||
- Verilog 代码智能生成
|
||||
- 集成 iverilog 仿真工具
|
||||
- VCD 波形文件查看器
|
||||
```
|
||||
|
||||
### 3. 创建 LICENSE 文件
|
||||
|
||||
如果使用 MIT 许可证,创建 `LICENSE` 文件:
|
||||
|
||||
```
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2025 IC Coder Team
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction...
|
||||
```
|
||||
|
||||
### 4. 优化 README.md
|
||||
|
||||
确保 README 包含:
|
||||
|
||||
- 清晰的功能介绍
|
||||
- 使用截图或 GIF 演示
|
||||
- 详细的使用说明
|
||||
- 系统要求
|
||||
- 常见问题解答
|
||||
|
||||
---
|
||||
|
||||
## 打包与发布
|
||||
|
||||
### 方式一:命令行发布(推荐)
|
||||
|
||||
这是最便捷的发布方式,适合频繁更新。
|
||||
|
||||
**步骤:**
|
||||
|
||||
1. **登录发布者账号**
|
||||
|
||||
```bash
|
||||
pnpm vsce login ic-coder-team
|
||||
```
|
||||
|
||||
系统会提示输入 Personal Access Token,粘贴之前创建的 PAT。
|
||||
|
||||
2. **打包插件**
|
||||
|
||||
```bash
|
||||
# 执行生产环境构建
|
||||
pnpm run package
|
||||
|
||||
# 打包成 .vsix 文件
|
||||
pnpm vsce package
|
||||
```
|
||||
|
||||
这会生成 `ic-coder-plugin-0.0.2.vsix` 文件。
|
||||
|
||||
3. **发布到市场**
|
||||
|
||||
```bash
|
||||
pnpm vsce publish
|
||||
```
|
||||
|
||||
发布成功后会显示插件的市场链接。
|
||||
|
||||
**一键发布(跳过打包步骤):**
|
||||
|
||||
```bash
|
||||
# 直接发布当前版本
|
||||
pnpm vsce publish
|
||||
```
|
||||
|
||||
### 方式二:手动上传
|
||||
|
||||
适合首次发布或网络环境受限的情况。
|
||||
|
||||
**步骤:**
|
||||
|
||||
1. 本地打包插件:
|
||||
|
||||
```bash
|
||||
pnpm run package
|
||||
pnpm vsce package[pnpm vsce package --no-dependencies]
|
||||
```
|
||||
|
||||
2. 访问 [发布者管理页面](https://marketplace.visualstudio.com/manage/publishers/ic-coder-team)
|
||||
|
||||
3. 点击 **New extension** → **Visual Studio Code**
|
||||
|
||||
4. 上传 `ic-coder-plugin-0.0.2.vsix` 文件
|
||||
|
||||
5. 填写插件信息(如果需要)并提交
|
||||
|
||||
6. 等待审核通过
|
||||
|
||||
---
|
||||
|
||||
## 版本更新
|
||||
|
||||
### 自动更新版本号
|
||||
|
||||
使用 `vsce publish` 命令可以自动更新版本号并发布:
|
||||
|
||||
```bash
|
||||
# 补丁版本更新(0.0.2 → 0.0.3)
|
||||
pnpm vsce publish patch
|
||||
|
||||
# 次版本更新(0.0.2 → 0.1.0)
|
||||
pnpm vsce publish minor
|
||||
|
||||
# 主版本更新(0.0.2 → 1.0.0)
|
||||
pnpm vsce publish major
|
||||
```
|
||||
|
||||
### 手动指定版本
|
||||
|
||||
```bash
|
||||
# 发布指定版本
|
||||
npx vsce publish --packagePath iccoder-1.0.7.vsix
|
||||
```
|
||||
|
||||
### 更新流程建议
|
||||
|
||||
1. 修改代码并测试
|
||||
2. 更新 `CHANGELOG.md` 记录变更
|
||||
3. 提交代码到 Git
|
||||
4. 执行发布命令
|
||||
5. 验证市场上的插件是否正常
|
||||
|
||||
## 更新流程
|
||||
|
||||
1. 修改版本号
|
||||
|
||||
手动修改 修改package.json文件
|
||||
|
||||
命令修改
|
||||
|
||||
```bash
|
||||
#补丁版本 (1.0.0 -> 1.0.1)
|
||||
pnpm version patch
|
||||
|
||||
#次要版本 (1.0.0 -> 1.1.0)
|
||||
pnpm version minor
|
||||
|
||||
#主要版本 (1.0.0 -> 2.0.0)
|
||||
pnpm version major
|
||||
```
|
||||
|
||||
2. 打包
|
||||
|
||||
```bash
|
||||
#先编译
|
||||
pnpm run compile
|
||||
|
||||
#中间build
|
||||
pnpm run build
|
||||
|
||||
#后打包成.vsix
|
||||
pnpm vsce package --no-dependencies
|
||||
```
|
||||
|
||||
3. 手动上传/命令上传
|
||||
- https://marketplace.visualstudio.com/ 在这个里面手动上传 更新就选择update
|
||||
- 命令上传:vsce publish
|
||||
|
||||
---
|
||||
|
||||
## 常见问题
|
||||
|
||||
### 1. 发布失败:Authentication failed
|
||||
|
||||
**原因:** PAT Token 无效或过期
|
||||
|
||||
**解决方案:**
|
||||
|
||||
- 重新生成 PAT Token
|
||||
- 重新登录:`pnpm vsce login ic-coder-team`
|
||||
|
||||
### 2. 发布失败:Publisher not found
|
||||
|
||||
**原因:** Publisher ID 不存在或不匹配
|
||||
|
||||
**解决方案:**
|
||||
|
||||
- 检查 `package.json` 中的 `publisher` 字段
|
||||
- 确认已在市场创建对应的 Publisher
|
||||
|
||||
### 3. 打包失败:Missing files
|
||||
|
||||
**原因:** 必需文件缺失
|
||||
|
||||
**解决方案:**
|
||||
|
||||
- 确保 `dist/` 目录存在且包含编译后的代码
|
||||
- 运行 `pnpm run package` 重新构建
|
||||
|
||||
### 4. 插件审核被拒
|
||||
|
||||
**常见原因:**
|
||||
|
||||
- 插件名称或描述违反市场规则
|
||||
- 图标不符合要求(建议 128x128 PNG)
|
||||
- README 内容不完整
|
||||
|
||||
**解决方案:**
|
||||
|
||||
- 查看审核反馈邮件
|
||||
- 修改相关内容后重新发布
|
||||
|
||||
### 5. 如何撤回已发布的版本?
|
||||
|
||||
```bash
|
||||
# 取消发布指定版本
|
||||
pnpm vsce unpublish ic-coder-team.ic-coder-plugin@0.0.2
|
||||
|
||||
# 取消发布整个插件(慎用)
|
||||
pnpm vsce unpublish ic-coder-team.ic-coder-plugin
|
||||
```
|
||||
|
||||
### 6. 如何本地测试 .vsix 文件?
|
||||
|
||||
```bash
|
||||
# 在 VS Code 中安装本地 .vsix 文件
|
||||
code --install-extension ic-coder-plugin-0.0.2.vsix
|
||||
```
|
||||
|
||||
或者在 VS Code 中:
|
||||
|
||||
1. 打开扩展面板
|
||||
2. 点击 `...` 菜单
|
||||
3. 选择 **Install from VSIX...**
|
||||
4. 选择 `.vsix` 文件
|
||||
|
||||
---
|
||||
|
||||
## 发布检查清单
|
||||
|
||||
在正式发布前,请确认以下事项:
|
||||
|
||||
- [ ] 代码已充分测试,无明显 Bug
|
||||
- [ ] `package.json` 版本号已更新
|
||||
- [ ] `CHANGELOG.md` 已记录本次更新内容
|
||||
- [ ] README.md 内容完整且准确
|
||||
- [ ] 图标和资源文件正常显示
|
||||
- [ ] 已在本地安装测试 .vsix 文件
|
||||
- [ ] 已创建 Azure DevOps PAT Token
|
||||
- [ ] 已创建 VS Code Marketplace Publisher
|
||||
- [ ] 已执行 `pnpm run package` 构建生产版本
|
||||
|
||||
---
|
||||
|
||||
## 参考资源
|
||||
|
||||
- [VS Code 插件发布官方文档](https://code.visualstudio.com/api/working-with-extensions/publishing-extension)
|
||||
- [vsce 工具文档](https://github.com/microsoft/vscode-vsce)
|
||||
- [Azure DevOps 文档](https://docs.microsoft.com/en-us/azure/devops/)
|
||||
- [VS Code 插件市场](https://marketplace.visualstudio.com/)
|
||||
|
||||
---
|
||||
|
||||
**文档维护:** IC Coder Team
|
||||
**最后更新:** 2025-12-29
|
||||
637
docs/Vivado联动前后端对接文档.md
Normal file
637
docs/Vivado联动前后端对接文档.md
Normal file
@ -0,0 +1,637 @@
|
||||
# Vivado 联动前后端对接文档
|
||||
|
||||
## 1. 概述
|
||||
|
||||
本文档描述后端 AI 服务如何调用前端的 Vivado 工具,以及前端如何响应和返回结果。
|
||||
|
||||
### 1.1 调用流程
|
||||
|
||||
```
|
||||
后端 AI 服务
|
||||
↓ (1) 发送工具调用请求
|
||||
前端 Extension (MessageHandler)
|
||||
↓ (2) 解析请求,调用 VivadoRunner
|
||||
VivadoRunner
|
||||
↓ (3) 执行 Vivado,实时推送进度
|
||||
前端 Webview
|
||||
↓ (4) 显示进度和结果
|
||||
前端 Extension
|
||||
↓ (5) 返回执行结果给后端
|
||||
后端 AI 服务
|
||||
```
|
||||
|
||||
## 2. 工具定义(后端)
|
||||
|
||||
### 2.1 工具注册
|
||||
|
||||
后端需要在工具列表中注册 `runVivado` 工具:
|
||||
|
||||
```json
|
||||
{
|
||||
"name": "runVivado",
|
||||
"description": "调用本地 Vivado 工具执行 FPGA 综合、实现或生成比特流。用于将 Verilog 代码部署到 FPGA 硬件。使用前必须先询问用户必要的参数(如芯片型号、执行模式)。",
|
||||
"inputSchema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"command": {
|
||||
"type": "string",
|
||||
"enum": ["synthesis", "implementation", "bitstream"],
|
||||
"description": "要执行的命令类型:synthesis(综合)、implementation(实现)、bitstream(生成比特流)"
|
||||
},
|
||||
"topModule": {
|
||||
"type": "string",
|
||||
"description": "顶层模块名称"
|
||||
},
|
||||
"files": {
|
||||
"type": "array",
|
||||
"items": { "type": "string" },
|
||||
"description": "输入的 Verilog 文件路径列表"
|
||||
},
|
||||
"constraints": {
|
||||
"type": "string",
|
||||
"description": "约束文件路径(.xdc 文件),可选"
|
||||
},
|
||||
"part": {
|
||||
"type": "string",
|
||||
"description": "FPGA 芯片型号(如 xc7a35tcpg236-1),必须从用户处获取"
|
||||
},
|
||||
"mode": {
|
||||
"type": "string",
|
||||
"enum": ["batch", "gui"],
|
||||
"description": "执行模式:batch(后台批处理)、gui(打开图形界面),必须询问用户"
|
||||
}
|
||||
},
|
||||
"required": ["command", "topModule", "files", "part", "mode"]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 2.2 后端调用前的准备工作
|
||||
|
||||
**重要**:后端在调用 `runVivado` 工具前,必须先向用户询问必要参数:
|
||||
|
||||
1. **芯片型号(part)**:必须询问,例如 "xc7a35tcpg236-1"
|
||||
2. **执行模式(mode)**:必须询问用户选择
|
||||
- `batch`:后台批处理执行,自动完成
|
||||
- `gui`:打开 Vivado 图形界面,用户手动操作
|
||||
3. **顶层模块名**:可从文件名推断,但建议确认
|
||||
4. **约束文件**:询问是否有时序约束文件(.xdc)
|
||||
|
||||
**询问示例**:
|
||||
```
|
||||
AI: 我将使用 Vivado 进行综合。请提供以下信息:
|
||||
1. FPGA 芯片型号(例如:xc7a35tcpg236-1)
|
||||
2. 执行模式:
|
||||
- 批处理模式:后台自动执行,完成后返回结果
|
||||
- 图形界面:打开 Vivado GUI,您可以手动操作
|
||||
3. 是否有约束文件(.xdc)?
|
||||
|
||||
用户: xc7a35tcpg236-1,批处理模式,没有约束文件
|
||||
|
||||
AI: 好的,开始后台综合...
|
||||
[调用 runVivado 工具]
|
||||
```
|
||||
|
||||
### 2.3 调用示例
|
||||
|
||||
#### 示例 1:综合单个文件(批处理模式)
|
||||
|
||||
```json
|
||||
{
|
||||
"tool": "runVivado",
|
||||
"parameters": {
|
||||
"command": "synthesis",
|
||||
"topModule": "counter",
|
||||
"files": ["counter.v"],
|
||||
"part": "xc7a35tcpg236-1",
|
||||
"mode": "batch"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### 示例 2:综合带约束文件(图形界面模式)
|
||||
|
||||
```json
|
||||
{
|
||||
"tool": "runVivado",
|
||||
"parameters": {
|
||||
"command": "synthesis",
|
||||
"topModule": "uart_top",
|
||||
"files": ["uart_tx.v", "uart_rx.v", "uart_top.v"],
|
||||
"constraints": "constraints.xdc",
|
||||
"part": "xc7k325tffg900-2",
|
||||
"mode": "gui"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### 示例 3:实现(批处理模式)
|
||||
|
||||
```json
|
||||
{
|
||||
"tool": "runVivado",
|
||||
"parameters": {
|
||||
"command": "implementation",
|
||||
"topModule": "counter",
|
||||
"part": "xc7a35tcpg236-1",
|
||||
"mode": "batch"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### 示例 4:生成比特流(图形界面)
|
||||
|
||||
```json
|
||||
{
|
||||
"tool": "runVivado",
|
||||
"parameters": {
|
||||
"command": "bitstream",
|
||||
"topModule": "counter",
|
||||
"part": "xc7a35tcpg236-1",
|
||||
"mode": "gui"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 3. 前端接收和处理
|
||||
|
||||
### 3.1 后端如何控制前端
|
||||
|
||||
**核心机制**:后端通过调用 `runVivado` 工具来控制前端执行 Vivado 命令。
|
||||
|
||||
**控制流程**:
|
||||
1. 后端识别用户意图(如"打开 Vivado"、"开始仿真")
|
||||
2. 后端向用户询问必要参数(芯片型号等)
|
||||
3. 后端调用 `runVivado` 工具,传递参数
|
||||
4. 前端接收工具调用,执行相应操作
|
||||
5. 前端返回执行结果给后端
|
||||
6. 后端将结果展示给用户
|
||||
|
||||
**示例场景**:
|
||||
```
|
||||
用户输入:"打开 Vivado 进行综合"
|
||||
|
||||
后端处理:
|
||||
1. 识别意图 → 需要调用 runVivado 工具
|
||||
2. 检查参数 → 缺少芯片型号
|
||||
3. 询问用户 → "请提供 FPGA 芯片型号"
|
||||
4. 用户回复 → "xc7a35tcpg236-1"
|
||||
5. 调用工具 → runVivado({ command: "synthesis", part: "xc7a35tcpg236-1", ... })
|
||||
6. 前端执行 → VivadoRunner 启动 Vivado
|
||||
7. 返回结果 → { success: true, ... }
|
||||
8. 展示结果 → "综合完成,耗时 45 秒"
|
||||
```
|
||||
|
||||
### 3.2 MessageHandler 处理逻辑
|
||||
|
||||
前端在 `messageHandler.ts` 中添加工具处理:
|
||||
|
||||
```typescript
|
||||
// src/utils/messageHandler.ts
|
||||
|
||||
export async function handleToolExecution(
|
||||
panel: vscode.WebviewPanel,
|
||||
toolName: string,
|
||||
parameters: any
|
||||
): Promise<any> {
|
||||
|
||||
if (toolName === 'runVivado') {
|
||||
return await handleVivadoTool(panel, parameters);
|
||||
}
|
||||
|
||||
// 其他工具处理...
|
||||
}
|
||||
|
||||
async function handleVivadoTool(
|
||||
panel: vscode.WebviewPanel,
|
||||
parameters: any
|
||||
): Promise<VivadoToolResponse> {
|
||||
|
||||
const { command, topModule, files, constraints, part, mode } = parameters;
|
||||
|
||||
// 验证必需参数
|
||||
if (!part) {
|
||||
return {
|
||||
success: false,
|
||||
command,
|
||||
executionTime: 0,
|
||||
output: '',
|
||||
error: '缺少必需参数:芯片型号(part)。后端应该先询问用户。'
|
||||
};
|
||||
}
|
||||
|
||||
if (!mode) {
|
||||
return {
|
||||
success: false,
|
||||
command,
|
||||
executionTime: 0,
|
||||
output: '',
|
||||
error: '缺少必需参数:执行模式(mode)。后端应该询问用户选择 batch 或 gui。'
|
||||
};
|
||||
}
|
||||
|
||||
// 构建请求
|
||||
const request: VivadoToolRequest = {
|
||||
command,
|
||||
parameters: {
|
||||
topModule,
|
||||
files,
|
||||
constraints,
|
||||
part,
|
||||
mode
|
||||
},
|
||||
importOutput: {
|
||||
enabled: mode === 'batch', // 只有批处理模式才自动导入
|
||||
targetDir: path.join(
|
||||
vscode.workspace.workspaceFolders![0].uri.fsPath,
|
||||
'vivado_output'
|
||||
)
|
||||
}
|
||||
};
|
||||
|
||||
// 向前端发送开始消息
|
||||
panel.webview.postMessage({
|
||||
type: 'vivado-start',
|
||||
command
|
||||
});
|
||||
|
||||
// 执行 Vivado
|
||||
const response = await runVivado(request, (progress) => {
|
||||
// 实时推送进度到前端
|
||||
panel.webview.postMessage({
|
||||
type: 'vivado-progress',
|
||||
progress
|
||||
});
|
||||
});
|
||||
|
||||
// 向前端发送完成消息
|
||||
panel.webview.postMessage({
|
||||
type: 'vivado-complete',
|
||||
response
|
||||
});
|
||||
|
||||
// 返回结果给后端
|
||||
return response;
|
||||
}
|
||||
```
|
||||
|
||||
## 4. 响应格式
|
||||
|
||||
### 4.1 成功响应
|
||||
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"command": "synthesis",
|
||||
"executionTime": 45230,
|
||||
"output": "Vivado 执行日志...",
|
||||
"importedFiles": [
|
||||
"/path/to/vivado_output/counter_synth.dcp",
|
||||
"/path/to/vivado_output/counter_utilization_synth.rpt"
|
||||
],
|
||||
"reports": {
|
||||
"resources": "LUT: 32/20800 (0.15%)\nFF: 8/41600 (0.02%)",
|
||||
"timing": "WNS: 5.234ns, TNS: 0.000ns"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 4.2 失败响应
|
||||
|
||||
```json
|
||||
{
|
||||
"success": false,
|
||||
"command": "synthesis",
|
||||
"executionTime": 1250,
|
||||
"output": "部分执行日志...",
|
||||
"error": "ERROR: [Synth 8-439] module 'counter' not found"
|
||||
}
|
||||
```
|
||||
|
||||
## 5. 后端使用指南
|
||||
|
||||
### 5.1 AI 对话流程(完整版)
|
||||
|
||||
```
|
||||
用户:帮我用 Vivado 综合一下 counter.v
|
||||
|
||||
AI 分析:
|
||||
1. 用户想要综合 Verilog 文件
|
||||
2. 需要调用 runVivado 工具
|
||||
3. 命令类型是 synthesis
|
||||
4. 顶层模块名从文件名推断为 counter
|
||||
5. 输入文件是 counter.v
|
||||
6. ⚠️ 缺少必要参数:芯片型号
|
||||
|
||||
AI 回复用户:
|
||||
"好的,我将使用 Vivado 进行综合。请提供以下信息:
|
||||
1. FPGA 芯片型号(例如:xc7a35tcpg236-1、xc7k325tffg900-2)
|
||||
2. 是否有约束文件(.xdc)?"
|
||||
|
||||
用户:xc7a35tcpg236-1,没有约束文件
|
||||
|
||||
AI 调用工具:
|
||||
{
|
||||
"tool": "runVivado",
|
||||
"parameters": {
|
||||
"command": "synthesis",
|
||||
"topModule": "counter",
|
||||
"files": ["counter.v"],
|
||||
"part": "xc7a35tcpg236-1"
|
||||
}
|
||||
}
|
||||
|
||||
前端执行并返回结果
|
||||
|
||||
AI 回复用户:
|
||||
"Vivado 综合完成!
|
||||
- 执行时间:45.2 秒
|
||||
- 芯片型号:xc7a35tcpg236-1
|
||||
- 资源使用:LUT: 32/20800 (0.15%), FF: 8/41600 (0.02%)
|
||||
- 产出文件已导入到 vivado_output 目录"
|
||||
```
|
||||
|
||||
### 5.2 完整流程示例
|
||||
|
||||
```
|
||||
用户:用 Vivado 跑完整个流程
|
||||
|
||||
AI:好的,我将依次执行综合、实现和生成比特流。请提供:
|
||||
1. FPGA 芯片型号
|
||||
2. 顶层模块名
|
||||
3. 是否有约束文件
|
||||
|
||||
用户:xc7a35tcpg236-1,顶层模块是 counter,没有约束文件
|
||||
|
||||
AI:收到,开始执行...
|
||||
|
||||
步骤 1:综合
|
||||
[调用] runVivado { command: "synthesis", topModule: "counter", files: ["counter.v"], part: "xc7a35tcpg236-1" }
|
||||
[结果] 综合成功,耗时 45s
|
||||
|
||||
步骤 2:实现
|
||||
[调用] runVivado { command: "implementation", topModule: "counter", part: "xc7a35tcpg236-1" }
|
||||
[结果] 实现成功,耗时 120s,时序满足要求
|
||||
|
||||
步骤 3:生成比特流
|
||||
[调用] runVivado { command: "bitstream", topModule: "counter", part: "xc7a35tcpg236-1" }
|
||||
[结果] 比特流生成成功,文件:counter.bit
|
||||
|
||||
完成!所有文件已导入到 vivado_output 目录。
|
||||
```
|
||||
|
||||
## 6. 错误处理
|
||||
|
||||
### 6.1 常见错误
|
||||
|
||||
#### 错误 1:Vivado 未配置
|
||||
|
||||
```json
|
||||
{
|
||||
"success": false,
|
||||
"error": "Vivado 未配置,请在设置中配置 Vivado 路径"
|
||||
}
|
||||
```
|
||||
|
||||
**AI 应该回复**:
|
||||
"Vivado 尚未配置,请先在插件设置中配置 Vivado 的安装路径。"
|
||||
|
||||
#### 错误 2:文件不存在
|
||||
|
||||
```json
|
||||
{
|
||||
"success": false,
|
||||
"error": "输入文件不存在: counter.v"
|
||||
}
|
||||
```
|
||||
|
||||
**AI 应该回复**:
|
||||
"找不到文件 counter.v,请确认文件路径是否正确。"
|
||||
|
||||
#### 错误 3:综合失败
|
||||
|
||||
```json
|
||||
{
|
||||
"success": false,
|
||||
"error": "ERROR: [Synth 8-439] module 'counter' not found",
|
||||
"output": "详细日志..."
|
||||
}
|
||||
```
|
||||
|
||||
**AI 应该回复**:
|
||||
"综合失败,错误信息:找不到模块 'counter'。请检查:
|
||||
1. 模块名是否正确
|
||||
2. 文件中是否定义了该模块
|
||||
3. 是否有语法错误"
|
||||
|
||||
### 6.2 错误处理建议
|
||||
|
||||
后端收到 `success: false` 时:
|
||||
1. 提取 `error` 字段中的错误信息
|
||||
2. 分析错误类型(配置问题、文件问题、语法问题等)
|
||||
3. 给用户提供具体的解决建议
|
||||
4. 必要时可以查看 `output` 字段获取详细日志
|
||||
|
||||
## 7. 进度推送(可选)
|
||||
|
||||
前端会实时推送进度信息到 Webview,后端无需处理,但可以了解进度格式:
|
||||
|
||||
```json
|
||||
{
|
||||
"type": "vivado-progress",
|
||||
"progress": {
|
||||
"stage": "synthesis",
|
||||
"percentage": 45,
|
||||
"message": "正在综合模块 counter..."
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 8. 测试建议
|
||||
|
||||
### 8.1 后端测试用例
|
||||
|
||||
```javascript
|
||||
// 测试用例 1:基本综合
|
||||
test('综合单个文件', async () => {
|
||||
const result = await callTool('runVivado', {
|
||||
command: 'synthesis',
|
||||
topModule: 'counter',
|
||||
files: ['counter.v']
|
||||
});
|
||||
|
||||
expect(result.success).toBe(true);
|
||||
expect(result.importedFiles.length).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
// 测试用例 2:错误处理
|
||||
test('文件不存在', async () => {
|
||||
const result = await callTool('runVivado', {
|
||||
command: 'synthesis',
|
||||
topModule: 'test',
|
||||
files: ['not_exist.v']
|
||||
});
|
||||
|
||||
expect(result.success).toBe(false);
|
||||
expect(result.error).toContain('不存在');
|
||||
});
|
||||
```
|
||||
|
||||
## 9. 注意事项
|
||||
|
||||
### 9.1 后端必须询问的参数
|
||||
|
||||
**关键要求**:后端在调用 `runVivado` 前,必须先向用户收集以下参数:
|
||||
|
||||
| 参数 | 是否必须 | 询问方式 | 示例 |
|
||||
|------|---------|---------|------|
|
||||
| part(芯片型号) | ✅ 必须 | 直接询问 | "请提供 FPGA 芯片型号(如 xc7a35tcpg236-1)" |
|
||||
| mode(执行模式) | ✅ 必须 | 提供选项 | "选择执行模式:1.批处理 2.图形界面" |
|
||||
| topModule | ✅ 必须 | 可推断或询问 | 从文件名推断,或询问"顶层模块名是什么?" |
|
||||
| files | ✅ 必须(综合时) | 可推断或询问 | 从当前文件或工作区推断 |
|
||||
| constraints | ❌ 可选 | 询问 | "是否有约束文件(.xdc)?" |
|
||||
|
||||
### 9.2 常见用户输入场景
|
||||
|
||||
#### 场景 1:用户说"打开 Vivado"
|
||||
```
|
||||
用户:打开 Vivado
|
||||
|
||||
后端分析:用户想使用 Vivado,但没有指定具体操作
|
||||
|
||||
后端回复:
|
||||
"好的,请问您想执行什么操作?
|
||||
1. 综合(Synthesis)- 将 Verilog 转换为门级网表
|
||||
2. 实现(Implementation)- 布局布线
|
||||
3. 生成比特流(Bitstream)- 生成 .bit 文件
|
||||
|
||||
另外,请提供:
|
||||
- FPGA 芯片型号(例如:xc7a35tcpg236-1)
|
||||
- 执行模式:批处理(后台自动)或 图形界面(手动操作)"
|
||||
```
|
||||
|
||||
#### 场景 2:用户说"开始仿真"
|
||||
```
|
||||
用户:开始仿真
|
||||
|
||||
后端分析:用户可能混淆了仿真和综合
|
||||
|
||||
后端回复:
|
||||
"您是想:
|
||||
1. 使用 iverilog 进行功能仿真(验证逻辑)
|
||||
2. 使用 Vivado 进行综合(部署到 FPGA)
|
||||
|
||||
请选择您需要的操作。"
|
||||
```
|
||||
|
||||
#### 场景 3:用户提供完整信息
|
||||
```
|
||||
用户:用 Vivado 综合 counter.v,芯片是 xc7a35tcpg236-1,批处理模式
|
||||
|
||||
后端分析:信息完整,可以直接调用
|
||||
|
||||
后端操作:
|
||||
[调用] runVivado({
|
||||
command: "synthesis",
|
||||
topModule: "counter",
|
||||
files: ["counter.v"],
|
||||
part: "xc7a35tcpg236-1",
|
||||
mode: "batch"
|
||||
})
|
||||
```
|
||||
|
||||
#### 场景 4:用户选择图形界面
|
||||
```
|
||||
用户:打开 Vivado 图形界面做综合
|
||||
|
||||
后端分析:用户明确要求 GUI 模式
|
||||
|
||||
后端询问:
|
||||
"好的,请提供:
|
||||
1. FPGA 芯片型号
|
||||
2. 顶层模块名"
|
||||
|
||||
用户:xc7a35tcpg236-1, counter
|
||||
|
||||
后端操作:
|
||||
[调用] runVivado({
|
||||
command: "synthesis",
|
||||
topModule: "counter",
|
||||
files: ["counter.v"],
|
||||
part: "xc7a35tcpg236-1",
|
||||
mode: "gui"
|
||||
})
|
||||
|
||||
前端执行:
|
||||
- 生成 TCL 脚本和项目文件
|
||||
- 执行: vivado counter_project.xpr (打开图形界面)
|
||||
- 返回: { success: true, message: "Vivado GUI 已启动" }
|
||||
|
||||
后端回复:
|
||||
"Vivado 图形界面已打开,您可以在界面中手动操作。"
|
||||
```
|
||||
|
||||
### 9.3 执行时间
|
||||
- 综合:小型设计 30s-2min,大型设计 5-30min
|
||||
- 实现:通常是综合时间的 2-3 倍
|
||||
- 生成比特流:通常 10-30s
|
||||
|
||||
后端应该设置合理的超时时间(建议 10 分钟)。
|
||||
|
||||
### 9.4 依赖关系
|
||||
- `implementation` 需要先执行 `synthesis`
|
||||
- `bitstream` 需要先执行 `implementation`
|
||||
|
||||
后端 AI 应该理解这个依赖关系,按顺序调用。
|
||||
|
||||
### 9.5 文件路径
|
||||
- 所有文件路径都是相对于工作区根目录
|
||||
- 前端会自动解析为绝对路径
|
||||
- 支持相对路径和绝对路径
|
||||
|
||||
## 10. 参数传递详细说明
|
||||
|
||||
### 10.1 必需参数
|
||||
|
||||
| 参数 | 类型 | 说明 | 获取方式 |
|
||||
|------|------|------|----------|
|
||||
| command | string | 命令类型 | 从用户意图推断 |
|
||||
| topModule | string | 顶层模块名 | 从文件名推断或询问用户 |
|
||||
| files | string[] | 源文件列表 | 从工作区查找或用户指定 |
|
||||
| part | string | 芯片型号 | **必须询问用户** |
|
||||
|
||||
### 10.2 可选参数
|
||||
|
||||
| 参数 | 类型 | 说明 | 默认值 |
|
||||
|------|------|------|--------|
|
||||
| constraints | string | 约束文件路径 | 无 |
|
||||
|
||||
### 10.3 参数验证规则
|
||||
|
||||
后端在调用前应验证:
|
||||
- `part` 格式正确(如 xc7a35tcpg236-1)
|
||||
- `files` 数组不为空
|
||||
- `topModule` 不为空
|
||||
- `command` 在枚举值内
|
||||
|
||||
## 11. 快速集成清单
|
||||
|
||||
后端开发者需要做的事情:
|
||||
|
||||
- [ ] 在工具列表中注册 `runVivado` 工具
|
||||
- [ ] **实现参数询问逻辑(芯片型号等)**
|
||||
- [ ] 实现工具调用逻辑(发送请求到前端)
|
||||
- [ ] 处理返回结果(success/error)
|
||||
- [ ] 实现错误处理和用户提示
|
||||
- [ ] 理解三个命令的依赖关系
|
||||
- [ ] 设置合理的超时时间(建议 10 分钟)
|
||||
- [ ] 编写测试用例
|
||||
|
||||
前端开发者需要做的事情:
|
||||
|
||||
- [ ] 实现 `handleVivadoTool` 函数
|
||||
- [ ] 集成 VivadoRunner
|
||||
- [ ] 实现进度推送
|
||||
- [ ] 实现结果展示
|
||||
- [ ] 处理各种错误情况
|
||||
- [ ] 验证传入的参数完整性
|
||||
923
docs/Vivado联动功能技术设计文档.md
Normal file
923
docs/Vivado联动功能技术设计文档.md
Normal file
@ -0,0 +1,923 @@
|
||||
# Vivado 联动功能技术设计文档
|
||||
|
||||
## 1. 架构设计
|
||||
|
||||
### 1.1 整体架构
|
||||
|
||||
```
|
||||
┌─────────────────────────────────────────────────────────────┐
|
||||
│ 后端 AI 服务 │
|
||||
│ (调用 runVivado 工具) │
|
||||
└────────────────────────────┬────────────────────────────────┘
|
||||
│ 工具调用请求
|
||||
↓
|
||||
┌─────────────────────────────────────────────────────────────┐
|
||||
│ VS Code Extension │
|
||||
│ ┌──────────────────────────────────────────────────────┐ │
|
||||
│ │ ICHelperPanel (Webview) │ │
|
||||
│ │ - 接收后端工具调用 │ │
|
||||
│ │ - 显示执行进度和日志 │ │
|
||||
│ │ - 展示执行结果 │ │
|
||||
│ └──────────────────────────────────────────────────────┘ │
|
||||
│ ↓ │
|
||||
│ ┌──────────────────────────────────────────────────────┐ │
|
||||
│ │ VivadoRunner (utils/vivadoRunner.ts) │ │
|
||||
│ │ - 配置管理 │ │
|
||||
│ │ - TCL 脚本生成 │ │
|
||||
│ │ - 命令执行 │ │
|
||||
│ │ - 进度监控 │ │
|
||||
│ │ - 结果解析 │ │
|
||||
│ └──────────────────────────────────────────────────────┘ │
|
||||
│ ↓ │
|
||||
│ ┌──────────────────────────────────────────────────────┐ │
|
||||
│ │ FileImporter (utils/fileImporter.ts) │ │
|
||||
│ │ - 查找产出文件 │ │
|
||||
│ │ - 复制文件到目标目录 │ │
|
||||
│ │ - 通知文件变更 │ │
|
||||
│ └──────────────────────────────────────────────────────┘ │
|
||||
└─────────────────────────────────────────────────────────────┘
|
||||
↓
|
||||
┌─────────────────────────────────────────────────────────────┐
|
||||
│ 本地 Vivado 工具 │
|
||||
│ (通过子进程执行 TCL 脚本) │
|
||||
└─────────────────────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
### 1.2 模块职责
|
||||
|
||||
#### 1.2.1 VivadoRunner
|
||||
- 读取和验证 Vivado 配置
|
||||
- 根据命令类型生成 TCL 脚本
|
||||
- 启动子进程执行 Vivado
|
||||
- 实时捕获输出并解析进度
|
||||
- 返回执行结果
|
||||
|
||||
#### 1.2.2 FileImporter
|
||||
- 根据文件模式查找产出文件
|
||||
- 复制文件到指定目录
|
||||
- 返回已导入的文件列表
|
||||
|
||||
#### 1.2.3 MessageHandler
|
||||
- 接收后端的 `runVivado` 工具调用
|
||||
- 调用 VivadoRunner 执行
|
||||
- 向 Webview 推送进度和结果
|
||||
|
||||
## 2. 数据结构设计
|
||||
|
||||
### 2.1 配置结构
|
||||
|
||||
```typescript
|
||||
/**
|
||||
* Vivado 配置
|
||||
*/
|
||||
interface VivadoConfig {
|
||||
enabled: boolean;
|
||||
executablePath: string;
|
||||
workingDir: string;
|
||||
part: string;
|
||||
commands: {
|
||||
synthesis: string;
|
||||
implementation: string;
|
||||
bitstream: string;
|
||||
};
|
||||
outputFiles: {
|
||||
synthesis: string[];
|
||||
implementation: string[];
|
||||
bitstream: string[];
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
### 2.2 请求和响应结构
|
||||
|
||||
```typescript
|
||||
/**
|
||||
* Vivado 工具请求
|
||||
*/
|
||||
interface VivadoToolRequest {
|
||||
command: 'synthesis' | 'implementation' | 'bitstream';
|
||||
parameters?: {
|
||||
topModule?: string;
|
||||
files?: string[];
|
||||
part?: string;
|
||||
constraints?: string;
|
||||
outputDir?: string;
|
||||
};
|
||||
importOutput?: {
|
||||
enabled: boolean;
|
||||
targetDir: string;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Vivado 工具响应
|
||||
*/
|
||||
interface VivadoToolResponse {
|
||||
success: boolean;
|
||||
command: string;
|
||||
executionTime: number;
|
||||
output: string;
|
||||
error?: string;
|
||||
importedFiles?: string[];
|
||||
reports?: {
|
||||
resources?: string;
|
||||
timing?: string;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行进度
|
||||
*/
|
||||
interface VivadoProgress {
|
||||
stage: string;
|
||||
percentage: number;
|
||||
message: string;
|
||||
}
|
||||
```
|
||||
|
||||
## 3. 核心模块实现
|
||||
|
||||
### 3.1 配置管理
|
||||
|
||||
#### 3.1.1 配置读取
|
||||
```typescript
|
||||
// src/utils/vivadoConfig.ts
|
||||
|
||||
import * as vscode from 'vscode';
|
||||
import * as path from 'path';
|
||||
import * as fs from 'fs';
|
||||
|
||||
export function getVivadoConfig(): VivadoConfig | null {
|
||||
// 优先读取项目配置
|
||||
const workspaceFolder = vscode.workspace.workspaceFolders?.[0];
|
||||
if (workspaceFolder) {
|
||||
const projectConfigPath = path.join(
|
||||
workspaceFolder.uri.fsPath,
|
||||
'.vscode',
|
||||
'ic-coder-vivado.json'
|
||||
);
|
||||
if (fs.existsSync(projectConfigPath)) {
|
||||
const content = fs.readFileSync(projectConfigPath, 'utf-8');
|
||||
return JSON.parse(content).vivado;
|
||||
}
|
||||
}
|
||||
|
||||
// 读取全局配置
|
||||
const config = vscode.workspace.getConfiguration('ic-coder');
|
||||
return config.get<VivadoConfig>('vivado') || null;
|
||||
}
|
||||
|
||||
export function validateConfig(config: VivadoConfig): string | null {
|
||||
if (!config.enabled) {
|
||||
return 'Vivado 未启用';
|
||||
}
|
||||
if (!fs.existsSync(config.executablePath)) {
|
||||
return `Vivado 可执行文件不存在: ${config.executablePath}`;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
```
|
||||
|
||||
### 3.2 TCL 脚本生成
|
||||
|
||||
#### 3.2.1 脚本生成器
|
||||
```typescript
|
||||
// src/utils/tclGenerator.ts
|
||||
|
||||
export function generateSynthesisTcl(
|
||||
topModule: string,
|
||||
files: string[],
|
||||
part: string,
|
||||
constraints?: string,
|
||||
outputDir?: string
|
||||
): string {
|
||||
const output = outputDir || '.';
|
||||
let tcl = `# Vivado 综合脚本\n\n`;
|
||||
|
||||
// 读取源文件
|
||||
files.forEach(file => {
|
||||
tcl += `read_verilog ${file}\n`;
|
||||
});
|
||||
|
||||
// 读取约束文件
|
||||
if (constraints) {
|
||||
tcl += `read_xdc ${constraints}\n`;
|
||||
}
|
||||
|
||||
tcl += `\n# 综合\n`;
|
||||
tcl += `synth_design -part ${part} -top ${topModule}\n\n`;
|
||||
|
||||
// 生成报告
|
||||
tcl += `# 生成报告\n`;
|
||||
tcl += `report_utilization -file ${output}/${topModule}_utilization_synth.rpt\n`;
|
||||
tcl += `report_timing -file ${output}/${topModule}_timing_synth.rpt\n\n`;
|
||||
|
||||
// 保存检查点
|
||||
tcl += `# 保存检查点\n`;
|
||||
tcl += `write_checkpoint -force ${output}/${topModule}_synth.dcp\n`;
|
||||
|
||||
return tcl;
|
||||
}
|
||||
|
||||
export function generateImplementationTcl(
|
||||
dcpFile: string,
|
||||
outputDir?: string
|
||||
): string {
|
||||
const output = outputDir || '.';
|
||||
const baseName = path.basename(dcpFile, '.dcp').replace('_synth', '');
|
||||
|
||||
let tcl = `# Vivado 实现脚本\n\n`;
|
||||
tcl += `open_checkpoint ${dcpFile}\n\n`;
|
||||
|
||||
tcl += `# 优化\n`;
|
||||
tcl += `opt_design\n`;
|
||||
tcl += `place_design\n`;
|
||||
tcl += `route_design\n\n`;
|
||||
|
||||
tcl += `# 生成报告\n`;
|
||||
tcl += `report_utilization -file ${output}/${baseName}_utilization_impl.rpt\n`;
|
||||
tcl += `report_timing_summary -file ${output}/${baseName}_timing_impl.rpt\n\n`;
|
||||
|
||||
tcl += `# 保存检查点\n`;
|
||||
tcl += `write_checkpoint -force ${output}/${baseName}_impl.dcp\n`;
|
||||
|
||||
return tcl;
|
||||
}
|
||||
|
||||
export function generateBitstreamTcl(
|
||||
dcpFile: string,
|
||||
outputDir?: string
|
||||
): string {
|
||||
const output = outputDir || '.';
|
||||
const baseName = path.basename(dcpFile, '.dcp').replace('_impl', '');
|
||||
|
||||
let tcl = `# Vivado 比特流生成脚本\n\n`;
|
||||
tcl += `open_checkpoint ${dcpFile}\n\n`;
|
||||
|
||||
tcl += `# 生成比特流\n`;
|
||||
tcl += `write_bitstream -force ${output}/${baseName}.bit\n`;
|
||||
|
||||
return tcl;
|
||||
}
|
||||
```
|
||||
|
||||
### 3.3 VivadoRunner 实现
|
||||
|
||||
```typescript
|
||||
// src/utils/vivadoRunner.ts
|
||||
|
||||
import * as vscode from 'vscode';
|
||||
import * as path from 'path';
|
||||
import * as fs from 'fs';
|
||||
import { spawn } from 'child_process';
|
||||
import { getVivadoConfig, validateConfig } from './vivadoConfig';
|
||||
import { generateSynthesisTcl, generateImplementationTcl, generateBitstreamTcl } from './tclGenerator';
|
||||
|
||||
export async function runVivado(
|
||||
request: VivadoToolRequest,
|
||||
progressCallback?: (progress: VivadoProgress) => void
|
||||
): Promise<VivadoToolResponse> {
|
||||
const startTime = Date.now();
|
||||
|
||||
// 读取配置
|
||||
const config = getVivadoConfig();
|
||||
if (!config) {
|
||||
return {
|
||||
success: false,
|
||||
command: request.command,
|
||||
executionTime: 0,
|
||||
output: '',
|
||||
error: 'Vivado 未配置'
|
||||
};
|
||||
}
|
||||
|
||||
// 验证配置
|
||||
const configError = validateConfig(config);
|
||||
if (configError) {
|
||||
return {
|
||||
success: false,
|
||||
command: request.command,
|
||||
executionTime: 0,
|
||||
output: '',
|
||||
error: configError
|
||||
};
|
||||
}
|
||||
|
||||
// 准备工作目录
|
||||
const workingDir = resolveWorkingDir(config.workingDir);
|
||||
if (!fs.existsSync(workingDir)) {
|
||||
fs.mkdirSync(workingDir, { recursive: true });
|
||||
}
|
||||
|
||||
// 生成 TCL 脚本
|
||||
const tclScript = generateTclScript(request, config, workingDir);
|
||||
const tclPath = path.join(workingDir, `${request.command}.tcl`);
|
||||
fs.writeFileSync(tclPath, tclScript);
|
||||
|
||||
// 执行 Vivado
|
||||
const result = await executeVivado(
|
||||
config.executablePath,
|
||||
tclPath,
|
||||
workingDir,
|
||||
progressCallback
|
||||
);
|
||||
|
||||
const executionTime = Date.now() - startTime;
|
||||
|
||||
// 解析报告
|
||||
const reports = parseReports(request.command, workingDir, request.parameters?.topModule);
|
||||
|
||||
// 导入文件
|
||||
let importedFiles: string[] = [];
|
||||
if (request.importOutput?.enabled && result.success) {
|
||||
importedFiles = await importOutputFiles(
|
||||
request.command,
|
||||
config,
|
||||
workingDir,
|
||||
request.importOutput.targetDir
|
||||
);
|
||||
}
|
||||
|
||||
return {
|
||||
success: result.success,
|
||||
command: request.command,
|
||||
executionTime,
|
||||
output: result.output,
|
||||
error: result.error,
|
||||
importedFiles,
|
||||
reports
|
||||
};
|
||||
}
|
||||
|
||||
function generateTclScript(
|
||||
request: VivadoToolRequest,
|
||||
config: VivadoConfig,
|
||||
workingDir: string
|
||||
): string {
|
||||
const { command, parameters } = request;
|
||||
const part = parameters?.part || config.part;
|
||||
|
||||
switch (command) {
|
||||
case 'synthesis':
|
||||
return generateSynthesisTcl(
|
||||
parameters?.topModule || 'top',
|
||||
parameters?.files || [],
|
||||
part,
|
||||
parameters?.constraints,
|
||||
parameters?.outputDir
|
||||
);
|
||||
case 'implementation':
|
||||
const synthDcp = path.join(workingDir, `${parameters?.topModule}_synth.dcp`);
|
||||
return generateImplementationTcl(synthDcp, parameters?.outputDir);
|
||||
case 'bitstream':
|
||||
const implDcp = path.join(workingDir, `${parameters?.topModule}_impl.dcp`);
|
||||
return generateBitstreamTcl(implDcp, parameters?.outputDir);
|
||||
default:
|
||||
throw new Error(`未知命令: ${command}`);
|
||||
}
|
||||
}
|
||||
|
||||
async function executeVivado(
|
||||
executablePath: string,
|
||||
tclPath: string,
|
||||
workingDir: string,
|
||||
progressCallback?: (progress: VivadoProgress) => void
|
||||
): Promise<{ success: boolean; output: string; error?: string }> {
|
||||
return new Promise((resolve) => {
|
||||
let output = '';
|
||||
let errorOutput = '';
|
||||
|
||||
const process = spawn(executablePath, ['-mode', 'batch', '-source', tclPath], {
|
||||
cwd: workingDir,
|
||||
shell: true
|
||||
});
|
||||
|
||||
process.stdout.on('data', (data) => {
|
||||
const text = data.toString();
|
||||
output += text;
|
||||
|
||||
// 解析进度
|
||||
if (progressCallback) {
|
||||
const progress = parseProgress(text);
|
||||
if (progress) {
|
||||
progressCallback(progress);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
process.stderr.on('data', (data) => {
|
||||
errorOutput += data.toString();
|
||||
});
|
||||
|
||||
process.on('close', (code) => {
|
||||
if (code === 0) {
|
||||
resolve({ success: true, output });
|
||||
} else {
|
||||
resolve({ success: false, output, error: errorOutput || '执行失败' });
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function parseProgress(logText: string): VivadoProgress | null {
|
||||
// 解析 Vivado 日志中的进度信息
|
||||
if (logText.includes('Starting synthesis')) {
|
||||
return { stage: 'synthesis', percentage: 10, message: '开始综合' };
|
||||
}
|
||||
if (logText.includes('Finished synthesis')) {
|
||||
return { stage: 'synthesis', percentage: 100, message: '综合完成' };
|
||||
}
|
||||
// 更多进度解析...
|
||||
return null;
|
||||
}
|
||||
|
||||
function parseReports(
|
||||
command: string,
|
||||
workingDir: string,
|
||||
topModule?: string
|
||||
): { resources?: string; timing?: string } {
|
||||
const reports: { resources?: string; timing?: string } = {};
|
||||
|
||||
if (command === 'synthesis' || command === 'implementation') {
|
||||
const utilizationFile = path.join(
|
||||
workingDir,
|
||||
`${topModule}_utilization_${command === 'synthesis' ? 'synth' : 'impl'}.rpt`
|
||||
);
|
||||
if (fs.existsSync(utilizationFile)) {
|
||||
const content = fs.readFileSync(utilizationFile, 'utf-8');
|
||||
reports.resources = extractResourceSummary(content);
|
||||
}
|
||||
|
||||
const timingFile = path.join(
|
||||
workingDir,
|
||||
`${topModule}_timing_${command === 'synthesis' ? 'synth' : 'impl'}.rpt`
|
||||
);
|
||||
if (fs.existsSync(timingFile)) {
|
||||
const content = fs.readFileSync(timingFile, 'utf-8');
|
||||
reports.timing = extractTimingSummary(content);
|
||||
}
|
||||
}
|
||||
|
||||
return reports;
|
||||
}
|
||||
|
||||
function extractResourceSummary(reportContent: string): string {
|
||||
// 提取资源使用摘要
|
||||
const lines = reportContent.split('\n');
|
||||
const summary: string[] = [];
|
||||
|
||||
for (const line of lines) {
|
||||
if (line.includes('LUT') || line.includes('FF') || line.includes('BRAM')) {
|
||||
summary.push(line.trim());
|
||||
}
|
||||
}
|
||||
|
||||
return summary.join('\n');
|
||||
}
|
||||
|
||||
function extractTimingSummary(reportContent: string): string {
|
||||
// 提取时序摘要
|
||||
const lines = reportContent.split('\n');
|
||||
for (const line of lines) {
|
||||
if (line.includes('WNS') || line.includes('TNS')) {
|
||||
return line.trim();
|
||||
}
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
function resolveWorkingDir(workingDir: string): string {
|
||||
const workspaceFolder = vscode.workspace.workspaceFolders?.[0];
|
||||
if (workspaceFolder) {
|
||||
return workingDir.replace('${workspaceFolder}', workspaceFolder.uri.fsPath);
|
||||
}
|
||||
return workingDir;
|
||||
}
|
||||
```
|
||||
|
||||
### 3.4 文件导入实现
|
||||
|
||||
```typescript
|
||||
// src/utils/fileImporter.ts
|
||||
|
||||
import * as vscode from 'vscode';
|
||||
import * as path from 'path';
|
||||
import * as fs from 'fs';
|
||||
import * as glob from 'glob';
|
||||
|
||||
export async function importOutputFiles(
|
||||
command: string,
|
||||
config: VivadoConfig,
|
||||
sourceDir: string,
|
||||
targetDir: string
|
||||
): Promise<string[]> {
|
||||
const patterns = config.outputFiles[command] || [];
|
||||
const importedFiles: string[] = [];
|
||||
|
||||
for (const pattern of patterns) {
|
||||
const files = glob.sync(pattern, { cwd: sourceDir });
|
||||
|
||||
for (const file of files) {
|
||||
const sourcePath = path.join(sourceDir, file);
|
||||
const targetPath = path.join(targetDir, file);
|
||||
|
||||
// 确保目标目录存在
|
||||
const targetDirPath = path.dirname(targetPath);
|
||||
if (!fs.existsSync(targetDirPath)) {
|
||||
fs.mkdirSync(targetDirPath, { recursive: true });
|
||||
}
|
||||
|
||||
// 复制文件
|
||||
fs.copyFileSync(sourcePath, targetPath);
|
||||
importedFiles.push(targetPath);
|
||||
}
|
||||
}
|
||||
|
||||
return importedFiles;
|
||||
}
|
||||
```
|
||||
|
||||
### 3.5 MessageHandler 集成
|
||||
|
||||
```typescript
|
||||
// src/utils/messageHandler.ts (新增部分)
|
||||
|
||||
import { runVivado } from './vivadoRunner';
|
||||
|
||||
// 在 handleUserMessage 中添加 Vivado 工具处理
|
||||
export async function handleVivadoTool(
|
||||
panel: vscode.WebviewPanel,
|
||||
toolCall: any
|
||||
): Promise<VivadoToolResponse> {
|
||||
const { command, topModule, files, constraints, part } = toolCall.parameters;
|
||||
|
||||
// 验证必需参数
|
||||
if (!part) {
|
||||
return {
|
||||
success: false,
|
||||
command,
|
||||
executionTime: 0,
|
||||
output: '',
|
||||
error: '缺少必需参数:芯片型号(part)'
|
||||
};
|
||||
}
|
||||
|
||||
// 构建请求
|
||||
const request: VivadoToolRequest = {
|
||||
command,
|
||||
parameters: {
|
||||
topModule,
|
||||
files,
|
||||
constraints,
|
||||
part
|
||||
},
|
||||
importOutput: {
|
||||
enabled: true,
|
||||
targetDir: path.join(vscode.workspace.workspaceFolders![0].uri.fsPath, 'vivado_output')
|
||||
}
|
||||
};
|
||||
|
||||
// 向前端发送开始消息
|
||||
panel.webview.postMessage({
|
||||
type: 'vivado-start',
|
||||
command
|
||||
});
|
||||
|
||||
// 执行 Vivado
|
||||
const response = await runVivado(request, (progress) => {
|
||||
// 推送进度
|
||||
panel.webview.postMessage({
|
||||
type: 'vivado-progress',
|
||||
progress
|
||||
});
|
||||
});
|
||||
|
||||
// 向前端发送结果
|
||||
panel.webview.postMessage({
|
||||
type: 'vivado-complete',
|
||||
response
|
||||
});
|
||||
|
||||
// 返回结果给后端
|
||||
return response;
|
||||
}
|
||||
```
|
||||
|
||||
### 3.6 参数验证和处理
|
||||
|
||||
```typescript
|
||||
// src/utils/vivadoValidator.ts
|
||||
|
||||
export interface ValidationResult {
|
||||
valid: boolean;
|
||||
error?: string;
|
||||
}
|
||||
|
||||
export function validateVivadoRequest(request: VivadoToolRequest): ValidationResult {
|
||||
const { command, parameters } = request;
|
||||
|
||||
// 验证命令类型
|
||||
if (!['synthesis', 'implementation', 'bitstream'].includes(command)) {
|
||||
return { valid: false, error: `无效的命令类型: ${command}` };
|
||||
}
|
||||
|
||||
// 验证必需参数
|
||||
if (!parameters?.topModule) {
|
||||
return { valid: false, error: '缺少顶层模块名(topModule)' };
|
||||
}
|
||||
|
||||
if (!parameters?.part) {
|
||||
return { valid: false, error: '缺少芯片型号(part)' };
|
||||
}
|
||||
|
||||
// 验证芯片型号格式
|
||||
const partPattern = /^xc[0-9a-z]+$/i;
|
||||
if (!partPattern.test(parameters.part)) {
|
||||
return { valid: false, error: `芯片型号格式不正确: ${parameters.part}` };
|
||||
}
|
||||
|
||||
// 综合命令需要文件列表
|
||||
if (command === 'synthesis') {
|
||||
if (!parameters?.files || parameters.files.length === 0) {
|
||||
return { valid: false, error: '综合命令需要提供源文件列表' };
|
||||
}
|
||||
}
|
||||
|
||||
return { valid: true };
|
||||
}
|
||||
```
|
||||
|
||||
## 4. 前端 UI 实现
|
||||
|
||||
### 4.1 进度显示组件
|
||||
|
||||
```typescript
|
||||
// src/views/vivadoProgress.ts
|
||||
|
||||
export function renderVivadoProgress(progress: VivadoProgress): string {
|
||||
return `
|
||||
<div class="vivado-progress">
|
||||
<div class="progress-header">
|
||||
<span class="stage">${progress.stage}</span>
|
||||
<span class="percentage">${progress.percentage}%</span>
|
||||
</div>
|
||||
<div class="progress-bar">
|
||||
<div class="progress-fill" style="width: ${progress.percentage}%"></div>
|
||||
</div>
|
||||
<div class="progress-message">${progress.message}</div>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
```
|
||||
|
||||
### 4.2 结果展示组件
|
||||
|
||||
```typescript
|
||||
// src/views/vivadoResult.ts
|
||||
|
||||
export function renderVivadoResult(response: VivadoToolResponse): string {
|
||||
if (!response.success) {
|
||||
return `
|
||||
<div class="vivado-result error">
|
||||
<h4>❌ 执行失败</h4>
|
||||
<pre>${response.error}</pre>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
|
||||
return `
|
||||
<div class="vivado-result success">
|
||||
<h4>✅ 执行成功</h4>
|
||||
<div class="result-info">
|
||||
<p>命令: ${response.command}</p>
|
||||
<p>执行时间: ${(response.executionTime / 1000).toFixed(2)}s</p>
|
||||
</div>
|
||||
|
||||
${response.reports?.resources ? `
|
||||
<div class="report-section">
|
||||
<h5>资源使用</h5>
|
||||
<pre>${response.reports.resources}</pre>
|
||||
</div>
|
||||
` : ''}
|
||||
|
||||
${response.reports?.timing ? `
|
||||
<div class="report-section">
|
||||
<h5>时序信息</h5>
|
||||
<pre>${response.reports.timing}</pre>
|
||||
</div>
|
||||
` : ''}
|
||||
|
||||
${response.importedFiles && response.importedFiles.length > 0 ? `
|
||||
<div class="imported-files">
|
||||
<h5>已导入文件</h5>
|
||||
<ul>
|
||||
${response.importedFiles.map(f => `<li>${f}</li>`).join('')}
|
||||
</ul>
|
||||
</div>
|
||||
` : ''}
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
```
|
||||
|
||||
## 5. 配置界面实现
|
||||
|
||||
### 5.1 设置页面扩展
|
||||
|
||||
```typescript
|
||||
// src/views/vivadoSettings.ts
|
||||
|
||||
export function renderVivadoSettings(config: VivadoConfig | null): string {
|
||||
return `
|
||||
<div class="vivado-settings">
|
||||
<h3>Vivado 配置</h3>
|
||||
|
||||
<div class="setting-item">
|
||||
<label>启用 Vivado</label>
|
||||
<input type="checkbox" id="vivado-enabled" ${config?.enabled ? 'checked' : ''}>
|
||||
</div>
|
||||
|
||||
<div class="setting-item">
|
||||
<label>可执行文件路径</label>
|
||||
<input type="text" id="vivado-path" value="${config?.executablePath || ''}"
|
||||
placeholder="C:/Xilinx/Vivado/2023.1/bin/vivado.bat">
|
||||
<button onclick="testVivado()">测试</button>
|
||||
</div>
|
||||
|
||||
<div class="setting-item">
|
||||
<label>工作目录</label>
|
||||
<input type="text" id="vivado-workdir" value="${config?.workingDir || ''}"
|
||||
placeholder="\${workspaceFolder}/vivado_project">
|
||||
</div>
|
||||
|
||||
<div class="setting-item">
|
||||
<label>FPGA 型号</label>
|
||||
<input type="text" id="vivado-part" value="${config?.part || ''}"
|
||||
placeholder="xc7a35tcpg236-1">
|
||||
</div>
|
||||
|
||||
<button onclick="saveVivadoConfig()">保存配置</button>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
```
|
||||
|
||||
## 6. 测试方案
|
||||
|
||||
### 6.1 单元测试
|
||||
|
||||
```typescript
|
||||
// src/test/vivadoRunner.test.ts
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { generateSynthesisTcl } from '../utils/tclGenerator';
|
||||
|
||||
suite('Vivado TCL Generator', () => {
|
||||
test('生成综合脚本', () => {
|
||||
const tcl = generateSynthesisTcl(
|
||||
'counter',
|
||||
['counter.v'],
|
||||
'xc7a35tcpg236-1'
|
||||
);
|
||||
|
||||
assert.ok(tcl.includes('read_verilog counter.v'));
|
||||
assert.ok(tcl.includes('synth_design'));
|
||||
assert.ok(tcl.includes('write_checkpoint'));
|
||||
});
|
||||
});
|
||||
```
|
||||
|
||||
### 6.2 集成测试
|
||||
|
||||
```typescript
|
||||
// src/test/vivadoIntegration.test.ts
|
||||
|
||||
suite('Vivado Integration', () => {
|
||||
test('完整综合流程', async () => {
|
||||
const request: VivadoToolRequest = {
|
||||
command: 'synthesis',
|
||||
parameters: {
|
||||
topModule: 'counter',
|
||||
files: ['test/fixtures/counter.v']
|
||||
}
|
||||
};
|
||||
|
||||
const response = await runVivado(request);
|
||||
assert.ok(response.success);
|
||||
assert.ok(response.executionTime > 0);
|
||||
});
|
||||
});
|
||||
```
|
||||
|
||||
## 7. 部署和发布
|
||||
|
||||
### 7.1 文件清单
|
||||
|
||||
新增文件:
|
||||
- `src/utils/vivadoConfig.ts` - 配置管理
|
||||
- `src/utils/tclGenerator.ts` - TCL 脚本生成
|
||||
- `src/utils/vivadoRunner.ts` - Vivado 执行器
|
||||
- `src/utils/fileImporter.ts` - 文件导入
|
||||
- `src/views/vivadoProgress.ts` - 进度显示
|
||||
- `src/views/vivadoResult.ts` - 结果展示
|
||||
- `src/views/vivadoSettings.ts` - 设置界面
|
||||
|
||||
修改文件:
|
||||
- `src/utils/messageHandler.ts` - 添加 Vivado 工具处理
|
||||
- `src/views/settingsComponent.ts` - 添加 Vivado 设置页面
|
||||
|
||||
### 7.2 配置文件更新
|
||||
|
||||
```json
|
||||
// package.json (新增配置项)
|
||||
{
|
||||
"contributes": {
|
||||
"configuration": {
|
||||
"properties": {
|
||||
"ic-coder.vivado.enabled": {
|
||||
"type": "boolean",
|
||||
"default": false,
|
||||
"description": "启用 Vivado 集成"
|
||||
},
|
||||
"ic-coder.vivado.executablePath": {
|
||||
"type": "string",
|
||||
"default": "",
|
||||
"description": "Vivado 可执行文件路径"
|
||||
},
|
||||
"ic-coder.vivado.workingDir": {
|
||||
"type": "string",
|
||||
"default": "${workspaceFolder}/vivado_project",
|
||||
"description": "Vivado 工作目录"
|
||||
},
|
||||
"ic-coder.vivado.part": {
|
||||
"type": "string",
|
||||
"default": "xc7a35tcpg236-1",
|
||||
"description": "默认 FPGA 型号"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 8. 常见问题和解决方案
|
||||
|
||||
### 8.1 Vivado 许可证问题
|
||||
|
||||
**问题**:执行时提示许可证错误
|
||||
|
||||
**解决方案**:
|
||||
1. 检查环境变量 `XILINX_VIVADO` 是否设置
|
||||
2. 确认许可证服务器可访问
|
||||
3. 在配置中添加许可证路径
|
||||
|
||||
### 8.2 路径问题
|
||||
|
||||
**问题**:Windows 路径包含空格导致执行失败
|
||||
|
||||
**解决方案**:
|
||||
```typescript
|
||||
function escapeWindowsPath(p: string): string {
|
||||
return p.includes(' ') ? `"${p}"` : p;
|
||||
}
|
||||
```
|
||||
|
||||
### 8.3 执行超时
|
||||
|
||||
**问题**:大型项目综合时间过长
|
||||
|
||||
**解决方案**:
|
||||
- 增加超时时间配置
|
||||
- 添加取消执行功能
|
||||
- 显示详细进度信息
|
||||
|
||||
## 9. 性能优化
|
||||
|
||||
### 9.1 日志缓冲
|
||||
|
||||
限制日志输出大小,避免内存溢出:
|
||||
|
||||
```typescript
|
||||
const MAX_LOG_SIZE = 1024 * 1024; // 1MB
|
||||
let logBuffer = '';
|
||||
|
||||
process.stdout.on('data', (data) => {
|
||||
logBuffer += data.toString();
|
||||
if (logBuffer.length > MAX_LOG_SIZE) {
|
||||
logBuffer = logBuffer.slice(-MAX_LOG_SIZE / 2);
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
### 9.2 增量构建
|
||||
|
||||
支持增量综合,只重新综合修改的模块。
|
||||
|
||||
## 10. 后续优化方向
|
||||
|
||||
1. **并行执行**:支持多个设计同时综合
|
||||
2. **缓存机制**:缓存未修改模块的综合结果
|
||||
3. **云端集成**:支持云端 Vivado 服务
|
||||
4. **可视化报告**:图形化展示资源使用和时序
|
||||
5. **自动约束生成**:根据设计自动生成 XDC 约束文件
|
||||
|
||||
Reference in New Issue
Block a user