litex/milkymist/uart/__init__.py

29 lines
812 B
Python
Raw Normal View History

2011-12-16 15:30:22 -05:00
from migen.fhdl.structure import *
2011-12-13 11:33:12 -05:00
from migen.bus import csr
class Inst:
2011-12-16 15:30:22 -05:00
def __init__(self, csr_addr, clk_freq, baud=115200, break_en_default=Constant(0)):
2011-12-13 11:33:12 -05:00
self.bus = csr.Slave("uart")
2011-12-16 15:30:22 -05:00
declare_signal(self, "tx")
declare_signal(self, "rx")
declare_signal(self, "irq")
declare_signal(self, "brk")
self._inst = Instance("uart",
2011-12-13 11:33:12 -05:00
[("csr_do", self.bus.d_o),
("uart_tx", self.tx),
("irq", self.irq),
("break", self.brk)],
[("csr_a", self.bus.a_i),
("csr_we", self.bus.we_i),
("csr_di", self.bus.d_i),
("uart_rx", self.rx)],
2011-12-17 09:54:42 -05:00
[("csr_addr", Constant(csr_addr, BV(5))),
2011-12-13 11:33:12 -05:00
("clk_freq", clk_freq),
("baud", baud),
("break_en_default", break_en_default)],
"sys_clk",
"sys_rst")
2011-12-16 10:02:49 -05:00
def get_fragment(self):
2011-12-16 15:30:22 -05:00
return Fragment(instances=[self._inst], pads={self.tx, self.rx})