//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
//
|
//
|
// (c) Copyright 2010-2011 Xilinx, Inc. All rights reserved.
|
// (c) Copyright 2010-2011 Xilinx, Inc. All rights reserved.
|
//
|
//
|
// This file contains confidential and proprietary information
|
// This file contains confidential and proprietary information
|
// of Xilinx, Inc. and is protected under U.S. and
|
// of Xilinx, Inc. and is protected under U.S. and
|
// international copyright and other intellectual property
|
// international copyright and other intellectual property
|
// laws.
|
// laws.
|
//
|
//
|
// DISCLAIMER
|
// DISCLAIMER
|
// This disclaimer is not a license and does not grant any
|
// This disclaimer is not a license and does not grant any
|
// rights to the materials distributed herewith. Except as
|
// rights to the materials distributed herewith. Except as
|
// otherwise provided in a valid license issued to you by
|
// otherwise provided in a valid license issued to you by
|
// Xilinx, and to the maximum extent permitted by applicable
|
// Xilinx, and to the maximum extent permitted by applicable
|
// law: (1) THESE MATERIALS ARE MADE AVAILABLE "AS IS" AND
|
// law: (1) THESE MATERIALS ARE MADE AVAILABLE "AS IS" AND
|
// WITH ALL FAULTS, AND XILINX HEREBY DISCLAIMS ALL WARRANTIES
|
// WITH ALL FAULTS, AND XILINX HEREBY DISCLAIMS ALL WARRANTIES
|
// AND CONDITIONS, EXPRESS, IMPLIED, OR STATUTORY, INCLUDING
|
// AND CONDITIONS, EXPRESS, IMPLIED, OR STATUTORY, INCLUDING
|
// BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, NON-
|
// BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, NON-
|
// INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE; and
|
// INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE; and
|
// (2) Xilinx shall not be liable (whether in contract or tort,
|
// (2) Xilinx shall not be liable (whether in contract or tort,
|
// including negligence, or under any other theory of
|
// including negligence, or under any other theory of
|
// liability) for any loss or damage of any kind or nature
|
// liability) for any loss or damage of any kind or nature
|
// related to, arising under or in connection with these
|
// related to, arising under or in connection with these
|
// materials, including for any direct, or any indirect,
|
// materials, including for any direct, or any indirect,
|
// special, incidental, or consequential loss or damage
|
// special, incidental, or consequential loss or damage
|
// (including loss of data, profits, goodwill, or any type of
|
// (including loss of data, profits, goodwill, or any type of
|
// loss or damage suffered as a result of any action brought
|
// loss or damage suffered as a result of any action brought
|
// by a third party) even if such damage or loss was
|
// by a third party) even if such damage or loss was
|
// reasonably foreseeable or Xilinx had been advised of the
|
// reasonably foreseeable or Xilinx had been advised of the
|
// possibility of the same.
|
// possibility of the same.
|
//
|
//
|
// CRITICAL APPLICATIONS
|
// CRITICAL APPLICATIONS
|
// Xilinx products are not designed or intended to be fail-
|
// Xilinx products are not designed or intended to be fail-
|
// safe, or for use in any application requiring fail-safe
|
// safe, or for use in any application requiring fail-safe
|
// performance, such as life-support or safety devices or
|
// performance, such as life-support or safety devices or
|
// systems, Class III medical devices, nuclear facilities,
|
// systems, Class III medical devices, nuclear facilities,
|
// applications related to the deployment of airbags, or any
|
// applications related to the deployment of airbags, or any
|
// other applications that could lead to death, personal
|
// other applications that could lead to death, personal
|
// injury, or severe property or environmental damage
|
// injury, or severe property or environmental damage
|
// (individually and collectively, "Critical
|
// (individually and collectively, "Critical
|
// Applications"). Customer assumes the sole risk and
|
// Applications"). Customer assumes the sole risk and
|
// liability of any use of Xilinx products in Critical
|
// liability of any use of Xilinx products in Critical
|
// Applications, subject only to applicable laws and
|
// Applications, subject only to applicable laws and
|
// regulations governing limitations on product liability.
|
// regulations governing limitations on product liability.
|
//
|
//
|
// THIS COPYRIGHT NOTICE AND DISCLAIMER MUST BE RETAINED AS
|
// THIS COPYRIGHT NOTICE AND DISCLAIMER MUST BE RETAINED AS
|
// PART OF THIS FILE AT ALL TIMES.
|
// PART OF THIS FILE AT ALL TIMES.
|
//
|
//
|
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
// Project : Series-7 Integrated Block for PCI Express
|
// Project : Series-7 Integrated Block for PCI Express
|
// File : cl_a7pcie_x4_pipe_clock.v
|
// File : cl_a7pcie_x4_pipe_clock.v
|
// Version : 1.10
|
// Version : 1.11
|
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
// Filename : pipe_clock.v
|
// Filename : pipe_clock.v
|
// Description : PIPE Clock Module for 7 Series Transceiver
|
// Description : PIPE Clock Module for 7 Series Transceiver
|
// Version : 15.3
|
// Version : 15.3
|
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
|
|
|
|
|
|
`timescale 1ns / 1ps
|
`timescale 1ns / 1ps
|
|
|
|
|
|
|
//---------- PIPE Clock Module -------------------------------------------------
|
//---------- PIPE Clock Module -------------------------------------------------
|
module cl_a7pcie_x4_pipe_clock #
|
module cl_a7pcie_x4_pipe_clock #
|
(
|
(
|
|
|
parameter PCIE_ASYNC_EN = "FALSE", // PCIe async enable
|
parameter PCIE_ASYNC_EN = "FALSE", // PCIe async enable
|
parameter PCIE_TXBUF_EN = "FALSE", // PCIe TX buffer enable for Gen1/Gen2 only
|
parameter PCIE_TXBUF_EN = "FALSE", // PCIe TX buffer enable for Gen1/Gen2 only
|
parameter PCIE_LANE = 1, // PCIe number of lanes
|
parameter PCIE_LANE = 1, // PCIe number of lanes
|
parameter PCIE_LINK_SPEED = 3, // PCIe link speed
|
parameter PCIE_LINK_SPEED = 3, // PCIe link speed
|
parameter PCIE_REFCLK_FREQ = 0, // PCIe reference clock frequency
|
parameter PCIE_REFCLK_FREQ = 0, // PCIe reference clock frequency
|
parameter PCIE_USERCLK1_FREQ = 2, // PCIe user clock 1 frequency
|
parameter PCIE_USERCLK1_FREQ = 2, // PCIe user clock 1 frequency
|
parameter PCIE_USERCLK2_FREQ = 2, // PCIe user clock 2 frequency
|
parameter PCIE_USERCLK2_FREQ = 2, // PCIe user clock 2 frequency
|
parameter PCIE_OOBCLK_MODE = 1, // PCIe oob clock mode
|
parameter PCIE_OOBCLK_MODE = 1, // PCIe oob clock mode
|
parameter PCIE_DEBUG_MODE = 0 // PCIe Debug mode
|
parameter PCIE_DEBUG_MODE = 0 // PCIe Debug mode
|
|
|
)
|
)
|
|
|
(
|
(
|
|
|
//---------- Input -------------------------------------
|
//---------- Input -------------------------------------
|
input CLK_CLK,
|
input CLK_CLK,
|
input CLK_TXOUTCLK,
|
input CLK_TXOUTCLK,
|
input [PCIE_LANE-1:0] CLK_RXOUTCLK_IN,
|
input [PCIE_LANE-1:0] CLK_RXOUTCLK_IN,
|
input CLK_RST_N,
|
input CLK_RST_N,
|
input [PCIE_LANE-1:0] CLK_PCLK_SEL,
|
input [PCIE_LANE-1:0] CLK_PCLK_SEL,
|
input CLK_GEN3,
|
input CLK_GEN3,
|
|
|
//---------- Output ------------------------------------
|
//---------- Output ------------------------------------
|
output CLK_PCLK,
|
output CLK_PCLK,
|
output CLK_RXUSRCLK,
|
output CLK_RXUSRCLK,
|
output [PCIE_LANE-1:0] CLK_RXOUTCLK_OUT,
|
output [PCIE_LANE-1:0] CLK_RXOUTCLK_OUT,
|
output CLK_DCLK,
|
output CLK_DCLK,
|
output CLK_OOBCLK,
|
output CLK_OOBCLK,
|
output CLK_USERCLK1,
|
output CLK_USERCLK1,
|
output CLK_USERCLK2,
|
output CLK_USERCLK2,
|
output CLK_MMCM_LOCK
|
output CLK_MMCM_LOCK
|
|
|
);
|
);
|
|
|
//---------- Select Clock Divider ----------------------
|
//---------- Select Clock Divider ----------------------
|
localparam DIVCLK_DIVIDE = (PCIE_REFCLK_FREQ == 2) ? 1 :
|
localparam DIVCLK_DIVIDE = (PCIE_REFCLK_FREQ == 2) ? 1 :
|
(PCIE_REFCLK_FREQ == 1) ? 1 : 1;
|
(PCIE_REFCLK_FREQ == 1) ? 1 : 1;
|
|
|
localparam CLKFBOUT_MULT_F = (PCIE_REFCLK_FREQ == 2) ? 4 :
|
localparam CLKFBOUT_MULT_F = (PCIE_REFCLK_FREQ == 2) ? 4 :
|
(PCIE_REFCLK_FREQ == 1) ? 8 : 10;
|
(PCIE_REFCLK_FREQ == 1) ? 8 : 10;
|
|
|
localparam CLKIN1_PERIOD = (PCIE_REFCLK_FREQ == 2) ? 4 :
|
localparam CLKIN1_PERIOD = (PCIE_REFCLK_FREQ == 2) ? 4 :
|
(PCIE_REFCLK_FREQ == 1) ? 8 : 10;
|
(PCIE_REFCLK_FREQ == 1) ? 8 : 10;
|
|
|
localparam CLKOUT0_DIVIDE_F = 8;
|
localparam CLKOUT0_DIVIDE_F = 8;
|
|
|
localparam CLKOUT1_DIVIDE = 4;
|
localparam CLKOUT1_DIVIDE = 4;
|
|
|
localparam CLKOUT2_DIVIDE = (PCIE_USERCLK1_FREQ == 5) ? 2 :
|
localparam CLKOUT2_DIVIDE = (PCIE_USERCLK1_FREQ == 5) ? 2 :
|
(PCIE_USERCLK1_FREQ == 4) ? 4 :
|
(PCIE_USERCLK1_FREQ == 4) ? 4 :
|
(PCIE_USERCLK1_FREQ == 3) ? 8 :
|
(PCIE_USERCLK1_FREQ == 3) ? 8 :
|
(PCIE_USERCLK1_FREQ == 1) ? 32 : 16;
|
(PCIE_USERCLK1_FREQ == 1) ? 32 : 16;
|
|
|
localparam CLKOUT3_DIVIDE = (PCIE_USERCLK2_FREQ == 5) ? 2 :
|
localparam CLKOUT3_DIVIDE = (PCIE_USERCLK2_FREQ == 5) ? 2 :
|
(PCIE_USERCLK2_FREQ == 4) ? 4 :
|
(PCIE_USERCLK2_FREQ == 4) ? 4 :
|
(PCIE_USERCLK2_FREQ == 3) ? 8 :
|
(PCIE_USERCLK2_FREQ == 3) ? 8 :
|
(PCIE_USERCLK2_FREQ == 1) ? 32 : 16;
|
(PCIE_USERCLK2_FREQ == 1) ? 32 : 16;
|
|
|
localparam CLKOUT4_DIVIDE = 20;
|
localparam CLKOUT4_DIVIDE = 20;
|
|
|
//---------- Select Reference Clock --------------------
|
//---------- Select Reference Clock --------------------
|
localparam REFCLK_SEL = ((PCIE_TXBUF_EN == "TRUE") && (PCIE_LINK_SPEED != 3)) ? 1'd1 : 1'd0;
|
localparam REFCLK_SEL = ((PCIE_TXBUF_EN == "TRUE") && (PCIE_LINK_SPEED != 3)) ? 1'd1 : 1'd0;
|
|
|
//---------- Input Registers ---------------------------
|
//---------- Input Registers ---------------------------
|
(* ASYNC_REG = "TRUE", SHIFT_EXTRACT = "NO" *) reg [PCIE_LANE-1:0] pclk_sel_reg1 = {PCIE_LANE{1'd0}};
|
(* ASYNC_REG = "TRUE", SHIFT_EXTRACT = "NO" *) reg [PCIE_LANE-1:0] pclk_sel_reg1 = {PCIE_LANE{1'd0}};
|
(* ASYNC_REG = "TRUE", SHIFT_EXTRACT = "NO" *) reg gen3_reg1 = 1'd0;
|
(* ASYNC_REG = "TRUE", SHIFT_EXTRACT = "NO" *) reg gen3_reg1 = 1'd0;
|
|
|
(* ASYNC_REG = "TRUE", SHIFT_EXTRACT = "NO" *) reg [PCIE_LANE-1:0] pclk_sel_reg2 = {PCIE_LANE{1'd0}};
|
(* ASYNC_REG = "TRUE", SHIFT_EXTRACT = "NO" *) reg [PCIE_LANE-1:0] pclk_sel_reg2 = {PCIE_LANE{1'd0}};
|
(* ASYNC_REG = "TRUE", SHIFT_EXTRACT = "NO" *) reg gen3_reg2 = 1'd0;
|
(* ASYNC_REG = "TRUE", SHIFT_EXTRACT = "NO" *) reg gen3_reg2 = 1'd0;
|
|
|
//---------- Internal Signals --------------------------
|
//---------- Internal Signals --------------------------
|
wire refclk;
|
wire refclk;
|
wire mmcm_fb;
|
wire mmcm_fb;
|
wire clk_125mhz;
|
wire clk_125mhz;
|
wire clk_125mhz_buf;
|
wire clk_125mhz_buf;
|
wire clk_250mhz;
|
wire clk_250mhz;
|
wire userclk1;
|
wire userclk1;
|
wire userclk2;
|
wire userclk2;
|
wire oobclk;
|
wire oobclk;
|
reg pclk_sel = 1'd0;
|
reg pclk_sel = 1'd0;
|
|
|
//---------- Output Registers --------------------------
|
//---------- Output Registers --------------------------
|
wire pclk_1;
|
wire pclk_1;
|
wire pclk;
|
wire pclk;
|
wire userclk1_1;
|
wire userclk1_1;
|
wire userclk2_1;
|
wire userclk2_1;
|
wire mmcm_lock;
|
wire mmcm_lock;
|
|
|
//---------- Generate Per-Lane Signals -----------------
|
//---------- Generate Per-Lane Signals -----------------
|
genvar i; // Index for per-lane signals
|
genvar i; // Index for per-lane signals
|
|
|
|
|
|
|
//---------- Input FF ----------------------------------------------------------
|
//---------- Input FF ----------------------------------------------------------
|
always @ (posedge pclk)
|
always @ (posedge pclk)
|
begin
|
begin
|
|
|
if (!CLK_RST_N)
|
if (!CLK_RST_N)
|
begin
|
begin
|
//---------- 1st Stage FF --------------------------
|
//---------- 1st Stage FF --------------------------
|
pclk_sel_reg1 <= {PCIE_LANE{1'd0}};
|
pclk_sel_reg1 <= {PCIE_LANE{1'd0}};
|
gen3_reg1 <= 1'd0;
|
gen3_reg1 <= 1'd0;
|
//---------- 2nd Stage FF --------------------------
|
//---------- 2nd Stage FF --------------------------
|
pclk_sel_reg2 <= {PCIE_LANE{1'd0}};
|
pclk_sel_reg2 <= {PCIE_LANE{1'd0}};
|
gen3_reg2 <= 1'd0;
|
gen3_reg2 <= 1'd0;
|
end
|
end
|
else
|
else
|
begin
|
begin
|
//---------- 1st Stage FF --------------------------
|
//---------- 1st Stage FF --------------------------
|
pclk_sel_reg1 <= CLK_PCLK_SEL;
|
pclk_sel_reg1 <= CLK_PCLK_SEL;
|
gen3_reg1 <= CLK_GEN3;
|
gen3_reg1 <= CLK_GEN3;
|
//---------- 2nd Stage FF --------------------------
|
//---------- 2nd Stage FF --------------------------
|
pclk_sel_reg2 <= pclk_sel_reg1;
|
pclk_sel_reg2 <= pclk_sel_reg1;
|
gen3_reg2 <= gen3_reg1;
|
gen3_reg2 <= gen3_reg1;
|
end
|
end
|
|
|
end
|
end
|
|
|
|
|
|
|
//---------- Select Reference clock or TXOUTCLK --------------------------------
|
//---------- Select Reference clock or TXOUTCLK --------------------------------
|
generate if ((PCIE_TXBUF_EN == "TRUE") && (PCIE_LINK_SPEED != 3))
|
generate if ((PCIE_TXBUF_EN == "TRUE") && (PCIE_LINK_SPEED != 3))
|
|
|
begin : refclk_i
|
begin : refclk_i
|
|
|
//---------- Select Reference Clock ----------------------------------------
|
//---------- Select Reference Clock ----------------------------------------
|
BUFG refclk_i
|
BUFG refclk_i
|
(
|
(
|
|
|
//---------- Input -------------------------------------
|
//---------- Input -------------------------------------
|
.I (CLK_CLK),
|
.I (CLK_CLK),
|
//---------- Output ------------------------------------
|
//---------- Output ------------------------------------
|
.O (refclk)
|
.O (refclk)
|
|
|
);
|
);
|
|
|
end
|
end
|
|
|
else
|
else
|
|
|
begin : txoutclk_i
|
begin : txoutclk_i
|
|
|
//---------- Select TXOUTCLK -----------------------------------------------
|
//---------- Select TXOUTCLK -----------------------------------------------
|
BUFG txoutclk_i
|
BUFG txoutclk_i
|
(
|
(
|
|
|
//---------- Input -------------------------------------
|
//---------- Input -------------------------------------
|
.I (CLK_TXOUTCLK),
|
.I (CLK_TXOUTCLK),
|
//---------- Output ------------------------------------
|
//---------- Output ------------------------------------
|
.O (refclk)
|
.O (refclk)
|
|
|
);
|
);
|
|
|
end
|
end
|
|
|
endgenerate
|
endgenerate
|
|
|
|
|
|
|
//---------- MMCM --------------------------------------------------------------
|
//---------- MMCM --------------------------------------------------------------
|
MMCME2_ADV #
|
MMCME2_ADV #
|
(
|
(
|
|
|
.BANDWIDTH ("OPTIMIZED"),
|
.BANDWIDTH ("OPTIMIZED"),
|
.CLKOUT4_CASCADE ("FALSE"),
|
.CLKOUT4_CASCADE ("FALSE"),
|
.COMPENSATION ("ZHOLD"),
|
.COMPENSATION ("ZHOLD"),
|
.STARTUP_WAIT ("FALSE"),
|
.STARTUP_WAIT ("FALSE"),
|
.DIVCLK_DIVIDE (DIVCLK_DIVIDE),
|
.DIVCLK_DIVIDE (DIVCLK_DIVIDE),
|
.CLKFBOUT_MULT_F (CLKFBOUT_MULT_F),
|
.CLKFBOUT_MULT_F (CLKFBOUT_MULT_F),
|
.CLKFBOUT_PHASE (0.000),
|
.CLKFBOUT_PHASE (0.000),
|
.CLKFBOUT_USE_FINE_PS ("FALSE"),
|
.CLKFBOUT_USE_FINE_PS ("FALSE"),
|
.CLKOUT0_DIVIDE_F (CLKOUT0_DIVIDE_F),
|
.CLKOUT0_DIVIDE_F (CLKOUT0_DIVIDE_F),
|
.CLKOUT0_PHASE (0.000),
|
.CLKOUT0_PHASE (0.000),
|
.CLKOUT0_DUTY_CYCLE (0.500),
|
.CLKOUT0_DUTY_CYCLE (0.500),
|
.CLKOUT0_USE_FINE_PS ("FALSE"),
|
.CLKOUT0_USE_FINE_PS ("FALSE"),
|
.CLKOUT1_DIVIDE (CLKOUT1_DIVIDE),
|
.CLKOUT1_DIVIDE (CLKOUT1_DIVIDE),
|
.CLKOUT1_PHASE (0.000),
|
.CLKOUT1_PHASE (0.000),
|
.CLKOUT1_DUTY_CYCLE (0.500),
|
.CLKOUT1_DUTY_CYCLE (0.500),
|
.CLKOUT1_USE_FINE_PS ("FALSE"),
|
.CLKOUT1_USE_FINE_PS ("FALSE"),
|
.CLKOUT2_DIVIDE (CLKOUT2_DIVIDE),
|
.CLKOUT2_DIVIDE (CLKOUT2_DIVIDE),
|
.CLKOUT2_PHASE (0.000),
|
.CLKOUT2_PHASE (0.000),
|
.CLKOUT2_DUTY_CYCLE (0.500),
|
.CLKOUT2_DUTY_CYCLE (0.500),
|
.CLKOUT2_USE_FINE_PS ("FALSE"),
|
.CLKOUT2_USE_FINE_PS ("FALSE"),
|
.CLKOUT3_DIVIDE (CLKOUT3_DIVIDE),
|
.CLKOUT3_DIVIDE (CLKOUT3_DIVIDE),
|
.CLKOUT3_PHASE (0.000),
|
.CLKOUT3_PHASE (0.000),
|
.CLKOUT3_DUTY_CYCLE (0.500),
|
.CLKOUT3_DUTY_CYCLE (0.500),
|
.CLKOUT3_USE_FINE_PS ("FALSE"),
|
.CLKOUT3_USE_FINE_PS ("FALSE"),
|
.CLKOUT4_DIVIDE (CLKOUT4_DIVIDE),
|
.CLKOUT4_DIVIDE (CLKOUT4_DIVIDE),
|
.CLKOUT4_PHASE (0.000),
|
.CLKOUT4_PHASE (0.000),
|
.CLKOUT4_DUTY_CYCLE (0.500),
|
.CLKOUT4_DUTY_CYCLE (0.500),
|
.CLKOUT4_USE_FINE_PS ("FALSE"),
|
.CLKOUT4_USE_FINE_PS ("FALSE"),
|
.CLKIN1_PERIOD (CLKIN1_PERIOD),
|
.CLKIN1_PERIOD (CLKIN1_PERIOD),
|
.REF_JITTER1 (0.010)
|
.REF_JITTER1 (0.010)
|
|
|
)
|
)
|
mmcm_i
|
mmcm_i
|
(
|
(
|
|
|
//---------- Input ------------------------------------
|
//---------- Input ------------------------------------
|
.CLKIN1 (refclk),
|
.CLKIN1 (refclk),
|
//.CLKIN2 (1'd0), // not used, comment out CLKIN2 if it cause implementation issues
|
.CLKIN2 (1'd0), // not used, comment out CLKIN2 if it cause implementation issues
|
//.CLKIN2 (refclk), // not used, comment out CLKIN2 if it cause implementation issues
|
//.CLKIN2 (refclk), // not used, comment out CLKIN2 if it cause implementation issues
|
.CLKINSEL (1'd1),
|
.CLKINSEL (1'd1),
|
.CLKFBIN (mmcm_fb),
|
.CLKFBIN (mmcm_fb),
|
.RST (!CLK_RST_N),
|
.RST (!CLK_RST_N),
|
.PWRDWN (1'd0),
|
.PWRDWN (1'd0),
|
|
|
//---------- Output ------------------------------------
|
//---------- Output ------------------------------------
|
.CLKFBOUT (mmcm_fb),
|
.CLKFBOUT (mmcm_fb),
|
.CLKFBOUTB (),
|
.CLKFBOUTB (),
|
.CLKOUT0 (clk_125mhz),
|
.CLKOUT0 (clk_125mhz),
|
.CLKOUT0B (),
|
.CLKOUT0B (),
|
.CLKOUT1 (clk_250mhz),
|
.CLKOUT1 (clk_250mhz),
|
.CLKOUT1B (),
|
.CLKOUT1B (),
|
.CLKOUT2 (userclk1),
|
.CLKOUT2 (userclk1),
|
.CLKOUT2B (),
|
.CLKOUT2B (),
|
.CLKOUT3 (userclk2),
|
.CLKOUT3 (userclk2),
|
.CLKOUT3B (),
|
.CLKOUT3B (),
|
.CLKOUT4 (oobclk),
|
.CLKOUT4 (oobclk),
|
.CLKOUT5 (),
|
.CLKOUT5 (),
|
.CLKOUT6 (),
|
.CLKOUT6 (),
|
.LOCKED (mmcm_lock),
|
.LOCKED (mmcm_lock),
|
|
|
//---------- Dynamic Reconfiguration -------------------
|
//---------- Dynamic Reconfiguration -------------------
|
.DCLK ( 1'd0),
|
.DCLK ( 1'd0),
|
.DADDR ( 7'd0),
|
.DADDR ( 7'd0),
|
.DEN ( 1'd0),
|
.DEN ( 1'd0),
|
.DWE ( 1'd0),
|
.DWE ( 1'd0),
|
.DI (16'd0),
|
.DI (16'd0),
|
.DO (),
|
.DO (),
|
.DRDY (),
|
.DRDY (),
|
|
|
//---------- Dynamic Phase Shift -----------------------
|
//---------- Dynamic Phase Shift -----------------------
|
.PSCLK (1'd0),
|
.PSCLK (1'd0),
|
.PSEN (1'd0),
|
.PSEN (1'd0),
|
.PSINCDEC (1'd0),
|
.PSINCDEC (1'd0),
|
.PSDONE (),
|
.PSDONE (),
|
|
|
//---------- Status ------------------------------------
|
//---------- Status ------------------------------------
|
.CLKINSTOPPED (),
|
.CLKINSTOPPED (),
|
.CLKFBSTOPPED ()
|
.CLKFBSTOPPED ()
|
|
|
);
|
);
|
|
|
|
|
|
|
//---------- Select PCLK MUX ---------------------------------------------------
|
//---------- Select PCLK MUX ---------------------------------------------------
|
generate if (PCIE_LINK_SPEED != 1)
|
generate if (PCIE_LINK_SPEED != 1)
|
|
|
begin : pclk_i1_bufgctrl
|
begin : pclk_i1_bufgctrl
|
//---------- PCLK Mux ----------------------------------
|
//---------- PCLK Mux ----------------------------------
|
BUFGCTRL pclk_i1
|
BUFGCTRL pclk_i1
|
(
|
(
|
//---------- Input ---------------------------------
|
//---------- Input ---------------------------------
|
.CE0 (1'd1),
|
.CE0 (1'd1),
|
.CE1 (1'd1),
|
.CE1 (1'd1),
|
.I0 (clk_125mhz),
|
.I0 (clk_125mhz),
|
.I1 (clk_250mhz),
|
.I1 (clk_250mhz),
|
.IGNORE0 (1'd0),
|
.IGNORE0 (1'd0),
|
.IGNORE1 (1'd0),
|
.IGNORE1 (1'd0),
|
.S0 (~pclk_sel),
|
.S0 (~pclk_sel),
|
.S1 ( pclk_sel),
|
.S1 ( pclk_sel),
|
//---------- Output --------------------------------
|
//---------- Output --------------------------------
|
.O (pclk_1)
|
.O (pclk_1)
|
);
|
);
|
end
|
end
|
|
|
else
|
else
|
|
|
//---------- Select PCLK Buffer ------------------------
|
//---------- Select PCLK Buffer ------------------------
|
begin : pclk_i1_bufg
|
begin : pclk_i1_bufg
|
//---------- PCLK Buffer -------------------------------
|
//---------- PCLK Buffer -------------------------------
|
BUFG pclk_i1
|
BUFG pclk_i1
|
(
|
(
|
//---------- Input ---------------------------------
|
//---------- Input ---------------------------------
|
.I (clk_125mhz),
|
.I (clk_125mhz),
|
//---------- Output --------------------------------
|
//---------- Output --------------------------------
|
.O (clk_125mhz_buf)
|
.O (clk_125mhz_buf)
|
);
|
);
|
assign pclk_1 = clk_125mhz_buf;
|
assign pclk_1 = clk_125mhz_buf;
|
end
|
end
|
|
|
endgenerate
|
endgenerate
|
|
|
|
|
|
|
//---------- Generate RXOUTCLK Buffer for Debug --------------------------------
|
//---------- Generate RXOUTCLK Buffer for Debug --------------------------------
|
generate if ((PCIE_DEBUG_MODE == 1) || (PCIE_ASYNC_EN == "TRUE"))
|
generate if ((PCIE_DEBUG_MODE == 1) || (PCIE_ASYNC_EN == "TRUE"))
|
|
|
begin : rxoutclk_per_lane
|
begin : rxoutclk_per_lane
|
//---------- Generate per Lane -------------------------
|
//---------- Generate per Lane -------------------------
|
for (i=0; i<PCIE_LANE; i=i+1)
|
for (i=0; i<PCIE_LANE; i=i+1)
|
|
|
begin : rxoutclk_i
|
begin : rxoutclk_i
|
//---------- RXOUTCLK Buffer -----------------------
|
//---------- RXOUTCLK Buffer -----------------------
|
BUFG rxoutclk_i
|
BUFG rxoutclk_i
|
(
|
(
|
//---------- Input -----------------------------
|
//---------- Input -----------------------------
|
.I (CLK_RXOUTCLK_IN[i]),
|
.I (CLK_RXOUTCLK_IN[i]),
|
//---------- Output ----------------------------
|
//---------- Output ----------------------------
|
.O (CLK_RXOUTCLK_OUT[i])
|
.O (CLK_RXOUTCLK_OUT[i])
|
);
|
);
|
end
|
end
|
|
|
end
|
end
|
|
|
else
|
else
|
|
|
//---------- Disable RXOUTCLK Buffer for Normal Operation
|
//---------- Disable RXOUTCLK Buffer for Normal Operation
|
begin : rxoutclk_i_disable
|
begin : rxoutclk_i_disable
|
assign CLK_RXOUTCLK_OUT = {PCIE_LANE{1'd0}};
|
assign CLK_RXOUTCLK_OUT = {PCIE_LANE{1'd0}};
|
end
|
end
|
|
|
endgenerate
|
endgenerate
|
|
|
|
|
//---------- Generate DCLK Buffer ----------------------------------------------
|
//---------- Generate DCLK Buffer ----------------------------------------------
|
generate if (PCIE_LINK_SPEED != 1)
|
generate if (PCIE_LINK_SPEED != 1)
|
|
|
begin : dclk_i_bufg
|
begin : dclk_i_bufg
|
//---------- DCLK Buffer -------------------------------
|
//---------- DCLK Buffer -------------------------------
|
BUFG dclk_i
|
BUFG dclk_i
|
(
|
(
|
//---------- Input ---------------------------------
|
//---------- Input ---------------------------------
|
.I (clk_125mhz),
|
.I (clk_125mhz),
|
//---------- Output --------------------------------
|
//---------- Output --------------------------------
|
.O (CLK_DCLK)
|
.O (CLK_DCLK)
|
);
|
);
|
end
|
end
|
|
|
else
|
else
|
|
|
//---------- Disable DCLK Buffer -----------------------
|
//---------- Disable DCLK Buffer -----------------------
|
begin : dclk_i
|
begin : dclk_i
|
assign CLK_DCLK = clk_125mhz_buf; // always 125 MHz in Gen1
|
assign CLK_DCLK = clk_125mhz_buf; // always 125 MHz in Gen1
|
end
|
end
|
|
|
endgenerate
|
endgenerate
|
|
|
|
|
|
|
//---------- Generate USERCLK1 Buffer ------------------------------------------
|
//---------- Generate USERCLK1 Buffer ------------------------------------------
|
generate if (PCIE_USERCLK1_FREQ != 0)
|
generate if (PCIE_USERCLK1_FREQ != 0)
|
|
|
begin : userclk1_i1
|
begin : userclk1_i1
|
//---------- USERCLK1 Buffer ---------------------------
|
//---------- USERCLK1 Buffer ---------------------------
|
BUFG usrclk1_i1
|
BUFG usrclk1_i1
|
(
|
(
|
//---------- Input ---------------------------------
|
//---------- Input ---------------------------------
|
.I (userclk1),
|
.I (userclk1),
|
//---------- Output --------------------------------
|
//---------- Output --------------------------------
|
.O (userclk1_1)
|
.O (userclk1_1)
|
);
|
);
|
end
|
end
|
|
|
else
|
else
|
|
|
//---------- Disable USERCLK1 Buffer -------------------
|
//---------- Disable USERCLK1 Buffer -------------------
|
begin : disable_userclk1_i1
|
begin : disable_userclk1_i1
|
assign userclk1_1 = 1'd0;
|
assign userclk1_1 = 1'd0;
|
end
|
end
|
|
|
endgenerate
|
endgenerate
|
|
|
|
|
|
|
//---------- Generate USERCLK2 Buffer ------------------------------------------
|
//---------- Generate USERCLK2 Buffer ------------------------------------------
|
generate if (PCIE_USERCLK2_FREQ != 0)
|
generate if (PCIE_USERCLK2_FREQ != 0)
|
|
|
begin : userclk2_i1
|
begin : userclk2_i1
|
//---------- USERCLK2 Buffer ---------------------------
|
//---------- USERCLK2 Buffer ---------------------------
|
BUFG usrclk2_i1
|
BUFG usrclk2_i1
|
(
|
(
|
//---------- Input ---------------------------------
|
//---------- Input ---------------------------------
|
.I (userclk2),
|
.I (userclk2),
|
//---------- Output --------------------------------
|
//---------- Output --------------------------------
|
.O (userclk2_1)
|
.O (userclk2_1)
|
);
|
);
|
end
|
end
|
|
|
else
|
else
|
|
|
//---------- Disable USERCLK2 Buffer -------------------
|
//---------- Disable USERCLK2 Buffer -------------------
|
begin : userclk2_i1_disable
|
begin : userclk2_i1_disable
|
assign userclk2_1 = 1'd0;
|
assign userclk2_1 = 1'd0;
|
end
|
end
|
|
|
endgenerate
|
endgenerate
|
|
|
|
|
|
|
//---------- Generate OOBCLK Buffer --------------------------------------------
|
//---------- Generate OOBCLK Buffer --------------------------------------------
|
generate if (PCIE_OOBCLK_MODE == 2)
|
generate if (PCIE_OOBCLK_MODE == 2)
|
|
|
begin : oobclk_i1
|
begin : oobclk_i1
|
//---------- OOBCLK Buffer -----------------------------
|
//---------- OOBCLK Buffer -----------------------------
|
BUFG oobclk_i1
|
BUFG oobclk_i1
|
(
|
(
|
//---------- Input ---------------------------------
|
//---------- Input ---------------------------------
|
.I (oobclk),
|
.I (oobclk),
|
//---------- Output --------------------------------
|
//---------- Output --------------------------------
|
.O (CLK_OOBCLK)
|
.O (CLK_OOBCLK)
|
);
|
);
|
end
|
end
|
|
|
else
|
else
|
|
|
//---------- Disable OOBCLK Buffer ---------------------
|
//---------- Disable OOBCLK Buffer ---------------------
|
begin : oobclk_i1_disable
|
begin : oobclk_i1_disable
|
assign CLK_OOBCLK = pclk;
|
assign CLK_OOBCLK = pclk;
|
end
|
end
|
|
|
endgenerate
|
endgenerate
|
|
|
|
|
|
|
//---------- Generate 2nd Stage Buffers ----------------------------------------
|
//---------- Generate 2nd Stage Buffers ----------------------------------------
|
generate if ((PCIE_LINK_SPEED == 3) && (PCIE_ASYNC_EN == "TRUE"))
|
generate if ((PCIE_LINK_SPEED == 3) && (PCIE_ASYNC_EN == "TRUE"))
|
|
|
begin : second_stage_buf
|
begin : second_stage_buf
|
|
|
//---------- PCLK Buffer ---------------------------------------------------
|
//---------- PCLK Buffer ---------------------------------------------------
|
BUFG pclk_i2
|
BUFG pclk_i2
|
(
|
(
|
//---------- Input -------------------------------------
|
//---------- Input -------------------------------------
|
.I (pclk_1),
|
.I (pclk_1),
|
//---------- Output ------------------------------------
|
//---------- Output ------------------------------------
|
.O (pclk)
|
.O (pclk)
|
);
|
);
|
|
|
|
|
|
|
//---------- RXUSRCLK Mux --------------------------------------------------
|
//---------- RXUSRCLK Mux --------------------------------------------------
|
BUFGCTRL rxusrclk_i2
|
BUFGCTRL rxusrclk_i2
|
(
|
(
|
//---------- Input ---------------------------------
|
//---------- Input ---------------------------------
|
.CE0 (1'b1),
|
.CE0 (1'b1),
|
.CE1 (1'b1),
|
.CE1 (1'b1),
|
.I0 (pclk_1),
|
.I0 (pclk_1),
|
.I1 (CLK_RXOUTCLK_IN[0]),
|
.I1 (CLK_RXOUTCLK_IN[0]),
|
.IGNORE0 (1'b0),
|
.IGNORE0 (1'b0),
|
.IGNORE1 (1'b0),
|
.IGNORE1 (1'b0),
|
.S0 (~gen3_reg2),
|
.S0 (~gen3_reg2),
|
.S1 ( gen3_reg2),
|
.S1 ( gen3_reg2),
|
//---------- Output --------------------------------
|
//---------- Output --------------------------------
|
.O (CLK_RXUSRCLK)
|
.O (CLK_RXUSRCLK)
|
);
|
);
|
|
|
|
|
|
|
//---------- Generate USERCLK1 Buffer --------------------------------------
|
//---------- Generate USERCLK1 Buffer --------------------------------------
|
if (PCIE_USERCLK1_FREQ != 0)
|
if (PCIE_USERCLK1_FREQ != 0)
|
|
|
begin : userclk1_i2
|
begin : userclk1_i2
|
//---------- USERCLK1 Buffer -----------------------
|
//---------- USERCLK1 Buffer -----------------------
|
BUFG usrclk1_i2
|
BUFG usrclk1_i2
|
(
|
(
|
//---------- Input -----------------------------
|
//---------- Input -----------------------------
|
.I (userclk1_1),
|
.I (userclk1_1),
|
//---------- Output ----------------------------
|
//---------- Output ----------------------------
|
.O (CLK_USERCLK1)
|
.O (CLK_USERCLK1)
|
);
|
);
|
end
|
end
|
|
|
else
|
else
|
|
|
//---------- Disable USERCLK1 Buffer ---------------
|
//---------- Disable USERCLK1 Buffer ---------------
|
begin : userclk1_i2_disable
|
begin : userclk1_i2_disable
|
assign CLK_USERCLK1 = userclk1_1;
|
assign CLK_USERCLK1 = userclk1_1;
|
end
|
end
|
|
|
|
|
|
|
//---------- Generate USERCLK2 Buffer --------------------------------------
|
//---------- Generate USERCLK2 Buffer --------------------------------------
|
if (PCIE_USERCLK2_FREQ != 0)
|
if (PCIE_USERCLK2_FREQ != 0)
|
|
|
begin : userclk2_i2
|
begin : userclk2_i2
|
//---------- USERCLK2 Buffer -----------------------
|
//---------- USERCLK2 Buffer -----------------------
|
BUFG usrclk2_i2
|
BUFG usrclk2_i2
|
(
|
(
|
//---------- Input -----------------------------
|
//---------- Input -----------------------------
|
.I (userclk2_1),
|
.I (userclk2_1),
|
//---------- Output ----------------------------
|
//---------- Output ----------------------------
|
.O (CLK_USERCLK2)
|
.O (CLK_USERCLK2)
|
);
|
);
|
end
|
end
|
|
|
else
|
else
|
|
|
//---------- Disable USERCLK2 Buffer ---------------
|
//---------- Disable USERCLK2 Buffer ---------------
|
begin : userclk2_i2_disable
|
begin : userclk2_i2_disable
|
assign CLK_USERCLK2 = userclk2_1;
|
assign CLK_USERCLK2 = userclk2_1;
|
end
|
end
|
|
|
end
|
end
|
|
|
else
|
else
|
|
|
//---------- Disable 2nd Stage Buffer --------------------------------------
|
//---------- Disable 2nd Stage Buffer --------------------------------------
|
begin : second_stage_buf_disable
|
begin : second_stage_buf_disable
|
assign pclk = pclk_1;
|
assign pclk = pclk_1;
|
assign CLK_RXUSRCLK = pclk_1;
|
assign CLK_RXUSRCLK = pclk_1;
|
assign CLK_USERCLK1 = userclk1_1;
|
assign CLK_USERCLK1 = userclk1_1;
|
assign CLK_USERCLK2 = userclk2_1;
|
assign CLK_USERCLK2 = userclk2_1;
|
end
|
end
|
|
|
endgenerate
|
endgenerate
|
|
|
|
|
|
|
//---------- Select PCLK -------------------------------------------------------
|
//---------- Select PCLK -------------------------------------------------------
|
always @ (posedge pclk)
|
always @ (posedge pclk)
|
begin
|
begin
|
|
|
if (!CLK_RST_N)
|
if (!CLK_RST_N)
|
pclk_sel <= 1'd0;
|
pclk_sel <= 1'd0;
|
else
|
else
|
begin
|
begin
|
//---------- Select 250 MHz ------------------------
|
//---------- Select 250 MHz ------------------------
|
if (&pclk_sel_reg2)
|
if (&pclk_sel_reg2)
|
pclk_sel <= 1'd1;
|
pclk_sel <= 1'd1;
|
//---------- Select 125 MHz ------------------------
|
//---------- Select 125 MHz ------------------------
|
else if (&(~pclk_sel_reg2))
|
else if (&(~pclk_sel_reg2))
|
pclk_sel <= 1'd0;
|
pclk_sel <= 1'd0;
|
//---------- Hold PCLK -----------------------------
|
//---------- Hold PCLK -----------------------------
|
else
|
else
|
pclk_sel <= pclk_sel;
|
pclk_sel <= pclk_sel;
|
end
|
end
|
|
|
end
|
end
|
|
|
|
|
|
|
//---------- PIPE Clock Output -------------------------------------------------
|
//---------- PIPE Clock Output -------------------------------------------------
|
assign CLK_PCLK = pclk;
|
assign CLK_PCLK = pclk;
|
assign CLK_MMCM_LOCK = mmcm_lock;
|
assign CLK_MMCM_LOCK = mmcm_lock;
|
|
|
|
|
|
|
endmodule
|
endmodule
|
|
|