Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 4c601cc

Browse files
committedJul 24, 2015
misoclib/com/uart: remove irq condition parameters and use "non-full" for tx irq, "non-empty" for rx irq.
An optimal solution for both sync and async mode is not easy to implement, it would requires moving CDC out of UART module and handling in the PHY with AsyncFIFO or minimal depth. For now use the solution that works for both cases. We'll try to optimize that if we have performance issues.
1 parent ce11b30 commit 4c601cc

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed
 

Diff for: ‎misoclib/com/uart/__init__.py

+6-13
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ def _get_uart_fifo(depth, sink_cd="sys", source_cd="sys"):
1515

1616
class UART(Module, AutoCSR):
1717
def __init__(self, phy,
18-
tx_fifo_depth=16, tx_irq_condition="empty",
19-
rx_fifo_depth=16, rx_irq_condition="non-empty",
18+
tx_fifo_depth=16,
19+
rx_fifo_depth=16,
2020
phy_cd="sys"):
2121
self._rxtx = CSR(8)
2222
self._txfull = CSRStatus()
@@ -33,33 +33,26 @@ def __init__(self, phy,
3333
tx_fifo = _get_uart_fifo(tx_fifo_depth, source_cd=phy_cd)
3434
self.submodules += tx_fifo
3535

36-
tx_irqs = {
37-
"empty": tx_fifo.source.stb,
38-
"non-full": ~tx_fifo.sink.ack
39-
}
40-
4136
self.comb += [
4237
tx_fifo.sink.stb.eq(self._rxtx.re),
4338
tx_fifo.sink.data.eq(self._rxtx.r),
4439
self._txfull.status.eq(~tx_fifo.sink.ack),
4540
Record.connect(tx_fifo.source, phy.sink),
46-
self.ev.tx.trigger.eq(tx_irqs[tx_irq_condition])
41+
# Generate TX IRQ when tx_fifo becomes non-full
42+
self.ev.tx.trigger.eq(~tx_fifo.sink.ack)
4743
]
4844

4945

5046
# RX
5147
rx_fifo = _get_uart_fifo(rx_fifo_depth, sink_cd=phy_cd)
5248
self.submodules += rx_fifo
5349

54-
rx_irqs = {
55-
"non-empty": ~rx_fifo.source.stb,
56-
"full": rx_fifo.sink.ack
57-
}
5850

5951
self.comb += [
6052
Record.connect(phy.source, rx_fifo.sink),
6153
self._rxempty.status.eq(~rx_fifo.source.stb),
6254
self._rxtx.w.eq(rx_fifo.source.data),
6355
rx_fifo.source.ack.eq(self.ev.rx.clear),
64-
self.ev.rx.trigger.eq(rx_irqs[rx_irq_condition])
56+
# Generate RX IRQ when tx_fifo becomes non-empty
57+
self.ev.rx.trigger.eq(~rx_fifo.source.stb)
6558
]

0 commit comments

Comments
 (0)
Please sign in to comment.