Skip to main content

sv_query — 面向 agent 的 SystemVerilog 语义查询 + 客观校验引擎

Tests PyPI Python

让 agent 查询并验证 RTL 事实,而不是靠读源码猜。

Beta(0.3.10): 质量足以试用,但明确不宣称 1.0 的语义完整性/外部准确率。 发布前已知限制见 KNOWN_LIMITATIONS; 发布流程见 RELEASE.md。

agent 面向的 RTL 查询 + 客观校验层:服务动态 debug(波形值由外部工具提供)与 design 理解; 核心是 canonical identity、evidence、双向验证,而不是自然语言解释。

回归基线见 docs/INDEX.md 当前基线 | Python 3.11+ | pyslang 语义 AST | NetworkX graph | 真实项目 + 性能基准 + agent 对照(内部)

更新日期: 2026-11-30(0.3.10 beta;P199 semantic reset / CDC removal / scanner;基线计数统一引用 INDEX)


开发位置: 本仓库是唯一开发主线。私有仓库 sv_query_private 只做旧历史归档,不继续开发。 详见 docs/dev/REPOSITORY_LAYOUT.md。

Found a wrong query answer? Report a miss without sharing proprietary RTL.

Beta contract: stable vs no-promise surface, evidence grades, cold-start expectations — read.

Privacy: no telemetry / no RTL upload by default; details.

English docs: User guide · Known limitations

Install

pip install sv_query
# or, in an isolated environment:
uv pip install sv_query

For repository development:

git clone https://github.com/fundou1081/sv_query.git
cd sv_query
pip install -e ".[dev]"

Real-project evidence (non-blind)

Two CVA6 historical fixes were compared with grep, not blind-discovered: _i → _q cycle mismatch and a DTLB PPN bit-select gating defect. The durable conclusion: drivers --evidence binds the source expression; bus-level answers can miss bit-select defects and need graph nodes down-drill.

Reports: value cases · follow-ups.

English summary

sv_query is an agent-facing query and objective-verification layer for SystemVerilog. It builds a semantic graph from pyslang, exposes read-only JSON queries (drivers, loads, paths, dataflow, scope, constraints, covergroups, consistency/claim verification), and reports evidence strength explicitly (verified / partial / unknown). It is a beta: structural queries are useful today, but semantic completeness and external accuracy claims remain limited; see KNOWN_LIMITATIONS.

为什么用 sv_query

  • 位级追踪(scoped): SignalSource 结构化存储 bit_range + op + casts;位对位只在已建模算子/连接上成立,比较/变量移位等仍总线粒度(见 KNOWN_LIMITATIONS)
  • 穿透子模块: wrapper port passthrough + bus 位桥(同构直连 / 切片偏移)
  • 语义优先: class / constraint / covergroup / UVM role 走 pyslang semantic AST; UVM 宏/调用因预处理器会丢宏,是唯一 syntactic regex 例外(显式标 confidence,不作为 verify 证明)
  • class/constraint/covergroup/UVM: 继承约束链、rand/randc 标记、covergroup 采样/反向查询、 UVM sequence/factory 静态关系
  • 客观校验: 全图 / bit-level 结构一致性 + claim 验证 + finding 局部证据
  • 可复现验证: strict_uart / verilog-axi / picorv32 / SERV smoke;3 设计性能基准; 单级 CDC 反幻觉 walkthrough;12 题双模型 source-only vs sv_query 对照(内部)。 尚未跑 HWE-Bench/VeriBugBench,不宣称对外准确率/成本收益。

全设计图已退役;局部 finding review 仍为 exp(review render),不是核心能力。 RTL typo detection / ranking 属于独立项目 rtl_typo_checker,不在 sv_query core。


项目定位(2026-11-05)

完整方向见 product_direction_2026-10-31。

  • 主场景:agent 的 RTL debug / design 理解;迭代查询、多批脚本、按结论继续追问。
  • 动态 debug 分工:波形值由外部工具提取;sv_query 提供 canonical id/别名、层级、位映射、clock/reset、sequential stage、源码 evidence。
  • 函数/class:RTL 函数名 + 源码足够(不 inline);class 关注调用链/继承/对象关系、 constraint/covergroup 与 UVM 静态关系。
  • 证据分级:semantic 结果优先;UVM 宏相关的 confidence=syntactic 只作线索,不作证明。
  • 核心原则:事实与证据优先;未知/空/歧义显式;双向一致性 + claim verification。

5-minute quickstart

New here? Follow docs/QUICKSTART.md. The short version:

pip install sv_query
export FL=sim/tests/fixtures/scheduler_minimal/filelist.f
sv_query capabilities --json
sv_query graph nodes --filelist "$FL" --json
sv_query drivers Scheduler_minimal.s0_reg --filelist "$FL" --json

JSON mode is quiet by default; use --verbose to keep stderr. Empty results are unknown, not proof of absence; see KNOWN_LIMITATIONS.

功能分层

层 命令
Scope scope / instances / hierarchy / ports / params / connections / class
Trace drivers / loads / paths / dataflow analyze / controlflow analyze / trace evidence/profile/lookup/manifest
Verify verify consistency / verify claim / verify structural(仅客观结构一致性;RTL typo 是独立项目)
Class/约束/覆盖 class --relations(含 UVM 静态) / trace constraints / trace covergroups / trace coverpoints / trace covergroup
Locate stats / search / graph nodes/edges / graph subgraph / capabilities
State snapshot save/list/compare/delete
exp audit / diagnose / trace overview / review render / architecture graph / trace impact(默认隐藏,不承诺契约)

