litex/lib/sata/k7sataphy/__init__.py

60 lines
1.8 KiB
Python
Raw Normal View History

from migen.fhdl.std import *
from migen.flow.actor import Sink, Source
from lib.sata.k7sataphy.std import *
from lib.sata.k7sataphy.gtx import K7SATAPHYGTX
from lib.sata.k7sataphy.crg import K7SATAPHYCRG
from lib.sata.k7sataphy.ctrl import K7SATAPHYHostCtrl, K7SATAPHYDeviceCtrl
from lib.sata.k7sataphy.datapath import K7SATAPHYRXAlign
from lib.sata.k7sataphy.datapath import K7SATAPHYRXConvert, K7SATAPHYTXConvert
class K7SATAPHY(Module):
def __init__(self, pads, clk_freq, host=True, default_speed="SATA3"):
self.sink = Sink([("d", 32)])
self.source = Source([("d", 32)])
2014-09-27 10:10:39 -04:00
# GTX
gtx = K7SATAPHYGTX(pads, default_speed)
2014-09-27 10:10:39 -04:00
self.submodules += gtx
# CRG / CTRL
crg = K7SATAPHYCRG(pads, gtx, clk_freq, default_speed)
2014-09-27 10:10:39 -04:00
if host:
ctrl = K7SATAPHYHostCtrl(gtx, clk_freq)
2014-09-27 10:10:39 -04:00
else:
ctrl = K7SATAPHYDeviceCtrl(gtx, clk_freq)
2014-09-27 10:10:39 -04:00
self.submodules += crg, ctrl
self.comb += ctrl.start.eq(crg.ready)
# DATAPATH
2014-09-25 08:52:16 -04:00
rxalign = K7SATAPHYRXAlign()
rxconvert = K7SATAPHYRXConvert()
txconvert = K7SATAPHYTXConvert()
2014-09-27 10:10:39 -04:00
self.submodules += rxalign, rxconvert, txconvert
2014-09-25 08:52:16 -04:00
self.comb += [
rxalign.rxdata_i.eq(gtx.rxdata),
rxalign.rxcharisk_i.eq(gtx.rxcharisk),
rxconvert.rxdata.eq(rxalign.rxdata_o),
rxconvert.rxcharisk.eq(rxalign.rxcharisk_o),
gtx.txdata.eq(txconvert.txdata),
gtx.txcharisk.eq(txconvert.txcharisk)
]
2014-09-24 07:56:32 -04:00
self.comb += [
2014-09-27 10:10:39 -04:00
If(ctrl.ready,
2014-09-25 08:52:16 -04:00
txconvert.sink.stb.eq(self.sink.stb),
txconvert.sink.data.eq(self.sink.d),
txconvert.sink.charisk.eq(0),
self.sink.ack.eq(txconvert.sink.ack),
2014-09-24 07:56:32 -04:00
).Else(
2014-09-25 08:52:16 -04:00
txconvert.sink.stb.eq(1),
txconvert.sink.data.eq(ctrl.txdata),
txconvert.sink.charisk.eq(ctrl.txcharisk)
),
2014-09-25 08:52:16 -04:00
self.source.stb.eq(rxconvert.source.stb),
self.source.payload.eq(rxconvert.source.payload),
rxconvert.source.ack.eq(self.source.ack),
ctrl.rxdata.eq(rxconvert.source.data)
2014-09-24 07:56:32 -04:00
]