Skip to content

Commit 08fd7b3

Browse files
committed
lib.io: fix type check in io.Buffer.elaborate.
Before this commit, the elaboration would access `self._port.invert`, which may not be present on custom `PortLike`s.
1 parent 652dbef commit 08fd7b3

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

amaranth/lib/io.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,8 @@ def direction(self):
587587
def elaborate(self, platform):
588588
if hasattr(platform, "get_io_buffer"):
589589
return platform.get_io_buffer(self)
590+
elif not isinstance(self._port, (SingleEndedPort, DifferentialPort, SimulationPort)):
591+
raise TypeError("Cannot elaborate generic 'Buffer' with port {self._port!r}") # :nocov:
590592

591593
m = Module()
592594

@@ -632,8 +634,6 @@ def elaborate(self, platform):
632634
if self.direction in (Direction.Output, Direction.Bidir):
633635
m.d.comb += self._port.o.eq(o_inv)
634636
m.d.comb += self._port.oe.eq(self.oe.replicate(len(self._port)))
635-
else:
636-
raise TypeError("Cannot elaborate generic 'Buffer' with port {self._port!r}") # :nocov:
637637

638638
return m
639639

0 commit comments

Comments
 (0)