rtl-aid 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.
rtl_aid-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Vishwaksen Reddy Dhareddy
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.
rtl_aid-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,263 @@
1
+ Metadata-Version: 2.4
2
+ Name: rtl-aid
3
+ Version: 0.1.0
4
+ Summary: CI-native documentation layer for RTL projects
5
+ Author: vishwaksen-1
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/vishwaksen-1/rtl-aid
8
+ Project-URL: Issues, https://github.com/vishwaksen-1/rtl-aid/issues
9
+ Keywords: verilog,systemverilog,rtl,fpga,asic,eda,documentation,linting,ci,hardware,verilator,dependency-graph,code-analysis,agentic
10
+ Requires-Python: >=3.7
11
+ Description-Content-Type: text/markdown
12
+ License-File: LICENSE
13
+ Dynamic: license-file
14
+
15
+ # rtl-aid
16
+
17
+ CI-native documentation layer for RTL projects.
18
+
19
+ Parses Verilog/SystemVerilog source files, extracts module structure, and generates Markdown documentation that stays in sync with your RTL — automatically.
20
+
21
+ ---
22
+
23
+ ## Tools
24
+
25
+ | Command | Purpose |
26
+ |---------|---------|
27
+ | `rtldoc` | Generate and maintain module documentation |
28
+ | `rtllint` | Run verilator lint and tag warnings inline in source |
29
+
30
+ ---
31
+
32
+ ## Installation
33
+
34
+ ```bash
35
+ pip install rtl-aid
36
+ ```
37
+
38
+ Or from source:
39
+
40
+ ```bash
41
+ git clone https://github.com/vishwaksen-1/rtl-aid
42
+ cd rtl-aid
43
+ pip install -e .
44
+ ```
45
+
46
+ **Requirements**
47
+
48
+ - Python 3.7+
49
+ - `rtllint` requires [verilator](https://verilator.org) — a system binary, not installable via pip:
50
+
51
+ ```bash
52
+ # Debian / Ubuntu
53
+ sudo apt install verilator
54
+
55
+ # macOS
56
+ brew install verilator
57
+ ```
58
+
59
+ `rtldoc` has no external dependencies. If verilator is missing, `rtllint` will exit with a clear error and install instructions.
60
+
61
+ ---
62
+
63
+ ## rtldoc
64
+
65
+ ### Quick start
66
+
67
+ ```bash
68
+ # Document all modules in a directory
69
+ rtldoc -d rtl/
70
+
71
+ # Document specific files
72
+ rtldoc -f rtl/core/alu.v rtl/core/decoder.v
73
+
74
+ # Custom output directory
75
+ rtldoc -d rtl/ -o docs/modules/
76
+ ```
77
+
78
+ ### What gets generated
79
+
80
+ For each module, a Markdown file is created or updated:
81
+
82
+ ```markdown
83
+ # alu
84
+
85
+ ## Description
86
+ TODO: Add description
87
+
88
+ ## Parameters
89
+ - DATA_WIDTH = 8
90
+ - OP_WIDTH = 4
91
+
92
+ ## Inputs
93
+ - clk
94
+ - rst
95
+ - op
96
+ - operand_a
97
+ - operand_b
98
+
99
+ ## Outputs
100
+ - result
101
+ - overflow
102
+
103
+ ## Calls
104
+ - [mux4](mux4.md)
105
+
106
+ ## Called By
107
+ - [cpu_core](cpu_core.md)
108
+ ```
109
+
110
+ The `Description` section is **never overwritten** — you write it once, rtldoc preserves it on every run. All other sections are auto-managed.
111
+
112
+ ### CLI reference
113
+
114
+ ```
115
+ rtldoc (-d DIR [DIR...] | -f FILE [FILE...]) [options]
116
+
117
+ Input:
118
+ -d, --dir DIR [DIR...] Recursively scan directories for .v / .sv files
119
+ -f, --file FILE [FILE...] Parse specific files (no directory traversal)
120
+
121
+ Output:
122
+ -o, --out OUT_DIR Output directory (default: temp/docs/modules)
123
+ --json-graph Write dependency graph to graph.json
124
+
125
+ Filtering:
126
+ --exclude PATTERN [...] Exclude paths containing any of these strings
127
+
128
+ Run modes:
129
+ --dry-run Show what would be written without touching files
130
+ --ci Fail (exit 1) on missing descriptions, no-IO modules,
131
+ or self-instantiations
132
+ --print-errors Print CI issues to stdout (in addition to the error log)
133
+
134
+ Verbosity:
135
+ -v Print modified file paths
136
+ -vv Print modified files + section-level diffs (+adds/-removals)
137
+ ```
138
+
139
+ ### CI integration
140
+
141
+ ```yaml
142
+ # .github/workflows/docs.yml
143
+ - name: Check RTL docs
144
+ run: rtldoc -d rtl/ -o docs/modules/ --ci --print-errors
145
+ ```
146
+
147
+ Exit codes: `0` = clean, `1` = CI check failed.
148
+
149
+ Testbench files (`_tb.v`, `_tb.sv`, `_bench.v`, `_testbench.v`, and `.sv` variants) are automatically excluded from scanning.
150
+
151
+ ### Dry run
152
+
153
+ Preview what would change before committing:
154
+
155
+ ```bash
156
+ rtldoc -d rtl/ --dry-run
157
+ ```
158
+
159
+ ```
160
+ [DRY RUN] Would write:
161
+ docs/modules/alu.md
162
+ docs/modules/decoder.md
163
+
164
+ 5 module(s) processed — 2 doc(s) would be written, 3 unchanged
165
+ ```
166
+
167
+ ### Dependency graph
168
+
169
+ ```bash
170
+ rtldoc -d rtl/ --json-graph -o docs/modules/
171
+ ```
172
+
173
+ Writes `docs/modules/graph.json`:
174
+
175
+ ```json
176
+ {
177
+ "cpu_core": {
178
+ "calls": ["alu", "decoder", "register_file"],
179
+ "called_by": []
180
+ },
181
+ "alu": {
182
+ "calls": ["mux4"],
183
+ "called_by": ["cpu_core"]
184
+ }
185
+ }
186
+ ```
187
+
188
+ ---
189
+
190
+ ## rtllint
191
+
192
+ Runs `verilator --lint-only -Wall` on a file and tags each warned line with an inline comment. Useful for tracking lint debt without blocking a build.
193
+
194
+ ### Usage
195
+
196
+ ```bash
197
+ rtllint rtl/core/alu.v
198
+
199
+ # With include directories
200
+ rtllint -I rtl/includes -I rtl/common rtl/core/alu.v
201
+
202
+ # Multiple files
203
+ rtllint rtl/core/*.v
204
+
205
+ # Preview without modifying files
206
+ rtllint --dry-run rtl/core/alu.v
207
+ ```
208
+
209
+ ### What gets written
210
+
211
+ Given a verilator warning on line 75:
212
+
213
+ ```
214
+ %Warning-WIDTHEXPAND: rtl/alu.v:75:12: Operator ADD generates 9 bits ...
215
+ ```
216
+
217
+ rtllint modifies `alu.v` in place:
218
+
219
+ ```verilog
220
+ // lint-test: verilator --lint-only -Wall rtl/alu.v
221
+ // tb-test: tba
222
+ ...
223
+ assign result = a + b; /* Check: Operator ADD generates 9 bits ... */
224
+ ```
225
+
226
+ Re-running rtllint replaces existing `/* Check: */` tags — it does not stack duplicates.
227
+
228
+ ### CLI reference
229
+
230
+ ```
231
+ rtllint FILE [FILE...] [options]
232
+
233
+ -I, --include DIR Add include directory (repeatable)
234
+ --dry-run Show issues without modifying files
235
+ -v Print full verilator output
236
+ ```
237
+
238
+ Exit codes: `0` = no issues found, `1` = one or more warnings/errors.
239
+
240
+ ---
241
+
242
+ ## Design principles
243
+
244
+ - **No heavy dependencies** — stdlib only, no parser frameworks
245
+ - **CI-first** — every flag is designed for scripted use
246
+ - **Safe for teams** — manual descriptions are never overwritten
247
+ - **Diff-aware** — files are only touched when content actually changes
248
+
249
+ ---
250
+
251
+ ## Supported syntax
252
+
253
+ | Feature | Status |
254
+ |---------|--------|
255
+ | Verilog-2001 (`.v`) | Supported |
256
+ | SystemVerilog (`.sv`) | Supported (port/param parsing) |
257
+ | ANSI port declarations | Supported |
258
+ | Comma-inherited port direction (`output reg a, b`) | Supported |
259
+ | Parameterised modules (`#(parameter ...)`) | Supported |
260
+ | Module instantiations with `#()` param override | Supported |
261
+ | Testbench auto-exclusion | Supported |
262
+ | Pre-2001 Verilog style | Not supported |
263
+ | Multi-module files | Not supported (first module only) |
@@ -0,0 +1,249 @@
1
+ # rtl-aid
2
+
3
+ CI-native documentation layer for RTL projects.
4
+
5
+ Parses Verilog/SystemVerilog source files, extracts module structure, and generates Markdown documentation that stays in sync with your RTL — automatically.
6
+
7
+ ---
8
+
9
+ ## Tools
10
+
11
+ | Command | Purpose |
12
+ |---------|---------|
13
+ | `rtldoc` | Generate and maintain module documentation |
14
+ | `rtllint` | Run verilator lint and tag warnings inline in source |
15
+
16
+ ---
17
+
18
+ ## Installation
19
+
20
+ ```bash
21
+ pip install rtl-aid
22
+ ```
23
+
24
+ Or from source:
25
+
26
+ ```bash
27
+ git clone https://github.com/vishwaksen-1/rtl-aid
28
+ cd rtl-aid
29
+ pip install -e .
30
+ ```
31
+
32
+ **Requirements**
33
+
34
+ - Python 3.7+
35
+ - `rtllint` requires [verilator](https://verilator.org) — a system binary, not installable via pip:
36
+
37
+ ```bash
38
+ # Debian / Ubuntu
39
+ sudo apt install verilator
40
+
41
+ # macOS
42
+ brew install verilator
43
+ ```
44
+
45
+ `rtldoc` has no external dependencies. If verilator is missing, `rtllint` will exit with a clear error and install instructions.
46
+
47
+ ---
48
+
49
+ ## rtldoc
50
+
51
+ ### Quick start
52
+
53
+ ```bash
54
+ # Document all modules in a directory
55
+ rtldoc -d rtl/
56
+
57
+ # Document specific files
58
+ rtldoc -f rtl/core/alu.v rtl/core/decoder.v
59
+
60
+ # Custom output directory
61
+ rtldoc -d rtl/ -o docs/modules/
62
+ ```
63
+
64
+ ### What gets generated
65
+
66
+ For each module, a Markdown file is created or updated:
67
+
68
+ ```markdown
69
+ # alu
70
+
71
+ ## Description
72
+ TODO: Add description
73
+
74
+ ## Parameters
75
+ - DATA_WIDTH = 8
76
+ - OP_WIDTH = 4
77
+
78
+ ## Inputs
79
+ - clk
80
+ - rst
81
+ - op
82
+ - operand_a
83
+ - operand_b
84
+
85
+ ## Outputs
86
+ - result
87
+ - overflow
88
+
89
+ ## Calls
90
+ - [mux4](mux4.md)
91
+
92
+ ## Called By
93
+ - [cpu_core](cpu_core.md)
94
+ ```
95
+
96
+ The `Description` section is **never overwritten** — you write it once, rtldoc preserves it on every run. All other sections are auto-managed.
97
+
98
+ ### CLI reference
99
+
100
+ ```
101
+ rtldoc (-d DIR [DIR...] | -f FILE [FILE...]) [options]
102
+
103
+ Input:
104
+ -d, --dir DIR [DIR...] Recursively scan directories for .v / .sv files
105
+ -f, --file FILE [FILE...] Parse specific files (no directory traversal)
106
+
107
+ Output:
108
+ -o, --out OUT_DIR Output directory (default: temp/docs/modules)
109
+ --json-graph Write dependency graph to graph.json
110
+
111
+ Filtering:
112
+ --exclude PATTERN [...] Exclude paths containing any of these strings
113
+
114
+ Run modes:
115
+ --dry-run Show what would be written without touching files
116
+ --ci Fail (exit 1) on missing descriptions, no-IO modules,
117
+ or self-instantiations
118
+ --print-errors Print CI issues to stdout (in addition to the error log)
119
+
120
+ Verbosity:
121
+ -v Print modified file paths
122
+ -vv Print modified files + section-level diffs (+adds/-removals)
123
+ ```
124
+
125
+ ### CI integration
126
+
127
+ ```yaml
128
+ # .github/workflows/docs.yml
129
+ - name: Check RTL docs
130
+ run: rtldoc -d rtl/ -o docs/modules/ --ci --print-errors
131
+ ```
132
+
133
+ Exit codes: `0` = clean, `1` = CI check failed.
134
+
135
+ Testbench files (`_tb.v`, `_tb.sv`, `_bench.v`, `_testbench.v`, and `.sv` variants) are automatically excluded from scanning.
136
+
137
+ ### Dry run
138
+
139
+ Preview what would change before committing:
140
+
141
+ ```bash
142
+ rtldoc -d rtl/ --dry-run
143
+ ```
144
+
145
+ ```
146
+ [DRY RUN] Would write:
147
+ docs/modules/alu.md
148
+ docs/modules/decoder.md
149
+
150
+ 5 module(s) processed — 2 doc(s) would be written, 3 unchanged
151
+ ```
152
+
153
+ ### Dependency graph
154
+
155
+ ```bash
156
+ rtldoc -d rtl/ --json-graph -o docs/modules/
157
+ ```
158
+
159
+ Writes `docs/modules/graph.json`:
160
+
161
+ ```json
162
+ {
163
+ "cpu_core": {
164
+ "calls": ["alu", "decoder", "register_file"],
165
+ "called_by": []
166
+ },
167
+ "alu": {
168
+ "calls": ["mux4"],
169
+ "called_by": ["cpu_core"]
170
+ }
171
+ }
172
+ ```
173
+
174
+ ---
175
+
176
+ ## rtllint
177
+
178
+ Runs `verilator --lint-only -Wall` on a file and tags each warned line with an inline comment. Useful for tracking lint debt without blocking a build.
179
+
180
+ ### Usage
181
+
182
+ ```bash
183
+ rtllint rtl/core/alu.v
184
+
185
+ # With include directories
186
+ rtllint -I rtl/includes -I rtl/common rtl/core/alu.v
187
+
188
+ # Multiple files
189
+ rtllint rtl/core/*.v
190
+
191
+ # Preview without modifying files
192
+ rtllint --dry-run rtl/core/alu.v
193
+ ```
194
+
195
+ ### What gets written
196
+
197
+ Given a verilator warning on line 75:
198
+
199
+ ```
200
+ %Warning-WIDTHEXPAND: rtl/alu.v:75:12: Operator ADD generates 9 bits ...
201
+ ```
202
+
203
+ rtllint modifies `alu.v` in place:
204
+
205
+ ```verilog
206
+ // lint-test: verilator --lint-only -Wall rtl/alu.v
207
+ // tb-test: tba
208
+ ...
209
+ assign result = a + b; /* Check: Operator ADD generates 9 bits ... */
210
+ ```
211
+
212
+ Re-running rtllint replaces existing `/* Check: */` tags — it does not stack duplicates.
213
+
214
+ ### CLI reference
215
+
216
+ ```
217
+ rtllint FILE [FILE...] [options]
218
+
219
+ -I, --include DIR Add include directory (repeatable)
220
+ --dry-run Show issues without modifying files
221
+ -v Print full verilator output
222
+ ```
223
+
224
+ Exit codes: `0` = no issues found, `1` = one or more warnings/errors.
225
+
226
+ ---
227
+
228
+ ## Design principles
229
+
230
+ - **No heavy dependencies** — stdlib only, no parser frameworks
231
+ - **CI-first** — every flag is designed for scripted use
232
+ - **Safe for teams** — manual descriptions are never overwritten
233
+ - **Diff-aware** — files are only touched when content actually changes
234
+
235
+ ---
236
+
237
+ ## Supported syntax
238
+
239
+ | Feature | Status |
240
+ |---------|--------|
241
+ | Verilog-2001 (`.v`) | Supported |
242
+ | SystemVerilog (`.sv`) | Supported (port/param parsing) |
243
+ | ANSI port declarations | Supported |
244
+ | Comma-inherited port direction (`output reg a, b`) | Supported |
245
+ | Parameterised modules (`#(parameter ...)`) | Supported |
246
+ | Module instantiations with `#()` param override | Supported |
247
+ | Testbench auto-exclusion | Supported |
248
+ | Pre-2001 Verilog style | Not supported |
249
+ | Multi-module files | Not supported (first module only) |
@@ -0,0 +1,31 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "rtl-aid"
7
+ version = "0.1.0"
8
+ description = "CI-native documentation layer for RTL projects"
9
+ readme = "README.md"
10
+ requires-python = ">=3.7"
11
+ license = { text = "MIT" }
12
+ authors = [
13
+ { name = "vishwaksen-1" }
14
+ ]
15
+ keywords = [
16
+ "verilog", "systemverilog", "rtl", "fpga", "asic", "eda",
17
+ "documentation", "linting", "ci", "hardware", "verilator",
18
+ "dependency-graph", "code-analysis", "agentic"
19
+ ]
20
+ dependencies = []
21
+
22
+ [project.urls]
23
+ Homepage = "https://github.com/vishwaksen-1/rtl-aid"
24
+ Issues = "https://github.com/vishwaksen-1/rtl-aid/issues"
25
+
26
+ [project.scripts]
27
+ rtldoc = "rtl_aid.cli:main"
28
+ rtllint = "rtl_aid.lint:main"
29
+
30
+ [tool.setuptools.packages.find]
31
+ where = ["src"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,4 @@
1
+ from .core import VerilogWikiParser
2
+
3
+ __version__ = "0.1.0"
4
+ __all__ = ["VerilogWikiParser"]
@@ -0,0 +1,94 @@
1
+ import argparse
2
+ from .core import VerilogWikiParser
3
+
4
+ def main():
5
+ parser = argparse.ArgumentParser()
6
+
7
+ group = parser.add_mutually_exclusive_group(required=True)
8
+
9
+ group.add_argument(
10
+ "-d", "--dir",
11
+ nargs="+",
12
+ metavar="DIR",
13
+ help="One or more directories to recursively scan for Verilog (.v) files"
14
+ )
15
+
16
+ group.add_argument(
17
+ "-f", "--file",
18
+ nargs="+",
19
+ metavar="FILE",
20
+ help="One or more specific Verilog files to parse (no directory traversal)"
21
+ )
22
+
23
+ parser.add_argument(
24
+ "-o", "--out",
25
+ default="temp/docs/modules",
26
+ metavar="OUT_DIR",
27
+ help="Output directory for generated markdown docs (default: temp/docs/modules)"
28
+ )
29
+
30
+ parser.add_argument(
31
+ "-v",
32
+ action="count",
33
+ default=0,
34
+ help="Verbose mode: -v shows modified files, -vv shows detailed section diffs"
35
+ )
36
+
37
+ parser.add_argument(
38
+ "--ci",
39
+ action="store_true",
40
+ help="Enable CI mode: fail (exit 1) on issues like missing docs, no IO, or invalid structures"
41
+ )
42
+
43
+ parser.add_argument(
44
+ "--print-errors",
45
+ action="store_true",
46
+ help="Print errors to stdout in addition to the error log file"
47
+ )
48
+
49
+ parser.add_argument(
50
+ "--json-graph",
51
+ action="store_true",
52
+ help="Generate dependency graph as JSON (graph.json) in output directory"
53
+ )
54
+
55
+ parser.add_argument(
56
+ "--exclude",
57
+ nargs="+",
58
+ metavar="EXCLUDE",
59
+ help="Directories or files to exclude from scanning"
60
+ )
61
+
62
+ parser.add_argument(
63
+ "--dry-run",
64
+ action="store_true",
65
+ help="Show what would be written without touching any files"
66
+ )
67
+
68
+ args = parser.parse_args()
69
+
70
+ paths = args.dir if args.dir else args.file
71
+
72
+ v = VerilogWikiParser(
73
+ paths,
74
+ verbose=args.v,
75
+ ci=args.ci,
76
+ json_graph=args.json_graph,
77
+ print_errors=args.print_errors,
78
+ exclude=args.exclude,
79
+ dry_run=args.dry_run,
80
+ )
81
+ v.scan()
82
+ v.generate_markdown(args.out)
83
+ v.write_json(args.out)
84
+ v.write_log()
85
+ v.run_ci_checks()
86
+
87
+ total = len(v.modules)
88
+ written = len(v.modified_files)
89
+ unchanged = total - written
90
+ action = "would be written" if args.dry_run else "written"
91
+ print(f"\n{total} module(s) processed — {written} doc(s) {action}, {unchanged} unchanged")
92
+
93
+ if __name__ == "__main__":
94
+ main()