[10] | 1 | // (c) Copyright 2006-2009 Xilinx, Inc. All rights reserved. |
---|
| 2 | // |
---|
| 3 | // This file contains confidential and proprietary information |
---|
| 4 | // of Xilinx, Inc. and is protected under U.S. and |
---|
| 5 | // international copyright and other intellectual property |
---|
| 6 | // laws. |
---|
| 7 | // |
---|
| 8 | // DISCLAIMER |
---|
| 9 | // This disclaimer is not a license and does not grant any |
---|
| 10 | // rights to the materials distributed herewith. Except as |
---|
| 11 | // otherwise provided in a valid license issued to you by |
---|
| 12 | // Xilinx, and to the maximum extent permitted by applicable |
---|
| 13 | // law: (1) THESE MATERIALS ARE MADE AVAILABLE "AS IS" AND |
---|
| 14 | // WITH ALL FAULTS, AND XILINX HEREBY DISCLAIMS ALL WARRANTIES |
---|
| 15 | // AND CONDITIONS, EXPRESS, IMPLIED, OR STATUTORY, INCLUDING |
---|
| 16 | // BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, NON- |
---|
| 17 | // INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE; and |
---|
| 18 | // (2) Xilinx shall not be liable (whether in contract or tort, |
---|
| 19 | // including negligence, or under any other theory of |
---|
| 20 | // liability) for any loss or damage of any kind or nature |
---|
| 21 | // related to, arising under or in connection with these |
---|
| 22 | // materials, including for any direct, or any indirect, |
---|
| 23 | // special, incidental, or consequential loss or damage |
---|
| 24 | // (including loss of data, profits, goodwill, or any type of |
---|
| 25 | // loss or damage suffered as a result of any action brought |
---|
| 26 | // by a third party) even if such damage or loss was |
---|
| 27 | // reasonably foreseeable or Xilinx had been advised of the |
---|
| 28 | // possibility of the same. |
---|
| 29 | // |
---|
| 30 | // CRITICAL APPLICATIONS |
---|
| 31 | // Xilinx products are not designed or intended to be fail- |
---|
| 32 | // safe, or for use in any application requiring fail-safe |
---|
| 33 | // performance, such as life-support or safety devices or |
---|
| 34 | // systems, Class III medical devices, nuclear facilities, |
---|
| 35 | // applications related to the deployment of airbags, or any |
---|
| 36 | // other applications that could lead to death, personal |
---|
| 37 | // injury, or severe property or environmental damage |
---|
| 38 | // (individually and collectively, "Critical |
---|
| 39 | // Applications"). Customer assumes the sole risk and |
---|
| 40 | // liability of any use of Xilinx products in Critical |
---|
| 41 | // Applications, subject only to applicable laws and |
---|
| 42 | // regulations governing limitations on product liability. |
---|
| 43 | // |
---|
| 44 | // |
---|
| 45 | // This disclaimer and copyright notice must be retained as part |
---|
| 46 | // of this file at all times. |
---|
| 47 | //***************************************************************************** |
---|
| 48 | // ____ ____ |
---|
| 49 | // / /\/ / |
---|
| 50 | // /___/ \ / Vendor: Xilinx |
---|
| 51 | // \ \ \/ Version: 3.6 |
---|
| 52 | // \ \ Application: MIG |
---|
| 53 | // / / Filename: ddr2_infrastructure.v |
---|
| 54 | // /___/ /\ Date Last Modified: $Date: 2010/06/29 12:03:43 $ |
---|
| 55 | // \ \ / \ Date Created: Wed Aug 16 2006 |
---|
| 56 | // \___\/\___\ |
---|
| 57 | // |
---|
| 58 | //Device: Virtex-5 |
---|
| 59 | //Design Name: DDR2 |
---|
| 60 | //Purpose: |
---|
| 61 | // Clock generation/distribution and reset synchronization |
---|
| 62 | //Reference: |
---|
| 63 | //Revision History: |
---|
| 64 | // Rev 1.1 - Parameter CLK_TYPE added and logic for DIFFERENTIAL and |
---|
| 65 | // SINGLE_ENDED added. PK. 6/20/08 |
---|
| 66 | // Rev 1.2 - Loacalparam CLK_GENERATOR added and logic for clocks generation |
---|
| 67 | // using PLL or DCM added as generic code. PK. 10/14/08 |
---|
| 68 | // Rev 1.3 - Added parameter NOCLK200 with default value '0'. Used for |
---|
| 69 | // controlling the instantiation of IBUFG for clk200. jul/03/09 |
---|
| 70 | //***************************************************************************** |
---|
| 71 | |
---|
| 72 | `timescale 1ns/1ps |
---|
| 73 | |
---|
| 74 | module ddr2_infrastructure # |
---|
| 75 | ( |
---|
| 76 | // Following parameters are for 72-bit RDIMM design (for ML561 Reference |
---|
| 77 | // board design). Actual values may be different. Actual parameters values |
---|
| 78 | // are passed from design top module dram module. Please refer to |
---|
| 79 | // the dram module for actual values. |
---|
| 80 | parameter CLK_PERIOD = 3000, |
---|
| 81 | parameter CLK_TYPE = "DIFFERENTIAL", |
---|
| 82 | parameter DLL_FREQ_MODE = "HIGH", |
---|
| 83 | parameter NOCLK200 = 0, |
---|
| 84 | parameter RST_ACT_LOW = 1 |
---|
| 85 | ) |
---|
| 86 | ( |
---|
| 87 | input sys_clk_p, |
---|
| 88 | input sys_clk_n, |
---|
| 89 | input sys_clk, |
---|
| 90 | input clk200_p, |
---|
| 91 | input clk200_n, |
---|
| 92 | input idly_clk_200, |
---|
| 93 | output clk0, |
---|
| 94 | output clk90, |
---|
| 95 | output clk200, |
---|
| 96 | output clkdiv0, |
---|
| 97 | input sys_rst_n, |
---|
| 98 | input idelay_ctrl_rdy, |
---|
| 99 | output rst0, |
---|
| 100 | output rst90, |
---|
| 101 | output rst200, |
---|
| 102 | output rstdiv0 |
---|
| 103 | ); |
---|
| 104 | |
---|
| 105 | // # of clock cycles to delay deassertion of reset. Needs to be a fairly |
---|
| 106 | // high number not so much for metastability protection, but to give time |
---|
| 107 | // for reset (i.e. stable clock cycles) to propagate through all state |
---|
| 108 | // machines and to all control signals (i.e. not all control signals have |
---|
| 109 | // resets, instead they rely on base state logic being reset, and the effect |
---|
| 110 | // of that reset propagating through the logic). Need this because we may not |
---|
| 111 | // be getting stable clock cycles while reset asserted (i.e. since reset |
---|
| 112 | // depends on PLL/DCM lock status) |
---|
| 113 | localparam RST_SYNC_NUM = 25; |
---|
| 114 | localparam CLK_PERIOD_NS = CLK_PERIOD / 1000.0; |
---|
| 115 | localparam CLK_PERIOD_INT = CLK_PERIOD/1000; |
---|
| 116 | |
---|
| 117 | // By default this Parameter (CLK_GENERATOR) value is "PLL". If this |
---|
| 118 | // Parameter is set to "PLL", PLL is used to generate the design clocks. |
---|
| 119 | // If this Parameter is set to "DCM", |
---|
| 120 | // DCM is used to generate the design clocks. |
---|
| 121 | localparam CLK_GENERATOR = "PLL"; |
---|
| 122 | |
---|
| 123 | wire clk0_bufg; |
---|
| 124 | wire clk0_bufg_in; |
---|
| 125 | wire clk90_bufg; |
---|
| 126 | wire clk90_bufg_in; |
---|
| 127 | wire clk200_bufg; |
---|
| 128 | wire clk200_ibufg; |
---|
| 129 | wire clkdiv0_bufg; |
---|
| 130 | wire clkdiv0_bufg_in; |
---|
| 131 | wire clkfbout_clkfbin; |
---|
| 132 | wire locked; |
---|
| 133 | reg [RST_SYNC_NUM-1:0] rst0_sync_r /* synthesis syn_maxfan = 10 */; |
---|
| 134 | reg [RST_SYNC_NUM-1:0] rst200_sync_r /* synthesis syn_maxfan = 10 */; |
---|
| 135 | reg [RST_SYNC_NUM-1:0] rst90_sync_r /* synthesis syn_maxfan = 10 */; |
---|
| 136 | reg [(RST_SYNC_NUM/2)-1:0] rstdiv0_sync_r /* synthesis syn_maxfan = 10 */; |
---|
| 137 | wire rst_tmp; |
---|
| 138 | wire sys_clk_ibufg; |
---|
| 139 | wire sys_rst; |
---|
| 140 | |
---|
| 141 | assign sys_rst = RST_ACT_LOW ? ~sys_rst_n: sys_rst_n; |
---|
| 142 | |
---|
| 143 | assign clk0 = clk0_bufg; |
---|
| 144 | assign clk90 = clk90_bufg; |
---|
| 145 | assign clk200 = clk200_bufg; |
---|
| 146 | assign clkdiv0 = clkdiv0_bufg; |
---|
| 147 | |
---|
| 148 | generate |
---|
| 149 | if(CLK_TYPE == "DIFFERENTIAL") begin : DIFF_ENDED_CLKS_INST |
---|
| 150 | //*************************************************************************** |
---|
| 151 | // Differential input clock input buffers |
---|
| 152 | //*************************************************************************** |
---|
| 153 | |
---|
| 154 | IBUFGDS_LVPECL_25 SYS_CLK_INST |
---|
| 155 | ( |
---|
| 156 | .I (sys_clk_p), |
---|
| 157 | .IB (sys_clk_n), |
---|
| 158 | .O (sys_clk_ibufg) |
---|
| 159 | ); |
---|
| 160 | |
---|
| 161 | IBUFGDS_LVPECL_25 IDLY_CLK_INST |
---|
| 162 | ( |
---|
| 163 | .I (clk200_p), |
---|
| 164 | .IB (clk200_n), |
---|
| 165 | .O (clk200_ibufg) |
---|
| 166 | ); |
---|
| 167 | |
---|
| 168 | end else if(CLK_TYPE == "SINGLE_ENDED") begin : SINGLE_ENDED_CLKS_INST |
---|
| 169 | //************************************************************************** |
---|
| 170 | // Single ended input clock input buffers |
---|
| 171 | //************************************************************************** |
---|
| 172 | |
---|
| 173 | BUFG SYS_CLK_INST |
---|
| 174 | ( |
---|
| 175 | .I (sys_clk), |
---|
| 176 | .O (sys_clk_ibufg) |
---|
| 177 | ); |
---|
| 178 | if ( NOCLK200 == 0 ) begin : IBUFG_INST |
---|
| 179 | BUFG IDLY_CLK_INST |
---|
| 180 | ( |
---|
| 181 | .I (idly_clk_200), |
---|
| 182 | .O (clk200_ibufg) |
---|
| 183 | ); |
---|
| 184 | end |
---|
| 185 | |
---|
| 186 | end |
---|
| 187 | endgenerate |
---|
| 188 | |
---|
| 189 | generate |
---|
| 190 | if ( ((NOCLK200 == 0) && (CLK_TYPE == "SINGLE_ENDED")) || (CLK_TYPE == "DIFFERENTIAL") ) begin : BUFG_INST |
---|
| 191 | BUFG CLK_200_BUFG |
---|
| 192 | ( |
---|
| 193 | .O (clk200_bufg), |
---|
| 194 | .I (clk200_ibufg) |
---|
| 195 | ); |
---|
| 196 | end else begin : NO_BUFG |
---|
| 197 | assign clk200_bufg = 1'b0; |
---|
| 198 | end |
---|
| 199 | endgenerate |
---|
| 200 | |
---|
| 201 | //*************************************************************************** |
---|
| 202 | // Global clock generation and distribution |
---|
| 203 | //*************************************************************************** |
---|
| 204 | |
---|
| 205 | generate |
---|
| 206 | if (CLK_GENERATOR == "PLL") begin : gen_pll_adv |
---|
| 207 | PLL_ADV # |
---|
| 208 | ( |
---|
| 209 | .BANDWIDTH ("OPTIMIZED"), |
---|
| 210 | .CLKIN1_PERIOD (CLK_PERIOD_NS), |
---|
| 211 | .CLKIN2_PERIOD (10.000), |
---|
| 212 | .CLKOUT0_DIVIDE (CLK_PERIOD_INT), |
---|
| 213 | .CLKOUT1_DIVIDE (CLK_PERIOD_INT), |
---|
| 214 | .CLKOUT2_DIVIDE (CLK_PERIOD_INT*2), |
---|
| 215 | .CLKOUT3_DIVIDE (1), |
---|
| 216 | .CLKOUT4_DIVIDE (1), |
---|
| 217 | .CLKOUT5_DIVIDE (1), |
---|
| 218 | .CLKOUT0_PHASE (0.000), |
---|
| 219 | .CLKOUT1_PHASE (90.000), |
---|
| 220 | .CLKOUT2_PHASE (0.000), |
---|
| 221 | .CLKOUT3_PHASE (0.000), |
---|
| 222 | .CLKOUT4_PHASE (0.000), |
---|
| 223 | .CLKOUT5_PHASE (0.000), |
---|
| 224 | .CLKOUT0_DUTY_CYCLE (0.500), |
---|
| 225 | .CLKOUT1_DUTY_CYCLE (0.500), |
---|
| 226 | .CLKOUT2_DUTY_CYCLE (0.500), |
---|
| 227 | .CLKOUT3_DUTY_CYCLE (0.500), |
---|
| 228 | .CLKOUT4_DUTY_CYCLE (0.500), |
---|
| 229 | .CLKOUT5_DUTY_CYCLE (0.500), |
---|
| 230 | .COMPENSATION ("SYSTEM_SYNCHRONOUS"), |
---|
| 231 | .DIVCLK_DIVIDE (1), |
---|
| 232 | .CLKFBOUT_MULT (CLK_PERIOD_INT), |
---|
| 233 | .CLKFBOUT_PHASE (0.0), |
---|
| 234 | .REF_JITTER (0.005000) |
---|
| 235 | ) |
---|
| 236 | u_pll_adv |
---|
| 237 | ( |
---|
| 238 | .CLKFBIN (clkfbout_clkfbin), |
---|
| 239 | .CLKINSEL (1'b1), |
---|
| 240 | .CLKIN1 (sys_clk_ibufg), |
---|
| 241 | .CLKIN2 (1'b0), |
---|
| 242 | .DADDR (5'b0), |
---|
| 243 | .DCLK (1'b0), |
---|
| 244 | .DEN (1'b0), |
---|
| 245 | .DI (16'b0), |
---|
| 246 | .DWE (1'b0), |
---|
| 247 | .REL (1'b0), |
---|
| 248 | .RST (sys_rst), |
---|
| 249 | .CLKFBDCM (), |
---|
| 250 | .CLKFBOUT (clkfbout_clkfbin), |
---|
| 251 | .CLKOUTDCM0 (), |
---|
| 252 | .CLKOUTDCM1 (), |
---|
| 253 | .CLKOUTDCM2 (), |
---|
| 254 | .CLKOUTDCM3 (), |
---|
| 255 | .CLKOUTDCM4 (), |
---|
| 256 | .CLKOUTDCM5 (), |
---|
| 257 | .CLKOUT0 (clk0_bufg_in), |
---|
| 258 | .CLKOUT1 (clk90_bufg_in), |
---|
| 259 | .CLKOUT2 (clkdiv0_bufg_in), |
---|
| 260 | .CLKOUT3 (), |
---|
| 261 | .CLKOUT4 (), |
---|
| 262 | .CLKOUT5 (), |
---|
| 263 | .DO (), |
---|
| 264 | .DRDY (), |
---|
| 265 | .LOCKED (locked) |
---|
| 266 | ); |
---|
| 267 | end else if (CLK_GENERATOR == "DCM") begin: gen_dcm_base |
---|
| 268 | DCM_BASE # |
---|
| 269 | ( |
---|
| 270 | .CLKIN_PERIOD (CLK_PERIOD_NS), |
---|
| 271 | .CLKDV_DIVIDE (2.0), |
---|
| 272 | .DLL_FREQUENCY_MODE (DLL_FREQ_MODE), |
---|
| 273 | .DUTY_CYCLE_CORRECTION ("TRUE"), |
---|
| 274 | .FACTORY_JF (16'hF0F0) |
---|
| 275 | ) |
---|
| 276 | u_dcm_base |
---|
| 277 | ( |
---|
| 278 | .CLK0 (clk0_bufg_in), |
---|
| 279 | .CLK180 (), |
---|
| 280 | .CLK270 (), |
---|
| 281 | .CLK2X (), |
---|
| 282 | .CLK2X180 (), |
---|
| 283 | .CLK90 (clk90_bufg_in), |
---|
| 284 | .CLKDV (clkdiv0_bufg_in), |
---|
| 285 | .CLKFX (), |
---|
| 286 | .CLKFX180 (), |
---|
| 287 | .LOCKED (locked), |
---|
| 288 | .CLKFB (clk0_bufg), |
---|
| 289 | .CLKIN (sys_clk_ibufg), |
---|
| 290 | .RST (sys_rst) |
---|
| 291 | ); |
---|
| 292 | end |
---|
| 293 | endgenerate |
---|
| 294 | |
---|
| 295 | BUFG U_BUFG_CLK0 |
---|
| 296 | ( |
---|
| 297 | .O (clk0_bufg), |
---|
| 298 | .I (clk0_bufg_in) |
---|
| 299 | ); |
---|
| 300 | |
---|
| 301 | BUFG U_BUFG_CLK90 |
---|
| 302 | ( |
---|
| 303 | .O (clk90_bufg), |
---|
| 304 | .I (clk90_bufg_in) |
---|
| 305 | ); |
---|
| 306 | |
---|
| 307 | BUFG U_BUFG_CLKDIV0 |
---|
| 308 | ( |
---|
| 309 | .O (clkdiv0_bufg), |
---|
| 310 | .I (clkdiv0_bufg_in) |
---|
| 311 | ); |
---|
| 312 | |
---|
| 313 | |
---|
| 314 | //*************************************************************************** |
---|
| 315 | // Reset synchronization |
---|
| 316 | // NOTES: |
---|
| 317 | // 1. shut down the whole operation if the PLL/ DCM hasn't yet locked (and |
---|
| 318 | // by inference, this means that external SYS_RST_IN has been asserted - |
---|
| 319 | // PLL/DCM deasserts LOCKED as soon as SYS_RST_IN asserted) |
---|
| 320 | // 2. In the case of all resets except rst200, also assert reset if the |
---|
| 321 | // IDELAY master controller is not yet ready |
---|
| 322 | // 3. asynchronously assert reset. This was we can assert reset even if |
---|
| 323 | // there is no clock (needed for things like 3-stating output buffers). |
---|
| 324 | // reset deassertion is synchronous. |
---|
| 325 | //*************************************************************************** |
---|
| 326 | |
---|
| 327 | assign rst_tmp = sys_rst | ~locked | ~idelay_ctrl_rdy; |
---|
| 328 | |
---|
| 329 | // synthesis attribute max_fanout of rst0_sync_r is 10 |
---|
| 330 | always @(posedge clk0_bufg or posedge rst_tmp) |
---|
| 331 | if (rst_tmp) |
---|
| 332 | rst0_sync_r <= {RST_SYNC_NUM{1'b1}}; |
---|
| 333 | else |
---|
| 334 | // logical left shift by one (pads with 0) |
---|
| 335 | rst0_sync_r <= rst0_sync_r << 1; |
---|
| 336 | |
---|
| 337 | // synthesis attribute max_fanout of rstdiv0_sync_r is 10 |
---|
| 338 | always @(posedge clkdiv0_bufg or posedge rst_tmp) |
---|
| 339 | if (rst_tmp) |
---|
| 340 | rstdiv0_sync_r <= {(RST_SYNC_NUM/2){1'b1}}; |
---|
| 341 | else |
---|
| 342 | // logical left shift by one (pads with 0) |
---|
| 343 | rstdiv0_sync_r <= rstdiv0_sync_r << 1; |
---|
| 344 | |
---|
| 345 | // synthesis attribute max_fanout of rst90_sync_r is 10 |
---|
| 346 | always @(posedge clk90_bufg or posedge rst_tmp) |
---|
| 347 | if (rst_tmp) |
---|
| 348 | rst90_sync_r <= {RST_SYNC_NUM{1'b1}}; |
---|
| 349 | else |
---|
| 350 | rst90_sync_r <= rst90_sync_r << 1; |
---|
| 351 | |
---|
| 352 | // make sure CLK200 doesn't depend on IDELAY_CTRL_RDY, else chicken n' egg |
---|
| 353 | // synthesis attribute max_fanout of rst200_sync_r is 10 |
---|
| 354 | always @(posedge clk200_bufg or negedge locked) |
---|
| 355 | if (!locked) |
---|
| 356 | rst200_sync_r <= {RST_SYNC_NUM{1'b1}}; |
---|
| 357 | else |
---|
| 358 | rst200_sync_r <= rst200_sync_r << 1; |
---|
| 359 | |
---|
| 360 | |
---|
| 361 | assign rst0 = rst0_sync_r[RST_SYNC_NUM-1]; |
---|
| 362 | assign rst90 = rst90_sync_r[RST_SYNC_NUM-1]; |
---|
| 363 | assign rst200 = rst200_sync_r[RST_SYNC_NUM-1]; |
---|
| 364 | assign rstdiv0 = rstdiv0_sync_r[(RST_SYNC_NUM/2)-1]; |
---|
| 365 | |
---|
| 366 | endmodule |
---|