| name | chip-microarch-chart-workflow |
| description | Use when generating microarchitecture charts (D2, Wavedrom, Interface diagrams). Triggers on '图表生成', 'chart workflow', 'D2编译', 'wavedrom编译', '接口图', '图表工作流', 'generate charts'. Orchestrates D2/Wavedrom/Interface chart generation, compilation and validation. |
| tools | ["Read","Write","Bash","Skill"] |
微架构图表生成工作流
本 skill 封装微架构文档中图表生成的标准化流程,确保每个子模块的图表完整生成。
输入参数
{
"module": "data_adpt",
"submodule": "input_if_mod",
"output_dir": "work/data_adpt_work/ds/doc/ua/tmp",
"charts": ["arch", "datapath", "fsm", "timing", "intf"]
}
工作流程
1. 架构图(arch)
1. Read 模块功能描述
2. Write wd_{sub}_arch.d2 到 {output_dir}/
3. 调用 Skill: chip-png-d2-gen
- d2_file: {output_dir}/wd_{sub}_arch.d2
- output_dir: {output_dir}/
4. Bash: 验证 {output_dir}/wd_{sub}_arch.png 存在
2. 数据通路图(datapath)
1. Read 数据通路描述
2. Write wd_{sub}_datapath.d2 到 {output_dir}/
3. 调用 Skill: chip-png-d2-gen
- d2_file: {output_dir}/wd_{sub}_datapath.d2
- output_dir: {output_dir}/
4. Bash: 验证 {output_dir}/wd_{sub}_datapath.png 存在
3. 状态机图(fsm)
1. Read 状态定义和转移条件
2. Write wd_{sub}_fsm.d2 到 {output_dir}/
3. 调用 Skill: chip-png-d2-gen
- d2_file: {output_dir}/wd_{sub}_fsm.d2
- output_dir: {output_dir}/
4. Bash: 验证 {output_dir}/wd_{sub}_fsm.png 存在
4. 时序图(timing)
1. Read 接口协议描述
2. Write wd_{desc}.json 到 {output_dir}/
3. 调用 Skill: chip-png-wavedrom-gen
- json_file: {output_dir}/wd_{desc}.json
- output_dir: {output_dir}/
4. Bash: 验证 {output_dir}/wd_{desc}.png 存在
5. 端口图(intf)
1. Read 端口列表
2. Write wd_intf_{sub}.json 到 {output_dir}/
3. 调用 Skill: chip-png-interface-gen
- json_file: {output_dir}/wd_intf_{sub}.json
- output_dir: {output_dir}/
4. Bash: 验证 {output_dir}/wd_intf_{sub}.png 存在
批量编译
node .claude/skills/chip-png-wavedrom-gen/gen_wavedrom.js {output_dir}/
验证清单
for f in {output_dir}/wd_*.d2; do
[ -f "${f%.d2}.png" ] || echo "MISSING: ${f%.d2}.png"
done
for f in {output_dir}/wd_*.json; do
[ -f "${f%.json}.png" ] || echo "MISSING: ${f%.json}.png"
done
使用示例
示例 1:
- 用户:「为 data_adpt 的 input_if_mod 生成全套微架构图表」
- 行为:依次生成架构图(.d2→.png)、数据通路图、状态机图、时序图(.json→.png)、端口图,验证所有 PNG 存在
示例 2:
- 用户:「只帮我编译 output_ctrl 的状态机图」
- 行为:读取
wd_output_ctrl_fsm.d2,调用 d2 --layout dagre 编译为 PNG,验证输出文件存在
异常处理
| 场景 | 触发条件 | 处理动作 |
|---|
| D2 编译失败 | .d2 语法错误或 d2 CLI 不可用 | 保留 .d2 源文件,标注 [D2-DEGRADED],降级为文本描述 |
| Wavedrom 解析失败 | .json 格式错误或 wavedrom-cli 不可用 | 保留 .json,标注错误位置,降级为文本时序表 |
| 源文件缺失 | .d2 或 .json 文件不存在 | 跳过该图表,标注 [CHART-MISSING] |
| PNG 未生成 | 编译成功但 PNG 文件不存在 | 检查输出目录权限,重试一次 |
检查点
检查前:
- 确认输出目录
{output_dir}/ 存在
- 确认图表源文件(.d2/.json)已生成
- 确认 d2/wavedrom-cli 工具可用
检查后:
- 确认所有
wd_*.d2 有对应 .png
- 确认所有
wd_*.json 有对应 .png
- 确认验证清单无 MISSING 项
降级策略
| 场景 | 处理方式 |
|---|
| D2 编译失败 | 保留 .d2,标注 [D2-DEGRADED],降级为文本描述 |
| Wavedrom 解析失败 | 保留 .json,标注错误位置,降级为文本时序表 |
| Interface 生成失败 | 跳过(非关键) |
输出
- 所有图表源文件(.d2/.json)在 {output_dir}/
- 所有编译产物(.png)在 {output_dir}/
- 验证报告(pass/fail 列表)