Skip to content

Commit

Permalink
lib.wiring: Add path argument to Component constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
rroohhh committed Sep 20, 2024
1 parent 8c5ed40 commit 2d75a52
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions amaranth/lib/wiring.py
Original file line number Diff line number Diff line change
Expand Up @@ -1648,6 +1648,9 @@ def __init__(self, data_width):
constructor creates attributes corresponding to all of the members defined in the signature.
If an attribute with the same name as that of a member already exists, an error is raied.
By default all members defined in the signature are created with a :py:`path` of :py:`()`.
This can be overwritten using the :py:`path` keyword argument of the superclass constructor.
Raises
------
:exc:`TypeError`
Expand All @@ -1658,7 +1661,7 @@ def __init__(self, data_width):
If a name conflict is detected between two variable annotations, or between a member
and an existing attribute.
"""
def __init__(self, signature=None, *, src_loc_at=0):
def __init__(self, signature=None, *, path=(), src_loc_at=0):
cls = type(self)
members = {}
for base in reversed(cls.mro()[:cls.mro().index(Component)]):
Expand Down Expand Up @@ -1692,7 +1695,7 @@ def __init__(self, signature=None, *, src_loc_at=0):
if hasattr(self, name):
raise NameError(f"Cannot initialize attribute for signature member {name!r} "
f"because an attribute with the same name already exists")
self.__dict__.update(signature.members.create(path=(), src_loc_at=src_loc_at + 1))
self.__dict__.update(signature.members.create(path=path, src_loc_at=src_loc_at + 1))

@property
def signature(self):
Expand Down

0 comments on commit 2d75a52

Please sign in to comment.