diff --git a/analysis/README.md b/analysis/README.md new file mode 100644 index 0000000..89baecc --- /dev/null +++ b/analysis/README.md @@ -0,0 +1,26 @@ +# 仓库完整性体检原始数据 + +本目录存放《低功耗 RISC-V 开源芯片综述》第 7 节(仓库完整性与可二次开发性实测评估)的原始数据与可复现工具。 + +| 文件 | 说明 | +|---|---| +| `scan_repos.py` | 结构化体检脚本(统计 RTL 规模、验证环境、构建体系、CI、依赖管理等) | +| `仓库体检原始输出.txt` | 2026-09-06 对 9 个仓库的实际扫描输出 | + +## 复现方法 + +体检时各仓库以浅克隆方式获取(`git clone --depth 1`),扫描脚本直接对本地目录统计: + +```bash +git clone --depth 1 https://github.com/olofk/serv.git # 其余 8 仓同理 +python3 scan_repos.py > 仓库体检原始输出.txt +``` + +## 扫描口径 + +- **RTL 行数**:`.v/.sv/.svh/.vh/.vhd/.vhdl/.scala` 源码文件行数合计(VexRiscv 含 SpinalHDL 源码) +- **验证环境**:tb/testbench/verif/dv/uvm/tests 等典型验证目录下的 RTL 文件计数 +- **构建体系**:FuseSoC `.core`、Makefile、Bazel(build/.bzl)、CMake、Tcl 脚本计数 +- **依赖管理**:`.gitmodules` 子模块清单;清单式外拉(pulpino `update-ips.py`、pulpissimo Bender)需结合 README 人工核查 + +注意:`git log` 显示的 HEAD 日期为扫描时点(2026-09-06)状态,各仓库后续会有新提交。 diff --git a/analysis/scan_repos.py b/analysis/scan_repos.py new file mode 100644 index 0000000..456ce63 --- /dev/null +++ b/analysis/scan_repos.py @@ -0,0 +1,85 @@ +#!/usr/bin/env python3 +"""Scan cloned RISC-V repos and print a compact completeness report.""" +import os, subprocess, io, sys + +sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding="utf-8") +REPO_DIR = "/data/repos" +REPOS = ["serv", "neorv32", "picorv32", "ibex", "VexRiscv", + "e203_hbirdv2", "pulpino", "pulpissimo", "opentitan"] + +RTL_EXT = {".v", ".sv", ".svh", ".vh", ".vhd", ".vhdl", ".fhdl", ".scala"} +TB_DIRS = {"tb", "tb_core", "testbench", "verif", "dv", "dv_uvm", "tests", "test", "tbench"} +DOC_EXT = {".md", ".rst", ".tex", ".pdf"} + +def head_date(repo): + try: + out = subprocess.run(["git", "log", "-1", "--format=%ci %h"], + cwd=os.path.join(REPO_DIR, repo), capture_output=True, text=True).stdout + return out.strip()[:16] + except Exception: + return "?" + +def scan(repo): + root = os.path.join(REPO_DIR, repo) + rtl_files = rtl_lines = doc_files = tb_rtl = 0 + core_files = makefiles = pyscripts = tcl = bazel = cmake = 0 + workflows, licenses = [], [] + gitmods = [] + for dirpath, dirnames, filenames in os.walk(root): + dirnames[:] = [d for d in dirnames if d != ".git"] + rel = os.path.relpath(dirpath, root) + parts = set(rel.replace("\\", "/").split("/")) + for f in filenames: + p = os.path.join(dirpath, f) + ext = os.path.splitext(f)[1].lower() + lf = f.lower() + if ext in RTL_EXT: + try: + with open(p, "rb") as fh: + n = sum(1 for _ in fh) + except Exception: + n = 0 + rtl_files += 1 + rtl_lines += n + if parts & TB_DIRS: + tb_rtl += 1 + elif ext in DOC_EXT: + doc_files += 1 + if lf == "license" or lf.startswith("license."): + licenses.append(os.path.relpath(p, root)) + if lf.endswith(".core"): + core_files += 1 + if lf in ("makefile",) or lf.startswith("makefile.") or lf.endswith(".mk"): + makefiles += 1 + if ext == ".py": + pyscripts += 1 + if ext == ".tcl": + tcl += 1 + if lf.startswith("bazelrc") or lf == "build" or lf.endswith(".bzl") or lf == "module_bazel": + bazel += 1 + if lf in ("cmakelists.txt",): + cmake += 1 + if rel == os.path.join(".github", "workflows"): + workflows = [f for f in filenames if f.endswith((".yml", ".yaml"))] + gm = os.path.join(root, ".gitmodules") + if os.path.exists(gm): + with open(gm, encoding="utf-8", errors="ignore") as fh: + gitmods = [l.split("=", 1)[1].strip() for l in fh if l.strip().startswith("path =")] + tops = sorted(d for d in os.listdir(root) + if os.path.isdir(os.path.join(root, d)) and d != ".git") + lic = licenses[0] if licenses else "MISSING" + readme = os.path.exists(os.path.join(root, "README.md")) or os.path.exists(os.path.join(root, "README.rst")) + print(f"=== {repo} ===") + print(f"HEAD: {head_date(repo)} | LICENSE: {lic} | README: {'Y' if readme else 'N'}") + print(f"RTL files: {rtl_files} | RTL lines: {rtl_lines} | TB rtl files: {tb_rtl} | doc files: {doc_files}") + print(f"FuseSoC .core: {core_files} | Makefile: {makefiles} | .py: {pyscripts} | .tcl: {tcl} | bazel-ish: {bazel} | cmake: {cmake}") + print(f"CI workflows: {len(workflows)} {workflows[:4]}") + print(f"submodules({len(gitmods)}): {gitmods[:12]}") + print(f"top dirs: {tops}") + print() + +for r in REPOS: + try: + scan(r) + except Exception as e: + print(f"=== {r} === ERROR {e}\n") diff --git a/analysis/仓库体检原始输出.txt b/analysis/仓库体检原始输出.txt new file mode 100644 index 0000000..27d2a47 --- /dev/null +++ b/analysis/仓库体检原始输出.txt @@ -0,0 +1,72 @@ +=== serv === +HEAD: 2026-08-25 14:38 | LICENSE: LICENSE | README: Y +RTL files: 78 | RTL lines: 6701 | TB rtl files: 0 | doc files: 14 +FuseSoC .core: 4 | Makefile: 2 | .py: 4 | .tcl: 10 | bazel-ish: 0 | cmake: 5 +CI workflows: 5 ['openlane.yml', 'lint.yml', 'ci.yml', 'pages.yml'] +submodules(0): [] +top dirs: ['.github', 'bench', 'data', 'doc', 'rtl', 'servant', 'servile', 'serving', 'sw', 'verif', 'zephyr'] + +=== neorv32 === +HEAD: 2026-09-06 08:37 | LICENSE: LICENSE | README: Y +RTL files: 74 | RTL lines: 28094 | TB rtl files: 0 | doc files: 25 +FuseSoC .core: 0 | Makefile: 38 | .py: 0 | .tcl: 1 | bazel-ish: 0 | cmake: 0 +CI workflows: 3 ['Processor.yml', 'Verilog.yml', 'Documentation.yml'] +submodules(0): [] +top dirs: ['.github', 'docs', 'rtl', 'sim', 'sw'] + +=== picorv32 === +HEAD: 2026-07-31 17:45 | LICENSE: tests/LICENSE | README: Y +RTL files: 41 | RTL lines: 9133 | TB rtl files: 0 | doc files: 4 +FuseSoC .core: 5 | Makefile: 11 | .py: 8 | .tcl: 8 | bazel-ish: 0 | cmake: 0 +CI workflows: 1 ['ci.yml'] +submodules(0): [] +top dirs: ['.github', 'dhrystone', 'firmware', 'picosoc', 'scripts', 'tests'] + +=== ibex === +HEAD: 2026-08-31 07:52 | LICENSE: LICENSE | README: Y +RTL files: 654 | RTL lines: 109042 | TB rtl files: 266 | doc files: 120 +FuseSoC .core: 209 | Makefile: 50 | .py: 200 | .tcl: 24 | bazel-ish: 7 | cmake: 0 +CI workflows: 5 ['private-ci.yml', 'cla.yml', 'ci.yml', 'ci-formal.yml'] +submodules(0): [] +top dirs: ['.github', 'ci', 'doc', 'dv', 'examples', 'formal', 'lint', 'nix', 'rtl', 'shared', 'syn', 'util', 'vendor'] + +=== VexRiscv === +HEAD: 2026-08-31 17:50 | LICENSE: LICENSE | README: Y +RTL files: 122 | RTL lines: 27279 | TB rtl files: 13 | doc files: 8 +FuseSoC .core: 0 | Makefile: 34 | .py: 5 | .tcl: 9 | bazel-ish: 0 | cmake: 0 +CI workflows: 1 ['scala.yml'] +submodules(1): ['src/test/resources/VexRiscvRegressionData'] +top dirs: ['.github', 'assets', 'doc', 'project', 'scripts', 'src'] + +=== e203_hbirdv2 === +HEAD: 2025-08-06 10:51 | LICENSE: LICENSE | README: Y +RTL files: 141 | RTL lines: 57651 | TB rtl files: 1 | doc files: 20 +FuseSoC .core: 2 | Makefile: 13 | .py: 12 | .tcl: 16 | bazel-ish: 0 | cmake: 0 +CI workflows: 1 ['deploy_doc.yaml'] +submodules(0): [] +top dirs: ['.github', 'doc', 'fpga', 'pics', 'riscv-tools', 'rtl', 'tb', 'vsim'] + +=== pulpino === +HEAD: 2019-05-29 11:29 | LICENSE: LICENSE | README: Y +RTL files: 49 | RTL lines: 10608 | TB rtl files: 12 | doc files: 23 +FuseSoC .core: 0 | Makefile: 51 | .py: 22 | .tcl: 25 | bazel-ish: 0 | cmake: 118 +CI workflows: 0 [] +submodules(0): [] +top dirs: ['ci', 'doc', 'fpga', 'ips', 'rtl', 'sw', 'tb', 'vsim'] + +=== pulpissimo === +HEAD: 2024-05-30 19:02 | LICENSE: LICENSE.md | README: Y +RTL files: 107 | RTL lines: 87497 | TB rtl files: 11 | doc files: 52 +FuseSoC .core: 1 | Makefile: 46 | .py: 42 | .tcl: 70 | bazel-ish: 0 | cmake: 0 +CI workflows: 1 ['gitlab-ci.yml'] +submodules(2): ['sw/pulp-runtime', 'sw/regression_tests'] +top dirs: ['.github', 'doc', 'hw', 'sw', 'target', 'utils'] + +=== opentitan === +HEAD: 2026-09-04 20:21 | LICENSE: LICENSE | README: Y +RTL files: 3995 | RTL lines: 1156179 | TB rtl files: 2670 | doc files: 885 +FuseSoC .core: 821 | Makefile: 31 | .py: 667 | .tcl: 137 | bazel-ish: 794 | cmake: 0 +CI workflows: 12 ['cherrypick.yml', 'private-ci.yml', 'pr_change_check.yml', 'monthly.yml'] +submodules(0): [] +top dirs: ['.github', 'ci', 'doc', 'hw', 'quality', 'release', 'rules', 'signing', 'site', 'sw', 'third_party', 'toolchain', 'util'] +