bb-check-cdc

SkillDev tools

AST-based check for CDC/RDC violations: compares against MAS clock_domains to find cross-domain signals and verifies they are protected by the 2ff-sync CBB. Triggers: (1) before synthesis in bba-guru-synthesis; (2) explicit /bb-check-cdc.

Available today. Use it from your connected AI after setup.

Connect ahel once, and every AI you use reads what you have installed.

Then ask your AI: use the bb-check-cdc skill

What this skill tells your AI

The instructions your AI receives, as published by amoslee2026/babel in .claude/skills/bb-check-cdc/SKILL.md and read by ahel’s review.

职责

bb-parse-ast 的 AST + MAS.clock_domains,识别跨时钟域 register-to-register 路径,检查是否通过 2ff 同步器,输出 violation 报告。

  • 调用者:bba-guru-synthesis
  • 上游:bb-parse-ast(backend=auto 自动降级到 verible/slang)
  • 禁止使用:Task / Agent / Skill

Input Args

argtyperequired默认说明
file_listpathtruefile_list.f
ast_pathpathtruebb-parse-ast 产出
mas_pathpathtruedesigns/<name>/mas/mas.json
design_namestringtrue
stampstringfalse<auto>

Output Contract

field
artifact_pathdesigns/<name>/cdc/cdc_report.json
script_pathdesigns/<name>/cdc/check_cdc_<stamp>.py
log_pathdesigns/<name>/cdc/cdc_<stamp>.log
violations[{type,from_clk,to_clk,signal,line,waived:bool}]
cleanbool(unwaived violations==[])
validbool

4-Phase 执行

Phase 1 — render_cdc_py

scripts/render_cdc_py.py 渲染:

import json
ast = json.load(open(ast_path))
mas = json.load(open(mas_path))
domains = mas["clock_domains"]
# 1. 抽取所有 always_ff (@posedge clk) blocks
# 2. 对每条赋值,标注其 clock domain (信号→sensitivity clock)
# 3. R-to-R 路径:from_clk != to_clk → 候选 violation
# 4. 检查 sink 之前是否经过 wiki/cbb/2ff-sync 实例
violations = analyze(ast, domains)
json.dump({"violations": violations}, open(out, "w"))

Phase 2 — run_cdc

timeout 600 uv run python <script_path> > <log> 2>&1,追加 exit:<rc>

Phase 3 — parse_cdc

scripts/parse_cdc.py

  • 解析输出 JSON
  • clean = all(not v.waived for v in violations)
  • cdc_report.json

Phase 4 — return

返回 JSON。clean=false → bba-guru-synthesis 开 rtl-needs-fix(CDC 不允许 waive)。

收敛 / 失败

状态行动
clean=true进 yosys
clean=false(unwaived)rtl-needs-fix 退出
pyverilog 解析失败重试 bb-parse-ast --backend verible(或 slang
Phase 2 timeout(600s)error="CDC_TIMEOUT"

资源索引

  • scripts/render_cdc_py.pyscripts/run_cdc.pyscripts/parse_cdc.py
  • references/2ff_sync_pattern.md — 同步器识别规则
  • Gotcha/cdc_false_positives.md — handshake / gray code 等不视为 violation

Signals

GitHub stars
42
Forks
10
Last commit
Aug 2026
Advanced
Catalog kind
skill
Gateway key
bb-check-cdc
Source
github.com/amoslee2026/babel