mirror of
https://github.com/enjoy-digital/litex.git
synced 2025-01-04 09:52:26 -05:00
mmcm: configure default divider with default_speed
This commit is contained in:
parent
45f7f8aff5
commit
f23c5aa724
3 changed files with 13 additions and 7 deletions
|
@ -9,12 +9,12 @@ from lib.sata.k7sataphy.datapath import K7SATAPHYRXAlign
|
||||||
from lib.sata.k7sataphy.datapath import K7SATAPHYRXConvert, K7SATAPHYTXConvert
|
from lib.sata.k7sataphy.datapath import K7SATAPHYRXConvert, K7SATAPHYTXConvert
|
||||||
|
|
||||||
class K7SATAPHY(Module):
|
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.sink = Sink([("d", 32)], True)
|
||||||
self.source = Source([("d", 32)], True)
|
self.source = Source([("d", 32)], True)
|
||||||
|
|
||||||
# GTX
|
# GTX
|
||||||
gtx = K7SATAPHYGTX(pads, "SATA3")
|
gtx = K7SATAPHYGTX(pads, default_speed)
|
||||||
self.comb += [
|
self.comb += [
|
||||||
gtx.rxrate.eq(0b000),
|
gtx.rxrate.eq(0b000),
|
||||||
gtx.txrate.eq(0b000),
|
gtx.txrate.eq(0b000),
|
||||||
|
@ -22,7 +22,7 @@ class K7SATAPHY(Module):
|
||||||
self.submodules += gtx
|
self.submodules += gtx
|
||||||
|
|
||||||
# CRG / CTRL
|
# CRG / CTRL
|
||||||
crg = K7SATAPHYCRG(pads, gtx, clk_freq)
|
crg = K7SATAPHYCRG(pads, gtx, clk_freq, default_speed)
|
||||||
if host:
|
if host:
|
||||||
ctrl = K7SATAPHYHostCtrl(gtx)
|
ctrl = K7SATAPHYHostCtrl(gtx)
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -25,7 +25,7 @@ class K7SATAPHYReconfig(Module):
|
||||||
)
|
)
|
||||||
|
|
||||||
class K7SATAPHYCRG(Module):
|
class K7SATAPHYCRG(Module):
|
||||||
def __init__(self, pads, gtx, clk_freq):
|
def __init__(self, pads, gtx, clk_freq, default_speed):
|
||||||
self.reset = Signal()
|
self.reset = Signal()
|
||||||
self.ready = Signal()
|
self.ready = Signal()
|
||||||
|
|
||||||
|
@ -59,6 +59,12 @@ class K7SATAPHYCRG(Module):
|
||||||
mmcm_clk_i = Signal()
|
mmcm_clk_i = Signal()
|
||||||
mmcm_clk0_o = Signal()
|
mmcm_clk0_o = Signal()
|
||||||
mmcm_clk1_o = Signal()
|
mmcm_clk1_o = Signal()
|
||||||
|
mmcm_div_config = {
|
||||||
|
"SATA1" : 16,
|
||||||
|
"SATA2" : 8,
|
||||||
|
"SATA3" : 4
|
||||||
|
}
|
||||||
|
mmcm_div = mmcm_div_config[default_speed]
|
||||||
self.specials += [
|
self.specials += [
|
||||||
Instance("BUFG", i_I=gtx.txoutclk, o_O=mmcm_clk_i),
|
Instance("BUFG", i_I=gtx.txoutclk, o_O=mmcm_clk_i),
|
||||||
Instance("MMCME2_ADV",
|
Instance("MMCME2_ADV",
|
||||||
|
@ -74,10 +80,10 @@ class K7SATAPHYCRG(Module):
|
||||||
i_CLKIN1=mmcm_clk_i, i_CLKFBIN=mmcm_fb, o_CLKFBOUT=mmcm_fb,
|
i_CLKIN1=mmcm_clk_i, i_CLKFBIN=mmcm_fb, o_CLKFBOUT=mmcm_fb,
|
||||||
|
|
||||||
# CLK0
|
# 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
|
# 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),
|
Instance("BUFG", i_I=mmcm_clk0_o, o_O=self.cd_sata_tx.clk),
|
||||||
]
|
]
|
||||||
|
|
|
@ -6,7 +6,7 @@ from migen.flow.actor import Sink, Source
|
||||||
from lib.sata.k7sataphy.std import *
|
from lib.sata.k7sataphy.std import *
|
||||||
|
|
||||||
class K7SATAPHYGTX(Module):
|
class K7SATAPHYGTX(Module):
|
||||||
def __init__(self, pads, default_speed="SATA3"):
|
def __init__(self, pads, default_speed):
|
||||||
self.drp = DRPBus()
|
self.drp = DRPBus()
|
||||||
|
|
||||||
# Channel - Ref Clock Ports
|
# Channel - Ref Clock Ports
|
||||||
|
|
Loading…
Reference in a new issue