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

Subversion Repositories pcie_sg_dma

[/] [pcie_sg_dma/] [branches/] [Virtex6/] [ML605_ISE13.3/] [ipcore_dir_ISE13.3/] [v6_pcie_v1_6/] [source/] [pcie_clocking_v6.vhd] - Blame information for rev 13

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 13 barabba
-------------------------------------------------------------------------------
2
--
3
-- (c) Copyright 2009-2011 Xilinx, Inc. All rights reserved.
4
--
5
-- This file contains confidential and proprietary information
6
-- of Xilinx, Inc. and is protected under U.S. and
7
-- international copyright and other intellectual property
8
-- laws.
9
--
10
-- DISCLAIMER
11
-- This disclaimer is not a license and does not grant any
12
-- rights to the materials distributed herewith. Except as
13
-- otherwise provided in a valid license issued to you by
14
-- Xilinx, and to the maximum extent permitted by applicable
15
-- law: (1) THESE MATERIALS ARE MADE AVAILABLE "AS IS" AND
16
-- WITH ALL FAULTS, AND XILINX HEREBY DISCLAIMS ALL WARRANTIES
17
-- AND CONDITIONS, EXPRESS, IMPLIED, OR STATUTORY, INCLUDING
18
-- BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, NON-
19
-- INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE; and
20
-- (2) Xilinx shall not be liable (whether in contract or tort,
21
-- including negligence, or under any other theory of
22
-- liability) for any loss or damage of any kind or nature
23
-- related to, arising under or in connection with these
24
-- materials, including for any direct, or any indirect,
25
-- special, incidental, or consequential loss or damage
26
-- (including loss of data, profits, goodwill, or any type of
27
-- loss or damage suffered as a result of any action brought
28
-- by a third party) even if such damage or loss was
29
-- reasonably foreseeable or Xilinx had been advised of the
30
-- possibility of the same.
31
--
32
-- CRITICAL APPLICATIONS
33
-- Xilinx products are not designed or intended to be fail-
34
-- safe, or for use in any application requiring fail-safe
35
-- performance, such as life-support or safety devices or
36
-- systems, Class III medical devices, nuclear facilities,
37
-- applications related to the deployment of airbags, or any
38
-- other applications that could lead to death, personal
39
-- injury, or severe property or environmental damage
40
-- (individually and collectively, "Critical
41
-- Applications"). Customer assumes the sole risk and
42
-- liability of any use of Xilinx products in Critical
43
-- Applications, subject only to applicable laws and
44
-- regulations governing limitations on product liability.
45
--
46
-- THIS COPYRIGHT NOTICE AND DISCLAIMER MUST BE RETAINED AS
47
-- PART OF THIS FILE AT ALL TIMES.
48
--
49
-------------------------------------------------------------------------------
50
-- Project    : Virtex-6 Integrated Block for PCI Express
51
-- File       : pcie_clocking_v6.vhd
52
-- Version    : 1.7
53
---- Description: Clocking module for Virtex6 PCIe Block
54
----
55
----
56
----
57
----------------------------------------------------------------------------------
58
 
59
library ieee;
60
   use ieee.std_logic_1164.all;
61
 
62
library unisim;
63
use unisim.vcomponents.all;
64
 
65
entity pcie_clocking_v6 is
66
   generic (
67
 
68
      IS_ENDPOINT                                  : boolean := TRUE;
69
      CAP_LINK_WIDTH                               : integer := 8;              -- 1 - x1 , 2 - x2 , 4 - x4 , 8 - x8
70
      CAP_LINK_SPEED                               : integer := 1;              -- 1 - Gen1 , 2 - Gen2
71
      REF_CLK_FREQ                                 : integer := 0;               -- 0 - 100 MHz , 1 - 125 MHz , 2 - 250 MHz
72
      USER_CLK_FREQ                                : integer := 3               -- 0 - 31.25 MHz , 1 - 62.5 MHz , 2 - 125 MHz , 3 - 250 MHz , 4 - 500Mhz
73
 
74
   );
75
   port (
76
      sys_clk                                      : in std_logic;
77
      gt_pll_lock                                  : in std_logic;
78
      sel_lnk_rate                                 : in std_logic;
79
      sel_lnk_width                                : in std_logic_vector(1 downto 0);
80
      sys_clk_bufg                                 : out std_logic;
81
      pipe_clk                                     : out std_logic;
82
      user_clk                                     : out std_logic;
83
      block_clk                                    : out std_logic;
84
      drp_clk                                      : out std_logic;
85
      clock_locked                                 : out std_logic
86
   );
87
end pcie_clocking_v6;
88
 
89
architecture v6_pcie of pcie_clocking_v6 is
90
 
91
  -- MMCM Configuration
92
 
93
  function clkin_prd(
94
    constant REF_CLK_FREQ     : integer)
95
    return real is
96
     variable CLKIN_PERD : real := 0.0;
97
  begin  -- clkin_prd
98
 
99
    if (REF_CLK_FREQ = 0) then
100
      CLKIN_PERD := 10.0;
101
    elsif (REF_CLK_FREQ = 1) then
102
      CLKIN_PERD := 8.0;
103
    elsif (REF_CLK_FREQ = 2) then
104
      CLKIN_PERD := 4.0;
105
    else
106
      CLKIN_PERD := 0.0;
107
    end if;
108
    return CLKIN_PERD;
109
  end clkin_prd;
110
 
111
   constant mmcm_clockin_period                    : real := clkin_prd(REF_CLK_FREQ);
112
 
113
  function clkfb_mul(
114
    constant REF_CLK_FREQ     : integer)
115
    return real is
116
     variable CLKFB_MULT : real := 0.0;
117
  begin  -- clkfb_mul
118
 
119
    if (REF_CLK_FREQ = 0) then
120
      CLKFB_MULT := 10.0;
121
    elsif (REF_CLK_FREQ = 1) then
122
      CLKFB_MULT := 8.0;
123
    elsif (REF_CLK_FREQ = 2) then
124
      CLKFB_MULT := 8.0;
125
    else
126
      CLKFB_MULT := 0.0;
127
    end if;
128
    return CLKFB_MULT;
129
  end clkfb_mul;
130
 
131
   constant mmcm_clockfb_mult                      : real := clkfb_mul(REF_CLK_FREQ);
132
 
133
  function divclk_div(
134
    constant REF_CLK_FREQ     : integer)
135
    return integer is
136
     variable DIVCLK_DIVIDE : integer := 0;
137
  begin  -- divclk_div
138
 
139
    if (REF_CLK_FREQ = 0) then
140
      DIVCLK_DIVIDE := 1;
141
    elsif (REF_CLK_FREQ = 1) then
142
      DIVCLK_DIVIDE := 1;
143
    elsif (REF_CLK_FREQ = 2) then
144
      DIVCLK_DIVIDE := 2;
145
    else
146
      DIVCLK_DIVIDE := 0;
147
    end if;
148
    return DIVCLK_DIVIDE;
149
  end divclk_div;
150
 
151
   constant mmcm_divclk_divide                     : integer := divclk_div(REF_CLK_FREQ);
152
 
153
   constant mmcm_clock0_div                        : real := 4.0;
154
   constant mmcm_clock1_div                        : integer := 8;
155
 
156
   constant TCQ : integer := 1;
157
 
158
  function clk2_div(
159
    constant LNK_WDT          : integer;
160
    constant LNK_SPD          : integer;
161
    constant USR_CLK_FREQ     : integer)
162
    return integer is
163
     variable CLK_DIV : integer := 1;
164
  begin  -- clk2_div
165
 
166
    if ((LNK_WDT = 1) and (LNK_SPD = 1) and (USR_CLK_FREQ = 0)) then
167
      CLK_DIV := 32;
168
    elsif ((LNK_WDT = 1) and (LNK_SPD = 1) and (USR_CLK_FREQ = 1)) then
169
      CLK_DIV := 16;
170
    elsif ((LNK_WDT = 1) and (LNK_SPD = 2) and (USR_CLK_FREQ = 1)) then
171
      CLK_DIV := 16;
172
    elsif ((LNK_WDT = 2) and (LNK_SPD = 1) and (USR_CLK_FREQ = 1)) then
173
      CLK_DIV := 16;
174
    else
175
      CLK_DIV := 2;
176
    end if;
177
    return CLK_DIV;
178
  end clk2_div;
179
 
180
   constant mmcm_clock2_div                        : integer := clk2_div(CAP_LINK_WIDTH, CAP_LINK_SPEED, USER_CLK_FREQ);
181
   constant mmcm_clock3_div                        : integer := 2;
182
 
183
   signal mmcm_locked                              : std_logic;
184
   signal mmcm_clkfbin                             : std_logic;
185
   signal mmcm_clkfbout                            : std_logic;
186
   signal mmcm_reset                               : std_logic;
187
   signal clk_500                                  : std_logic;
188
   signal clk_250                                  : std_logic;
189
   signal clk_125                                  : std_logic;
190
   signal user_clk_prebuf                          : std_logic;
191
   signal sel_lnk_rate_d                           : std_logic;
192
   signal reg_clock_locked                         : std_logic_vector(1 downto 0) := "11";
193
 
194
   -- Declare intermediate signals for referenced outputs
195
   signal sys_clk_bufg_v6pcie3                         : std_logic;
196
   signal pipe_clk_v6pcie                              : std_logic;
197
   signal user_clk_v6pcie4                             : std_logic;
198
   signal block_clk_v6pcie0                            : std_logic;
199
   signal clock_locked_v6pcie                          : std_logic;
200
   signal drp_clk_v6pcie1                              : std_logic;
201
 
202
  signal clock_locked_int : std_logic;
203
 
204
begin
205
   -- Drive referenced outputs
206
   sys_clk_bufg <= sys_clk_bufg_v6pcie3;
207
   pipe_clk <= pipe_clk_v6pcie;
208
   user_clk <= user_clk_v6pcie4;
209
   block_clk <= block_clk_v6pcie0;
210
   drp_clk <= drp_clk_v6pcie1;
211
   clock_locked <= clock_locked_v6pcie;
212
   clock_locked_v6pcie <= clock_locked_int and mmcm_locked;
213
   clock_locked_int <= not(reg_clock_locked(1));
214
 
215
 
216
   -- MMCM Reset
217
     mmcm_reset <= '0';
218
 
219
   -- PIPE Clock BUFG.
220
 
221
   GEN1_LINK : if (CAP_LINK_SPEED = 1) generate
222
      pipe_clk_bufg : BUFG port map (O  => pipe_clk_v6pcie, I  => clk_125 );
223
 
224
   end generate;
225
 
226
   GEN2_LINK : if (CAP_LINK_SPEED = 2) generate
227
      sel_lnk_rate_delay : SRL16E generic map ( INIT  => X"0000" )
228
                                  port map (
229
                                    Q    => sel_lnk_rate_d,
230
                                    D    => sel_lnk_rate,
231
                                    CLK  => pipe_clk_v6pcie,
232
                                    CE   => clock_locked_v6pcie,
233
                                    A3   => '1',
234
                                    A2   => '1',
235
                                    A1   => '1',
236
                                    A0   => '1'
237
                                    );
238
 
239
      pipe_clk_bufgmux : BUFGMUX port map (
240
                                    O   => pipe_clk_v6pcie,
241
                                    I0  => clk_125,
242
                                    I1  => clk_250,
243
                                    S   => sel_lnk_rate_d
244
                                    );
245
 
246
      end generate;
247
   ILLEGAL_LINK_SPEED : if ((CAP_LINK_SPEED /= 1) and (CAP_LINK_SPEED /= 2)) generate
248
 
249
         --$display("Confiuration Error : CAP_LINK_SPEED = %d, must be either 1 or 2.", CAP_LINK_SPEED);
250
         --$finish;
251
 
252
   end generate;
253
 
254
   -- User Clock BUFG.
255
   x1_GEN1_31_25 : if ((CAP_LINK_WIDTH = 1) and (CAP_LINK_SPEED = 1) and (USER_CLK_FREQ = 0)) generate
256
 
257
     user_clk_bufg : BUFG port map ( O => user_clk_v6pcie4, I => user_clk_prebuf );
258
 
259
   end generate;
260
 
261
   x1_GEN1_62_50 : if ((CAP_LINK_WIDTH = 1) and (CAP_LINK_SPEED = 1) and (USER_CLK_FREQ = 1)) generate
262
 
263
     user_clk_bufg : BUFG port map ( O => user_clk_v6pcie4, I => user_clk_prebuf );
264
 
265
   end generate;
266
 
267
   x1_GEN1_125_00 : if ((CAP_LINK_WIDTH = 1) and (CAP_LINK_SPEED = 1) and (USER_CLK_FREQ = 2)) generate
268
 
269
     user_clk_bufg : BUFG port map ( O => user_clk_v6pcie4, I => clk_125 );
270
 
271
   end generate;
272
 
273
   x1_GEN1_250_00 : if ((CAP_LINK_WIDTH = 1) and (CAP_LINK_SPEED = 1) and (USER_CLK_FREQ = 3)) generate
274
 
275
     user_clk_bufg : BUFG port map ( O => user_clk_v6pcie4, I => clk_250 );
276
 
277
   end generate;
278
 
279
   x1_GEN2_62_50 : if ((CAP_LINK_WIDTH = 1) and (CAP_LINK_SPEED = 2) and (USER_CLK_FREQ = 1)) generate
280
 
281
     user_clk_bufg : BUFG port map ( O => user_clk_v6pcie4, I  => user_clk_prebuf );
282
 
283
   end generate;
284
 
285
   x1_GEN2_125_00 : if ((CAP_LINK_WIDTH = 1) and (CAP_LINK_SPEED = 2) and (USER_CLK_FREQ = 2)) generate
286
 
287
     user_clk_bufg : BUFG port map ( O => user_clk_v6pcie4, I  => clk_125 );
288
 
289
   end generate;
290
 
291
   x1_GEN2_250_00 : if ((CAP_LINK_WIDTH = 1) and (CAP_LINK_SPEED = 2) and (USER_CLK_FREQ = 3)) generate
292
 
293
     user_clk_bufg : BUFG port map ( O => user_clk_v6pcie4, I => clk_250 );
294
 
295
   end generate;
296
 
297
   x2_GEN1_62_50 : if ((CAP_LINK_WIDTH = 2) and (CAP_LINK_SPEED = 1) and (USER_CLK_FREQ = 1)) generate
298
 
299
     user_clk_bufg : BUFG port map ( O => user_clk_v6pcie4, I => user_clk_prebuf );
300
 
301
   end generate;
302
 
303
   x2_GEN1_125_00 : if ((CAP_LINK_WIDTH = 2) and (CAP_LINK_SPEED = 1) and (USER_CLK_FREQ = 2)) generate
304
 
305
     user_clk_bufg : BUFG port map ( O => user_clk_v6pcie4, I => clk_125 );
306
 
307
   end generate;
308
 
309
   x2_GEN1_250_00 : if ((CAP_LINK_WIDTH = 2) and (CAP_LINK_SPEED = 1) and (USER_CLK_FREQ = 3)) generate
310
 
311
     user_clk_bufg : BUFG port map ( O => user_clk_v6pcie4, I => clk_250 );
312
 
313
   end generate;
314
 
315
   x2_GEN2_125_00 : if ((CAP_LINK_WIDTH = 2) and (CAP_LINK_SPEED = 2) and (USER_CLK_FREQ = 2)) generate
316
 
317
     user_clk_bufg : BUFG port map ( O => user_clk_v6pcie4, I => clk_125 );
318
 
319
   end generate;
320
 
321
   x2_GEN2_250_00 : if ((CAP_LINK_WIDTH = 2) and (CAP_LINK_SPEED = 2) and (USER_CLK_FREQ = 3)) generate
322
 
323
     user_clk_bufg : BUFG port map ( O => user_clk_v6pcie4, I => clk_250 );
324
 
325
   end generate;
326
 
327
   x4_GEN1_125_00 : if ((CAP_LINK_WIDTH = 4) and (CAP_LINK_SPEED = 1) and (USER_CLK_FREQ = 2)) generate
328
 
329
     user_clk_bufg : BUFG port map ( O => user_clk_v6pcie4, I => clk_125 );
330
 
331
   end generate;
332
 
333
   x4_GEN1_250_00 : if ((CAP_LINK_WIDTH = 4) and (CAP_LINK_SPEED = 1) and (USER_CLK_FREQ = 3)) generate
334
 
335
     user_clk_bufg : BUFG port map ( O => user_clk_v6pcie4, I => clk_250 );
336
 
337
   end generate;
338
 
339
   x4_GEN2_250_00 : if ((CAP_LINK_WIDTH = 4) and (CAP_LINK_SPEED = 2) and (USER_CLK_FREQ = 3)) generate
340
 
341
     user_clk_bufg : BUFG port map ( O => user_clk_v6pcie4, I => clk_250 );
342
 
343
   end generate;
344
 
345
   x8_GEN1_250_00 : if ((CAP_LINK_WIDTH = 8) and (CAP_LINK_SPEED = 1) and (USER_CLK_FREQ = 3)) generate
346
 
347
     user_clk_bufg : BUFG port map ( O => user_clk_v6pcie4, I => clk_250 );
348
 
349
   end generate;
350
 
351
   x8_GEN2_250_00 : if ((CAP_LINK_WIDTH = 8) and (CAP_LINK_SPEED = 2) and (USER_CLK_FREQ = 4)) generate
352
 
353
     user_clk_bufg : BUFG port map ( O => user_clk_v6pcie4, I => clk_250 );
354
 
355
     block_clk_bufg : BUFG port map ( O => block_clk_v6pcie0, I => clk_500 );
356
 
357
   end generate;
358
 
359
--   v6pcie42 : if (not((CAP_LINK_WIDTH = 8) and (CAP_LINK_SPEED = 2) and (USER_CLK_FREQ = 4))) generate
360
 
361
    --$display("Confiuration Error : Unsupported Link Width, Link Speed and User Clock Frequency Combination");
362
    --$finish;
363
 
364
--   end generate;
365
 
366
   -- DRP clk
367
   drp_clk_bufg_i : BUFG port map ( O => drp_clk_v6pcie1, I => clk_125 );
368
 
369
   -- Feedback BUFG. Required for Temp Compensation
370
   clkfbin_bufg_i : BUFG port map ( O => mmcm_clkfbin, I => mmcm_clkfbout );
371
 
372
   -- sys_clk BUFG. 
373
   sys_clk_bufg_i : BUFG port map ( O => sys_clk_bufg_v6pcie3, I => sys_clk );
374
 
375
   mmcm_adv_i : MMCM_ADV
376
      generic map (
377
         -- 5 for 100 MHz , 4 for 125 MHz , 2 for 250 MHz
378
         CLKFBOUT_MULT_F   => mmcm_clockfb_mult,
379
         DIVCLK_DIVIDE     => mmcm_divclk_divide,
380
         CLKFBOUT_PHASE    => 0.0,
381
         -- 10 for 100 MHz, 4 for 250 MHz
382
         CLKIN1_PERIOD     => mmcm_clockin_period,
383
         CLKIN2_PERIOD     => mmcm_clockin_period,
384
         -- 500 MHz / mmcm_clockx_div  
385
         CLKOUT0_DIVIDE_F  => mmcm_clock0_div,
386
         CLKOUT0_PHASE     => 0.0,
387
         CLKOUT1_DIVIDE    => mmcm_clock1_div,
388
         CLKOUT1_PHASE     => 0.0,
389
         CLKOUT2_DIVIDE    => mmcm_clock2_div,
390
         CLKOUT2_PHASE     => 0.0,
391
         CLKOUT3_DIVIDE    => mmcm_clock3_div,
392
         CLKOUT3_PHASE     => 0.0
393
      )
394
      port map (
395
         clkfbout      => mmcm_clkfbout,
396
         clkout0       => clk_250,              -- 250 MHz for pipe_clk
397
         clkout1       => clk_125,              -- 125 MHz for pipe_clk
398
         clkout2       => user_clk_prebuf,      -- user clk
399
         clkout3       => clk_500,
400
         clkout4       => open,
401
         clkout5       => open,
402
         clkout6       => open,
403
         do            => open,
404
         drdy          => open,
405
         clkfboutb     => open,
406
         clkfbstopped  => open,
407
         clkinstopped  => open,
408
         clkout0b      => open,
409
         clkout1b      => open,
410
         clkout2b      => open,
411
         clkout3b      => open,
412
         psdone        => open,
413
         locked        => mmcm_locked,
414
         clkfbin       => mmcm_clkfbin,
415
         clkin1        => sys_clk,
416
         clkin2        => '0',
417
         clkinsel      => '1',
418
         daddr         => "0000000",
419
         dclk          => '0',
420
         den           => '0',
421
         di            => "0000000000000000",
422
         dwe           => '0',
423
         psen          => '0',
424
         psincdec      => '0',
425
         pwrdwn        => '0',
426
         psclk         => '0',
427
         rst           => mmcm_reset
428
      );
429
 
430
  -- Synchronize MMCM locked output
431
  process (pipe_clk_v6pcie, gt_pll_lock)
432
  begin
433
 
434
    if ((not(gt_pll_lock)) = '1') then
435
 
436
      reg_clock_locked <= "11" after (TCQ)*1 ps;
437
 
438
    elsif (pipe_clk_v6pcie'event and pipe_clk_v6pcie = '1') then
439
 
440
      reg_clock_locked <= (reg_clock_locked(0) & '0') after (TCQ)*1 ps;
441
 
442
    end if;
443
  end process;
444
 
445
end v6_pcie;
446
 
447
 
448
 

powered by: WebSVN 2.1.0

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