Skip to main content

CI-native documentation layer for RTL projects

Project description

rtl-aid

CI-native documentation layer for RTL projects.

Parses Verilog/SystemVerilog source files, extracts module structure, and generates Markdown documentation that stays in sync with your RTL — automatically.


Tools

Command Purpose
rtldoc Generate and maintain module documentation
rtllint Run verilator lint and tag warnings inline in source

Installation

pip install rtl-aid

Or from source:

git clone https://github.com/vishwaksen-1/rtl-aid
cd rtl-aid
pip install -e .

Requirements

  • Python 3.7+
  • rtllint requires verilator — a system binary, not installable via pip:
# Debian / Ubuntu
sudo apt install verilator

# macOS
brew install verilator

rtldoc has no external dependencies. If verilator is missing, rtllint will exit with a clear error and install instructions.


rtldoc

Quick start

# Document all modules in a directory
rtldoc -d rtl/

# Document specific files
rtldoc -f rtl/core/alu.v rtl/core/decoder.v

# Custom output directory
rtldoc -d rtl/ -o docs/modules/

What gets generated

For each module, a Markdown file is created or updated:

# alu

## Description
TODO: Add description

## Parameters
- DATA_WIDTH = 8
- OP_WIDTH = 4

## Inputs
- clk
- rst
- op
- operand_a
- operand_b

## Outputs
- result
- overflow

## Calls
- [mux4](mux4.md)

## Called By
- [cpu_core](cpu_core.md)

The Description section is never overwritten — you write it once, rtldoc preserves it on every run. All other sections are auto-managed.

CLI reference

rtldoc (-d DIR [DIR...] | -f FILE [FILE...]) [options]

Input:
  -d, --dir DIR [DIR...]    Recursively scan directories for .v / .sv files
  -f, --file FILE [FILE...]  Parse specific files (no directory traversal)

Output:
  -o, --out OUT_DIR          Output directory (default: temp/docs/modules)
  --json-graph               Write dependency graph to graph.json

Filtering:
  --exclude PATTERN [...]    Exclude paths containing any of these strings

Run modes:
  --dry-run                  Show what would be written without touching files
  --ci                       Fail (exit 1) on missing descriptions, no-IO modules,
                             or self-instantiations
  --print-errors             Print CI issues to stdout (in addition to the error log)

Verbosity:
  -v                         Print modified file paths
  -vv                        Print modified files + section-level diffs (+adds/-removals)

CI integration

# .github/workflows/docs.yml
- name: Check RTL docs
  run: rtldoc -d rtl/ -o docs/modules/ --ci --print-errors

Exit codes: 0 = clean, 1 = CI check failed.

Testbench files (_tb.v, _tb.sv, _bench.v, _testbench.v, and .sv variants) are automatically excluded from scanning.

Dry run

Preview what would change before committing:

rtldoc -d rtl/ --dry-run
[DRY RUN] Would write:
  docs/modules/alu.md
  docs/modules/decoder.md

5 module(s) processed — 2 doc(s) would be written, 3 unchanged

Dependency graph

rtldoc -d rtl/ --json-graph -o docs/modules/

Writes docs/modules/graph.json:

{
  "cpu_core": {
    "calls": ["alu", "decoder", "register_file"],
    "called_by": []
  },
  "alu": {
    "calls": ["mux4"],
    "called_by": ["cpu_core"]
  }
}

rtllint

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.

Usage

rtllint rtl/core/alu.v

# With include directories
rtllint -I rtl/includes -I rtl/common rtl/core/alu.v

# Multiple files
rtllint rtl/core/*.v

# Preview without modifying files
rtllint --dry-run rtl/core/alu.v

What gets written

Given a verilator warning on line 75:

%Warning-WIDTHEXPAND: rtl/alu.v:75:12: Operator ADD generates 9 bits ...

rtllint modifies alu.v in place:

// lint-test: verilator --lint-only -Wall rtl/alu.v
// tb-test: tba
...
assign result = a + b;  /* Check: Operator ADD generates 9 bits ... */

Re-running rtllint replaces existing /* Check: */ tags — it does not stack duplicates.

CLI reference

rtllint FILE [FILE...] [options]

  -I, --include DIR    Add include directory (repeatable)
  --dry-run            Show issues without modifying files
  -v                   Print full verilator output

Exit codes: 0 = no issues found, 1 = one or more warnings/errors.


Design principles

  • No heavy dependencies — stdlib only, no parser frameworks
  • CI-first — every flag is designed for scripted use
  • Safe for teams — manual descriptions are never overwritten
  • Diff-aware — files are only touched when content actually changes

Supported syntax

Feature Status
Verilog-2001 (.v) Supported
SystemVerilog (.sv) Supported (port/param parsing)
ANSI port declarations Supported
Comma-inherited port direction (output reg a, b) Supported
Parameterised modules (#(parameter ...)) Supported
Module instantiations with #() param override Supported
Testbench auto-exclusion Supported
Pre-2001 Verilog style Not supported
Multi-module files Not supported (first module only)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rtl_aid-0.1.0.tar.gz (15.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rtl_aid-0.1.0-py3-none-any.whl (11.4 kB view details)

Uploaded Python 3

File details

Details for the file rtl_aid-0.1.0.tar.gz.

File metadata

  • Download URL: rtl_aid-0.1.0.tar.gz
  • Upload date:
  • Size: 15.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.6

File hashes

Hashes for rtl_aid-0.1.0.tar.gz
Algorithm Hash digest
SHA256 b242abe0a16e853a3be4c0260fdbab8f50bbeb96969c6986600a31a712f757bd
MD5 765848e7201b2daa8942615d43fa6a76
BLAKE2b-256 acc73ab7e685f1574e6bb3ab345dec52befcde3a1866b2087e69e3d1a2212957

See more details on using hashes here.

File details

Details for the file rtl_aid-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: rtl_aid-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 11.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.6

File hashes

Hashes for rtl_aid-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fd41baa7dfac39e987234dad802d04fda537e6bcc3bdf25a51336635215ae74e
MD5 bf45cff93b02aff9fe6fb09be3ac22bb
BLAKE2b-256 7bb21d8dcd8471cd126b81505a74e2e61e4792f1392414fb65ed3922098cfe57

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page