Skip to content

Commit 369dc19

Browse files
rroohhhwhitequark
authored andcommitted
rpc: add support for wiring.Component
Do not infer the ports from the publicly accessible wires, but instead delegate finding the ports to the `rtlil.convert` function
1 parent e30d822 commit 369dc19

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

amaranth/rpc.py

+9-5
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import argparse
44
import importlib
55

6+
from amaranth.lib.wiring import Signature
7+
68
from .hdl import Signal, Elaboratable
79
from .back import rtlil
810

@@ -68,11 +70,13 @@ def _serve_yosys(modules):
6870

6971
try:
7072
elaboratable = modules[module_name](*args, **kwargs)
71-
ports = []
72-
# By convention, any public attribute that is a Signal is considered a port.
73-
for port_name, port in vars(elaboratable).items():
74-
if not port_name.startswith("_") and isinstance(port, Signal):
75-
ports += port._lhs_signals()
73+
ports = None
74+
if not (hasattr(elaboratable, "signature") and isinstance(elaboratable.signature, Signature)):
75+
ports = []
76+
# By convention, any public attribute that is a Signal is considered a port.
77+
for port_name, port in vars(elaboratable).items():
78+
if not port_name.startswith("_") and isinstance(port, Signal):
79+
ports += port._lhs_signals()
7680
rtlil_text = rtlil.convert(elaboratable, name=module_name, ports=ports)
7781
response = {"frontend": "ilang", "source": rtlil_text}
7882
except Exception as error:

0 commit comments

Comments
 (0)