AMC13
Firmwares for the different applications of the AMC13 uTCA board made at Boston University
 All Classes Variables
mig_7series_v1_9_iodelay_ctrl.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: 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: Virtex-6
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 
81  (
82  parameter TCQ = 100,
83  // clk->out delay (sim only)
84  parameter IODELAY_GRP = "IODELAY_MIG",
85  // May be assigned unique name when
86  // multiple IP cores used in design
87  parameter REFCLK_TYPE = "DIFFERENTIAL",
88  // Reference clock type
89  // "DIFFERENTIAL","SINGLE_ENDED"
90  // NO_BUFFER, USE_SYSTEM_CLOCK
91  parameter SYSCLK_TYPE = "DIFFERENTIAL",
92  // input clock type
93  // DIFFERENTIAL, SINGLE_ENDED,
94  // NO_BUFFER
95  parameter SYS_RST_PORT = "FALSE",
96  // "TRUE" - if pin is selected for sys_rst
97  // and IBUF will be instantiated.
98  // "FALSE" - if pin is not selected for sys_rst
99  parameter RST_ACT_LOW = 1,
100  // Reset input polarity
101  // (0 = active high, 1 = active low)
102  parameter DIFF_TERM_REFCLK = "TRUE"
103  // Differential Termination
104  )
105  (
106  input clk_ref_p,
107  input clk_ref_n,
108  input clk_ref_i,
109  input sys_rst,
110  output clk_ref,
111  output sys_rst_o,
112  output iodelay_ctrl_rdy
113  );
114 
115  // # of clock cycles to delay deassertion of reset. Needs to be a fairly
116  // high number not so much for metastability protection, but to give time
117  // for reset (i.e. stable clock cycles) to propagate through all state
118  // machines and to all control signals (i.e. not all control signals have
119  // resets, instead they rely on base state logic being reset, and the effect
120  // of that reset propagating through the logic). Need this because we may not
121  // be getting stable clock cycles while reset asserted (i.e. since reset
122  // depends on DCM lock status)
123  // COMMENTED, RC, 01/13/09 - causes pack error in MAP w/ larger #
124  localparam RST_SYNC_NUM = 15;
125  // localparam RST_SYNC_NUM = 25;
126 
127  wire clk_ref_bufg;
128  wire clk_ref_ibufg;
129  wire rst_ref;
130  (* keep = "true", max_fanout = 10 *) reg [RST_SYNC_NUM-1:0] rst_ref_sync_r /* synthesis syn_maxfan = 10 **/;
131  wire rst_tmp_idelay;
132  wire sys_rst_act_hi;
133 
134  //***************************************************************************
135 
136  // If the pin is selected for sys_rst in GUI, IBUF will be instantiated.
137  // If the pin is not selected in GUI, sys_rst signal is expected to be
138  // driven internally.
139  generate
140  if (SYS_RST_PORT == "TRUE")
141  IBUF u_sys_rst_ibuf
142  (
143  .I (sys_rst),
144  .O (sys_rst_o)
145  );
146  else
147  assign sys_rst_o = sys_rst;
148  endgenerate
149 
150  // Possible inversion of system reset as appropriate
151  assign sys_rst_act_hi = RST_ACT_LOW ? ~sys_rst_o: sys_rst_o;
152 
153  //***************************************************************************
154  // 1) Input buffer for IDELAYCTRL reference clock - handle either a
155  // differential or single-ended input. Global clock buffer is used to
156  // drive the rest of FPGA logic.
157  // 2) For NO_BUFFER option, Reference clock will be driven from internal
158  // clock i.e., clock is driven from fabric. Input buffers and Global
159  // clock buffers will not be instaitaed.
160  // 3) For USE_SYSTEM_CLOCK, input buffer output of system clock will be used
161  // as the input reference clock. Global clock buffer is used to drive
162  // the rest of FPGA logic.
163  //***************************************************************************
164 
165  generate
166  if (REFCLK_TYPE == "DIFFERENTIAL") begin: diff_clk_ref
167  IBUFGDS #
168  (
169  .DIFF_TERM (DIFF_TERM_REFCLK),
170  .IBUF_LOW_PWR ("FALSE")
171  )
172  u_ibufg_clk_ref
173  (
174  .I (clk_ref_p),
175  .IB (clk_ref_n),
176  .O (clk_ref_ibufg)
177  );
178 
179  BUFG u_bufg_clk_ref
180  (
181  .O (clk_ref_bufg),
182  .I (clk_ref_ibufg)
183  );
184  end else if (REFCLK_TYPE == "SINGLE_ENDED") begin : se_clk_ref
185  IBUFG #
186  (
187  .IBUF_LOW_PWR ("FALSE")
188  )
189  u_ibufg_clk_ref
190  (
191  .I (clk_ref_i),
192  .O (clk_ref_ibufg)
193  );
194 
195  BUFG u_bufg_clk_ref
196  (
197  .O (clk_ref_bufg),
198  .I (clk_ref_ibufg)
199  );
200  end else if ((REFCLK_TYPE == "NO_BUFFER") ||
201  (REFCLK_TYPE == "USE_SYSTEM_CLOCK" && SYSCLK_TYPE == "NO_BUFFER")) begin : clk_ref_noibuf_nobuf
202  assign clk_ref_bufg = clk_ref_i;
203  end else if (REFCLK_TYPE == "USE_SYSTEM_CLOCK" && SYSCLK_TYPE != "NO_BUFFER") begin : clk_ref_noibuf
204  BUFG u_bufg_clk_ref
205  (
206  .O (clk_ref_bufg),
207  .I (clk_ref_i)
208  );
209  end
210  endgenerate
211 
212  //***************************************************************************
213  // Global clock buffer for IDELAY reference clock
214  //***************************************************************************
215 
216 
217  assign clk_ref = clk_ref_bufg;
218 
219  //*****************************************************************
220  // IDELAYCTRL reset
221  // This assumes an external clock signal driving the IDELAYCTRL
222  // blocks. Otherwise, if a PLL drives IDELAYCTRL, then the PLL
223  // lock signal will need to be incorporated in this.
224  //*****************************************************************
225 
226  // Add PLL lock if PLL drives IDELAYCTRL in user design
227  assign rst_tmp_idelay = sys_rst_act_hi;
228 
229  always @(posedge clk_ref_bufg or posedge rst_tmp_idelay)
230  if (rst_tmp_idelay)
231  rst_ref_sync_r <= #TCQ {RST_SYNC_NUM{1'b1}};
232  else
233  rst_ref_sync_r <= #TCQ rst_ref_sync_r << 1;
234 
235  assign rst_ref = rst_ref_sync_r[RST_SYNC_NUM-1];
236 
237  //*****************************************************************
238 
239  (* IODELAY_GROUP = IODELAY_GRP *) IDELAYCTRL u_idelayctrl
240  (
241  .RDY (iodelay_ctrl_rdy),
242  .REFCLK (clk_ref_bufg),
243  .RST (rst_ref)
244  );
245 
246 endmodule