From ad9f7d461243b9e050c319692ea55cc59f310dd4 Mon Sep 17 00:00:00 2001
From: Wanda <wanda@phinode.net>
Date: Sat, 9 Dec 2023 13:00:38 +0100
Subject: [PATCH] Align Signature.create signature with current Amaranth.

This fixes fallout of amaranth-lang/amaranth#991.

Fixes #60.
---
 amaranth_soc/csr/bus.py      | 16 ++++++++--------
 amaranth_soc/event.py        |  8 ++++----
 amaranth_soc/wishbone/bus.py |  8 ++++----
 3 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/amaranth_soc/csr/bus.py b/amaranth_soc/csr/bus.py
index e1205ab..10d4bb9 100644
--- a/amaranth_soc/csr/bus.py
+++ b/amaranth_soc/csr/bus.py
@@ -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.
@@ -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.
@@ -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):
@@ -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.
@@ -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.
@@ -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):
diff --git a/amaranth_soc/event.py b/amaranth_soc/event.py
index b08453a..f6c0c4c 100644
--- a/amaranth_soc/event.py
+++ b/amaranth_soc/event.py
@@ -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.
@@ -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.
@@ -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):
diff --git a/amaranth_soc/wishbone/bus.py b/amaranth_soc/wishbone/bus.py
index dfe7729..f7056b0 100644
--- a/amaranth_soc/wishbone/bus.py
+++ b/amaranth_soc/wishbone/bus.py
@@ -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.
@@ -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.
@@ -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):