Skip to content

Commit f855225

Browse files
author
Jean THOMAS
committed
Add AsyncSerialTX
1 parent 41e10d5 commit f855225

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

lambdalib/cores/serial.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,40 @@
22

33
from amaranth import *
44
from amaranth.lib.cdc import *
5-
from amaranth_stdio.serial import AsyncSerial
5+
from amaranth_stdio.serial import AsyncSerial, AsyncSerialTX
66

77
from .time.timer import *
88
from ..interface import stream
99

1010

1111
__all__ = [
1212
"AsyncSerialStream",
13+
"AsyncSerialTXStream",
1314
"AsyncSerialStreamHalfDuplex",
1415
]
1516

1617

18+
class AsyncSerialTXStream(Elaboratable):
19+
def __init__(self, o, *args, **kwargs):
20+
self._serial = AsyncSerialTX(*args, **kwargs)
21+
self._o = o
22+
dw = len(self._serial.data)
23+
self.sink = stream.Endpoint([("data", dw)])
24+
25+
def elaborate(self, platform):
26+
m = Module()
27+
m.submodules += self._serial
28+
29+
m.d.comb += [
30+
self._serial.data.eq(self.sink.data),
31+
self._serial.ack.eq(self.sink.valid),
32+
self.sink.ready.eq(self._serial.rdy),
33+
self._o.eq(self._serial.o),
34+
]
35+
36+
return m
37+
38+
1739
class AsyncSerialStream(Elaboratable):
1840
""" Stream wrapper around AsyncSerial.
1941

0 commit comments

Comments
 (0)