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

Subversion Repositories usb_fpga_2_14

[/] [usb_fpga_2_14/] [trunk/] [examples/] [memfifo/] [fpga-2.04b/] [ipcore_dir/] [mem0/] [user_design/] [rtl/] [infrastructure.orig.v] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 ZTEX
//*****************************************************************************
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: 2011/06/02 07:17:09 $
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_i,
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
  reg                        syn_clk0_powerup_pll_locked;
123
 
124
  wire                       sys_rst;
125
  wire                       bufpll_mcb_locked;
126
  (* KEEP = "TRUE" *) wire sys_clk_ibufg;
127
 
128
  assign sys_rst = C_RST_ACT_LOW ? ~sys_rst_i: sys_rst_i;
129
  assign clk0        = clk0_bufg;
130
  assign pll_lock    = bufpll_mcb_locked;
131
 
132
  generate
133
    if (C_INPUT_CLK_TYPE == "DIFFERENTIAL") begin: diff_input_clk
134
 
135
      //***********************************************************************
136
      // Differential input clock input buffers
137
      //***********************************************************************
138
 
139
      IBUFGDS #
140
        (
141
         .DIFF_TERM    ("TRUE")
142
         )
143
        u_ibufg_sys_clk
144
          (
145
           .I  (sys_clk_p),
146
           .IB (sys_clk_n),
147
           .O  (sys_clk_ibufg)
148
           );
149
 
150
    end else if (C_INPUT_CLK_TYPE == "SINGLE_ENDED") begin: se_input_clk
151
 
152
      //***********************************************************************
153
      // SINGLE_ENDED input clock input buffers
154
      //***********************************************************************
155
 
156
      IBUFG  u_ibufg_sys_clk
157
          (
158
           .I  (sys_clk),
159
           .O  (sys_clk_ibufg)
160
           );
161
   end
162
  endgenerate
163
 
164
  //***************************************************************************
165
  // Global clock generation and distribution
166
  //***************************************************************************
167
 
168
    PLL_ADV #
169
        (
170
         .BANDWIDTH          ("OPTIMIZED"),
171
         .CLKIN1_PERIOD      (CLK_PERIOD_NS),
172
         .CLKIN2_PERIOD      (CLK_PERIOD_NS),
173
         .CLKOUT0_DIVIDE     (C_CLKOUT0_DIVIDE),
174
         .CLKOUT1_DIVIDE     (C_CLKOUT1_DIVIDE),
175
         .CLKOUT2_DIVIDE     (C_CLKOUT2_DIVIDE),
176
         .CLKOUT3_DIVIDE     (C_CLKOUT3_DIVIDE),
177
         .CLKOUT4_DIVIDE     (1),
178
         .CLKOUT5_DIVIDE     (1),
179
         .CLKOUT0_PHASE      (0.000),
180
         .CLKOUT1_PHASE      (180.000),
181
         .CLKOUT2_PHASE      (0.000),
182
         .CLKOUT3_PHASE      (0.000),
183
         .CLKOUT4_PHASE      (0.000),
184
         .CLKOUT5_PHASE      (0.000),
185
         .CLKOUT0_DUTY_CYCLE (0.500),
186
         .CLKOUT1_DUTY_CYCLE (0.500),
187
         .CLKOUT2_DUTY_CYCLE (0.500),
188
         .CLKOUT3_DUTY_CYCLE (0.500),
189
         .CLKOUT4_DUTY_CYCLE (0.500),
190
         .CLKOUT5_DUTY_CYCLE (0.500),
191
         .SIM_DEVICE         ("SPARTAN6"),
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
   BUFGCE U_BUFG_CLK1
239
    (
240
     .O (mcb_drp_clk),
241
     .I (mcb_drp_clk_bufg_in),
242
     .CE (locked)
243
     );
244
 
245
  always @(posedge mcb_drp_clk , 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
  always @(posedge clk0_bufg , posedge sys_rst)
254
      if(sys_rst)
255
         syn_clk0_powerup_pll_locked <= 1'b0;
256
 
257
      else if (bufpll_mcb_locked)
258
         syn_clk0_powerup_pll_locked <= 1'b1;
259
 
260
 
261
  //***************************************************************************
262
  // Reset synchronization
263
  // NOTES:
264
  //   1. shut down the whole operation if the PLL hasn't yet locked (and
265
  //      by inference, this means that external SYS_RST_IN has been asserted -
266
  //      PLL deasserts LOCKED as soon as SYS_RST_IN asserted)
267
  //   2. asynchronously assert reset. This was we can assert reset even if
268
  //      there is no clock (needed for things like 3-stating output buffers).
269
  //      reset deassertion is synchronous.
270
  //   3. asynchronous reset only look at pll_lock from PLL during power up. After
271
  //      power up and pll_lock is asserted, the powerup_pll_locked will be asserted
272
  //      forever until sys_rst is asserted again. PLL will lose lock when FPGA 
273
  //      enters suspend mode. We don't want reset to MCB get
274
  //      asserted in the application that needs suspend feature.
275
  //***************************************************************************
276
 
277
 
278
  assign async_rst = sys_rst | ~powerup_pll_locked;
279
  // synthesis attribute max_fanout of rst0_sync_r is 10
280
  assign rst_tmp = sys_rst | ~syn_clk0_powerup_pll_locked;
281
 
282
  always @(posedge clk0_bufg or posedge rst_tmp)
283
    if (rst_tmp)
284
      rst0_sync_r <= {RST_SYNC_NUM{1'b1}};
285
    else
286
      // logical left shift by one (pads with 0)
287
      rst0_sync_r <= rst0_sync_r << 1;
288
 
289
 
290
  assign rst0    = rst0_sync_r[RST_SYNC_NUM-1];
291
 
292
 
293
BUFPLL_MCB BUFPLL_MCB1
294
( .IOCLK0         (sysclk_2x),
295
  .IOCLK1         (sysclk_2x_180),
296
  .LOCKED         (locked),
297
  .GCLK           (mcb_drp_clk),
298
  .SERDESSTROBE0  (pll_ce_0),
299
  .SERDESSTROBE1  (pll_ce_90),
300
  .PLLIN0         (clk_2x_0),
301
  .PLLIN1         (clk_2x_180),
302
  .LOCK           (bufpll_mcb_locked)
303
  );
304
 
305
 
306
endmodule

powered by: WebSVN 2.1.0

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