26 lines
776 B
Python
26 lines
776 B
Python
from migen import *
|
|
from migen.genlib.fifo import SyncFIFO
|
|
from uart import UART
|
|
|
|
|
|
class UARTLogger(Module):
|
|
def __init__(self, sys_clk_freq):
|
|
# UART PHY interface
|
|
self.uart_rx = Signal()
|
|
self.uart_tx = Signal()
|
|
|
|
# Attach FIFO to UART TX, send rate is too slow w.r.t sysclk
|
|
self.submodules.tx_fifo = SyncFIFO(8, 64)
|
|
|
|
self.submodules.uart = UART(round((115200/sys_clk_freq)*2**32))
|
|
self.comb += [
|
|
# PHY connection
|
|
self.uart.phy_rx.eq(self.uart_rx),
|
|
self.uart_tx.eq(self.uart.phy_tx),
|
|
|
|
# UART TX path
|
|
self.uart.tx_data.eq(self.tx_fifo.dout),
|
|
self.uart.tx_stb.eq(self.tx_fifo.readable),
|
|
self.tx_fifo.re.eq(self.uart.tx_ack),
|
|
]
|