feat: SystemVerilog/Verilog language support (incl. UVM)#691
Open
StopJoking97 wants to merge 1 commit into
Open
feat: SystemVerilog/Verilog language support (incl. UVM)#691StopJoking97 wants to merge 1 commit into
StopJoking97 wants to merge 1 commit into
Conversation
Adds a SystemVerilog/Verilog extractor backed by the gmlarumbe tree-sitter grammar (vendored as a prebuilt wasm), plus small, opt-in engine extensions. SystemVerilog is a superset of Verilog, so one grammar indexes both: .sv/.svh/.v/.vh. What it indexes: - modules/programs/packages/interfaces/classes; typedefs (enum typedef -> enum + members) - module instantiation hierarchy (emitted as instantiates + calls so callers/callees/impact surface the design tree) - class inheritance (extends, with package-qualified base resolution) - methods, including extern out-of-class bodies (Class::method) and the function new constructor - this./super. method calls resolved up the inheritance chain (super reaches the parent's method, never a false self-edge) - class composition: a typed-handle field -> references edge (the UVM env->agent->driver/monitor topology) - UVM factory type_id::create (override-aware) and TLM .connect() dataflow (e.g. monitor -> scoreboard) Engine touch-points are additive and opt-in: - new optional LanguageExtractor.methodScopeKinds gates method-vs-function by enclosing scope; languages that leave it unset are unaffected - name-matcher gains an extends/implements kind-bias toward type-like targets - two SystemVerilog-gated resolution post-passes bind inheritance-aware handle calls and the factory/TLM markers after the class graph exists Tests: 31 cases in __tests__/systemverilog.test.ts covering extraction and cross-file resolution. Vendored grammar: gmlarumbe/tree-sitter-systemverilog (prebuilt wasm, ABI 15).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds SystemVerilog/Verilog as an indexed language (
.sv.svh.v.vh), backed by the gmlarumbe/tree-sitter-systemverilog grammar (vendored as a prebuilt wasm, tree-sitter ABI 15). SystemVerilog is a strict superset of Verilog, so one grammar covers both — including UVM (which is "just" SystemVerilog classes + macros).Goal: make an RTL/UVM codebase navigable with the same
callers/callees/impact/ graph tooling CodeGraph already gives software — the design hierarchy, the class/UVM-component tree, and transaction dataflow.What it indexes
enum+ members)instantiatesandcalls, socallers/callees/impactsurface the RTL tree)extendswith package-qualified base resolution (pkg::Base)externout-of-class bodies (Class::method), and thefunction newconstructorthis./super.calls resolve up theextendschain —super.build_phase()binds to the parent's method, never a false self-edgereferencesedge, soenv → agent → driver/monitoris queryabletype_id::create(override-aware) composition, and.connect()TLM dataflow (e.g.monitor → scoreboard)Engine changes (additive, opt-in)
Most of the work is a self-contained extractor (
src/extraction/languages/systemverilog.ts). The few shared-engine touch-points are no-ops for existing languages:LanguageExtractor.methodScopeKinds(new, optional): gates method-vs-function by enclosing scope. Languages that leave it unset keep their exact prior behavior.extends/implementskind-bias toward type-like targets (a base class should outrank a same-named function).src/resolution/index.ts): bind the inheritance-aware handle calls and the factory/TLM markers after the class graph exists. Gated onlanguage === 'systemverilog'+ a__sv_*marker prefix, so other languages never enter them.Tests
__tests__/systemverilog.test.ts— 31 cases covering extraction and cross-file resolution (the resolved edges, not just extraction): the inheritance chain-walk, composition, factory override, and the TLM dataflow.Notes
src/extraction/wasm/vendoring pattern — happy to move it to git-lfs or a download-on-install step if you'd prefer.Feedback very welcome — glad to split this up, rework the engine touch-points, or adjust anything to fit the project's direction.