1 |
2 |
ZTEX |
//*****************************************************************************
|
2 |
|
|
// (c) Copyright 2009 - 2013 Xilinx, Inc. All rights reserved.
|
3 |
|
|
//
|
4 |
|
|
// This file contains confidential and proprietary information
|
5 |
|
|
// of Xilinx, Inc. and is protected under U.S. and
|
6 |
|
|
// international copyright and other intellectual property
|
7 |
|
|
// laws.
|
8 |
|
|
//
|
9 |
|
|
// DISCLAIMER
|
10 |
|
|
// This disclaimer is not a license and does not grant any
|
11 |
|
|
// rights to the materials distributed herewith. Except as
|
12 |
|
|
// otherwise provided in a valid license issued to you by
|
13 |
|
|
// Xilinx, and to the maximum extent permitted by applicable
|
14 |
|
|
// law: (1) THESE MATERIALS ARE MADE AVAILABLE "AS IS" AND
|
15 |
|
|
// WITH ALL FAULTS, AND XILINX HEREBY DISCLAIMS ALL WARRANTIES
|
16 |
|
|
// AND CONDITIONS, EXPRESS, IMPLIED, OR STATUTORY, INCLUDING
|
17 |
|
|
// BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, NON-
|
18 |
|
|
// INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE; and
|
19 |
|
|
// (2) Xilinx shall not be liable (whether in contract or tort,
|
20 |
|
|
// including negligence, or under any other theory of
|
21 |
|
|
// liability) for any loss or damage of any kind or nature
|
22 |
|
|
// related to, arising under or in connection with these
|
23 |
|
|
// materials, including for any direct, or any indirect,
|
24 |
|
|
// special, incidental, or consequential loss or damage
|
25 |
|
|
// (including loss of data, profits, goodwill, or any type of
|
26 |
|
|
// loss or damage suffered as a result of any action brought
|
27 |
|
|
// by a third party) even if such damage or loss was
|
28 |
|
|
// reasonably foreseeable or Xilinx had been advised of the
|
29 |
|
|
// possibility of the same.
|
30 |
|
|
//
|
31 |
|
|
// CRITICAL APPLICATIONS
|
32 |
|
|
// Xilinx products are not designed or intended to be fail-
|
33 |
|
|
// safe, or for use in any application requiring fail-safe
|
34 |
|
|
// performance, such as life-support or safety devices or
|
35 |
|
|
// systems, Class III medical devices, nuclear facilities,
|
36 |
|
|
// applications related to the deployment of airbags, or any
|
37 |
|
|
// other applications that could lead to death, personal
|
38 |
|
|
// injury, or severe property or environmental damage
|
39 |
|
|
// (individually and collectively, "Critical
|
40 |
|
|
// Applications"). Customer assumes the sole risk and
|
41 |
|
|
// liability of any use of Xilinx products in Critical
|
42 |
|
|
// Applications, subject only to applicable laws and
|
43 |
|
|
// regulations governing limitations on product liability.
|
44 |
|
|
//
|
45 |
|
|
// THIS COPYRIGHT NOTICE AND DISCLAIMER MUST BE RETAINED AS
|
46 |
|
|
// PART OF THIS FILE AT ALL TIMES.
|
47 |
|
|
//
|
48 |
|
|
//*****************************************************************************
|
49 |
|
|
// ____ ____
|
50 |
|
|
// / /\/ /
|
51 |
|
|
// /___/ \ / Vendor: Xilinx
|
52 |
|
|
// \ \ \/ Version: %version
|
53 |
|
|
// \ \ Application: MIG
|
54 |
|
|
// / / Filename: iodelay_ctrl.v
|
55 |
|
|
// /___/ /\ Date Last Modified: $Date: 2011/06/02 08:34:56 $
|
56 |
|
|
// \ \ / \ Date Created: Wed Aug 16 2006
|
57 |
|
|
// \___\/\___\
|
58 |
|
|
//
|
59 |
|
|
//Device: 7 Series
|
60 |
|
|
//Design Name: DDR3 SDRAM
|
61 |
|
|
//Purpose:
|
62 |
|
|
// This module instantiates the IDELAYCTRL primitive, which continously
|
63 |
|
|
// calibrates the IODELAY elements in the region to account for varying
|
64 |
|
|
// environmental conditions. A 200MHz or 300MHz reference clock (depending
|
65 |
|
|
// on the desired IODELAY tap resolution) must be supplied
|
66 |
|
|
//Reference:
|
67 |
|
|
//Revision History:
|
68 |
|
|
//*****************************************************************************
|
69 |
|
|
|
70 |
|
|
/******************************************************************************
|
71 |
|
|
**$Id: iodelay_ctrl.v,v 1.1 2011/06/02 08:34:56 mishra Exp $
|
72 |
|
|
**$Date: 2011/06/02 08:34:56 $
|
73 |
|
|
**$Author: mishra $
|
74 |
|
|
**$Revision: 1.1 $
|
75 |
|
|
**$Source: /devl/xcs/repo/env/Databases/ip/src2/O/mig_7series_v1_3/data/dlib/7series/ddr3_sdram/verilog/rtl/clocking/iodelay_ctrl.v,v $
|
76 |
|
|
******************************************************************************/
|
77 |
|
|
|
78 |
|
|
`timescale 1ps/1ps
|
79 |
|
|
|
80 |
|
|
module mig_7series_v2_3_iodelay_ctrl #
|
81 |
|
|
(
|
82 |
|
|
parameter TCQ = 100,
|
83 |
|
|
// clk->out delay (sim only)
|
84 |
|
|
parameter IODELAY_GRP0 = "IODELAY_MIG0",
|
85 |
|
|
// May be assigned unique name when
|
86 |
|
|
// multiple IP cores used in design
|
87 |
|
|
parameter IODELAY_GRP1 = "IODELAY_MIG1",
|
88 |
|
|
// May be assigned unique name when
|
89 |
|
|
// multiple IP cores used in design
|
90 |
|
|
parameter REFCLK_TYPE = "DIFFERENTIAL",
|
91 |
|
|
// Reference clock type
|
92 |
|
|
// "DIFFERENTIAL","SINGLE_ENDED"
|
93 |
|
|
// NO_BUFFER, USE_SYSTEM_CLOCK
|
94 |
|
|
parameter SYSCLK_TYPE = "DIFFERENTIAL",
|
95 |
|
|
// input clock type
|
96 |
|
|
// DIFFERENTIAL, SINGLE_ENDED,
|
97 |
|
|
// NO_BUFFER
|
98 |
|
|
parameter SYS_RST_PORT = "FALSE",
|
99 |
|
|
// "TRUE" - if pin is selected for sys_rst
|
100 |
|
|
// and IBUF will be instantiated.
|
101 |
|
|
// "FALSE" - if pin is not selected for sys_rst
|
102 |
|
|
parameter RST_ACT_LOW = 1,
|
103 |
|
|
// Reset input polarity
|
104 |
|
|
// (0 = active high, 1 = active low)
|
105 |
|
|
parameter DIFF_TERM_REFCLK = "TRUE",
|
106 |
|
|
// Differential Termination
|
107 |
|
|
parameter FPGA_SPEED_GRADE = 1,
|
108 |
|
|
// FPGA speed grade
|
109 |
|
|
parameter REF_CLK_MMCM_IODELAY_CTRL = "FALSE"
|
110 |
|
|
)
|
111 |
|
|
(
|
112 |
|
|
input clk_ref_p,
|
113 |
|
|
input clk_ref_n,
|
114 |
|
|
input clk_ref_i,
|
115 |
|
|
input sys_rst,
|
116 |
|
|
output [1:0] clk_ref,
|
117 |
|
|
output sys_rst_o,
|
118 |
|
|
output [1:0] iodelay_ctrl_rdy
|
119 |
|
|
);
|
120 |
|
|
|
121 |
|
|
// # of clock cycles to delay deassertion of reset. Needs to be a fairly
|
122 |
|
|
// high number not so much for metastability protection, but to give time
|
123 |
|
|
// for reset (i.e. stable clock cycles) to propagate through all state
|
124 |
|
|
// machines and to all control signals (i.e. not all control signals have
|
125 |
|
|
// resets, instead they rely on base state logic being reset, and the effect
|
126 |
|
|
// of that reset propagating through the logic). Need this because we may not
|
127 |
|
|
// be getting stable clock cycles while reset asserted (i.e. since reset
|
128 |
|
|
// depends on DCM lock status)
|
129 |
|
|
// COMMENTED, RC, 01/13/09 - causes pack error in MAP w/ larger #
|
130 |
|
|
localparam RST_SYNC_NUM = 15;
|
131 |
|
|
// localparam RST_SYNC_NUM = 25;
|
132 |
|
|
|
133 |
|
|
wire clk_ref_ibufg;
|
134 |
|
|
wire clk_ref_mmcm_300;
|
135 |
|
|
wire clk_ref_mmcm_400;
|
136 |
|
|
wire mmcm_clkfbout;
|
137 |
|
|
wire mmcm_Locked;
|
138 |
|
|
wire [1:0] rst_ref;
|
139 |
|
|
reg [RST_SYNC_NUM-1:0] rst_ref_sync_r [1:0] /* synthesis syn_maxfan = 10 */;
|
140 |
|
|
wire rst_tmp_idelay;
|
141 |
|
|
wire sys_rst_act_hi;
|
142 |
|
|
|
143 |
|
|
//***************************************************************************
|
144 |
|
|
|
145 |
|
|
// If the pin is selected for sys_rst in GUI, IBUF will be instantiated.
|
146 |
|
|
// If the pin is not selected in GUI, sys_rst signal is expected to be
|
147 |
|
|
// driven internally.
|
148 |
|
|
generate
|
149 |
|
|
if (SYS_RST_PORT == "TRUE")
|
150 |
|
|
IBUF u_sys_rst_ibuf
|
151 |
|
|
(
|
152 |
|
|
.I (sys_rst),
|
153 |
|
|
.O (sys_rst_o)
|
154 |
|
|
);
|
155 |
|
|
else
|
156 |
|
|
assign sys_rst_o = sys_rst;
|
157 |
|
|
endgenerate
|
158 |
|
|
|
159 |
|
|
// Possible inversion of system reset as appropriate
|
160 |
|
|
assign sys_rst_act_hi = RST_ACT_LOW ? ~sys_rst_o: sys_rst_o;
|
161 |
|
|
|
162 |
|
|
//***************************************************************************
|
163 |
|
|
// 1) Input buffer for IDELAYCTRL reference clock - handle either a
|
164 |
|
|
// differential or single-ended input. Global clock buffer is used to
|
165 |
|
|
// drive the rest of FPGA logic.
|
166 |
|
|
// 2) For NO_BUFFER option, Reference clock will be driven from internal
|
167 |
|
|
// clock i.e., clock is driven from fabric. Input buffers and Global
|
168 |
|
|
// clock buffers will not be instaitaed.
|
169 |
|
|
// 3) For USE_SYSTEM_CLOCK, input buffer output of system clock will be used
|
170 |
|
|
// as the input reference clock. Global clock buffer is used to drive
|
171 |
|
|
// the rest of FPGA logic.
|
172 |
|
|
//***************************************************************************
|
173 |
|
|
|
174 |
|
|
generate
|
175 |
|
|
if (REFCLK_TYPE == "DIFFERENTIAL") begin: diff_clk_ref
|
176 |
|
|
IBUFGDS #
|
177 |
|
|
(
|
178 |
|
|
.DIFF_TERM (DIFF_TERM_REFCLK),
|
179 |
|
|
.IBUF_LOW_PWR ("FALSE")
|
180 |
|
|
)
|
181 |
|
|
u_ibufg_clk_ref
|
182 |
|
|
(
|
183 |
|
|
.I (clk_ref_p),
|
184 |
|
|
.IB (clk_ref_n),
|
185 |
|
|
.O (clk_ref_ibufg)
|
186 |
|
|
);
|
187 |
|
|
|
188 |
|
|
end else if (REFCLK_TYPE == "SINGLE_ENDED") begin : se_clk_ref
|
189 |
|
|
IBUFG #
|
190 |
|
|
(
|
191 |
|
|
.IBUF_LOW_PWR ("FALSE")
|
192 |
|
|
)
|
193 |
|
|
u_ibufg_clk_ref
|
194 |
|
|
(
|
195 |
|
|
.I (clk_ref_i),
|
196 |
|
|
.O (clk_ref_ibufg)
|
197 |
|
|
);
|
198 |
|
|
|
199 |
|
|
end else if ((REFCLK_TYPE == "NO_BUFFER") ||
|
200 |
|
|
(REFCLK_TYPE == "USE_SYSTEM_CLOCK" && SYSCLK_TYPE == "NO_BUFFER")) begin : clk_ref_noibuf_nobuf
|
201 |
|
|
assign clk_ref_ibufg = clk_ref_i;
|
202 |
|
|
end else if (REFCLK_TYPE == "USE_SYSTEM_CLOCK" && SYSCLK_TYPE != "NO_BUFFER") begin : clk_ref_noibuf
|
203 |
|
|
assign clk_ref_ibufg = clk_ref_i;
|
204 |
|
|
end
|
205 |
|
|
endgenerate
|
206 |
|
|
|
207 |
|
|
// reference clock 300MHz and 400MHz generation with MMCM
|
208 |
|
|
generate
|
209 |
|
|
if (REF_CLK_MMCM_IODELAY_CTRL == "TRUE") begin: clk_ref_mmcm_gen
|
210 |
|
|
|
211 |
|
|
MMCME2_ADV
|
212 |
|
|
#(.BANDWIDTH ("HIGH"),
|
213 |
|
|
.CLKOUT4_CASCADE ("FALSE"),
|
214 |
|
|
.COMPENSATION ("INTERNAL"),
|
215 |
|
|
.STARTUP_WAIT ("FALSE"),
|
216 |
|
|
.DIVCLK_DIVIDE (1),
|
217 |
|
|
.CLKFBOUT_MULT_F (6),
|
218 |
|
|
.CLKFBOUT_PHASE (0.000),
|
219 |
|
|
.CLKFBOUT_USE_FINE_PS ("FALSE"),
|
220 |
|
|
.CLKOUT0_DIVIDE_F (4),
|
221 |
|
|
.CLKOUT0_PHASE (0.000),
|
222 |
|
|
.CLKOUT0_DUTY_CYCLE (0.500),
|
223 |
|
|
.CLKOUT0_USE_FINE_PS ("FALSE"),
|
224 |
|
|
.CLKOUT1_DIVIDE (3),
|
225 |
|
|
.CLKOUT1_PHASE (0.000),
|
226 |
|
|
.CLKOUT1_DUTY_CYCLE (0.500),
|
227 |
|
|
.CLKOUT1_USE_FINE_PS ("FALSE"),
|
228 |
|
|
.CLKIN1_PERIOD (5),
|
229 |
|
|
.REF_JITTER1 (0.000))
|
230 |
|
|
mmcm_i
|
231 |
|
|
// Output clocks
|
232 |
|
|
(.CLKFBOUT (mmcm_clkfbout),
|
233 |
|
|
.CLKFBOUTB (),
|
234 |
|
|
.CLKOUT0 (clk_ref_mmcm_300),
|
235 |
|
|
.CLKOUT0B (),
|
236 |
|
|
.CLKOUT1 (clk_ref_mmcm_400),
|
237 |
|
|
.CLKOUT1B (),
|
238 |
|
|
.CLKOUT2 (),
|
239 |
|
|
.CLKOUT2B (),
|
240 |
|
|
.CLKOUT3 (),
|
241 |
|
|
.CLKOUT3B (),
|
242 |
|
|
.CLKOUT4 (),
|
243 |
|
|
.CLKOUT5 (),
|
244 |
|
|
.CLKOUT6 (),
|
245 |
|
|
// Input clock control
|
246 |
|
|
.CLKFBIN (mmcm_clkfbout),
|
247 |
|
|
.CLKIN1 (clk_ref_ibufg),
|
248 |
|
|
.CLKIN2 (1'b0),
|
249 |
|
|
// Tied to always select the primary input clock
|
250 |
|
|
.CLKINSEL (1'b1),
|
251 |
|
|
// Ports for dynamic reconfiguration
|
252 |
|
|
.DADDR (7'h0),
|
253 |
|
|
.DCLK (1'b0),
|
254 |
|
|
.DEN (1'b0),
|
255 |
|
|
.DI (16'h0),
|
256 |
|
|
.DO (),
|
257 |
|
|
.DRDY (),
|
258 |
|
|
.DWE (1'b0),
|
259 |
|
|
// Ports for dynamic phase shift
|
260 |
|
|
.PSCLK (1'b0),
|
261 |
|
|
.PSEN (1'b0),
|
262 |
|
|
.PSINCDEC (1'b0),
|
263 |
|
|
.PSDONE (),
|
264 |
|
|
// Other control and status signals
|
265 |
|
|
.LOCKED (mmcm_Locked),
|
266 |
|
|
.CLKINSTOPPED (),
|
267 |
|
|
.CLKFBSTOPPED (),
|
268 |
|
|
.PWRDWN (1'b0),
|
269 |
|
|
.RST (sys_rst_act_hi));
|
270 |
|
|
end
|
271 |
|
|
endgenerate
|
272 |
|
|
|
273 |
|
|
generate
|
274 |
|
|
if (REF_CLK_MMCM_IODELAY_CTRL == "TRUE") begin : clk_ref_300_400_en
|
275 |
|
|
if(FPGA_SPEED_GRADE == 1) begin: clk_ref_300
|
276 |
|
|
BUFG u_bufg_clk_ref_300
|
277 |
|
|
(
|
278 |
|
|
.O (clk_ref[1]),
|
279 |
|
|
.I (clk_ref_mmcm_300)
|
280 |
|
|
);
|
281 |
|
|
end else if (FPGA_SPEED_GRADE == 2 || FPGA_SPEED_GRADE == 3) begin: clk_ref_400
|
282 |
|
|
BUFG u_bufg_clk_ref_400
|
283 |
|
|
(
|
284 |
|
|
.O (clk_ref[1]),
|
285 |
|
|
.I (clk_ref_mmcm_400)
|
286 |
|
|
);
|
287 |
|
|
end
|
288 |
|
|
end
|
289 |
|
|
endgenerate
|
290 |
|
|
|
291 |
|
|
generate
|
292 |
|
|
if ((REFCLK_TYPE == "DIFFERENTIAL") ||
|
293 |
|
|
(REFCLK_TYPE == "SINGLE_ENDED") ||
|
294 |
|
|
(REFCLK_TYPE == "USE_SYSTEM_CLOCK" && SYSCLK_TYPE != "NO_BUFFER")) begin: clk_ref_200
|
295 |
|
|
BUFG u_bufg_clk_ref
|
296 |
|
|
(
|
297 |
|
|
.O (clk_ref[0]),
|
298 |
|
|
.I (clk_ref_ibufg)
|
299 |
|
|
);
|
300 |
|
|
end else begin: clk_ref_200_no_buffer
|
301 |
|
|
assign clk_ref[0] = clk_ref_i;
|
302 |
|
|
end
|
303 |
|
|
endgenerate
|
304 |
|
|
|
305 |
|
|
//*****************************************************************
|
306 |
|
|
// IDELAYCTRL reset
|
307 |
|
|
// This assumes an external clock signal driving the IDELAYCTRL
|
308 |
|
|
// blocks. Otherwise, if a PLL drives IDELAYCTRL, then the PLL
|
309 |
|
|
// lock signal will need to be incorporated in this.
|
310 |
|
|
//*****************************************************************
|
311 |
|
|
|
312 |
|
|
// Add PLL lock if PLL drives IDELAYCTRL in user design
|
313 |
|
|
assign rst_tmp_idelay = sys_rst_act_hi;
|
314 |
|
|
|
315 |
|
|
generate
|
316 |
|
|
if (REF_CLK_MMCM_IODELAY_CTRL == "TRUE") begin: rst_ref_gen_1
|
317 |
|
|
always @(posedge clk_ref[1] or posedge rst_tmp_idelay)
|
318 |
|
|
if (rst_tmp_idelay)
|
319 |
|
|
rst_ref_sync_r[1] <= #TCQ {RST_SYNC_NUM{1'b1}};
|
320 |
|
|
else
|
321 |
|
|
rst_ref_sync_r[1] <= #TCQ rst_ref_sync_r[1] << 1;
|
322 |
|
|
|
323 |
|
|
assign rst_ref[1] = rst_ref_sync_r[1][RST_SYNC_NUM-1];
|
324 |
|
|
end
|
325 |
|
|
endgenerate
|
326 |
|
|
|
327 |
|
|
always @(posedge clk_ref[0] or posedge rst_tmp_idelay)
|
328 |
|
|
if (rst_tmp_idelay)
|
329 |
|
|
rst_ref_sync_r[0] <= #TCQ {RST_SYNC_NUM{1'b1}};
|
330 |
|
|
else
|
331 |
|
|
rst_ref_sync_r[0] <= #TCQ rst_ref_sync_r[0] << 1;
|
332 |
|
|
|
333 |
|
|
assign rst_ref[0] = rst_ref_sync_r[0][RST_SYNC_NUM-1];
|
334 |
|
|
|
335 |
|
|
//*****************************************************************
|
336 |
|
|
|
337 |
|
|
generate
|
338 |
|
|
if (REF_CLK_MMCM_IODELAY_CTRL == "TRUE") begin: idelayctrl_gen_1
|
339 |
|
|
(* IODELAY_GROUP = IODELAY_GRP1 *) IDELAYCTRL u_idelayctrl_300_400
|
340 |
|
|
(
|
341 |
|
|
.RDY (iodelay_ctrl_rdy[1]),
|
342 |
|
|
.REFCLK (clk_ref[1]),
|
343 |
|
|
.RST (rst_ref[1])
|
344 |
|
|
);
|
345 |
|
|
end
|
346 |
|
|
endgenerate
|
347 |
|
|
|
348 |
|
|
(* IODELAY_GROUP = IODELAY_GRP0 *) IDELAYCTRL u_idelayctrl_200
|
349 |
|
|
(
|
350 |
|
|
.RDY (iodelay_ctrl_rdy[0]),
|
351 |
|
|
.REFCLK (clk_ref[0]),
|
352 |
|
|
.RST (rst_ref[0])
|
353 |
|
|
);
|
354 |
|
|
|
355 |
|
|
endmodule
|