AMC13
Firmwares for the different applications of the AMC13 uTCA board made at Boston University
 All Classes Variables
mig_7series_v1_9_infrastructure.v
1  //*****************************************************************************
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: infrastructure.v
55 // /___/ /\ Date Last Modified: $Date: 2011/06/02 08:34:56 $
56 // \ \ / \ Date Created:Tue Jun 30 2009
57 // \___\/\___\
58 //
59 //Device: Virtex-6
60 //Design Name: DDR3 SDRAM
61 //Purpose:
62 // Clock generation/distribution and reset synchronization
63 //Reference:
64 //Revision History:
65 //*****************************************************************************
66 
67 /******************************************************************************
68 **$Id: infrastructure.v,v 1.1 2011/06/02 08:34:56 mishra Exp $
69 **$Date: 2011/06/02 08:34:56 $
70 **$Author: mishra $
71 **$Revision: 1.1 $
72 **$Source: /devl/xcs/repo/env/Databases/ip/src2/O/mig_7series_v1_3/data/dlib/7series/ddr3_sdram/verilog/rtl/clocking/infrastructure.v,v $
73 *******************************************************************************/
74 
75 `timescale 1ps/1ps
76 
77 
79  (
80  parameter SIMULATION = "FALSE", // Should be TRUE during design simulations and
81  // FALSE during implementations
82  parameter TCQ = 100, // clk->out delay (sim only)
83  parameter CLKIN_PERIOD = 3000, // Memory clock period
84  parameter nCK_PER_CLK = 2, // Fabric clk period:Memory clk period
85  parameter SYSCLK_TYPE = "DIFFERENTIAL",
86  // input clock type
87  // "DIFFERENTIAL","SINGLE_ENDED"
88  parameter UI_EXTRA_CLOCKS = "FALSE",
89  // Generates extra clocks as
90  // 1/2, 1/4 and 1/8 of fabrick clock.
91  // Valid for DDR2/DDR3 AXI interfaces
92  // based on GUI selection
93  parameter CLKFBOUT_MULT = 4, // write PLL VCO multiplier
94  parameter DIVCLK_DIVIDE = 1, // write PLL VCO divisor
95  parameter CLKOUT0_PHASE = 45.0, // VCO output divisor for clkout0
96  parameter CLKOUT0_DIVIDE = 16, // VCO output divisor for PLL clkout0
97  parameter CLKOUT1_DIVIDE = 4, // VCO output divisor for PLL clkout1
98  parameter CLKOUT2_DIVIDE = 64, // VCO output divisor for PLL clkout2
99  parameter CLKOUT3_DIVIDE = 16, // VCO output divisor for PLL clkout3
100  parameter MMCM_CLKOUT0_EN = "FALSE", // Enabled (or) Disable MMCM clkout0
101  parameter MMCM_CLKOUT1_EN = "FALSE", // Enabled (or) Disable MMCM clkout1
102  parameter MMCM_CLKOUT2_EN = "FALSE", // Enabled (or) Disable MMCM clkout2
103  parameter MMCM_CLKOUT3_EN = "FALSE", // Enabled (or) Disable MMCM clkout3
104  parameter MMCM_CLKOUT4_EN = "FALSE", // Enabled (or) Disable MMCM clkout4
105  parameter MMCM_CLKOUT0_DIVIDE = 1, // VCO output divisor for MMCM clkout0
106  parameter MMCM_CLKOUT1_DIVIDE = 1, // VCO output divisor for MMCM clkout1
107  parameter MMCM_CLKOUT2_DIVIDE = 1, // VCO output divisor for MMCM clkout2
108  parameter MMCM_CLKOUT3_DIVIDE = 1, // VCO output divisor for MMCM clkout3
109  parameter MMCM_CLKOUT4_DIVIDE = 1, // VCO output divisor for MMCM clkout4
110  parameter RST_ACT_LOW = 1
111  )
112  (
113  // Clock inputs
114  input mmcm_clk, // System clock diff input
115  // System reset input
116  input sys_rst, // core reset from user application
117  // PLLE2/IDELAYCTRL Lock status
118  input iodelay_ctrl_rdy, // IDELAYCTRL lock status
119  // Clock outputs
120 
121  output clk, // fabric clock freq ; either half rate or quarter rate and is
122  // determined by PLL parameters settings.
123  output mem_refclk, // equal to memory clock
124  output freq_refclk, // freq above 400 MHz: set freq_refclk = mem_refclk
125  // freq below 400 MHz: set freq_refclk = 2* mem_refclk or 4* mem_refclk;
126  // to hard PHY for phaser
127  output sync_pulse, // exactly 1/16 of mem_refclk and the sync pulse is exactly 1 memref_clk wide
128  output auxout_clk, // IO clk used to clock out Aux_Out ports
129  output ui_addn_clk_0, // MMCM out0 clk
130  output ui_addn_clk_1, // MMCM out1 clk
131  output ui_addn_clk_2, // MMCM out2 clk
132  output ui_addn_clk_3, // MMCM out3 clk
133  output ui_addn_clk_4, // MMCM out4 clk
134  output pll_locked, // locked output from PLLE2_ADV
135  output mmcm_locked, // locked output from MMCME2_ADV
136  // Reset outputs
137  output rstdiv0 // Reset CLK and CLKDIV logic (incl I/O),
138 
139  ,output rst_phaser_ref
140  ,input ref_dll_lock
141  );
142 
143  // # of clock cycles to delay deassertion of reset. Needs to be a fairly
144  // high number not so much for metastability protection, but to give time
145  // for reset (i.e. stable clock cycles) to propagate through all state
146  // machines and to all control signals (i.e. not all control signals have
147  // resets, instead they rely on base state logic being reset, and the effect
148  // of that reset propagating through the logic). Need this because we may not
149  // be getting stable clock cycles while reset asserted (i.e. since reset
150  // depends on DCM lock status)
151  localparam RST_SYNC_NUM = 25;
152 
153  // Round up for clk reset delay to ensure that CLKDIV reset deassertion
154  // occurs at same time or after CLK reset deassertion (still need to
155  // consider route delay - add one or two extra cycles to be sure!)
156  localparam RST_DIV_SYNC_NUM = (RST_SYNC_NUM+1)/2;
157 
158  // Input clock is assumed to be equal to the memory clock frequency
159  // User should change the parameter as necessary if a different input
160  // clock frequency is used
161  localparam real CLKIN1_PERIOD_NS = CLKIN_PERIOD / 1000.0;
162  localparam CLKOUT4_DIVIDE = 2 * CLKOUT1_DIVIDE;
163 
164  localparam integer VCO_PERIOD
165  = (CLKIN1_PERIOD_NS * DIVCLK_DIVIDE * 1000) / CLKFBOUT_MULT;
166 
167  localparam CLKOUT0_PERIOD = VCO_PERIOD * CLKOUT0_DIVIDE;
168  localparam CLKOUT1_PERIOD = VCO_PERIOD * CLKOUT1_DIVIDE;
169  localparam CLKOUT2_PERIOD = VCO_PERIOD * CLKOUT2_DIVIDE;
170  localparam CLKOUT3_PERIOD = VCO_PERIOD * CLKOUT3_DIVIDE;
171  localparam CLKOUT4_PERIOD = VCO_PERIOD * CLKOUT4_DIVIDE;
172 
173  localparam CLKOUT4_PHASE = (SIMULATION == "TRUE") ? 22.5 : 168.75;
174 
175  localparam real CLKOUT3_PERIOD_NS = CLKOUT3_PERIOD / 1000.0;
176  localparam real CLKOUT4_PERIOD_NS = CLKOUT4_PERIOD / 1000.0;
177 
178  //synthesis translate_off
179  initial begin
180  $display("############# Write Clocks PLLE2_ADV Parameters #############\n");
181  $display("nCK_PER_CLK = %7d", nCK_PER_CLK );
182  $display("CLK_PERIOD = %7d", CLKIN_PERIOD );
183  $display("CLKIN1_PERIOD = %7.3f", CLKIN1_PERIOD_NS);
184  $display("DIVCLK_DIVIDE = %7d", DIVCLK_DIVIDE );
185  $display("CLKFBOUT_MULT = %7d", CLKFBOUT_MULT );
186  $display("VCO_PERIOD = %7d", VCO_PERIOD );
187  $display("CLKOUT0_DIVIDE_F = %7d", CLKOUT0_DIVIDE );
188  $display("CLKOUT1_DIVIDE = %7d", CLKOUT1_DIVIDE );
189  $display("CLKOUT2_DIVIDE = %7d", CLKOUT2_DIVIDE );
190  $display("CLKOUT3_DIVIDE = %7d", CLKOUT3_DIVIDE );
191  $display("CLKOUT0_PERIOD = %7d", CLKOUT0_PERIOD );
192  $display("CLKOUT1_PERIOD = %7d", CLKOUT1_PERIOD );
193  $display("CLKOUT2_PERIOD = %7d", CLKOUT2_PERIOD );
194  $display("CLKOUT3_PERIOD = %7d", CLKOUT3_PERIOD );
195  $display("CLKOUT4_PERIOD = %7d", CLKOUT4_PERIOD );
196  $display("############################################################\n");
197  end
198  //synthesis translate_on
199 
200  wire clk_bufg;
201  wire clk_pll;
202  wire clkfbout_pll;
203  wire mmcm_clkfbout;
204  (* keep = "true", max_fanout = 10 *) wire pll_locked_i
205  /* synthesis syn_maxfan = 10 **/;
206  reg [RST_DIV_SYNC_NUM-2:0] rstdiv0_sync_r;
207  wire rst_tmp;
208  (* keep = "true", max_fanout = 10 *) reg rstdiv0_sync_r1
209  /* synthesis syn_maxfan = 10 **/;
210  wire sys_rst_act_hi;
211 
212  wire rst_tmp_phaser_ref;
213  (* keep = "true", max_fanout = 10 *) reg [RST_DIV_SYNC_NUM-1:0] rst_phaser_ref_sync_r
214  /* synthesis syn_maxfan = 10 **/;
215 
216  // Instantiation of the MMCM primitive
217  wire clkfbout;
218  wire MMCM_Locked_i;
219 
220  wire mmcm_clkout0;
221  wire mmcm_clkout1;
222  wire mmcm_clkout2;
223  wire mmcm_clkout3;
224  wire mmcm_clkout4;
225 
226  assign sys_rst_act_hi = RST_ACT_LOW ? ~sys_rst: sys_rst;
227 
228  //***************************************************************************
229  // Assign global clocks:
230  // 2. clk : Half rate / Quarter rate(used for majority of internal logic)
231  //***************************************************************************
232 
233  assign clk = clk_bufg;
234  assign pll_locked = pll_locked_i & MMCM_Locked_i;
235  assign mmcm_locked = MMCM_Locked_i;
236 
237  //***************************************************************************
238  // Global base clock generation and distribution
239  //***************************************************************************
240 
241  //*****************************************************************
242  // NOTES ON CALCULTING PROPER VCO FREQUENCY
243  // 1. VCO frequency =
244  // 1/((DIVCLK_DIVIDE * CLKIN_PERIOD)/(CLKFBOUT_MULT * nCK_PER_CLK))
245  // 2. VCO frequency must be in the range [TBD, TBD]
246  //*****************************************************************
247 
248  PLLE2_ADV #
249  (
250  .BANDWIDTH ("OPTIMIZED"),
251  .COMPENSATION ("INTERNAL"),
252  .STARTUP_WAIT ("FALSE"),
253  .CLKOUT0_DIVIDE (CLKOUT0_DIVIDE), // 4 freq_ref
254  .CLKOUT1_DIVIDE (CLKOUT1_DIVIDE), // 4 mem_ref
255  .CLKOUT2_DIVIDE (CLKOUT2_DIVIDE), // 16 sync
256  .CLKOUT3_DIVIDE (CLKOUT3_DIVIDE), // 16 sysclk
257  .CLKOUT4_DIVIDE (CLKOUT4_DIVIDE),
258  .CLKOUT5_DIVIDE (),
259  .DIVCLK_DIVIDE (DIVCLK_DIVIDE),
260  .CLKFBOUT_MULT (CLKFBOUT_MULT),
261  .CLKFBOUT_PHASE (0.000),
262  .CLKIN1_PERIOD (CLKIN1_PERIOD_NS),
263  .CLKIN2_PERIOD (),
264  .CLKOUT0_DUTY_CYCLE (0.500),
265  .CLKOUT0_PHASE (CLKOUT0_PHASE),
266  .CLKOUT1_DUTY_CYCLE (0.500),
267  .CLKOUT1_PHASE (0.000),
268  .CLKOUT2_DUTY_CYCLE (1.0/16.0),
269  .CLKOUT2_PHASE (9.84375), // PHASE shift is required for sync pulse generation.
270  .CLKOUT3_DUTY_CYCLE (0.500),
271  .CLKOUT3_PHASE (0.000),
272  .CLKOUT4_DUTY_CYCLE (0.500),
273  .CLKOUT4_PHASE (CLKOUT4_PHASE),
274  .CLKOUT5_DUTY_CYCLE (0.500),
275  .CLKOUT5_PHASE (0.000),
276  .REF_JITTER1 (0.010),
277  .REF_JITTER2 (0.010)
278  )
279  plle2_i
280  (
281  .CLKFBOUT (pll_clkfbout),
282  .CLKOUT0 (freq_refclk),
283  .CLKOUT1 (mem_refclk),
284  .CLKOUT2 (sync_pulse), // always 1/16 of mem_ref_clk
285  .CLKOUT3 (pll_clk3),
286  .CLKOUT4 (auxout_clk_i),
287  .CLKOUT5 (),
288  .DO (),
289  .DRDY (),
290  .LOCKED (pll_locked_i),
291  .CLKFBIN (pll_clkfbout),
292  .CLKIN1 (mmcm_clk),
293  .CLKIN2 (),
294  .CLKINSEL (1'b1),
295  .DADDR (7'b0),
296  .DCLK (1'b0),
297  .DEN (1'b0),
298  .DI (16'b0),
299  .DWE (1'b0),
300  .PWRDWN (1'b0),
301  .RST ( sys_rst_act_hi)
302  );
303 
304 
305  BUFH u_bufh_auxout_clk
306  (
307  .O (auxout_clk),
308  .I (auxout_clk_i)
309  );
310 
311  BUFG u_bufg_clkdiv0
312  (
313  .O (clk_bufg),
314  .I (clk_pll_i)
315  );
316 
317  localparam integer MMCM_VCO_MIN_FREQ = 600;
318  localparam integer MMCM_VCO_MAX_FREQ = 1200; // This is the maximum VCO frequency for a -1 part
319  localparam real MMCM_VCO_MIN_PERIOD = 1000000.0/MMCM_VCO_MAX_FREQ;
320  localparam real MMCM_VCO_MAX_PERIOD = 1000000.0/MMCM_VCO_MIN_FREQ;
321  localparam real MMCM_MULT_F_MID = CLKOUT3_PERIOD/(MMCM_VCO_MAX_PERIOD*0.75);
322  localparam real MMCM_EXPECTED_PERIOD = CLKOUT3_PERIOD / MMCM_MULT_F_MID;
323  localparam real MMCM_MULT_F = ((MMCM_EXPECTED_PERIOD > MMCM_VCO_MAX_PERIOD) ? MMCM_MULT_F_MID + 1.0 : MMCM_MULT_F_MID);
324  localparam real MMCM_VCO_FREQ = MMCM_MULT_F / (1 * CLKOUT3_PERIOD_NS);
325  localparam real MMCM_VCO_PERIOD = (CLKOUT3_PERIOD_NS * 1000) / MMCM_MULT_F;
326 
327  //synthesis translate_off
328  initial begin
329  $display("############# MMCME2_ADV Parameters #############\n");
330  $display("MMCM_VCO_MIN_PERIOD = %7.3f", MMCM_VCO_MIN_PERIOD);
331  $display("MMCM_VCO_MAX_PERIOD = %7.3f", MMCM_VCO_MAX_PERIOD);
332  $display("MMCM_MULT_F_MID = %7.3f", MMCM_MULT_F_MID);
333  $display("MMCM_EXPECTED_PERIOD = %7.3f", MMCM_EXPECTED_PERIOD);
334  $display("MMCM_MULT_F = %7.3f", MMCM_MULT_F);
335  $display("CLKOUT3_PERIOD_NS = %7.3f", CLKOUT3_PERIOD_NS);
336  $display("MMCM_VCO_FREQ (MHz) = %7.3f", MMCM_VCO_FREQ*1000.0);
337  $display("MMCM_VCO_PERIOD = %7.3f", MMCM_VCO_PERIOD);
338  $display("#################################################\n");
339  end
340  //synthesis translate_on
341 
342  generate
343  if (UI_EXTRA_CLOCKS == "TRUE") begin: gen_ui_extra_clocks
344 
345  localparam MMCM_CLKOUT0_DIVIDE_CAL = (MMCM_CLKOUT0_EN == "TRUE") ? MMCM_CLKOUT0_DIVIDE : MMCM_MULT_F;
346  localparam MMCM_CLKOUT1_DIVIDE_CAL = (MMCM_CLKOUT1_EN == "TRUE") ? MMCM_CLKOUT1_DIVIDE : MMCM_MULT_F;
347  localparam MMCM_CLKOUT2_DIVIDE_CAL = (MMCM_CLKOUT2_EN == "TRUE") ? MMCM_CLKOUT2_DIVIDE : MMCM_MULT_F;
348  localparam MMCM_CLKOUT3_DIVIDE_CAL = (MMCM_CLKOUT3_EN == "TRUE") ? MMCM_CLKOUT3_DIVIDE : MMCM_MULT_F;
349  localparam MMCM_CLKOUT4_DIVIDE_CAL = (MMCM_CLKOUT4_EN == "TRUE") ? MMCM_CLKOUT4_DIVIDE : MMCM_MULT_F;
350 
351  MMCME2_ADV
352  #(.BANDWIDTH ("HIGH"),
353  .CLKOUT4_CASCADE ("FALSE"),
354  .COMPENSATION ("BUF_IN"),
355  .STARTUP_WAIT ("FALSE"),
356  .DIVCLK_DIVIDE (1),
357  .CLKFBOUT_MULT_F (MMCM_MULT_F),
358  .CLKFBOUT_PHASE (0.000),
359  .CLKFBOUT_USE_FINE_PS ("FALSE"),
360  .CLKOUT0_DIVIDE_F (MMCM_CLKOUT0_DIVIDE_CAL),
361  .CLKOUT0_PHASE (0.000),
362  .CLKOUT0_DUTY_CYCLE (0.500),
363  .CLKOUT0_USE_FINE_PS ("FALSE"),
364  .CLKOUT1_DIVIDE (MMCM_CLKOUT1_DIVIDE_CAL),
365  .CLKOUT1_PHASE (0.000),
366  .CLKOUT1_DUTY_CYCLE (0.500),
367  .CLKOUT1_USE_FINE_PS ("FALSE"),
368  .CLKOUT2_DIVIDE (MMCM_CLKOUT2_DIVIDE_CAL),
369  .CLKOUT2_PHASE (0.000),
370  .CLKOUT2_DUTY_CYCLE (0.500),
371  .CLKOUT2_USE_FINE_PS ("FALSE"),
372  .CLKOUT3_DIVIDE (MMCM_CLKOUT3_DIVIDE_CAL),
373  .CLKOUT3_PHASE (0.000),
374  .CLKOUT3_DUTY_CYCLE (0.500),
375  .CLKOUT3_USE_FINE_PS ("FALSE"),
376  .CLKOUT4_DIVIDE (MMCM_CLKOUT4_DIVIDE_CAL),
377  .CLKOUT4_PHASE (0.000),
378  .CLKOUT4_DUTY_CYCLE (0.500),
379  .CLKOUT4_USE_FINE_PS ("FALSE"),
380  .CLKIN1_PERIOD (CLKOUT3_PERIOD_NS),
381  .REF_JITTER1 (0.000))
382  mmcm_i
383  // Output clocks
384  (.CLKFBOUT (clk_pll_i),
385  .CLKFBOUTB (),
386  .CLKOUT0 (mmcm_clkout0),
387  .CLKOUT0B (),
388  .CLKOUT1 (mmcm_clkout1),
389  .CLKOUT1B (),
390  .CLKOUT2 (mmcm_clkout2),
391  .CLKOUT2B (),
392  .CLKOUT3 (mmcm_clkout3),
393  .CLKOUT3B (),
394  .CLKOUT4 (mmcm_clkout4),
395  .CLKOUT5 (),
396  .CLKOUT6 (),
397  // Input clock control
398  .CLKFBIN (clk_bufg), // From BUFH network
399  .CLKIN1 (pll_clk3), // From PLL
400  .CLKIN2 (1'b0),
401  // Tied to always select the primary input clock
402  .CLKINSEL (1'b1),
403  // Ports for dynamic reconfiguration
404  .DADDR (7'h0),
405  .DCLK (1'b0),
406  .DEN (1'b0),
407  .DI (16'h0),
408  .DO (),
409  .DRDY (),
410  .DWE (1'b0),
411  // Ports for dynamic phase shift
412  .PSCLK (1'b0),
413  .PSEN (1'b0),
414  .PSINCDEC (1'b0),
415  .PSDONE (),
416  // Other control and status signals
417  .LOCKED (MMCM_Locked_i),
418  .CLKINSTOPPED (),
419  .CLKFBSTOPPED (),
420  .PWRDWN (1'b0),
421  .RST (~pll_locked_i));
422 
423  BUFG u_bufg_ui_addn_clk_0
424  (
425  .O (ui_addn_clk_0),
426  .I (mmcm_clkout0)
427  );
428 
429  BUFG u_bufg_ui_addn_clk_1
430  (
431  .O (ui_addn_clk_1),
432  .I (mmcm_clkout1)
433  );
434 
435  BUFG u_bufg_ui_addn_clk_2
436  (
437  .O (ui_addn_clk_2),
438  .I (mmcm_clkout2)
439  );
440 
441  BUFG u_bufg_ui_addn_clk_3
442  (
443  .O (ui_addn_clk_3),
444  .I (mmcm_clkout3)
445  );
446 
447  BUFG u_bufg_ui_addn_clk_4
448  (
449  .O (ui_addn_clk_4),
450  .I (mmcm_clkout4)
451  );
452 
453  end else begin: gen_mmcm
454 
455  MMCME2_ADV
456  #(.BANDWIDTH ("HIGH"),
457  .CLKOUT4_CASCADE ("FALSE"),
458  .COMPENSATION ("BUF_IN"),
459  .STARTUP_WAIT ("FALSE"),
460  .DIVCLK_DIVIDE (1),
461  .CLKFBOUT_MULT_F (MMCM_MULT_F),
462  .CLKFBOUT_PHASE (0.000),
463  .CLKFBOUT_USE_FINE_PS ("FALSE"),
464  .CLKOUT0_DIVIDE_F (MMCM_MULT_F),
465  .CLKOUT0_PHASE (0.000),
466  .CLKOUT0_DUTY_CYCLE (0.500),
467  .CLKOUT0_USE_FINE_PS ("FALSE"),
468  .CLKOUT1_DIVIDE (),
469  .CLKOUT1_PHASE (0.000),
470  .CLKOUT1_DUTY_CYCLE (0.500),
471  .CLKOUT1_USE_FINE_PS ("FALSE"),
472  .CLKIN1_PERIOD (CLKOUT3_PERIOD_NS),
473  .REF_JITTER1 (0.000))
474  mmcm_i
475  // Output clocks
476  (.CLKFBOUT (clk_pll_i),
477  .CLKFBOUTB (),
478  .CLKOUT0 (),
479  .CLKOUT0B (),
480  .CLKOUT1 (),
481  .CLKOUT1B (),
482  .CLKOUT2 (),
483  .CLKOUT2B (),
484  .CLKOUT3 (),
485  .CLKOUT3B (),
486  .CLKOUT4 (),
487  .CLKOUT5 (),
488  .CLKOUT6 (),
489  // Input clock control
490  .CLKFBIN (clk_bufg), // From BUFH network
491  .CLKIN1 (pll_clk3), // From PLL
492  .CLKIN2 (1'b0),
493  // Tied to always select the primary input clock
494  .CLKINSEL (1'b1),
495  // Ports for dynamic reconfiguration
496  .DADDR (7'h0),
497  .DCLK (1'b0),
498  .DEN (1'b0),
499  .DI (16'h0),
500  .DO (),
501  .DRDY (),
502  .DWE (1'b0),
503  // Ports for dynamic phase shift
504  .PSCLK (1'b0),
505  .PSEN (1'b0),
506  .PSINCDEC (1'b0),
507  .PSDONE (),
508  // Other control and status signals
509  .LOCKED (MMCM_Locked_i),
510  .CLKINSTOPPED (),
511  .CLKFBSTOPPED (),
512  .PWRDWN (1'b0),
513  .RST (~pll_locked_i));
514 
515  end
516  endgenerate
517 
518  //***************************************************************************
519  // RESET SYNCHRONIZATION DESCRIPTION:
520  // Various resets are generated to ensure that:
521  // 1. All resets are synchronously deasserted with respect to the clock
522  // domain they are interfacing to. There are several different clock
523  // domains - each one will receive a synchronized reset.
524  // 2. The reset deassertion order starts with deassertion of SYS_RST,
525  // followed by deassertion of resets for various parts of the design
526  // (see "RESET ORDER" below) based on the lock status of PLLE2s.
527  // RESET ORDER:
528  // 1. User deasserts SYS_RST
529  // 2. Reset PLLE2 and IDELAYCTRL
530  // 3. Wait for PLLE2 and IDELAYCTRL to lock
531  // 4. Release reset for all I/O primitives and internal logic
532  // OTHER NOTES:
533  // 1. Asynchronously assert reset. This way we can assert reset even if
534  // there is no clock (needed for things like 3-stating output buffers
535  // to prevent initial bus contention). Reset deassertion is synchronous.
536  //***************************************************************************
537 
538  //*****************************************************************
539  // CLKDIV logic reset
540  //*****************************************************************
541 
542  // Wait for PLLE2 and IDELAYCTRL to lock before releasing reset
543 
544  // current O,25.0 unisim phaser_ref never locks. Need to find out why .
545  assign rst_tmp = sys_rst_act_hi | ~iodelay_ctrl_rdy |
546  ~ref_dll_lock | ~MMCM_Locked_i;
547 
548  always @(posedge clk_bufg or posedge rst_tmp) begin
549  if (rst_tmp) begin
550  rstdiv0_sync_r <= #TCQ {RST_DIV_SYNC_NUM-1{1'b1}};
551  rstdiv0_sync_r1 <= #TCQ 1'b1 ;
552  end else begin
553  rstdiv0_sync_r <= #TCQ rstdiv0_sync_r << 1;
554  rstdiv0_sync_r1 <= #TCQ rstdiv0_sync_r[RST_DIV_SYNC_NUM-2];
555  end
556  end
557 
558  assign rstdiv0 = rstdiv0_sync_r1 ;
559 
560 
561  assign rst_tmp_phaser_ref = sys_rst_act_hi | ~pll_locked_i | ~iodelay_ctrl_rdy;
562 
563  always @(posedge clk_bufg or posedge rst_tmp_phaser_ref)
564  if (rst_tmp_phaser_ref)
565  rst_phaser_ref_sync_r <= #TCQ {RST_DIV_SYNC_NUM{1'b1}};
566  else
567  rst_phaser_ref_sync_r <= #TCQ rst_phaser_ref_sync_r << 1;
568 
569  assign rst_phaser_ref = rst_phaser_ref_sync_r[RST_DIV_SYNC_NUM-1];
570 
571 endmodule