2015-02-21 17:13:43 -05:00
|
|
|
from migen.fhdl.std import *
|
|
|
|
|
2015-03-22 05:56:29 -04:00
|
|
|
from misoclib.com.liteusb.common import *
|
2015-05-01 10:11:15 -04:00
|
|
|
from misoclib.com.uart import UART
|
2015-02-21 17:13:43 -05:00
|
|
|
|
2015-05-01 10:11:15 -04:00
|
|
|
class LiteUSBUARTPHY:
|
|
|
|
def __init__(self):
|
|
|
|
self.sink = Sink([("data", 8)])
|
|
|
|
self.source = Source([("data", 8)])
|
2015-04-13 08:27:31 -04:00
|
|
|
|
2015-05-01 10:11:15 -04:00
|
|
|
class LiteUSBUART(UART):
|
|
|
|
def __init__(self, port,
|
|
|
|
tx_fifo_depth=16,
|
|
|
|
rx_fifo_depth=16):
|
2015-04-13 08:09:58 -04:00
|
|
|
|
2015-05-01 10:11:15 -04:00
|
|
|
phy = LiteUSBUARTPHY()
|
|
|
|
UART.__init__(self, phy, tx_fifo_depth, rx_fifo_depth)
|
2015-04-13 08:09:58 -04:00
|
|
|
|
|
|
|
# TX
|
|
|
|
self.comb += [
|
2015-05-01 10:11:15 -04:00
|
|
|
port.sink.stb.eq(phy.sink.stb),
|
|
|
|
port.sink.sop.eq(1),
|
|
|
|
port.sink.eop.eq(1),
|
|
|
|
port.sink.length.eq(1),
|
|
|
|
port.sink.dst.eq(port.tag),
|
|
|
|
port.sink.data.eq(phy.sink.data),
|
|
|
|
phy.sink.ack.eq(port.sink.ack)
|
2015-04-13 08:09:58 -04:00
|
|
|
]
|
|
|
|
|
|
|
|
# RX
|
|
|
|
self.comb += [
|
2015-05-01 10:11:15 -04:00
|
|
|
phy.source.stb.eq(port.source.stb),
|
|
|
|
phy.source.data.eq(port.source.data),
|
|
|
|
port.source.ack.eq(phy.source.ack)
|
2015-04-13 08:09:58 -04:00
|
|
|
]
|