helloworld_ecp5: add delays between messages

Otherwise the FTDI UART goes out of sync and corrupts data.
pull/1/head
Sebastien Bourdeauducq 2019-04-30 15:52:38 +08:00
parent 1cf460b56f
commit d84b172245
1 changed files with 11 additions and 2 deletions

View File

@ -22,17 +22,26 @@ class Top(Elaboratable):
init=[ord(c) for c in string])
m.submodules.rdport = rdport = mem.read_port(synchronous=False)
wait = Signal()
tx = uart.RS232TX(round(2**32*self.baudrate/100e6))
m.submodules.tx = tx
m.d.comb += [
tx.stb.eq(1),
tx.stb.eq(~wait),
tx.data.eq(rdport.data),
self.serial_tx.eq(tx.tx)
]
with m.If(tx.ack):
release = Signal()
counter = Signal(25)
m.d.sync += Cat(counter, release).eq(counter + 1)
with m.If(release):
m.d.sync += wait.eq(0)
with m.If(~wait & tx.ack):
with m.If(rdport.addr == len(string) - 1):
m.d.sync += rdport.addr.eq(0)
m.d.sync += wait.eq(1)
with m.Else():
m.d.sync += rdport.addr.eq(rdport.addr + 1)