bb-find-module-deps

SkillFiles & storage

Scans the RTL directory to extract module hierarchy dependencies, performs a topological sort, and writes file_list.f (leaf modules first, top last) for use with Yosys/Verilator. Trigger scenarios: (1) generate a file list after bba-guru-rtl produces RTL; (2) explicitly invoke /bb-find-module-deps.

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-find-module-deps skill

What this skill tells your AI

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

职责

designs/<name>/rtl/*.sv,构建 module → file 映射 + module instantiation 图,Kahn 拓扑排序,写 file_list.f

  • 调用者:bba-guru-rtl
  • 下游:bb-check-lintbb-invoke-yosysbb-invoke-verilator
  • 禁止使用:Task / Agent / Skill

Input Args

argtyperequired默认说明
rtl_dirpathtruedesigns/<name>/rtl/
top_modulestringtrue顶层名
design_namestringtrue
include_dirslist[path]false[]+incdir+ 列表
defineslist[str]false[]+define+KEY=VAL
stampstringfalse<auto>

Output Contract

field
artifact_pathdesigns/<name>/file_list.f
script_pathdesigns/<name>/rtl/gen_filelist_<stamp>.py
module_countint
top_modulestr
orderlist[str](拓扑序模块名)
validbool
errorstring|null

4-Phase 执行

Phase 1 — render_filelist_py

scripts/render_filelist_py.py 生成 Python:

# 优先用 verible-verilog-syntax 解析(识别 interface/class/package 与 module,避免误判 — fix M-04)
# 失败时退到正则 fallback
try:
    import subprocess, json
    out = subprocess.check_output(["verible-verilog-syntax", "--export_json", f]).decode()
    ast = json.loads(out)
    # 遍历 ast 找 ModuleDeclaration nodes
except Exception:
    # fallback: 正则 `^\s*module\s+(\w+)` + 排除 interface/class/package 关键字
    pass

# 然后建 dep 图:parent_module → set(child_module)
# Kahn 拓扑(child 先 parent 后);检测环
# 写 file_list.f:incdir / define / 拓扑序文件

Phase 2 — run_filelist_gen

scripts/run_filelist.pytimeout 180 uv run python <script_path> > <log> 2>&1

Phase 3 — parse_filelist

scripts/parse_filelist.py

  • 验证 file_list.f 存在
  • 验证 top_module 对应文件是最后一个
  • 计数 module_count
  • log 含 Cyclic dependencyerror="cyclic: A->B->A"

Phase 4 — return

返回 JSON。bba-guru-rtl 直接把 artifact_path 传给下游。

file_list.f 格式

+incdir+designs/<name>/rtl/include
+define+TARGET_ASAP7
designs/<name>/rtl/uart_fifo.sv
designs/<name>/rtl/uart_rx.sv
designs/<name>/rtl/uart_tx.sv
designs/<name>/rtl/uart_ctrl.sv
designs/<name>/rtl/uart_top.sv

收敛 / 失败

状态行动
valid=truebb-check-lint
cyclicarch-needs-fix(模块循环必须重设计)
找不到 top_moduleerror="top not found",bba-guru-rtl 修正

资源索引

  • scripts/render_filelist_py.pyscripts/run_filelist.pyscripts/parse_filelist.py
  • lib/sv_module_regex.py — module/instantiation 正则集
  • Gotcha/sv_pitfalls.md — 接口/类等被误识别为 instantiation

Signals

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