Skip to content

Commit

Permalink
Align Signature.create signature with current Amaranth.
Browse files Browse the repository at this point in the history
This fixes fallout of amaranth-lang/amaranth#991.

Fixes #60.
  • Loading branch information
wanda-phi authored and jfng committed Dec 11, 2023
1 parent 2b37115 commit ad9f7d4
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
16 changes: 8 additions & 8 deletions amaranth_soc/csr/bus.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def check_parameters(cls, width, access):
except ValueError as e:
raise ValueError(f"{access!r} is not a valid Element.Access") from e

def create(self, *, path=()):
def create(self, *, path=None, src_loc_at=0):
"""Create a compatible interface.
See :meth:`wiring.Signature.create` for details.
Expand All @@ -111,7 +111,7 @@ def create(self, *, path=()):
-------
An :class:`Element` object using this signature.
"""
return Element(self.width, self.access, path=path)
return Element(self.width, self.access, path=path, src_loc_at=1 + src_loc_at)

def __eq__(self, other):
"""Compare signatures.
Expand Down Expand Up @@ -144,8 +144,8 @@ def __repr__(self):
------
See :meth:`Element.Signature.check_parameters`
"""
def __init__(self, width, access, *, path=()):
super().__init__(Element.Signature(width=width, access=access), path=path)
def __init__(self, width, access, *, path=None, src_loc_at=0):
super().__init__(Element.Signature(width=width, access=access), path=path, src_loc_at=1 + src_loc_at)

@property
def width(self):
Expand Down Expand Up @@ -254,7 +254,7 @@ def check_parameters(cls, *, addr_width, data_width):
if not isinstance(data_width, int) or data_width <= 0:
raise TypeError(f"Data width must be a positive integer, not {data_width!r}")

def create(self, *, path=()):
def create(self, *, path=None, src_loc_at=0):
"""Create a compatible interface.
See :meth:`wiring.Signature.create` for details.
Expand All @@ -265,7 +265,7 @@ def create(self, *, path=()):
"""
return Interface(addr_width=self.addr_width, data_width=self.data_width,
memory_map=self._memory_map, # if None, do not raise an exception
path=path)
path=path, src_loc_at=1 + src_loc_at)

def __eq__(self, other):
"""Compare signatures.
Expand Down Expand Up @@ -313,10 +313,10 @@ class Interface(wiring.PureInterface):
------
See :meth:`Signature.check_parameters`.
"""
def __init__(self, *, addr_width, data_width, memory_map=None, path=()):
def __init__(self, *, addr_width, data_width, memory_map=None, path=None, src_loc_at=0):
sig = Signature(addr_width=addr_width, data_width=data_width)
sig.memory_map = memory_map
super().__init__(sig, path=path)
super().__init__(sig, path=path, src_loc_at=1 + src_loc_at)

@property
def addr_width(self):
Expand Down
8 changes: 4 additions & 4 deletions amaranth_soc/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def check_parameters(cls, *, trigger):
except ValueError as e:
raise ValueError(f"{trigger!r} is not a valid Source.Trigger") from e

def create(self, *, path=()):
def create(self, *, path=None, src_loc_at=0):
"""Create a compatible interface.
See :meth:`wiring.Signature.create` for details.
Expand All @@ -91,7 +91,7 @@ def create(self, *, path=()):
"""
return Source(trigger=self.trigger,
event_map=self._event_map, # if None, do not raise an exception
path=path)
path=path, src_loc_at=1 + src_loc_at)

def __eq__(self, other):
"""Compare signatures.
Expand Down Expand Up @@ -121,10 +121,10 @@ def __repr__(self):
------
See :meth:`Source.Signature.check_parameters`.
"""
def __init__(self, *, trigger="level", event_map=None, path=()):
def __init__(self, *, trigger="level", event_map=None, path=None, src_loc_at=0):
sig = Source.Signature(trigger=trigger)
sig.event_map = event_map
super().__init__(sig, path=path)
super().__init__(sig, path=path, src_loc_at=1 + src_loc_at)

@property
def trigger(self):
Expand Down
8 changes: 4 additions & 4 deletions amaranth_soc/wishbone/bus.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ def check_parameters(cls, *, addr_width, data_width, granularity, features):
for feature in features:
Feature(feature) # raises ValueError if feature is invalid

def create(self, *, path=()):
def create(self, *, path=None, src_loc_at=0):
"""Create a compatible interface.
See :meth:`wiring.Signature.create` for details.
Expand All @@ -217,7 +217,7 @@ def create(self, *, path=()):
return Interface(addr_width=self.addr_width, data_width=self.data_width,
granularity=self.granularity, features=self.features,
memory_map=self._memory_map, # if None, do not raise an exception
path=path)
path=path, src_loc_at=1 + src_loc_at)

def __eq__(self, other):
"""Compare signatures.
Expand Down Expand Up @@ -262,11 +262,11 @@ class Interface(wiring.PureInterface):
See :meth:`Signature.check_parameters`.
"""
def __init__(self, *, addr_width, data_width, granularity=None, features=frozenset(),
memory_map=None, path=()):
memory_map=None, path=None, src_loc_at=0):
signature = Signature(addr_width=addr_width, data_width=data_width,
granularity=granularity, features=features)
signature.memory_map = memory_map
super().__init__(signature, path=path)
super().__init__(signature, path=path, src_loc_at=1 + src_loc_at)

@property
def addr_width(self):
Expand Down

0 comments on commit ad9f7d4

Please sign in to comment.