OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [orpsocv2/] [boards/] [xilinx/] [atlys/] [rtl/] [verilog/] [xilinx_ddr2/] [infrastructure.v] - Blame information for rev 627

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 627 stekern
//*****************************************************************************
2
// (c) Copyright 2010 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: 2010/10/27 17:40:11 $
56
// \   \  /  \    Date Created       : Mon Mar 2 2009
57
//  \___\/\___\
58
//
59
//Device           : Spartan-6
60
//Design Name      : DDR/DDR2/DDR3/LPDDR
61
//Purpose          : Clock generation/distribution and reset synchronization
62
//Reference        :
63
//Revision History :
64
//*****************************************************************************
65
 
66
 
67
`timescale 1ns/1ps
68
 
69
module infrastructure #
70
  (
71
   parameter C_INCLK_PERIOD    = 2500,
72
   parameter C_RST_ACT_LOW      = 1,
73
   parameter C_INPUT_CLK_TYPE   = "DIFFERENTIAL",
74
   parameter C_CLKOUT0_DIVIDE   = 1,
75
   parameter C_CLKOUT1_DIVIDE   = 1,
76
   parameter C_CLKOUT2_DIVIDE   = 16,
77
   parameter C_CLKOUT3_DIVIDE   = 8,
78
   parameter C_CLKFBOUT_MULT    = 2,
79
   parameter C_DIVCLK_DIVIDE    = 1
80
 
81
   )
82
  (
83
   input  sys_clk_p,
84
   input  sys_clk_n,
85
   input  sys_clk,
86
   input  sys_rst_n,
87
   output clk0,
88
   output rst0,
89
   output async_rst,
90
   output sysclk_2x,
91
   output sysclk_2x_180,
92
   output mcb_drp_clk,
93
   output pll_ce_0,
94
   output pll_ce_90,
95
   output pll_lock
96
 
97
   );
98
 
99
  // # of clock cycles to delay deassertion of reset. Needs to be a fairly
100
  // high number not so much for metastability protection, but to give time
101
  // for reset (i.e. stable clock cycles) to propagate through all state
102
  // machines and to all control signals (i.e. not all control signals have
103
  // resets, instead they rely on base state logic being reset, and the effect
104
  // of that reset propagating through the logic). Need this because we may not
105
  // be getting stable clock cycles while reset asserted (i.e. since reset
106
  // depends on PLL/DCM lock status)
107
 
108
  localparam RST_SYNC_NUM = 25;
109
  localparam CLK_PERIOD_NS = C_INCLK_PERIOD / 1000.0;
110
  localparam CLK_PERIOD_INT = C_INCLK_PERIOD/1000;
111
 
112
  wire                       clk_2x_0;
113
  wire                       clk_2x_180;
114
  wire                       clk0_bufg;
115
  wire                       clk0_bufg_in;
116
  wire                       mcb_drp_clk_bufg_in;
117
  wire                       clkfbout_clkfbin;
118
  wire                       locked;
119
  reg [RST_SYNC_NUM-1:0]     rst0_sync_r    /* synthesis syn_maxfan = 10 */;
120
  wire                       rst_tmp;
121
  reg                        powerup_pll_locked;
122
 
123
  wire                       sys_rst;
124
  wire                       bufpll_mcb_locked;
125
  (* KEEP = "TRUE" *) wire sys_clk_ibufg;
126
 
127
  assign sys_rst = C_RST_ACT_LOW ? ~sys_rst_n: sys_rst_n;
128
  assign clk0        = clk0_bufg;
129
  assign pll_lock    = bufpll_mcb_locked;
130
 
131
  generate
132
    if (C_INPUT_CLK_TYPE == "DIFFERENTIAL") begin: diff_input_clk
133
 
134
      //***********************************************************************
135
      // Differential input clock input buffers
136
      //***********************************************************************
137
 
138
      IBUFGDS #
139
        (
140
         .DIFF_TERM    ("TRUE")
141
         )
142
        u_ibufg_sys_clk
143
          (
144
           .I  (sys_clk_p),
145
           .IB (sys_clk_n),
146
           .O  (sys_clk_ibufg)
147
           );
148
 
149
    end else if (C_INPUT_CLK_TYPE == "SINGLE_ENDED") begin: se_input_clk
150
 
151
      //***********************************************************************
152
      // SINGLE_ENDED input clock input buffers
153
      //***********************************************************************
154
/* SJK
155
      IBUFG  u_ibufg_sys_clk
156
          (
157
           .I  (sys_clk),
158
           .O  (sys_clk_ibufg)
159
           );
160
*/
161
   assign sys_clk_ibufg = sys_clk;
162
   end
163
  endgenerate
164
 
165
  //***************************************************************************
166
  // Global clock generation and distribution
167
  //***************************************************************************
168
 
169
    PLL_ADV #
170
        (
171
         .BANDWIDTH          ("OPTIMIZED"),
172
         .CLKIN1_PERIOD      (CLK_PERIOD_NS),
173
         .CLKIN2_PERIOD      (CLK_PERIOD_NS),
174
         .CLKOUT0_DIVIDE     (C_CLKOUT0_DIVIDE),
175
         .CLKOUT1_DIVIDE     (C_CLKOUT1_DIVIDE),
176
         .CLKOUT2_DIVIDE     (C_CLKOUT2_DIVIDE),
177
         .CLKOUT3_DIVIDE     (C_CLKOUT3_DIVIDE),
178
         .CLKOUT4_DIVIDE     (1),
179
         .CLKOUT5_DIVIDE     (1),
180
         .CLKOUT0_PHASE      (0.000),
181
         .CLKOUT1_PHASE      (180.000),
182
         .CLKOUT2_PHASE      (0.000),
183
         .CLKOUT3_PHASE      (0.000),
184
         .CLKOUT4_PHASE      (0.000),
185
         .CLKOUT5_PHASE      (0.000),
186
         .CLKOUT0_DUTY_CYCLE (0.500),
187
         .CLKOUT1_DUTY_CYCLE (0.500),
188
         .CLKOUT2_DUTY_CYCLE (0.500),
189
         .CLKOUT3_DUTY_CYCLE (0.500),
190
         .CLKOUT4_DUTY_CYCLE (0.500),
191
         .CLKOUT5_DUTY_CYCLE (0.500),
192
         .COMPENSATION       ("INTERNAL"),
193
         .DIVCLK_DIVIDE      (C_DIVCLK_DIVIDE),
194
         .CLKFBOUT_MULT      (C_CLKFBOUT_MULT),
195
         .CLKFBOUT_PHASE     (0.0),
196
         .REF_JITTER         (0.005000)
197
         )
198
        u_pll_adv
199
          (
200
           .CLKFBIN     (clkfbout_clkfbin),
201
           .CLKINSEL    (1'b1),
202
           .CLKIN1      (sys_clk_ibufg),
203
           .CLKIN2      (1'b0),
204
           .DADDR       (5'b0),
205
           .DCLK        (1'b0),
206
           .DEN         (1'b0),
207
           .DI          (16'b0),
208
           .DWE         (1'b0),
209
           .REL         (1'b0),
210
           .RST         (sys_rst),
211
           .CLKFBDCM    (),
212
           .CLKFBOUT    (clkfbout_clkfbin),
213
           .CLKOUTDCM0  (),
214
           .CLKOUTDCM1  (),
215
           .CLKOUTDCM2  (),
216
           .CLKOUTDCM3  (),
217
           .CLKOUTDCM4  (),
218
           .CLKOUTDCM5  (),
219
           .CLKOUT0     (clk_2x_0),
220
           .CLKOUT1     (clk_2x_180),
221
           .CLKOUT2     (clk0_bufg_in),
222
           .CLKOUT3     (mcb_drp_clk_bufg_in),
223
           .CLKOUT4     (),
224
           .CLKOUT5     (),
225
           .DO          (),
226
           .DRDY        (),
227
           .LOCKED      (locked)
228
           );
229
 
230
 
231
 
232
   BUFG U_BUFG_CLK0
233
    (
234
     .O (clk0_bufg),
235
     .I (clk0_bufg_in)
236
     );
237
 
238
   BUFG U_BUFG_CLK1
239
    (
240
     .O (mcb_drp_clk),
241
     .I (mcb_drp_clk_bufg_in)
242
     );
243
 
244
 
245
  always @(posedge clk0_bufg , posedge sys_rst)
246
      if(sys_rst)
247
         powerup_pll_locked <= 1'b0;
248
 
249
      else if (bufpll_mcb_locked)
250
         powerup_pll_locked <= 1'b1;
251
 
252
  //***************************************************************************
253
  // Reset synchronization
254
  // NOTES:
255
  //   1. shut down the whole operation if the PLL hasn't yet locked (and
256
  //      by inference, this means that external SYS_RST_IN has been asserted -
257
  //      PLL deasserts LOCKED as soon as SYS_RST_IN asserted)
258
  //   2. asynchronously assert reset. This was we can assert reset even if
259
  //      there is no clock (needed for things like 3-stating output buffers).
260
  //      reset deassertion is synchronous.
261
  //   3. asynchronous reset only look at pll_lock from PLL during power up. After
262
  //      power up and pll_lock is asserted, the powerup_pll_locked will be asserted
263
  //      forever until sys_rst is asserted again. PLL will lose lock when FPGA 
264
  //      enters suspend mode. We don't want reset to MCB get
265
  //      asserted in the application that needs suspend feature.
266
  //***************************************************************************
267
 
268
  assign rst_tmp = sys_rst | ~powerup_pll_locked;
269
 
270
  assign async_rst = rst_tmp;
271
  // synthesis attribute max_fanout of rst0_sync_r is 10
272
  always @(posedge clk0_bufg or posedge rst_tmp)
273
    if (rst_tmp)
274
      rst0_sync_r <= {RST_SYNC_NUM{1'b1}};
275
    else
276
      // logical left shift by one (pads with 0)
277
      rst0_sync_r <= rst0_sync_r << 1;
278
 
279
 
280
  assign rst0    = rst0_sync_r[RST_SYNC_NUM-1];
281
 
282
 
283
BUFPLL_MCB BUFPLL_MCB1
284
( .IOCLK0         (sysclk_2x),
285
  .IOCLK1         (sysclk_2x_180),
286
  .LOCKED         (locked),
287
  .GCLK           (mcb_drp_clk),
288
  .SERDESSTROBE0  (pll_ce_0),
289
  .SERDESSTROBE1  (pll_ce_90),
290
  .PLLIN0         (clk_2x_0),
291
  .PLLIN1         (clk_2x_180),
292
  .LOCK           (bufpll_mcb_locked)
293
  );
294
 
295
 
296
endmodule

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.