print hello world on UART
This commit is contained in:
parent
b2bcbd7048
commit
ca0707fa88
|
@ -20,14 +20,25 @@ class Top:
|
||||||
m.submodules.clock = Instance("IBUFGDS",
|
m.submodules.clock = Instance("IBUFGDS",
|
||||||
i_I=self.clk156_p, i_IB=self.clk156_n, o_O=cd_sync.clk)
|
i_I=self.clk156_p, i_IB=self.clk156_n, o_O=cd_sync.clk)
|
||||||
|
|
||||||
|
string = "Hello World!\r\n"
|
||||||
|
mem = Memory(width=8, depth=len(string),
|
||||||
|
init=[ord(c) for c in string])
|
||||||
|
m.submodules.rdport = rdport = mem.read_port(synchronous=False)
|
||||||
|
|
||||||
tx = uart.RS232TX(round(2**32*self.baudrate/self.clk_freq))
|
tx = uart.RS232TX(round(2**32*self.baudrate/self.clk_freq))
|
||||||
m.submodules.tx = tx
|
m.submodules.tx = tx
|
||||||
m.d.comb += [
|
m.d.comb += [
|
||||||
tx.stb.eq(1),
|
tx.stb.eq(1),
|
||||||
tx.data.eq(ord("A")),
|
tx.data.eq(rdport.data),
|
||||||
self.serial_tx.eq(tx.tx)
|
self.serial_tx.eq(tx.tx)
|
||||||
]
|
]
|
||||||
|
|
||||||
|
with m.If(tx.ack):
|
||||||
|
with m.If(rdport.addr == len(string) - 1):
|
||||||
|
m.d.sync += rdport.addr.eq(0)
|
||||||
|
with m.Else():
|
||||||
|
m.d.sync += rdport.addr.eq(rdport.addr + 1)
|
||||||
|
|
||||||
return m
|
return m
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue