11from collections .abc import Mapping , Sequence
22from contextlib import contextmanager
33from amaranth import *
4+ from amaranth .hdl import ShapeLike
45from amaranth .lib import enum , wiring
56from amaranth .lib .wiring import In , Out , connect , flipped
67from amaranth .utils import ceil_log2
@@ -34,7 +35,7 @@ class Signature(wiring.Signature):
3435
3536 Parameters
3637 ----------
37- shape : :ref:`shape-castable <lang-shapecasting >`
38+ shape : :ref:`shape-like object <lang-shapelike >`
3839 Shape of the field.
3940 access : :class:`FieldPort.Access`
4041 Field access mode.
@@ -53,10 +54,8 @@ class Signature(wiring.Signature):
5354 this strobe is asserted.
5455 """
5556 def __init__ (self , shape , access ):
56- try :
57- Shape .cast (shape )
58- except TypeError as e :
59- raise TypeError (f"Field shape must be a shape-castable object, not { shape !r} " ) from e
57+ if not isinstance (shape , ShapeLike ):
58+ raise TypeError (f"Field shape must be a shape-like object, not { shape !r} " )
6059 # TODO(py3.9): Remove this. Python 3.8 and below use cls.__name__ in the error message
6160 # instead of cls.__qualname__.
6261 # FieldPort.Access(access)
@@ -119,7 +118,7 @@ def __repr__(self):
119118
120119 Attributes
121120 ----------
122- shape : :ref:`shape-castable <lang-shapecasting >`
121+ shape : :ref:`shape-like object <lang-shapelike >`
123122 Shape of the field. See :class:`FieldPort.Signature`.
124123 access : :class:`FieldPort.Access`
125124 Field access mode. See :class:`FieldPort.Signature`.
@@ -190,7 +189,7 @@ class FieldAction(wiring.Component):
190189
191190 Parameters
192191 ----------
193- shape : :ref:`shape-castable <lang-shapecasting >`
192+ shape : :ref:`shape-like object <lang-shapelike >`
194193 Shape of the field. See :class:`FieldPort.Signature`.
195194 access : :class:`FieldPort.Access`
196195 Field access mode. See :class:`FieldPort.Signature`.
0 commit comments