diff --git a/amaranth/lib/io.py b/amaranth/lib/io.py index c2bc59a10..c7a4bc2f0 100644 --- a/amaranth/lib/io.py +++ b/amaranth/lib/io.py @@ -518,6 +518,11 @@ class Buffer(wiring.Component): ---------- signature : :class:`Buffer.Signature` :py:`Signature(direction, len(port)).flip()`. + + Platform overrides + ------------------ + Define the :py:`get_io_buffer()` platform method to override the implementation of + :class:`Buffer`, e.g. to instantiate library cells directly. """ class Signature(wiring.Signature): """Signature of a combinational I/O buffer. @@ -587,6 +592,8 @@ def direction(self): def elaborate(self, platform): if hasattr(platform, "get_io_buffer"): return platform.get_io_buffer(self) + elif not isinstance(self._port, (SingleEndedPort, DifferentialPort, SimulationPort)): + raise TypeError("Cannot elaborate generic 'Buffer' with port {self._port!r}") # :nocov: m = Module() @@ -632,8 +639,6 @@ def elaborate(self, platform): if self.direction in (Direction.Output, Direction.Bidir): m.d.comb += self._port.o.eq(o_inv) m.d.comb += self._port.oe.eq(self.oe.replicate(len(self._port))) - else: - raise TypeError("Cannot elaborate generic 'Buffer' with port {self._port!r}") # :nocov: return m @@ -690,6 +695,11 @@ class FFBuffer(wiring.Component): ---------- signature : :class:`FFBuffer.Signature` :py:`Signature(direction, len(port)).flip()`. + + Platform overrides + ------------------ + Define the :py:`get_io_buffer()` platform method to override the implementation of + :class:`FFBuffer`, e.g. to instantiate library cells directly. """ class Signature(wiring.Signature): """Signature of a registered I/O buffer. @@ -898,6 +908,11 @@ class DDRBuffer(wiring.Component): ---------- signature : :class:`DDRBuffer.Signature` :py:`Signature(direction, len(port)).flip()`. + + Platform overrides + ------------------ + Define the :py:`get_io_buffer()` platform method to override the implementation of + :class:`DDRBuffer`, e.g. to instantiate library cells directly. """ class Signature(wiring.Signature): """Signature of a double data rate I/O buffer.