2014-09-23 17:03:32 -04:00
|
|
|
from migen.fhdl.std import *
|
|
|
|
|
|
|
|
from lib.sata.k7sataphy.std import *
|
|
|
|
from lib.sata.k7sataphy.gtx import GTXE2_CHANNEL
|
|
|
|
from lib.sata.k7sataphy.clocking import K7SATAPHYClocking
|
|
|
|
|
|
|
|
class K7SATAPHY(Module):
|
2014-09-24 07:56:32 -04:00
|
|
|
def __init__(self, pads, host=True):
|
|
|
|
self.sink = Sink([("d", 32)], True)
|
|
|
|
self.source = Source([("d", 32)], True)
|
2014-09-23 17:03:32 -04:00
|
|
|
|
|
|
|
self.submodules.gtx = GTXE2_CHANNEL(pads, "SATA3")
|
|
|
|
self.submodules.clocking = K7SATAPHYClocking(pads, self.gtx)
|
2014-09-24 07:56:32 -04:00
|
|
|
if host:
|
|
|
|
self.submodules.ctrl = K7SATAPHYHostCtrl(self.gtx)
|
|
|
|
else:
|
|
|
|
self.submodules.ctrl = K7SATAPHYDeviceCtrl(self.gtx)
|
|
|
|
self.comb += [
|
|
|
|
If(self.ctrl.link_up,
|
|
|
|
self.gtx.sink.stb.eq(self.sink.stb),
|
|
|
|
self.gtx.sink.data.eq(self.sink.data),
|
|
|
|
self.gtx.sink.charisk.eq(0),
|
|
|
|
self.sink.ack.eq(self.gtx.sink.ack),
|
|
|
|
).Else(
|
|
|
|
self.gtx.sink.stb.eq(1),
|
|
|
|
self.gtx.sink.data.eq(self.ctrl.txdata),
|
|
|
|
self.gtx.sink.charisk.eq(self.ctrl.txcharisk),
|
|
|
|
)
|
|
|
|
Record.connect(self.gtx.source, self.source),
|
|
|
|
self.ctrl.rxdata.eq(self.gtx.source.rxdata)
|
|
|
|
]
|