Skip to content

Commit

Permalink
rpc: add support for wiring.Component.
Browse files Browse the repository at this point in the history
Do not infer the ports from the publicly accessible wires, but instead
delegate finding the ports to the `rtlil.convert` function.
  • Loading branch information
rroohhh authored and jfng committed Oct 10, 2024
1 parent dd36508 commit b101f74
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
16 changes: 10 additions & 6 deletions amaranth/rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import argparse
import importlib

from amaranth.lib.wiring import Signature

from .hdl import Signal, Record, Elaboratable
from .back import rtlil

Expand Down Expand Up @@ -68,12 +70,14 @@ def _serve_yosys(modules):

try:
elaboratable = modules[module_name](*args, **kwargs)
ports = []
# By convention, any public attribute that is a Signal or a Record is
# considered a port.
for port_name, port in vars(elaboratable).items():
if not port_name.startswith("_") and isinstance(port, (Signal, Record)):
ports += port._lhs_signals()
ports = None
if not (hasattr(elaboratable, "signature") and isinstance(elaboratable.signature, Signature)):
ports = []
# By convention, any public attribute that is a Signal or a Record is
# considered a port.
for port_name, port in vars(elaboratable).items():
if not port_name.startswith("_") and isinstance(port, (Signal, Record)):
ports += port._lhs_signals()
rtlil_text = rtlil.convert(elaboratable, name=module_name, ports=ports)
response = {"frontend": "ilang", "source": rtlil_text}
except Exception as error:
Expand Down
11 changes: 9 additions & 2 deletions docs/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Documentation for past releases

Documentation for past releases of the Amaranth language and toolchain is available online:

* `Amaranth 0.5.3 <https://amaranth-lang.org/docs/amaranth/v0.5.3/>`_
* `Amaranth 0.5.2 <https://amaranth-lang.org/docs/amaranth/v0.5.2/>`_
* `Amaranth 0.5.1 <https://amaranth-lang.org/docs/amaranth/v0.5.1/>`_
* `Amaranth 0.5.0 <https://amaranth-lang.org/docs/amaranth/v0.5.0/>`_
Expand All @@ -21,8 +22,8 @@ Documentation for past releases of the Amaranth language and toolchain is availa
* `Amaranth 0.3 <https://amaranth-lang.org/docs/amaranth/v0.3/>`_


Version 0.5.3 (unreleased)
==========================
Version 0.5.3
=============


Language changes
Expand All @@ -31,6 +32,12 @@ Language changes
* Added: individual bits of the same signal can now be assigned from different modules or domains.


Toolchain changes
-----------------

* Added: the Amaranth RPC server can now elaborate :class:`amaranth.lib.wiring.Component` objects on demand.


Version 0.5.2
=============

Expand Down

0 comments on commit b101f74

Please sign in to comment.