Skip to content

Commit 0b31fb9

Browse files
committed
Add tool to export information on public IPs
1 parent 9c84a5f commit 0b31fb9

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed

chipflow_digital_ip/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from . import base
2+
from . import io
3+
from . import memory
4+
5+
6+
__all__ = ['io','memory','base']

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ test-docs.cmd = "true"
5757
lint.composite = ["./tools/license_check.sh", "ruff check"]
5858
#docs.cmd = "sphinx-build docs/ docs/_build/ -W --keep-going"
5959
doc.cmd = "true"
60+
export-ips.cmd = "./tools/export_ips.py"
6061

6162
[dependency-groups]
6263
dev = [

tools/export_ips.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import inspect
2+
import json
3+
import sys
4+
5+
from amaranth import Elaboratable
6+
from amaranth.lib import wiring
7+
8+
import amaranth_orchard
9+
10+
def children(mod):
11+
stack = [(attr, getattr(mod, attr)) for attr in dir(mod) if not attr.startswith("_")]
12+
done = []
13+
while stack:
14+
i = stack.pop()
15+
e,o = i
16+
if inspect.isclass(o) and o.__module__.startswith('chipflow_digital_ip') and issubclass(o, wiring.Component):
17+
yield o
18+
if inspect.ismodule(o):
19+
if e in done:
20+
continue
21+
done.append(e)
22+
stack.extend([(attr, getattr(o, attr)) for attr in dir(o) if not attr.startswith("_")])
23+
24+
gen = children(amaranth_orchard)
25+
output={}
26+
for cls in gen:
27+
output[f"{cls.__module__}.{cls.__qualname__}"]=cls.__doc__
28+
29+
json.dump(output, sys.stdout, indent=2)

0 commit comments

Comments
 (0)