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

Subversion Repositories pcie_ds_dma

[/] [pcie_ds_dma/] [trunk/] [core/] [ds_dma64/] [pcie_src/] [pcie_core64_m1/] [source/] [pcie_clocking.v] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 dsmv
 
2
//-----------------------------------------------------------------------------
3
//
4
// (c) Copyright 2009-2010 Xilinx, Inc. All rights reserved.
5
//
6
// This file contains confidential and proprietary information
7
// of Xilinx, Inc. and is protected under U.S. and
8
// international copyright and other intellectual property
9
// laws.
10
//
11
// DISCLAIMER
12
// This disclaimer is not a license and does not grant any
13
// rights to the materials distributed herewith. Except as
14
// otherwise provided in a valid license issued to you by
15
// Xilinx, and to the maximum extent permitted by applicable
16
// law: (1) THESE MATERIALS ARE MADE AVAILABLE "AS IS" AND
17
// WITH ALL FAULTS, AND XILINX HEREBY DISCLAIMS ALL WARRANTIES
18
// AND CONDITIONS, EXPRESS, IMPLIED, OR STATUTORY, INCLUDING
19
// BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, NON-
20
// INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE; and
21
// (2) Xilinx shall not be liable (whether in contract or tort,
22
// including negligence, or under any other theory of
23
// liability) for any loss or damage of any kind or nature
24
// related to, arising under or in connection with these
25
// materials, including for any direct, or any indirect,
26
// special, incidental, or consequential loss or damage
27
// (including loss of data, profits, goodwill, or any type of
28
// loss or damage suffered as a result of any action brought
29
// by a third party) even if such damage or loss was
30
// reasonably foreseeable or Xilinx had been advised of the
31
// possibility of the same.
32
//
33
// CRITICAL APPLICATIONS
34
// Xilinx products are not designed or intended to be fail-
35
// safe, or for use in any application requiring fail-safe
36
// performance, such as life-support or safety devices or
37
// systems, Class III medical devices, nuclear facilities,
38
// applications related to the deployment of airbags, or any
39
// other applications that could lead to death, personal
40
// injury, or severe property or environmental damage
41
// (individually and collectively, "Critical
42
// Applications"). Customer assumes the sole risk and
43
// liability of any use of Xilinx products in Critical
44
// Applications, subject only to applicable laws and
45
// regulations governing limitations on product liability.
46
//
47
// THIS COPYRIGHT NOTICE AND DISCLAIMER MUST BE RETAINED AS
48
// PART OF THIS FILE AT ALL TIMES.
49
//
50
//-----------------------------------------------------------------------------
51
// Project    : V5-Block Plus for PCI Express
52
// File       : pcie_clocking.v
53
//--------------------------------------------------------------------------------
54
//--------------------------------------------------------------------------------
55
//
56
//   ____  ____
57
//  /   /\/   /
58
// /___/  \  /    Vendor      : Xilinx
59
// \   \   \/     Version     : 1.1
60
//  \   \         Application : Generated by Xilinx PCI Express Wizard
61
//  /   /         Filename    : pcie_clocking.v
62
// /___/   /\     Module      : pcie_clocking
63
// \   \  /  \
64
//  \___\/\___\
65
//
66
//------------------------------------------------------------------------------
67
 
68
module pcie_clocking #
69
( parameter    G_DIVIDE_VAL = 2,  // use 2 or 4
70
  parameter    REF_CLK_FREQ = 1  // use 0 or 1
71
)
72
 
73
(
74
  input  clkin_pll,
75
  input  clkin_dcm,
76
  input  rst,
77
 
78
  output coreclk,
79
  output userclk,
80
  output gtx_usrclk,
81
  output txsync_clk,
82
  output locked,
83
  input  fast_train_simulation_only
84
 );
85
 
86
 
87
  wire clkfbout;
88
  wire clkfbin;
89
  wire clkout0;
90
  wire clkout1;
91
  wire clkout2;
92
  wire txsync_clkout;
93
 
94
 
95
  wire clk0;
96
  wire clkfb;
97
  wire clkdv;
98
  wire [15:0] not_connected;
99
 
100
  reg  [7:0]  lock_wait_cntr_7_0;
101
  reg  [7:0]  lock_wait_cntr_15_8;
102
  reg         pll_locked_out_r;
103
  reg         pll_locked_out_r_d;
104
  reg         pll_locked_out_r_2d;
105
  reg         time_elapsed;
106
 
107
 
108
  parameter G_DVIDED_VAL_PLL = G_DIVIDE_VAL*2;
109
 
110
   generate
111
       begin : use_pll
112
 
113
        // CALCULATED WAY (easier): must use bitgen -g plladv_xNyM_use_calc:Yes to enable this attribute
114
       // synthesis attribute CLKOUT1_DIVIDE pll1 "4";
115
       // synthesis attribute CLKOUT1_PHASE pll1 "0";
116
       // synthesis attribute CLKOUT1_DUTY_CYCLE pll1 "0.5";
117
 
118
       // synthesis attribute PLL_OPT_INV pll1 "001001";
119
       // synthesis attribute PLL_CP pll1 "2";
120
       // synthesis attribute PLL_RES pll1 "8";
121
 
122
          PLL_ADV #