visualize / arch / design 全设计图命令已于 2026-11-03 退役;review render 仍是 exp。


验证状态(2026-11-11)

项 状态
全量回归 见 INDEX 当前基线:canonical 0 failed;opensource/skip 计数不写死(口径见 INDEX)
开源 smoke strict_uart / verilog-axi / picorv32 / SERV
性能基准 picorv32 / verilog-axi / SERV;build、warm query、cold CLI、peak RSS
反幻觉 单级 CDC walkthrough:profile + fanin/fanout 反驳“两级同步器”
Agent 对照(内部) 固定协议 12 题 ×2 模型 ×2 臂 ×2 seed:T2 48/48,source 32/48;见下方
硬隔离 96-cell 矩阵;source 无 repo/CLI,T2 无 truth/task JSON;12×3 未跑
未做 外部 VeriBug/HWE 对照、真实根因/patch、token 成本、3rd seed

性能:构图是 cold CLI 主导成本(本机 verilog-axi 约 26 s / 13.8k nodes), 图内查询为毫秒级。不要把 warm query 的毫秒数字误读成冷启动查询。 详见 性能基准 与 反幻觉 walkthrough。

Agent 对照(内部,2026-11-07)

12 个“源码远、结构近”任务(AXI / SERV / PicoRV32),固定协议: source/T2 hard isolation、fact check、--depth 1、query log;2 seed。

模型 / 臂 exact(24 cells) high-conf 错
MiniMax-M3 / source 17/24 7/24
MiniMax-M3 / svq 24/24 0/24
DeepSeek-Flash / source 15/24 2/24
DeepSeek-Flash / svq 24/24 0/24

合计:

source: 32/48
svq:    48/48

观察:

  • svq 在两个 seed、两个模型上均 48/48;
  • source 仍出现 high-confidence 错误(9/48);
  • 这是 direct structural query,不是 debug reasoning;
  • token/cold-warm 成本未拆分,不能声称成本更低;
  • 不声称 HWE/VeriBug 或真实项目准确率。

硬隔离:source 臂拒绝 repo / sv_query / pilot artifact;T2 拒绝 task JSON/truth。 已跑 96-cell 矩阵;12×3 未跑(3rd seed 不做)。

详见 12-task 固定协议、 最终验证摘要、 硬隔离审计。


Python API

from sv_query.trace.unified_tracer import UnifiedTracer

tracer = UnifiedTracer(sources={"top.sv": src})
tracer.build_graph()
graph = tracer.get_graph()

drivers = tracer.trace_fanin_detailed("top.result")
for d in drivers:
    print(d.node.id, "<-", d.expression)
    print("  when:", d.condition or "always")

项目结构

sv_query/
├── src/sv_query/trace/              # 核心图/追踪/校验
│   ├── unified_tracer.py   # 统一入口
│   ├── core/
│   │   ├── graph/          # SignalGraph / models / analyzer
│   │   ├── driver_extractor.py
│   │   ├── graph_builder.py
│   │   └── visitors/
├── src/sv_query/cli/                # CLI (core/exp)
├── sim/tests/              # 测试
├── examples/               # 可复现 walkthrough(反幻觉 CDC)
├── docs/                   # 文档 / 性能数据
├── skills/                # OpenClaw skill 包 (sv-query, 供 agent 加载)
└── tools/                  # 独立工具(含 benchmark/query_perf.py)

测试

pip install -e ".[dev]"

# 日常主回归
python -m pytest sim/tests/ -m "not opensource" -q

# 开源项目验证
python -m pytest sim/tests/ -m opensource -v

详见 TESTING.md。计数以 docs/INDEX.md 当前基线为准。


相关文档

许可

MIT + Apache 2.0 双许可

Metadata

Release files for sv-query 0.3.10

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sv-query 0.3.10
File Size Uploaded Provenance Actions
sv_query-0.3.10.tar.gz 618.6 kB With provenance Details for sv_query-0.3.10.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for sv-query 0.3.10
File Interpreter ABI Platform Actions
sv_query-0.3.10-py3-none-any.whl Python 3 none any Details for sv_query-0.3.10-py3-none-any.whl

Total release size: 1.3 MB

Release files / sv_query-0.3.10.tar.gz

Download URL sv_query-0.3.10.tar.gz
Size 618.6 kB
Tags Source
SHA-256 checksum
How to use checksums
33bd8cf25a88934154950eb1b7260026b42fd1c22ed9bd60fc2a055569c351e0
BLAKE2b-256 checksum
How to use checksums
7287a6bcc7889f901711af18175e9ec23b90876a83eeabfe786e8135c5de3221
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.

Transparency log

Release files / sv_query-0.3.10-py3-none-any.whl

Download URL sv_query-0.3.10-py3-none-any.whl
Size 699.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
af6dfe7e53115a8320cf98ea1c6c3bf544f3d4836199e3dc7e6096c35df6a30d
BLAKE2b-256 checksum
How to use checksums
526a75e633a38a239e937d7b77d504f8978df01ecf0eae74619ee10aa57c2d90
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.

Transparency log

Security for sv-query 0.3.10

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for sv_query-0.3.10.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page