cores/uart: rename BridgedUART to UARTEmulator and rework/simplify it. Also integrated it in SoCCore with uart_name="emulator"
This commit is contained in:
parent
d40bf9d8a7
commit
26fe45fce1
|
@ -13,13 +13,15 @@ from litex.soc.interconnect.csr_eventmanager import *
|
||||||
from litex.soc.interconnect import stream
|
from litex.soc.interconnect import stream
|
||||||
from litex.soc.interconnect.wishbonebridge import WishboneStreamingBridge
|
from litex.soc.interconnect.wishbonebridge import WishboneStreamingBridge
|
||||||
|
|
||||||
# RS232 PHY ----------------------------------------------------------------------------------------
|
class UARTInterface:
|
||||||
|
|
||||||
class RS232PHYInterface:
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.sink = stream.Endpoint([("data", 8)])
|
self.sink = stream.Endpoint([("data", 8)])
|
||||||
self.source = stream.Endpoint([("data", 8)])
|
self.source = stream.Endpoint([("data", 8)])
|
||||||
|
|
||||||
|
# RS232 PHY ----------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class RS232PHYInterface(UARTInterface):
|
||||||
|
pass
|
||||||
|
|
||||||
class RS232PHYRX(Module):
|
class RS232PHYRX(Module):
|
||||||
def __init__(self, pads, tuning_word):
|
def __init__(self, pads, tuning_word):
|
||||||
|
@ -268,25 +270,21 @@ class UARTMultiplexer(Module):
|
||||||
]
|
]
|
||||||
self.comb += Case(self.sel, cases)
|
self.comb += Case(self.sel, cases)
|
||||||
|
|
||||||
class BridgedUart(UART):
|
# UART Emulator ------------------------------------------------------------------------------------
|
||||||
"""
|
|
||||||
Creates a UART that's fully compatible with the existing
|
|
||||||
UART class, except it adds a second UART that can be read
|
|
||||||
over the Wishbone bridge.
|
|
||||||
|
|
||||||
This allows a program on the other end of the Wishbone
|
class UARTEmulator(UART):
|
||||||
bridge to act as a terminal emulator on a board where
|
|
||||||
the UART is otherwise used as a Wishbone bridge.
|
|
||||||
"""
|
"""
|
||||||
def __init__(self, **kw):
|
UART emulation over Wishbone bridge.
|
||||||
class BridgedUartPhy:
|
|
||||||
def __init__(self):
|
Creates a fully compatible UART that can be used by the CPU as a regular UART and adds a second
|
||||||
self.sink = stream.Endpoint([("data", 8)])
|
UART, cross-connected to the main one to allow terminal emulation over a Wishbone bridge.
|
||||||
self.source = stream.Endpoint([("data", 8)])
|
"""
|
||||||
class CrossoverPhy:
|
def __init__(self, **kwargs):
|
||||||
def __init__(self, phy):
|
uart_phy = UARTInterface()
|
||||||
self.source = phy.sink
|
emul_phy = UARTInterface()
|
||||||
self.sink = phy.source
|
UART.__init__(self, uart_phy, **kwargs)
|
||||||
phy = BridgedUartPhy()
|
self.submodules.emul = UART(emul_phy)
|
||||||
UART.__init__(self, phy, **kw)
|
self.comb += [
|
||||||
self.submodules.xover = UART(CrossoverPhy(phy))
|
uart_phy.source.connect(emul_phy.sink),
|
||||||
|
emul_phy.source.connect(uart_phy.sink)
|
||||||
|
]
|
||||||
|
|
|
@ -241,6 +241,8 @@ class SoCCore(Module):
|
||||||
if with_uart:
|
if with_uart:
|
||||||
if uart_stub:
|
if uart_stub:
|
||||||
self.submodules.uart = uart.UARTStub()
|
self.submodules.uart = uart.UARTStub()
|
||||||
|
elif uart_name == "emulator":
|
||||||
|
self.submodules.uart = uart.UARTEmulator()
|
||||||
else:
|
else:
|
||||||
if uart_name == "jtag_atlantic":
|
if uart_name == "jtag_atlantic":
|
||||||
from litex.soc.cores.jtag import JTAGAtlantic
|
from litex.soc.cores.jtag import JTAGAtlantic
|
||||||
|
|
Loading…
Reference in New Issue