from lib.sata.k7sataphy.datapath import K7SATAPHYRXConvert, K7SATAPHYTXConvert
class K7SATAPHY(Module):
- def __init__(self, pads, clk_freq, host=True,):
+ def __init__(self, pads, clk_freq, host=True, default_speed="SATA3"):
self.sink = Sink([("d", 32)], True)
self.source = Source([("d", 32)], True)
# GTX
- gtx = K7SATAPHYGTX(pads, "SATA3")
+ gtx = K7SATAPHYGTX(pads, default_speed)
self.comb += [
gtx.rxrate.eq(0b000),
gtx.txrate.eq(0b000),
self.submodules += gtx
# CRG / CTRL
- crg = K7SATAPHYCRG(pads, gtx, clk_freq)
+ crg = K7SATAPHYCRG(pads, gtx, clk_freq, default_speed)
if host:
ctrl = K7SATAPHYHostCtrl(gtx)
else:
)
class K7SATAPHYCRG(Module):
- def __init__(self, pads, gtx, clk_freq):
+ def __init__(self, pads, gtx, clk_freq, default_speed):
self.reset = Signal()
self.ready = Signal()
mmcm_clk_i = Signal()
mmcm_clk0_o = Signal()
mmcm_clk1_o = Signal()
+ mmcm_div_config = {
+ "SATA1" : 16,
+ "SATA2" : 8,
+ "SATA3" : 4
+ }
+ mmcm_div = mmcm_div_config[default_speed]
self.specials += [
Instance("BUFG", i_I=gtx.txoutclk, o_O=mmcm_clk_i),
Instance("MMCME2_ADV",
i_CLKIN1=mmcm_clk_i, i_CLKFBIN=mmcm_fb, o_CLKFBOUT=mmcm_fb,
# CLK0
- p_CLKOUT0_DIVIDE_F=4.000, p_CLKOUT0_PHASE=0.000, o_CLKOUT0=mmcm_clk0_o,
+ p_CLKOUT0_DIVIDE_F=mmcm_div, p_CLKOUT0_PHASE=0.000, o_CLKOUT0=mmcm_clk0_o,
# CLK1
- p_CLKOUT1_DIVIDE=8, p_CLKOUT1_PHASE=0.000, o_CLKOUT1=mmcm_clk1_o,
+ p_CLKOUT1_DIVIDE=mmcm_div*2, p_CLKOUT1_PHASE=0.000, o_CLKOUT1=mmcm_clk1_o,
),
Instance("BUFG", i_I=mmcm_clk0_o, o_O=self.cd_sata_tx.clk),
]
from lib.sata.k7sataphy.std import *
class K7SATAPHYGTX(Module):
- def __init__(self, pads, default_speed="SATA3"):
+ def __init__(self, pads, default_speed):
self.drp = DRPBus()
# Channel - Ref Clock Ports