From dc3c72eee8c5069a0543757521c79e1d5d5cdd5c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jean-Fran=C3=A7ois=20Nguyen?= Date: Fri, 29 Oct 2021 18:55:33 +0200 Subject: [PATCH] periph.serial: add PHY as parameter, in order to use a blackbox. --- lambdasoc/periph/serial.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lambdasoc/periph/serial.py b/lambdasoc/periph/serial.py index 574f070..e887d48 100644 --- a/lambdasoc/periph/serial.py +++ b/lambdasoc/periph/serial.py @@ -6,6 +6,7 @@ from nmigen_soc.periph import ConstantMap from nmigen_stdio.serial import AsyncSerial from . import Peripheral +from ..sim.blackboxes.serial.wrapper import AsyncSerial_Blackbox __all__ = ["AsyncSerialPeripheral"] @@ -71,10 +72,13 @@ class AsyncSerialPeripheral(Peripheral, Elaboratable): irq : :class:`IRQLine` Interrupt request line. """ - def __init__(self, *, rx_depth=256, tx_depth=16, data_bits=8, **kwargs): + def __init__(self, *, core, rx_depth=256, tx_depth=16, **kwargs): super().__init__() - self._phy = AsyncSerial(data_bits=data_bits, **kwargs) + if not isinstance(core, (AsyncSerial, AsyncSerial_Blackbox)): + raise TypeError("Core must be an instance of AsyncSerial or AsyncSerial_Blackbox, " + "not {!r}".format(core)) + self._phy = core self._rx_fifo = SyncFIFOBuffered(width=self._phy.rx.data.width, depth=rx_depth) self._tx_fifo = SyncFIFOBuffered(width=self._phy.tx.data.width, depth=tx_depth) -- 2.30.2