@@ -25,6 +25,7 @@ class S7PCIEPHY(LiteXModule):
25
25
def __init__ (self , platform , pads , data_width = 64 , cd = "sys" ,
26
26
# PCIe hardblock parameters.
27
27
pcie_data_width = None ,
28
+ refclk_freq = 100e6 ,
28
29
bar0_size = 0x100000 ,
29
30
msi_type = "msi" ,
30
31
with_ptm = False ,
@@ -63,6 +64,7 @@ def __init__(self, platform, pads, data_width=64, cd="sys",
63
64
self .platform = platform
64
65
self .data_width = data_width
65
66
self .pcie_data_width = pcie_data_width
67
+ self .refclk_freq = refclk_freq
66
68
self .msi_type = msi_type
67
69
self .with_ptm = with_ptm
68
70
@@ -82,6 +84,7 @@ def __init__(self, platform, pads, data_width=64, cd="sys",
82
84
assert nlanes in [1 , 2 , 4 , 8 ]
83
85
assert data_width in [64 , 128 ]
84
86
assert pcie_data_width in [64 , 128 ]
87
+ assert refclk_freq in [100e6 , 125e6 , 250e6 ]
85
88
86
89
# Clocking / Reset -------------------------------------------------------------------------
87
90
self .pcie_refclk = pcie_refclk = Signal ()
@@ -94,7 +97,7 @@ def __init__(self, platform, pads, data_width=64, cd="sys",
94
97
i_IB = pads .clk_n ,
95
98
o_O = pcie_refclk
96
99
)
97
- platform .add_period_constraint (pads .clk_p , 1e9 / 100e6 )
100
+ platform .add_period_constraint (pads .clk_p , 1e9 / refclk_freq )
98
101
self .cd_pcie = ClockDomain ()
99
102
100
103
# TX (FPGA --> HOST) CDC / Data Width Conversion -------------------------------------------
@@ -175,7 +178,7 @@ def convert_size(command, size, max_size):
175
178
i_I = pipe_txoutclk ,
176
179
o_O = pipe_txoutclk_bufg ,
177
180
)
178
- mmcm .register_clkin (pipe_txoutclk_bufg , 100e6 )
181
+ mmcm .register_clkin (pipe_txoutclk_bufg , refclk_freq )
179
182
mmcm .create_clkout (self .cd_clk125 , 125e6 , margin = 0 )
180
183
mmcm .create_clkout (self .cd_clk250 , 250e6 , margin = 0 )
181
184
mmcm .create_clkout (self .cd_userclk1 , userclk1_freq , margin = 0 )
@@ -490,7 +493,7 @@ def add_sources(self, platform, phy_path, phy_filename=None, user_config=None):
490
493
"Max_Payload_Size" : "512_bytes" if self .nlanes != 8 else "256_bytes" ,
491
494
"Maximum_Link_Width" : f"X{ self .nlanes } " ,
492
495
"PCIe_Blk_Locn" : "X0Y0" ,
493
- "Ref_Clk_Freq" : "100_MHz " ,
496
+ "Ref_Clk_Freq" : f" { int ( self . refclk_freq / 1e6 ) } _MHz " ,
494
497
"Trans_Buf_Pipeline" : None ,
495
498
"Trgt_Link_Speed" : "4'h2" ,
496
499
"User_Clk_Freq" : 125 if self .nlanes != 8 else 250 ,
0 commit comments