Skip to content

Commit

Permalink
Add AsyncSerialTX
Browse files Browse the repository at this point in the history
  • Loading branch information
Jean THOMAS committed Dec 18, 2024
1 parent 41e10d5 commit f855225
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion lambdalib/cores/serial.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,40 @@

from amaranth import *
from amaranth.lib.cdc import *
from amaranth_stdio.serial import AsyncSerial
from amaranth_stdio.serial import AsyncSerial, AsyncSerialTX

from .time.timer import *
from ..interface import stream


__all__ = [
"AsyncSerialStream",
"AsyncSerialTXStream",
"AsyncSerialStreamHalfDuplex",
]


class AsyncSerialTXStream(Elaboratable):
def __init__(self, o, *args, **kwargs):
self._serial = AsyncSerialTX(*args, **kwargs)
self._o = o
dw = len(self._serial.data)
self.sink = stream.Endpoint([("data", dw)])

def elaborate(self, platform):
m = Module()
m.submodules += self._serial

m.d.comb += [
self._serial.data.eq(self.sink.data),
self._serial.ack.eq(self.sink.valid),
self.sink.ready.eq(self._serial.rdy),
self._o.eq(self._serial.o),
]

return m


class AsyncSerialStream(Elaboratable):
""" Stream wrapper around AsyncSerial.
Expand Down

0 comments on commit f855225

Please sign in to comment.