tangled
alpha
login
or
join now
nonbinary.computer
/
or1-design
0
fork
atom
OR-1 dataflow CPU sketch
0
fork
atom
overview
issues
pulls
pipelines
feat: add dfgraph package skeleton with CLI entry point
Orual
2 weeks ago
b5f53387
27c0870c
+40
2 changed files
expand all
collapse all
unified
split
dfgraph
__init__.py
__main__.py
+1
dfgraph/__init__.py
···
1
1
+
"""Dataflow graph renderer for OR1 dfasm programs."""
+39
dfgraph/__main__.py
···
1
1
+
"""CLI entry point: python -m dfgraph path/to/file.dfasm [--port 8420]"""
2
2
+
3
3
+
import argparse
4
4
+
import sys
5
5
+
from pathlib import Path
6
6
+
7
7
+
8
8
+
def main() -> None:
9
9
+
parser = argparse.ArgumentParser(
10
10
+
prog="dfgraph",
11
11
+
description="Visualise a dfasm dataflow program as an interactive graph.",
12
12
+
)
13
13
+
parser.add_argument(
14
14
+
"file",
15
15
+
type=Path,
16
16
+
help="Path to the .dfasm source file to visualise",
17
17
+
)
18
18
+
parser.add_argument(
19
19
+
"--port",
20
20
+
type=int,
21
21
+
default=8420,
22
22
+
help="Port for the web server (default: 8420)",
23
23
+
)
24
24
+
25
25
+
args = parser.parse_args()
26
26
+
27
27
+
if not args.file.exists():
28
28
+
print(f"Error: file not found: {args.file}", file=sys.stderr)
29
29
+
sys.exit(1)
30
30
+
31
31
+
if not args.file.suffix == ".dfasm":
32
32
+
print(f"Warning: expected .dfasm file, got: {args.file.suffix}", file=sys.stderr)
33
33
+
34
34
+
# Server startup will be added in Phase 4
35
35
+
print(f"dfgraph: would serve {args.file} on port {args.port}")
36
36
+
37
37
+
38
38
+
if __name__ == "__main__":
39
39
+
main()