hdl-kgraph 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- hdl_kgraph-0.1.0/.github/workflows/ci.yml +51 -0
- hdl_kgraph-0.1.0/.github/workflows/release.yml +41 -0
- hdl_kgraph-0.1.0/.gitignore +21 -0
- hdl_kgraph-0.1.0/CONTRIBUTING.md +38 -0
- hdl_kgraph-0.1.0/LICENSE +21 -0
- hdl_kgraph-0.1.0/PKG-INFO +138 -0
- hdl_kgraph-0.1.0/README.md +99 -0
- hdl_kgraph-0.1.0/ROADMAP.md +350 -0
- hdl_kgraph-0.1.0/docs/grammar-bakeoff.md +49 -0
- hdl_kgraph-0.1.0/docs/releasing.md +76 -0
- hdl_kgraph-0.1.0/pyproject.toml +87 -0
- hdl_kgraph-0.1.0/scripts/grammar_bakeoff.py +158 -0
- hdl_kgraph-0.1.0/src/hdl_kgraph/__init__.py +6 -0
- hdl_kgraph-0.1.0/src/hdl_kgraph/__main__.py +6 -0
- hdl_kgraph-0.1.0/src/hdl_kgraph/cli/__init__.py +1 -0
- hdl_kgraph-0.1.0/src/hdl_kgraph/cli/main.py +224 -0
- hdl_kgraph-0.1.0/src/hdl_kgraph/discovery.py +74 -0
- hdl_kgraph-0.1.0/src/hdl_kgraph/graph/__init__.py +1 -0
- hdl_kgraph-0.1.0/src/hdl_kgraph/graph/analysis.py +145 -0
- hdl_kgraph-0.1.0/src/hdl_kgraph/graph/builder.py +227 -0
- hdl_kgraph-0.1.0/src/hdl_kgraph/ids.py +34 -0
- hdl_kgraph-0.1.0/src/hdl_kgraph/parser/__init__.py +6 -0
- hdl_kgraph-0.1.0/src/hdl_kgraph/parser/base.py +79 -0
- hdl_kgraph-0.1.0/src/hdl_kgraph/parser/filelist.py +13 -0
- hdl_kgraph-0.1.0/src/hdl_kgraph/parser/perl.py +33 -0
- hdl_kgraph-0.1.0/src/hdl_kgraph/parser/preprocessor.py +16 -0
- hdl_kgraph-0.1.0/src/hdl_kgraph/parser/sln.py +31 -0
- hdl_kgraph-0.1.0/src/hdl_kgraph/parser/systemverilog.py +535 -0
- hdl_kgraph-0.1.0/src/hdl_kgraph/parser/tcl.py +60 -0
- hdl_kgraph-0.1.0/src/hdl_kgraph/parser/vhdl.py +33 -0
- hdl_kgraph-0.1.0/src/hdl_kgraph/pipeline.py +111 -0
- hdl_kgraph-0.1.0/src/hdl_kgraph/schema.py +167 -0
- hdl_kgraph-0.1.0/src/hdl_kgraph/storage/__init__.py +1 -0
- hdl_kgraph-0.1.0/src/hdl_kgraph/storage/sqlite_store.py +195 -0
- hdl_kgraph-0.1.0/tests/conftest.py +11 -0
- hdl_kgraph-0.1.0/tests/fixtures/adder.v +12 -0
- hdl_kgraph-0.1.0/tests/fixtures/alu.vhd +28 -0
- hdl_kgraph-0.1.0/tests/fixtures/broken.sv +14 -0
- hdl_kgraph-0.1.0/tests/fixtures/bus_if.sv +15 -0
- hdl_kgraph-0.1.0/tests/fixtures/classes.sv +20 -0
- hdl_kgraph-0.1.0/tests/fixtures/constraints.sdc +9 -0
- hdl_kgraph-0.1.0/tests/fixtures/count_scenario.sln +14 -0
- hdl_kgraph-0.1.0/tests/fixtures/dup_leaf_a.sv +7 -0
- hdl_kgraph-0.1.0/tests/fixtures/dup_leaf_b.sv +7 -0
- hdl_kgraph-0.1.0/tests/fixtures/ext_uvm.sv +8 -0
- hdl_kgraph-0.1.0/tests/fixtures/flow.tcl +9 -0
- hdl_kgraph-0.1.0/tests/fixtures/funcs_tasks.sv +18 -0
- hdl_kgraph-0.1.0/tests/fixtures/gen_fifo.pl +21 -0
- hdl_kgraph-0.1.0/tests/fixtures/imports_pkg.sv +19 -0
- hdl_kgraph-0.1.0/tests/fixtures/missing_child.sv +12 -0
- hdl_kgraph-0.1.0/tests/fixtures/my_pkg.sv +24 -0
- hdl_kgraph-0.1.0/tests/fixtures/power.upf +11 -0
- hdl_kgraph-0.1.0/tests/fixtures/prog_block.sv +10 -0
- hdl_kgraph-0.1.0/tests/fixtures/simple_counter.sv +16 -0
- hdl_kgraph-0.1.0/tests/fixtures/top.v +17 -0
- hdl_kgraph-0.1.0/tests/fixtures/top_positional.v +11 -0
- hdl_kgraph-0.1.0/tests/fixtures/uses_dup.sv +12 -0
- hdl_kgraph-0.1.0/tests/fixtures/uses_interface.sv +16 -0
- hdl_kgraph-0.1.0/tests/fixtures/wildcard_conn.sv +18 -0
- hdl_kgraph-0.1.0/tests/test_cli.py +134 -0
- hdl_kgraph-0.1.0/tests/test_discovery.py +65 -0
- hdl_kgraph-0.1.0/tests/test_ids.py +26 -0
- hdl_kgraph-0.1.0/tests/test_linker.py +170 -0
- hdl_kgraph-0.1.0/tests/test_parser_sv.py +207 -0
- hdl_kgraph-0.1.0/tests/test_parsers.py +45 -0
- hdl_kgraph-0.1.0/tests/test_schema.py +171 -0
- hdl_kgraph-0.1.0/tests/test_store.py +112 -0
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
|
|
8
|
+
concurrency:
|
|
9
|
+
group: ${{ github.workflow }}-${{ github.ref }}
|
|
10
|
+
cancel-in-progress: true
|
|
11
|
+
|
|
12
|
+
permissions:
|
|
13
|
+
contents: read
|
|
14
|
+
|
|
15
|
+
jobs:
|
|
16
|
+
lint:
|
|
17
|
+
runs-on: ubuntu-latest
|
|
18
|
+
steps:
|
|
19
|
+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
|
20
|
+
with:
|
|
21
|
+
persist-credentials: false
|
|
22
|
+
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
|
|
23
|
+
with:
|
|
24
|
+
python-version: "3.12"
|
|
25
|
+
cache: pip
|
|
26
|
+
- run: pip install -e .[dev]
|
|
27
|
+
- run: ruff check .
|
|
28
|
+
- run: ruff format --check .
|
|
29
|
+
- run: mypy
|
|
30
|
+
|
|
31
|
+
test:
|
|
32
|
+
runs-on: ${{ matrix.os }}
|
|
33
|
+
strategy:
|
|
34
|
+
fail-fast: false
|
|
35
|
+
matrix:
|
|
36
|
+
os: [ubuntu-latest]
|
|
37
|
+
python-version: ["3.10", "3.11", "3.12", "3.13"]
|
|
38
|
+
# One macOS/Windows run to catch grammar-wheel platform gaps cheaply.
|
|
39
|
+
include:
|
|
40
|
+
- { os: macos-latest, python-version: "3.12" }
|
|
41
|
+
- { os: windows-latest, python-version: "3.12" }
|
|
42
|
+
steps:
|
|
43
|
+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
|
44
|
+
with:
|
|
45
|
+
persist-credentials: false
|
|
46
|
+
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
|
|
47
|
+
with:
|
|
48
|
+
python-version: ${{ matrix.python-version }}
|
|
49
|
+
cache: pip
|
|
50
|
+
- run: pip install -e .[dev]
|
|
51
|
+
- run: pytest --cov=hdl_kgraph
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
name: Release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- "v*"
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
contents: read
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
build:
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
|
16
|
+
with:
|
|
17
|
+
persist-credentials: false
|
|
18
|
+
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
|
|
19
|
+
with:
|
|
20
|
+
python-version: "3.12"
|
|
21
|
+
- run: python -m pip install build
|
|
22
|
+
- run: python -m build
|
|
23
|
+
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
|
24
|
+
with:
|
|
25
|
+
name: dist
|
|
26
|
+
path: dist/
|
|
27
|
+
|
|
28
|
+
publish:
|
|
29
|
+
needs: build
|
|
30
|
+
runs-on: ubuntu-latest
|
|
31
|
+
environment:
|
|
32
|
+
name: pypi
|
|
33
|
+
url: https://pypi.org/p/hdl-kgraph
|
|
34
|
+
permissions:
|
|
35
|
+
id-token: write # required for PyPI trusted publishing (OIDC)
|
|
36
|
+
steps:
|
|
37
|
+
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
|
38
|
+
with:
|
|
39
|
+
name: dist
|
|
40
|
+
path: dist/
|
|
41
|
+
- uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc # v1.12.4
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*.egg-info/
|
|
5
|
+
dist/
|
|
6
|
+
build/
|
|
7
|
+
.venv/
|
|
8
|
+
venv/
|
|
9
|
+
|
|
10
|
+
# Tooling caches
|
|
11
|
+
.pytest_cache/
|
|
12
|
+
.ruff_cache/
|
|
13
|
+
.mypy_cache/
|
|
14
|
+
.coverage
|
|
15
|
+
coverage.xml
|
|
16
|
+
htmlcov/
|
|
17
|
+
|
|
18
|
+
# hdl-kgraph artifacts
|
|
19
|
+
.hdl-kgraph/
|
|
20
|
+
*.db
|
|
21
|
+
*.sqlite3
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# Contributing to hdl-kgraph
|
|
2
|
+
|
|
3
|
+
Thanks for your interest! The project is pre-alpha — see
|
|
4
|
+
[ROADMAP.md](ROADMAP.md) for what's planned and where help is most valuable.
|
|
5
|
+
|
|
6
|
+
## Dev setup
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
git clone https://github.com/chuanseng-ng/hdl-kgraph
|
|
10
|
+
cd hdl-kgraph
|
|
11
|
+
pip install -e .[dev]
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Before pushing:
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
ruff check . && ruff format --check . && mypy && pytest
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
CI runs the same checks on Python 3.10–3.13.
|
|
21
|
+
|
|
22
|
+
## The most valuable contribution: fixtures
|
|
23
|
+
|
|
24
|
+
HDL parsing lives and dies by real-world edge cases. If hdl-kgraph
|
|
25
|
+
mis-extracts (or chokes on) your code, please open an issue with the
|
|
26
|
+
**smallest self-contained HDL file that reproduces it** — strip proprietary
|
|
27
|
+
content, keep the construct. Accepted reproductions land in `tests/fixtures/`
|
|
28
|
+
and become permanent regression tests.
|
|
29
|
+
|
|
30
|
+
## Code conventions
|
|
31
|
+
|
|
32
|
+
- The graph schema (`src/hdl_kgraph/schema.py`) is the project's contract.
|
|
33
|
+
Extending it (new node/edge kinds) is fine; changing existing meanings needs
|
|
34
|
+
discussion in an issue first.
|
|
35
|
+
- Parsers are pass-1 only: per-file extraction, no cross-file resolution.
|
|
36
|
+
Cross-file logic belongs in the pass-2 linker (`graph/builder.py`).
|
|
37
|
+
- Every cross-file edge gets a confidence score per the convention in
|
|
38
|
+
`schema.py`.
|
hdl_kgraph-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Ng Chuan Seng
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: hdl-kgraph
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Knowledge graph extractor for SystemVerilog, Verilog, and VHDL
|
|
5
|
+
Project-URL: Homepage, https://github.com/chuanseng-ng/hdl-kgraph
|
|
6
|
+
Project-URL: Issues, https://github.com/chuanseng-ng/hdl-kgraph/issues
|
|
7
|
+
Project-URL: Roadmap, https://github.com/chuanseng-ng/hdl-kgraph/blob/main/ROADMAP.md
|
|
8
|
+
Author: Ng Chuan Seng
|
|
9
|
+
License-Expression: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: eda,hdl,knowledge-graph,systemverilog,tree-sitter,verilog,vhdl
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
19
|
+
Classifier: Topic :: Scientific/Engineering :: Electronic Design Automation (EDA)
|
|
20
|
+
Classifier: Topic :: Software Development :: Compilers
|
|
21
|
+
Requires-Python: >=3.10
|
|
22
|
+
Requires-Dist: click>=8.1
|
|
23
|
+
Requires-Dist: networkx>=3.0
|
|
24
|
+
Requires-Dist: tree-sitter-systemverilog>=0.3.1
|
|
25
|
+
Requires-Dist: tree-sitter>=0.23
|
|
26
|
+
Provides-Extra: all
|
|
27
|
+
Requires-Dist: fastmcp>=2; extra == 'all'
|
|
28
|
+
Requires-Dist: watchdog>=4; extra == 'all'
|
|
29
|
+
Provides-Extra: dev
|
|
30
|
+
Requires-Dist: mypy>=1.10; extra == 'dev'
|
|
31
|
+
Requires-Dist: pytest-cov; extra == 'dev'
|
|
32
|
+
Requires-Dist: pytest>=8; extra == 'dev'
|
|
33
|
+
Requires-Dist: ruff>=0.6; extra == 'dev'
|
|
34
|
+
Provides-Extra: mcp
|
|
35
|
+
Requires-Dist: fastmcp>=2; extra == 'mcp'
|
|
36
|
+
Provides-Extra: watch
|
|
37
|
+
Requires-Dist: watchdog>=4; extra == 'watch'
|
|
38
|
+
Description-Content-Type: text/markdown
|
|
39
|
+
|
|
40
|
+
# hdl-kgraph
|
|
41
|
+
|
|
42
|
+
[](https://github.com/chuanseng-ng/hdl-kgraph/actions/workflows/ci.yml)
|
|
43
|
+
|
|
44
|
+
**A knowledge graph for your HDL design.** hdl-kgraph parses SystemVerilog,
|
|
45
|
+
Verilog, and VHDL sources and builds a queryable graph of modules, entities,
|
|
46
|
+
instances, ports, parameters, signals, classes, packages, and the
|
|
47
|
+
relationships between them — design hierarchy, port connectivity, package
|
|
48
|
+
imports, class inheritance, clock domains, and more.
|
|
49
|
+
|
|
50
|
+
> **Status: alpha (v0.1).** SystemVerilog/Verilog structural extraction, the
|
|
51
|
+
> pass-2 linker, SQLite persistence, and the `build`/`status`/`query`/`tree`
|
|
52
|
+
> CLI are in. The preprocessor and filelists land in M2, VHDL in M3. See
|
|
53
|
+
> [ROADMAP.md](ROADMAP.md).
|
|
54
|
+
|
|
55
|
+
## Why
|
|
56
|
+
|
|
57
|
+
HDL codebases are graphs — hierarchy, connectivity, clock domains — but the
|
|
58
|
+
tools that understand them are locked inside simulators and synthesis flows.
|
|
59
|
+
hdl-kgraph extracts that structure into a local-first SQLite database you can
|
|
60
|
+
query from the CLI, scripts, or (later) AI assistants via MCP. The
|
|
61
|
+
architecture follows
|
|
62
|
+
[code-review-graph](https://github.com/tirth8205/code-review-graph), adapted
|
|
63
|
+
for hardware.
|
|
64
|
+
|
|
65
|
+
## Quickstart
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
pip install hdl-kgraph
|
|
69
|
+
|
|
70
|
+
hdl-kgraph build ./rtl # parse sources -> ./rtl/.hdl-kgraph/graph.db
|
|
71
|
+
hdl-kgraph status # files, parse errors, node/edge counts
|
|
72
|
+
hdl-kgraph tree soc_top # print the design hierarchy from a top module
|
|
73
|
+
hdl-kgraph query instances-of fifo
|
|
74
|
+
hdl-kgraph query unresolved # what couldn't be resolved (vendor IP, macros)
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
`build` accepts `--exclude GLOB` (repeatable) and `--max-file-size KB` to keep
|
|
78
|
+
generated netlists and vendored IP out of the graph. Files with syntax errors
|
|
79
|
+
still yield partial results; `status` reports the parse-error count.
|
|
80
|
+
Unresolved instance targets render as `[?]` in `tree` and ambiguous matches as
|
|
81
|
+
`[~0.6]` — see the confidence convention in [ROADMAP.md](ROADMAP.md).
|
|
82
|
+
|
|
83
|
+
Coming next:
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
hdl-kgraph build -f sim/tb.f # drive the build from a filelist (M2)
|
|
87
|
+
hdl-kgraph impact rtl/uart_tx.sv # what does my change affect? (M4)
|
|
88
|
+
hdl-kgraph visualize # interactive HTML graph (M5)
|
|
89
|
+
hdl-kgraph serve --mcp # MCP server for AI assistants (M6)
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## What gets extracted
|
|
93
|
+
|
|
94
|
+
- **Design units:** modules, interfaces/modports, packages, programs,
|
|
95
|
+
checkers, UDPs; VHDL entities, architectures, packages, configurations
|
|
96
|
+
- **Structure:** instances with port connections and parameter overrides,
|
|
97
|
+
generate blocks, `include`/`define` relationships, filelists
|
|
98
|
+
- **Verification:** SV classes (UVM hierarchies via inheritance chains),
|
|
99
|
+
constraints, covergroups, assertions/properties/sequences, clocking blocks
|
|
100
|
+
- **Dataflow (M5):** signal drivers/readers, clock and reset trees,
|
|
101
|
+
CDC-suspect crossings
|
|
102
|
+
|
|
103
|
+
Every cross-file edge carries a confidence score (resolved → heuristic), so
|
|
104
|
+
the graph is honest about what was proven syntactically vs inferred by name
|
|
105
|
+
matching. The full schema is documented in [ROADMAP.md](ROADMAP.md).
|
|
106
|
+
|
|
107
|
+
## Roadmap at a glance
|
|
108
|
+
|
|
109
|
+
| Milestone | Theme |
|
|
110
|
+
|---|---|
|
|
111
|
+
| M1 (v0.1) | SystemVerilog/Verilog structural graph + CLI |
|
|
112
|
+
| M2 (v0.2) | Preprocessor, `.f` filelists, includes |
|
|
113
|
+
| M3 (v0.3) | VHDL + mixed-language linking |
|
|
114
|
+
| M4 (v0.4) | Incremental updates, watch mode, impact analysis |
|
|
115
|
+
| M5 (v0.5) | Clock/reset/CDC analyses, lint checks, visualization |
|
|
116
|
+
| M6 (v0.6) | MCP server for AI assistants |
|
|
117
|
+
| M7 (v0.7) | Semantic enrichment (pyslang, GHDL) |
|
|
118
|
+
| M8 (v1.0) | C/C++/Python boundary (DPI-C, cocotb), stable API |
|
|
119
|
+
| M9 (v1.x) | Chisel/FIRRTL, Amaranth, SpinalHDL |
|
|
120
|
+
| M10 (v1.x) | Tcl/SDC/UPF constraints, Perl scripting, SLN portable stimulus |
|
|
121
|
+
|
|
122
|
+
Details and acceptance criteria: [ROADMAP.md](ROADMAP.md).
|
|
123
|
+
|
|
124
|
+
## Development
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
git clone https://github.com/chuanseng-ng/hdl-kgraph
|
|
128
|
+
cd hdl-kgraph
|
|
129
|
+
pip install -e .[dev]
|
|
130
|
+
ruff check . && ruff format --check . && mypy && pytest
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md). The single most useful contribution
|
|
134
|
+
right now: the smallest HDL file that breaks extraction.
|
|
135
|
+
|
|
136
|
+
## License
|
|
137
|
+
|
|
138
|
+
[MIT](LICENSE)
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# hdl-kgraph
|
|
2
|
+
|
|
3
|
+
[](https://github.com/chuanseng-ng/hdl-kgraph/actions/workflows/ci.yml)
|
|
4
|
+
|
|
5
|
+
**A knowledge graph for your HDL design.** hdl-kgraph parses SystemVerilog,
|
|
6
|
+
Verilog, and VHDL sources and builds a queryable graph of modules, entities,
|
|
7
|
+
instances, ports, parameters, signals, classes, packages, and the
|
|
8
|
+
relationships between them — design hierarchy, port connectivity, package
|
|
9
|
+
imports, class inheritance, clock domains, and more.
|
|
10
|
+
|
|
11
|
+
> **Status: alpha (v0.1).** SystemVerilog/Verilog structural extraction, the
|
|
12
|
+
> pass-2 linker, SQLite persistence, and the `build`/`status`/`query`/`tree`
|
|
13
|
+
> CLI are in. The preprocessor and filelists land in M2, VHDL in M3. See
|
|
14
|
+
> [ROADMAP.md](ROADMAP.md).
|
|
15
|
+
|
|
16
|
+
## Why
|
|
17
|
+
|
|
18
|
+
HDL codebases are graphs — hierarchy, connectivity, clock domains — but the
|
|
19
|
+
tools that understand them are locked inside simulators and synthesis flows.
|
|
20
|
+
hdl-kgraph extracts that structure into a local-first SQLite database you can
|
|
21
|
+
query from the CLI, scripts, or (later) AI assistants via MCP. The
|
|
22
|
+
architecture follows
|
|
23
|
+
[code-review-graph](https://github.com/tirth8205/code-review-graph), adapted
|
|
24
|
+
for hardware.
|
|
25
|
+
|
|
26
|
+
## Quickstart
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
pip install hdl-kgraph
|
|
30
|
+
|
|
31
|
+
hdl-kgraph build ./rtl # parse sources -> ./rtl/.hdl-kgraph/graph.db
|
|
32
|
+
hdl-kgraph status # files, parse errors, node/edge counts
|
|
33
|
+
hdl-kgraph tree soc_top # print the design hierarchy from a top module
|
|
34
|
+
hdl-kgraph query instances-of fifo
|
|
35
|
+
hdl-kgraph query unresolved # what couldn't be resolved (vendor IP, macros)
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
`build` accepts `--exclude GLOB` (repeatable) and `--max-file-size KB` to keep
|
|
39
|
+
generated netlists and vendored IP out of the graph. Files with syntax errors
|
|
40
|
+
still yield partial results; `status` reports the parse-error count.
|
|
41
|
+
Unresolved instance targets render as `[?]` in `tree` and ambiguous matches as
|
|
42
|
+
`[~0.6]` — see the confidence convention in [ROADMAP.md](ROADMAP.md).
|
|
43
|
+
|
|
44
|
+
Coming next:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
hdl-kgraph build -f sim/tb.f # drive the build from a filelist (M2)
|
|
48
|
+
hdl-kgraph impact rtl/uart_tx.sv # what does my change affect? (M4)
|
|
49
|
+
hdl-kgraph visualize # interactive HTML graph (M5)
|
|
50
|
+
hdl-kgraph serve --mcp # MCP server for AI assistants (M6)
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## What gets extracted
|
|
54
|
+
|
|
55
|
+
- **Design units:** modules, interfaces/modports, packages, programs,
|
|
56
|
+
checkers, UDPs; VHDL entities, architectures, packages, configurations
|
|
57
|
+
- **Structure:** instances with port connections and parameter overrides,
|
|
58
|
+
generate blocks, `include`/`define` relationships, filelists
|
|
59
|
+
- **Verification:** SV classes (UVM hierarchies via inheritance chains),
|
|
60
|
+
constraints, covergroups, assertions/properties/sequences, clocking blocks
|
|
61
|
+
- **Dataflow (M5):** signal drivers/readers, clock and reset trees,
|
|
62
|
+
CDC-suspect crossings
|
|
63
|
+
|
|
64
|
+
Every cross-file edge carries a confidence score (resolved → heuristic), so
|
|
65
|
+
the graph is honest about what was proven syntactically vs inferred by name
|
|
66
|
+
matching. The full schema is documented in [ROADMAP.md](ROADMAP.md).
|
|
67
|
+
|
|
68
|
+
## Roadmap at a glance
|
|
69
|
+
|
|
70
|
+
| Milestone | Theme |
|
|
71
|
+
|---|---|
|
|
72
|
+
| M1 (v0.1) | SystemVerilog/Verilog structural graph + CLI |
|
|
73
|
+
| M2 (v0.2) | Preprocessor, `.f` filelists, includes |
|
|
74
|
+
| M3 (v0.3) | VHDL + mixed-language linking |
|
|
75
|
+
| M4 (v0.4) | Incremental updates, watch mode, impact analysis |
|
|
76
|
+
| M5 (v0.5) | Clock/reset/CDC analyses, lint checks, visualization |
|
|
77
|
+
| M6 (v0.6) | MCP server for AI assistants |
|
|
78
|
+
| M7 (v0.7) | Semantic enrichment (pyslang, GHDL) |
|
|
79
|
+
| M8 (v1.0) | C/C++/Python boundary (DPI-C, cocotb), stable API |
|
|
80
|
+
| M9 (v1.x) | Chisel/FIRRTL, Amaranth, SpinalHDL |
|
|
81
|
+
| M10 (v1.x) | Tcl/SDC/UPF constraints, Perl scripting, SLN portable stimulus |
|
|
82
|
+
|
|
83
|
+
Details and acceptance criteria: [ROADMAP.md](ROADMAP.md).
|
|
84
|
+
|
|
85
|
+
## Development
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
git clone https://github.com/chuanseng-ng/hdl-kgraph
|
|
89
|
+
cd hdl-kgraph
|
|
90
|
+
pip install -e .[dev]
|
|
91
|
+
ruff check . && ruff format --check . && mypy && pytest
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md). The single most useful contribution
|
|
95
|
+
right now: the smallest HDL file that breaks extraction.
|
|
96
|
+
|
|
97
|
+
## License
|
|
98
|
+
|
|
99
|
+
[MIT](LICENSE)
|