在设计一个多时钟电路时,遇到了一些 MMCM 的配置问题,查阅了相关手册,整理记录一下。
涉及到的 Xilinx 官方文档有:
需要说明的是,7 系列以后的器件 PLL 是基于 MMCM 实现的 PLL,因此下面仅就 MMCM 做些记录。
一、MMCM 版本和调用方式
不同器件之间的版本:
7 系列器件的 MMCM 是 MMCME2,UltraScale+ 器件的是 MMCME4。
不同功能之间的版本(7 系列器件为例):
基本的 MMCM 是 MMCME2_BASE,高级功能的是 MMCME2_ADV。
调用 MMCM 的 2 种方法:
- GUI 面板配置
- 源语调用
推荐使用源语调用的方式,这样避免工程在不同器件及版本之间切换,需要重新生成所有的 IP。
二、MMCM 的频率配置及限制条件
2.1 MMCM 的频率配置
先来看一下 MMCM 的框图:
结合上述 MMCM 框图,解释如何配置输出时钟频率:
所有的时钟输出都是由 VCO 分频得到的,VCO 的频率为 FVCO,输入时钟频率为 FCLKIN,输出时钟频率为 FOUT。M 为倍频系数,D 为预分频系数,O 为输出分频系数。不同的输出时钟都是因为 O 不同,所有的输出时钟的 M 和 D 是相同的。这个在 PLL 配置面板上也能看到。
CLKFBOUT_MULT 为 M,DIVCLK_DIVIDE 为 D,下边方框里的 Devide 就是 O,可见每个输出时钟的 O 不相同。当然如果想自己调整 M,D,O,从而调整输出时钟,应当选中 Allow Override Mode,要不然无法修改。
再来看一下源语的使用方法:
例如,下面代码中 CLKFBOUT_MULT_F 设置成 8,DIVCLK_DIVIDE 设置成 1,CLKOUT0_DIVIDE_F 设置成 4,输入时钟频率 CLKIN1_PERIOD 等于 10,为 100Mhz。通过公式计算 CLKOUT0 输出为 100*8/4=200Mhz。
// MMCME2_ADV : In order to incorporate this function into the design, // Verilog : the following instance declaration needs to be placed // instance : in the body of the design code. The instance name // declaration : (MMCME2_ADV_inst) and/or the port declarations within the // code : parenthesis may be changed to properly reference and // : connect this function to the design. All inputs // : and outputs must be connected. // <-----Cut code below this line----> // MMCME2_ADV: Advanced Mixed Mode Clock Manager // Artix-7 // Xilinx HDL Language Template, version 2017.4 MMCME2_ADV #( .BANDWIDTH("OPTIMIZED"), // Jitter programming (OPTIMIZED, HIGH, LOW) .CLKFBOUT_MULT_F(8.0), // Multiply value for all CLKOUT (2.000-64.000). .CLKFBOUT_PHASE(0.0), // Phase offset in degrees of CLKFB (-360.000-360.000). // CLKIN_PERIOD: Input clock period in ns to ps resolution (i.e. 33.333 is 30 MHz). .CLKIN1_PERIOD(10.0), .CLKIN2_PERIOD(0.0), // CLKOUT0_DIVIDE - CLKOUT6_DIVIDE: Divide amount for CLKOUT (1-128) .CLKOUT1_DIVIDE(1), .CLKOUT2_DIVIDE(1), .CLKOUT3_DIVIDE(1), .CLKOUT4_DIVIDE(1), .CLKOUT5_DIVIDE(1), .CLKOUT6_DIVIDE(1), .CLKOUT0_DIVIDE_F(4.0), // Divide amount for CLKOUT0 (1.000-128.000). // CLKOUT0_DUTY_CYCLE - CLKOUT6_DUTY_CYCLE: Duty cycle for CLKOUT outputs (0.01-0.99). .CLKOUT0_DUTY_CYCLE(0.5), .CLKOUT1_DUTY_CYCLE(0.5), .CLKOUT2_DUTY_CYCLE(0.5), .CLKOUT3_DUTY_CYCLE(0.5), .CLKOUT4_DUTY_CYCLE(0.5), .CLKOUT5_DUTY_CYCLE(0.5), .CLKOUT6_DUTY_CYCLE(0.5), // CLKOUT0_PHASE - CLKOUT6_PHASE: Phase offset for CLKOUT outputs (-360.000-360.000). .CLKOUT0_PHASE(0.0), .CLKOUT1_PHASE(0.0), .CLKOUT2_PHASE(0.0), .CLKOUT3_PHASE(0.0), .CLKOUT4_PHASE(0.0), .CLKOUT5_PHASE(0.0), .CLKOUT6_PHASE(0.0), .CLKOUT4_CASCADE("FALSE"), // Cascade CLKOUT4 counter with CLKOUT6 (FALSE, TRUE) .COMPENSATION("ZHOLD"), // ZHOLD, BUF_IN, EXTERNAL, INTERNAL .DIVCLK_DIVIDE(1), // Master division value (1-106) // REF_JITTER: Reference input jitter in UI (0.000-0.999). .REF_JITTER1(0.0), .REF_JITTER2(0.0), .STARTUP_WAIT("FALSE"), // Delays DONE until MMCM is locked (FALSE, TRUE) // Spread Spectrum: Spread Spectrum Attributes .SS_EN("FALSE"), // Enables spread spectrum (FALSE, TRUE) .SS_MODE("CENTER_HIGH"), // CENTER_HIGH, CENTER_LOW, DOWN_HIGH, DOWN_LOW .SS_MOD_PERIOD(10000), // Spread spectrum modulation period (ns) (VALUES) // USE_FINE_PS: Fine phase shift enable (TRUE/FALSE) .CLKFBOUT_USE_FINE_PS("FALSE"), .CLKOUT0_USE_FINE_PS("FALSE"), .CLKOUT1_USE_FINE_PS("FALSE"), .CLKOUT2_USE_FINE_PS("FALSE"), .CLKOUT3_USE_FINE_PS("FALSE"), .CLKOUT4_USE_FINE_PS("FALSE"), .CLKOUT5_USE_FINE_PS("FALSE"), .CLKOUT6_USE_FINE_PS("FALSE") ) MMCME2_ADV_inst ( // Clock Outputs: 1-bit (each) output: User configurable clock outputs .CLKOUT0(CLKOUT0), // 1-bit output: CLKOUT0 .CLKOUT0B(CLKOUT0B), // 1-bit output: Inverted CLKOUT0 .CLKOUT1(CLKOUT1), // 1-bit output: CLKOUT1 .CLKOUT1B(CLKOUT1B), // 1-bit output: Inverted CLKOUT1 .CLKOUT2(CLKOUT2), // 1-bit output: CLKOUT2 .CLKOUT2B(CLKOUT2B), // 1-bit output: Inverted CLKOUT2 .CLKOUT3(CLKOUT3), // 1-bit output: CLKOUT3 .CLKOUT3B(CLKOUT3B), // 1-bit output: Inverted CLKOUT3 .CLKOUT4(CLKOUT4), // 1-bit output: CLKOUT4 .CLKOUT5(CLKOUT5), // 1-bit output: CLKOUT5 .CLKOUT6(CLKOUT6), // 1-bit output: CLKOUT6 // DRP Ports: 16-bit (each) output: Dynamic reconfiguration ports .DO(DO), // 16-bit output: DRP data .DRDY(DRDY), // 1-bit output: DRP ready // Dynamic Phase Shift Ports: 1-bit (each) output: Ports used for dynamic phase shifting of the outputs .PSDONE(PSDONE), // 1-bit output: Phase shift done // Feedback Clocks: 1-bit (each) output: Clock feedback ports .CLKFBOUT(CLKFBOUT), // 1-bit output: Feedback clock .CLKFBOUTB(CLKFBOUTB), // 1-bit output: Inverted CLKFBOUT // Status Ports: 1-bit (each) output: MMCM status ports .CLKFBSTOPPED(CLKFBSTOPPED), // 1-bit output: Feedback clock stopped .CLKINSTOPPED(CLKINSTOPPED), // 1-bit output: Input clock stopped .LOCKED(LOCKED), // 1-bit output: LOCK // Clock Inputs: 1-bit (each) input: Clock inputs .CLKIN1(CLKIN1), // 1-bit input: Primary clock .CLKIN2(CLKIN2), // 1-bit input: Secondary clock // Control Ports: 1-bit (each) input: MMCM control ports .CLKINSEL(CLKINSEL), // 1-bit input: Clock select, High=CLKIN1 Low=CLKIN2 .PWRDWN(PWRDWN), // 1-bit input: Power-down .RST(RST), // 1-bit input: Reset // DRP Ports: 7-bit (each) input: Dynamic reconfiguration ports .DADDR(DADDR), // 7-bit input: DRP address .DCLK(DCLK), // 1-bit input: DRP clock .DEN(DEN), // 1-bit input: DRP enable .DI(DI), // 16-bit input: DRP data .DWE(DWE), // 1-bit input: DRP write enable // Dynamic Phase Shift Ports: 1-bit (each) input: Ports used for dynamic phase shifting of the outputs .PSCLK(PSCLK), // 1-bit input: Phase shift clock .PSEN(PSEN), // 1-bit input: Phase shift enable .PSINCDEC(PSINCDEC), // 1-bit input: Phase shift increment/decrement // Feedback Clocks: 1-bit (each) input: Clock feedback ports .CLKFBIN(CLKFBIN) // 1-bit input: Feedback clock );
MMCM 驱动 OSERDESE2 的用法
当 MMCME2_ADV 输出时钟作为 OSERDESE2 输入时钟时,MMCME2_ADV 输出时钟通过 BUFGCE 和 BUFGCE_DIV 后,进入 OSERDESE2。好处是通过 BUFGCE 和 BUFGCE_DIV 来减少 CLK 与 CLKDIV 之间时钟偏差。
2.2 MMCM 的 VCO 频率限制
限制条件主要提现在 VCO 频率范围和输出频率范围,这在 7 系列器件 ds181 文档中可以找到该范围:
注意:PLL 和 MMCM 的 VCO 频率范围并非完全一样,具体可以对比 page40 和 page42。
因此,配置 MMCM 分频、倍频参数时,必须保证 VCO 频率在器件的范围之内,否则会报错,例如:
[DRC PDRC-43] PLL_adv_ClkFrequency_div_no_dclk: The computed value 200.000 MHz (CLKIN1_PERIOD, net fpga_ch2_clk_ctrl_reg[19]) for the VCO operating frequency of the PLLE2_ADV site PLLE2_ADV_X0Y0 (cell design_1_i/S2G_M_TOP_0/inst/fpga_ch2_ctrl_inst/PLLE2_BASE_inst) falls outside the operating range of the PLL VCO frequency for this device (800.000 – 1866.000 MHz). The computed value is (CLKFBOUT_MULT_F * 1000 / (CLKINx_PERIOD * DIVCLK_DIVIDE)). Please adjust either the input period CLKINx_PERIOD (5.000000), multiplication factor CLKFBOUT_MULT_F (5) or the division factor DIVCLK_DIVIDE (5), in order to achieve a VCO frequency within the rated operating range for this device.
三、feedback 的连接
根据 ug472 中对 MMCM feedback 的描述(page91~93),共有 2 种方法连接 feedback:
1)通过 BUFG 或者 BUFH,可以防止时钟偏斜(deskew);
2)直接连接,可以防抖,The MMCM feedback can be internal to the MMCM when the MMCM is used as a synthesizer or jitter filter and there is no required phase relationship between the MMCM input clock and the MMCM output clock.
另外,通过 IP 面板配置时,不同选项的含义,可以参考论坛的一个帖子:
- Automatic Control On-Chip
- Automatic Control Off-Chip
- User-Controlled On-Chip
- User-Controlled Off-Chip
Explanation for Clocking Feedback options in Clocking Wizard
以下内容后续更新
解释上述各种颜色的线:
Q:Any of the four clock-capable input pins can drive the PLL/MMCM in the CMT and the BUFH. The BUFG is shown as present in the region, but can be located physically somewhere else in the clock backbone.
Clock-capable pins can drive BUFGs anywhere in the same top/bottom side of the device. There are four tracks in the CMT backbone to support connectivity between vertical regions.
A:红色的线,从 CC 引脚(clock-capable input pins)引出,共 4 根时钟资源走线,驱动 CMT、BUFH 以及 BUFG。
Q:BUFG and BUFH share 12 routing tracks in the HROW and can drive all clocking points in the region. BUFGs can also drive BUFHs (not shown in Figure 1-4). This allows for individual clock enables (CE) on an otherwise global clock distribution.
A:黑色的线,从 BUFG 和 BUFH 引出,BUFG 和 BUFH 共享 12 根时钟走线资源,驱动区域所有的时钟节点(注:logic 对应两侧黑色的细线)。
Q:A GT quad has ten dedicated tracks to drive the CMT and clock buffers in the clock backbone.
A:黄色的线,从 GT 引出,共有 10 根时钟走线资源,驱动 CMT 和 BUF。
Q:The BUFRs located in the I/O bank have four tracks driving clocking points in the logic, CMT, and BUFG.
A:绿色的线,从 BUFR 引出,共 4 根时钟走线资源,驱动 logic(绿色的细线)、CMT 和 BUFG。
Q:CMTs can, with limitations, drive other CMTs in the adjacent regions using the CMT backbone. Similarly, clock-capable pins can drive, with the same limitations, CMTs in adjacent regions.
A:黑色的细线和红色的细线,用于驱动相邻区域的 CMTs。
Clock sources from one region can drive clock buffer resources in its own region as well as in a horizontally adjacent region.
A:一个区域的时钟资源可以驱动所在区域的时钟 buffer,也可以驱动水平相邻区域的时钟 buffer。
Q:CMTs, clock-capable pins, and serial transceivers can drive clocks into the horizontal adjacent region via the BUFH and also connect to the BUFGs in the same top/bottom side of the device.
A:黑、红、黄线,通过 BUFH,也连接至 BUFG,驱动水平相邻区域。
扫码关注尚为网微信公众号
原创文章,作者:sunev,如若转载,请注明出处:https://www.sunev.cn/embedded/1343.html