Skip to content

feat: SystemVerilog / Verilog / UVM support — structural graph with composition + TLM#382

Open
StopJoking97 wants to merge 1 commit into
Egonex-AI:mainfrom
StopJoking97:feat/systemverilog-uvm-support
Open

feat: SystemVerilog / Verilog / UVM support — structural graph with composition + TLM#382
StopJoking97 wants to merge 1 commit into
Egonex-AI:mainfrom
StopJoking97:feat/systemverilog-uvm-support

Conversation

@StopJoking97

Copy link
Copy Markdown

Summary

Adds recognition of SystemVerilog/Verilog (.sv .svh .v .vh) and a deterministic HDL knowledge graph. For RTL it captures the module instantiation hierarchy; for UVM it extracts the component composition tree (Type::type_id::create(...)) and the TLM data path (a.b.connect(c.d)), so a UVM testbench renders as one tree rooted at the test instead of a disconnected inheritance fan-out.

Two parser backends behind one HdlAnalysis shape:

  • tree-sitter-systemverilog (primary) — accurate AST extraction; ships a prebuilt .wasm grammar, loaded exactly like the existing grammars.
  • regex (zero-dep fallback) — also the AnalyzerPlugin for the standard structural pipeline; used when the WASM grammar can't load.

The deterministic assembler (assembleHdlGraph) is parser-agnostic — both backends produce an identical graph. Reuses existing edge types: contains, depends_on (instantiation + composition), inherits, publishes (TLM).

Linked issue(s)

None — happy to open a tracking issue if you'd prefer to discuss the approach first.

How I tested this

  • pnpm lint
  • pnpm --filter @understand-anything/core test720 passing, incl. SV parser/assembler unit tests, a tree-sitter↔regex equivalence integration test, and a self-contained 15-file uvm_demo fixture whose test asserts (by graph traversal) that the whole testbench is reachable from dut_base_test via composition.
  • pnpm test — the only failures locally are 9 pre-existing, env-specific ones unrelated to this change (worktree path separators / a Python merge script / tree-sitter init on Windows). CI will confirm on Linux.
  • Manual smoke test: node scripts/analyze-hdl.mjs <uvm_project> → 57 nodes / 55 edges; the UVM layer shows the full dut_base_test → env → agent → {driver, monitor, sequencer} + scoreboard tree, plus TLM monitor→scoreboard / driver→sequencer. The tree-sitter and regex backends produce identical graphs.

Versioning

  • N/A — additive feature; leaving the five manifests for you to bump on merge per CLAUDE.md (avoids version churn/conflicts in the PR).

Notes for review

This adds a deterministic HDL assembler (buildHdlGraph / buildHdlGraphTreeSitter) alongside the existing GraphBuilder, so the SV/UVM design edges (instantiation, inheritance, UVM composition, TLM) can be produced and asserted without an LLM run. The parser sits behind a seam (regex ↔ tree-sitter) and the assembler is parser-agnostic. Happy to adjust the architecture to your taste — e.g. fold the extraction into the existing tree-sitter LanguageExtractor pipeline, or drop the regex fallback.

🤖 Generated with Claude Code

Recognize .sv/.svh/.v/.vh and build a deterministic HDL knowledge graph
capturing the RTL module hierarchy and, for UVM, the component composition
tree (Type::type_id::create) and the TLM data path (a.b.connect(c.d)) — so a
UVM testbench renders as one test-rooted tree, not disconnected inheritance
fan-out.

- languages/configs/systemverilog.ts: language config + HDL/UVM concepts
- plugins/parsers/systemverilog-parser.ts: zero-dep regex AnalyzerPlugin
  (structural backend + fallback when the WASM grammar is unavailable)
- plugins/parsers/systemverilog-treesitter.ts: tree-sitter-systemverilog
  backend — accurate AST extraction, same HdlAnalysis shape
- analyzer/hdl-graph.ts: parser-agnostic assembler emitting module/class/
  function nodes + contains/depends_on/inherits/publishes edges and layers
- scripts/analyze-hdl.mjs: CLI (tree-sitter primary, regex fallback)
- tests + a self-contained 15-file uvm_demo fixture asserting the testbench
  converges into a single tree rooted at the UVM test

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant