供给FPGA的时钟有单端时钟,也有差分时钟,当输入是差分时钟时,需要将差分时钟转换为单端时钟输出来作为FPGA的系统工作时钟。
本次使用锁相环来实现差分到单端时钟的转换。
FPGA代码实现如下:
TOP层
`timescale 1ns / 1ps
//
// Company:
// Engineer:
//
// Create Date: 2023/08/31 09:09:58
// Design Name:
// Module Name: led_top
// Project Name:
// Target Devices:
// Tool Versions:
// Description:
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
//module led_top(input sys_clk_i_clk_n,input sys_clk_i_clk_p,output [1:0] led);//单端系统时钟wire sys_clk;wire locked;wire sys_rst;//差分时钟输入转单端clk_wiz_0 clk_wiz_0_u0(// Clock out ports.clk_out1(sys_clk), // output clk_out1// Status and control signals.locked(locked), // output locked// Clock in ports.clk_in1_p(sys_clk_i_clk_p), // input clk_in1_p.clk_in1_n(sys_clk_i_clk_n)); // input clk_in1_n//VIO给出复位信号vio_0 vio_0_u0 (.clk(sys_clk), // input wire clk.probe_out0(sys_rst) // output wire [0 : 0] probe_out0
);//计数器,实现led灯1秒翻转一次//100M时钟,计数10^8次,需27位计数器reg [27:0] cnt;always@(posedge sys_clk)if(sys_rst)cnt <= 28'd0;else if(cnt<28'd100_000_000)cnt <= cnt + 28'd1;else cnt <= 28'd0;//signalreg signal;always@(posedge sys_clk)if(sys_rst)signal <= 'd0;else if(cnt==28'd100)signal <= ~signal ;else signal <= signal;ila_0 ila_0_u0 (.clk(sys_clk), // input wire clk.probe0(led[0]), // input wire [0:0] probe0 .probe1(led[1]) // input wire [0:0] probe1
);assign led[0] = signal;assign led[1] = ~signal;endmodule
XDC引脚约束
#系统时钟管脚约束set_property -dict {PACKAGE_PIN E16 IOSTANDARD LVDS} [get_ports sys_clk_i_clk_p]set_property -dict {PACKAGE_PIN E15 IOSTANDARD LVDS} [get_ports sys_clk_i_clk_n]#led引脚约束set_property PACKAGE_PIN E12 [get_ports {led[0]}]set_property PACKAGE_PIN F13 [get_ports {led[1]}]set_property IOSTANDARD LVCMOS18 [get_ports {led[*]}]
本次验证差分时钟转单端采用的开发板为米联客M7Z100FA,核心板型号为xc7z100ffg900-2。