From b101f748598a4d8d471a26e44924274a8aef58e1 Mon Sep 17 00:00:00 2001 From: Robin Ole Heinemann Date: Mon, 7 Oct 2024 18:45:24 +0200 Subject: [PATCH] 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. --- amaranth/rpc.py | 16 ++++++++++------ docs/changes.rst | 11 +++++++++-- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/amaranth/rpc.py b/amaranth/rpc.py index ac3d2cffa..da83ff9a7 100644 --- a/amaranth/rpc.py +++ b/amaranth/rpc.py @@ -3,6 +3,8 @@ import argparse import importlib +from amaranth.lib.wiring import Signature + from .hdl import Signal, Record, Elaboratable from .back import rtlil @@ -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: diff --git a/docs/changes.rst b/docs/changes.rst index 58ca812f5..68e2d7218 100644 --- a/docs/changes.rst +++ b/docs/changes.rst @@ -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 `_ * `Amaranth 0.5.2 `_ * `Amaranth 0.5.1 `_ * `Amaranth 0.5.0 `_ @@ -21,8 +22,8 @@ Documentation for past releases of the Amaranth language and toolchain is availa * `Amaranth 0.3 `_ -Version 0.5.3 (unreleased) -========================== +Version 0.5.3 +============= Language changes @@ -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 =============