123
          (
124
            // 5 for 100 MHz, 2 for 250 MHz
125
            .CLKFBOUT_MULT (5-(REF_CLK_FREQ*3)),
126
            .CLKFBOUT_PHASE(0),
127
 
128
            // 10 for 100 MHz, 4 for 250 MHz
129
            .CLKIN1_PERIOD (10-(REF_CLK_FREQ*6)),
130
            .CLKIN2_PERIOD (10-(REF_CLK_FREQ*6)),
131
 
132
            .CLKOUT0_DIVIDE(2),
133
            .CLKOUT0_PHASE (0),
134
 
135
            .CLKOUT1_DIVIDE(G_DVIDED_VAL_PLL),
136
            .CLKOUT1_PHASE (0),
137
 
138
            .CLKOUT2_DIVIDE (4), // always 125 MHz for gtx_usrclk
139
            .CLKOUT2_PHASE (0),
140
 
141
            .CLKOUT3_DIVIDE (4), // always 125 MHz for tx_sync
142
            .CLKOUT3_PHASE (0)
143
 
144
            // .PLL_OPT_INV   (6'b001000),
145
 
146
          )
147
          pll_adv_i
148
          (
149
            .CLKIN1(clkin_pll),
150
            .CLKINSEL(1'b1),
151
            .CLKFBIN(clkfbin),
152
            .RST(rst),
153
            .CLKOUT0(clkout0),
154
            .CLKOUT1(clkout1),
155
            .CLKOUT2(clkout2),
156
            .CLKOUT3(txsync_clkout),
157
            .CLKFBOUT(clkfbout),
158
            //.LOCKED(locked)
159
            .LOCKED(pll_lk_out)
160
          );
161
          // PLL w/ internal feedback loop per UG190 Fig 3-11
162
          assign clkfbin = clkfbout;
163
 
164
          BUFG coreclk_pll_bufg  (.O(coreclk),    .I(clkout0)); // 250 MHz
165
          BUFG gtxclk_pll_bufg   (.O(gtx_usrclk), .I(clkout2));  // 125 MHz
166
          BUFG txsync_clk_pll_bufg   (.O(txsync_clk), .I(txsync_clkout));  // txsync_clk
167
 
168
      if (REF_CLK_FREQ == 1) // 250Mhz
169
      begin
170
          // lock not valid until 100us after PLL is released from reset
171
          always @(posedge clkin_pll or posedge rst)
172
          begin
173
             if(rst)
174
             begin
175
                lock_wait_cntr_7_0  <= 8'h0;
176
                lock_wait_cntr_15_8 <= 8'h0;
177
                pll_locked_out_r  <= 1'b0;
178
                time_elapsed      <= 1'b0;
179
             end else begin
180
                if ((lock_wait_cntr_15_8 == 8'h80) | time_elapsed)
181
                begin
182
                   pll_locked_out_r <= pll_lk_out;
183
                   time_elapsed     <= 1'b1;
184
                end else begin
185
                   lock_wait_cntr_7_0  <= lock_wait_cntr_7_0 + 1'b1;
186
                   lock_wait_cntr_15_8 <= (lock_wait_cntr_7_0 == 8'hff) ?
187
                       (lock_wait_cntr_15_8 + 1'b1) : lock_wait_cntr_15_8;
188
                end
189
             end
190
          end
191
      end
192
      else  // 100Mhz
193
      begin
194
          // lock not valid until 100us after PLL is released from reset
195
          always @(posedge clkin_pll or posedge rst)
196
          begin
197
             if(rst)
198
             begin
199
                lock_wait_cntr_7_0  <= 8'h0;
200
                lock_wait_cntr_15_8 <= 8'h0;
201
                pll_locked_out_r  <= 1'b0;
202
                time_elapsed      <= 1'b0;
203
             end else begin
204
                if ((lock_wait_cntr_15_8 == 8'h33) | time_elapsed)
205
                begin
206
                   pll_locked_out_r <= pll_lk_out;
207
                   time_elapsed     <= 1'b1;
208
                end else begin
209
                   lock_wait_cntr_7_0  <= lock_wait_cntr_7_0 + 1'b1;
210
                   lock_wait_cntr_15_8 <= (lock_wait_cntr_7_0 == 8'hff) ?
211
                       (lock_wait_cntr_15_8 + 1'b1) : lock_wait_cntr_15_8;
212
                end
213
             end
214
          end
215
      end
216
          // bring locked into PLL output domain
217
          always @(posedge coreclk or posedge rst)
218
          begin
219
             if (rst)
220
             begin
221
                pll_locked_out_r_d  <= 0;
222
                pll_locked_out_r_2d <= 0;
223
             end
224
             else
225
             begin
226
                pll_locked_out_r_d  <= pll_locked_out_r;
227
                pll_locked_out_r_2d <= pll_locked_out_r_d;
228
             end
229
          end
230
 
231
            assign locked = fast_train_simulation_only ?
232
                                     pll_lk_out : pll_locked_out_r_2d;
233
 
234
       end
235
 
236
 
237
   endgenerate
238
 
239
 
240
 
241
 
242
 
243
 
244
   generate
245
     if (G_DIVIDE_VAL == 1)
246
      begin : sameclk
247
        assign userclk = coreclk;
248
      end
249
     else
250
      begin : notsame
251
        BUFG usrclk_pll_bufg (.O(userclk), .I(clkout1)); // 125 MHz or 62.5 MHz
252
      end
253
   endgenerate
254
 
255
endmodule
256
 

powered by: WebSVN 2.1.0

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