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/] [tmp/] [backup_v6_pcie_v1_6/] [v6_pcie_v1_6/] [source/] [gtx_tx_sync_rate_v6.vhd] - Blame information for rev 13

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 13 barabba
 
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    : Virtex-6 Integrated Block for PCI Express
52
-- File       : gtx_tx_sync_rate_v6.vhd
53
-- Version    : 1.6
54
-- 
55
-- Module TX_SYNC
56
-- 
57
-------------------------------------------------------------------------------
58
library ieee;
59
   use ieee.std_logic_1164.all;
60
   use ieee.std_logic_unsigned.all;
61
 
62
-- Module TX_SYNC
63
 
64
entity GTX_TX_SYNC_RATE_V6 is
65
   generic (
66
      C_SIMULATION                              : integer := 0           -- Set to 1 for simulation
67
 
68
   );
69
   port (
70
      ENPMAPHASEALIGN                           : out std_logic;
71
      PMASETPHASE                               : out std_logic;
72
      SYNC_DONE                                 : out std_logic;
73
      OUT_DIV_RESET                             : out std_logic;
74
      PCS_RESET                                 : out std_logic;
75
      USER_PHYSTATUS                            : out std_logic;
76
      TXALIGNDISABLE                            : out std_logic;
77
      DELAYALIGNRESET                           : out std_logic;
78
      USER_CLK                                  : in std_logic;
79
      RESET                                     : in std_logic;
80
      RATE                                      : in std_logic;
81
      RATEDONE                                  : in std_logic;
82
      GT_PHYSTATUS                              : in std_logic;
83
      RESETDONE                                 : in std_logic
84
   );
85
end GTX_TX_SYNC_RATE_V6;
86
 
87
architecture v6_pcie of GTX_TX_SYNC_RATE_V6 is
88
 
89
   constant   TCQ                                       : integer := 1;
90
 
91
   FUNCTION to_stdlogic (
92
      in_val      : IN boolean) RETURN std_logic IS
93
   BEGIN
94
      IF (in_val) THEN
95
         RETURN('1');
96
      ELSE
97
         RETURN('0');
98
      END IF;
99
   END to_stdlogic;
100
 
101
   constant    IDLE                                     : std_logic_vector(21 downto 0) :=  "0000000000000000000001";
102
   constant    PHASEALIGN                               : std_logic_vector(21 downto 0) :=  "0000000000000000000010";
103
   constant    RATECHANGE_DIVRESET                      : std_logic_vector(21 downto 0) :=  "0000000000000000000100";
104
   constant    RATECHANGE_DIVRESET_POST                 : std_logic_vector(21 downto 0) :=  "0000000000000000001000";
105
   constant    RATECHANGE_ENPMADISABLE                  : std_logic_vector(21 downto 0) :=  "0000000000000000010000";
106
   constant    RATECHANGE_ENPMADISABLE_POST             : std_logic_vector(21 downto 0) :=  "0000000000000000100000";
107
   constant    RATECHANGE_PMARESET                      : std_logic_vector(21 downto 0) :=  "0000000000000001000000";
108
   constant    RATECHANGE_IDLE                          : std_logic_vector(21 downto 0) :=  "0000000000000010000000";
109
   constant    RATECHANGE_PCSRESET                      : std_logic_vector(21 downto 0) :=  "0000000000000100000000";
110
   constant    RATECHANGE_PCSRESET_POST                 : std_logic_vector(21 downto 0) :=  "0000000000001000000000";
111
   constant    RATECHANGE_ASSERTPHY                     : std_logic_vector(21 downto 0) :=  "0000000000010000000000";
112
   constant    RESET_STATE                              : std_logic_vector(21 downto 0) :=  "0000000000100000000000";
113
   constant    WAIT_PHYSTATUS                           : std_logic_vector(21 downto 0) :=  "0000000010000000000000";
114
   constant    RATECHANGE_PMARESET_POST                 : std_logic_vector(21 downto 0) :=  "0000000100000000000000";
115
   constant    RATECHANGE_DISABLEPHASE                  : std_logic_vector(21 downto 0) :=  "0000001000000000000000";
116
   constant    DELAYALIGNRST                            : std_logic_vector(21 downto 0) :=  "0000010000000000000000";
117
   constant    SETENPMAPHASEALIGN                       : std_logic_vector(21 downto 0) :=  "0000100000000000000000";
118
   constant    TXALIGNDISABLEDEASSERT                   : std_logic_vector(21 downto 0) :=  "0001000000000000000000";
119
   constant    RATECHANGE_TXDLYALIGNDISABLE             : std_logic_vector(21 downto 0) :=  "0010000000000000000000";
120
   constant    OUTDIVRESET                              : std_logic_vector(21 downto 0) :=  "0100000000000000000000";
121
   constant    RATECHANGE_DISABLE_TXALIGNDISABLE        : std_logic_vector(21 downto 0) :=  "1000000000000000000000";
122
 
123
 
124
  function s_idx(
125
    constant C_SIMULATION    : integer)
126
    return integer is
127
     variable sidx_out : integer := 8;
128
  begin  -- s_idx
129
 
130
    if (C_SIMULATION /= 0) then
131
      sidx_out := 0;
132
    else
133
      sidx_out := 2;
134
    end if;
135
    return sidx_out;
136
  end s_idx;
137
 
138
  function pma_idx(
139
    constant C_SIMULATION    : integer)
140
    return integer is
141
     variable pma_idx_out : integer := 8;
142
  begin  -- pma_idx
143
 
144
    if (C_SIMULATION /= 0) then
145
      pma_idx_out := 0;
146
    else
147
      pma_idx_out := 7;
148
    end if;
149
    return pma_idx_out;
150
  end pma_idx;
151
 
152
   constant   SYNC_IDX                            : integer := s_idx(C_SIMULATION);
153
   constant   PMARESET_IDX                        : integer := pma_idx(C_SIMULATION);
154
 
155
   signal ENPMAPHASEALIGN_c                       : std_logic;
156
   signal PMASETPHASE_c                           : std_logic;
157
   signal SYNC_DONE_c                             : std_logic;
158
   signal OUT_DIV_RESET_c                         : std_logic;
159
   signal PCS_RESET_c                             : std_logic;
160
   signal USER_PHYSTATUS_c                        : std_logic;
161
   signal DELAYALIGNRESET_c                       : std_logic;
162
   signal TXALIGNDISABLE_c                        : std_logic;
163
   signal state                                   : std_logic_vector(21 downto 0);
164
   signal nextstate                               : std_logic_vector(21 downto 0);
165
   signal wait_amt                                : std_logic_vector(15 downto 0);
166
   signal wait_c                                  : std_logic_vector(15 downto 0);
167
   signal waitcounter                             : std_logic_vector(7 downto 0);
168
   signal nextwaitcounter                         : std_logic_vector(7 downto 0);
169
   signal waitcounter2                            : std_logic_vector(7 downto 0);
170
   signal waitcounter2_check                      : std_logic_vector(7 downto 0);
171
   signal nextwaitcounter2                        : std_logic_vector(7 downto 0);
172
   signal ratedone_r                              : std_logic;
173
   signal ratedone_r2                             : std_logic;
174
   signal ratedone_pulse_i                        : std_logic;
175
 
176
   signal gt_phystatus_q                          : std_logic;
177
 
178
   -- Declare intermediate signals for referenced outputs
179
   signal state_v6pcie0                           : std_logic_vector(4 downto 0);
180
--   signal waitcounter_v6pcie1                     : std_logic_vector(16 downto 0);
181
 
182
begin
183
 
184
   -- Drive referenced outputs
185
--   state <= state_v6pcie0;
186
--   waitcounter <= waitcounter_v6pcie1;
187
 
188
   process (USER_CLK)
189
   begin
190
      if (USER_CLK'event and USER_CLK = '1') then
191
 
192
         if (RESET = '1') then
193
 
194
            state <= RESET_STATE after (TCQ)*1 ps;
195
            waitcounter <= X"00" after (TCQ)*1 ps;
196
            waitcounter2 <= X"00" after (TCQ)*1 ps;
197
            USER_PHYSTATUS <= GT_PHYSTATUS after (TCQ)*1 ps;
198
            SYNC_DONE <= '0' after (TCQ)*1 ps;
199
            ENPMAPHASEALIGN <= '1' after (TCQ)*1 ps;
200
            PMASETPHASE <= '0' after (TCQ)*1 ps;
201
            OUT_DIV_RESET <= '0' after (TCQ)*1 ps;
202
            PCS_RESET <= '0' after (TCQ)*1 ps;
203
            DELAYALIGNRESET <= '0' after (TCQ)*1 ps;
204
            TXALIGNDISABLE <= '1' after (TCQ)*1 ps;
205
 
206
         else
207
 
208
            state <= nextstate after (TCQ)*1 ps;
209
            waitcounter <= nextwaitcounter after (TCQ)*1 ps;
210
            waitcounter2 <= nextwaitcounter2 after (TCQ)*1 ps;
211
            USER_PHYSTATUS <= USER_PHYSTATUS_c after (TCQ)*1 ps;
212
            SYNC_DONE <= SYNC_DONE_c after (TCQ)*1 ps;
213
            ENPMAPHASEALIGN <= ENPMAPHASEALIGN_c after (TCQ)*1 ps;
214
            PMASETPHASE <= PMASETPHASE_c after (TCQ)*1 ps;
215
            OUT_DIV_RESET <= OUT_DIV_RESET_c after (TCQ)*1 ps;
216
            PCS_RESET <= PCS_RESET_c after (TCQ)*1 ps;
217
            DELAYALIGNRESET <= DELAYALIGNRESET_c after (TCQ)*1 ps;
218
            TXALIGNDISABLE <= TXALIGNDISABLE_c after (TCQ)*1 ps;
219
 
220
         end if;
221
      end if;
222
   end process;
223
 
224
   waitcounter2_check <= waitcounter2 + X"01" when (waitcounter = X"FF") else
225
                        waitcounter2;
226
 
227
   process (state, GT_PHYSTATUS, waitcounter, waitcounter2, waitcounter2_check, ratedone_pulse_i, gt_phystatus_q, RESETDONE)
228
   begin
229
 
230
      -- DEFAULT CONDITIONS
231
 
232
      DELAYALIGNRESET_c <= '0';
233
      SYNC_DONE_c <= '0';
234
      ENPMAPHASEALIGN_c <= '1';
235
      PMASETPHASE_c <= '0';
236
      OUT_DIV_RESET_c <= '0';
237
      PCS_RESET_c <= '0';
238
      TXALIGNDISABLE_c <= '0';
239
      nextstate <= state;
240
      USER_PHYSTATUS_c <= GT_PHYSTATUS;
241
 
242
      nextwaitcounter <= waitcounter + X"01";
243
      nextwaitcounter2 <= waitcounter2_check;
244
 
245
      case state is
246
 
247
        -- START IN RESET
248
         when RESET_STATE =>
249
            TXALIGNDISABLE_c <= '1';
250
            ENPMAPHASEALIGN_c <= '0';
251
            nextstate <= OUTDIVRESET;
252
            nextwaitcounter <= X"00";
253
            nextwaitcounter2 <= X"00";
254
 
255
         -- Assert OUTDIVRESET
256
         when OUTDIVRESET =>
257
            OUT_DIV_RESET_c <= '1';
258
            TXALIGNDISABLE_c <= '1';
259
            ENPMAPHASEALIGN_c <= '0';
260
            if ((waitcounter(4)) = '1') then
261
               nextstate <= DELAYALIGNRST;
262
               nextwaitcounter <= X"00";
263
               nextwaitcounter2 <= X"00";
264
            end if;
265
 
266
         -- ASSERT TXDLYALIGNRESET FOR 16 CLOCK CYCLES
267
         when DELAYALIGNRST =>
268
            DELAYALIGNRESET_c <= '1';
269
            ENPMAPHASEALIGN_c <= '0';
270
            TXALIGNDISABLE_c <= '1';
271
            if ((waitcounter(4)) = '1') then
272
               nextstate <= SETENPMAPHASEALIGN;
273
               nextwaitcounter <= X"00";
274
               nextwaitcounter2 <= X"00";
275
            end if;
276
 
277
         -- ASSERT ENPMAPHASEALIGN FOR 32 CLOCK CYCLES
278
         when SETENPMAPHASEALIGN =>
279
            TXALIGNDISABLE_c <= '1';
280
            if ((waitcounter(5)) = '1') then
281
               nextstate <= PHASEALIGN;
282
               nextwaitcounter <= X"00";
283
               nextwaitcounter2 <= X"00";
284
            end if;
285
 
286
         -- ASSERT PMASETPHASE OUT OF RESET for 32K CYCLES
287
         when PHASEALIGN =>
288
            PMASETPHASE_c <= '1';
289
            TXALIGNDISABLE_c <= '1';
290
            if ((waitcounter2(PMARESET_IDX)) = '1') then
291
               nextstate <= TXALIGNDISABLEDEASSERT;
292
               nextwaitcounter <= X"00";
293
               nextwaitcounter2 <= X"00";
294
            end if;
295
 
296
         -- KEEP TXALIGNDISABLE ASSERTED for 64 CYCLES
297
         when TXALIGNDISABLEDEASSERT =>
298
            TXALIGNDISABLE_c <= '1';
299
            if ((waitcounter(6)) = '1') then
300
               nextwaitcounter <= X"00";
301
               nextstate <= IDLE;
302
               nextwaitcounter2 <= X"00";
303
            end if;
304
 
305
         -- NOW IN IDLE, ASSERT SYNC DONE, WAIT FOR RATECHANGE
306
         when IDLE =>
307
            SYNC_DONE_c <= '1';
308
            if (ratedone_pulse_i = '1') then
309
               USER_PHYSTATUS_c <= '0';
310
               nextstate <= WAIT_PHYSTATUS;
311
               nextwaitcounter <= X"00";
312
               nextwaitcounter2 <= X"00";
313
            end if;
314
 
315
         -- WAIT FOR PHYSTATUS
316
         when WAIT_PHYSTATUS =>
317
            USER_PHYSTATUS_c <= '0';
318
            if (gt_phystatus_q = '1') then
319
               nextstate <= RATECHANGE_IDLE;
320
               nextwaitcounter <= X"00";
321
               nextwaitcounter2 <= X"00";
322
            end if;
323
 
324
         -- WAIT 64 CYCLES BEFORE WE START THE RATE CHANGE
325
         when RATECHANGE_IDLE =>
326
            USER_PHYSTATUS_c <= '0';
327
            if ((waitcounter(6)) = '1') then
328
               nextstate <= RATECHANGE_TXDLYALIGNDISABLE;
329
               nextwaitcounter <= X"00";
330
               nextwaitcounter2 <= X"00";
331
            end if;
332
 
333
         -- ASSERT TXALIGNDISABLE FOR 32 CYCLES
334
         when RATECHANGE_TXDLYALIGNDISABLE =>
335
            USER_PHYSTATUS_c <= '0';
336
            TXALIGNDISABLE_c <= '1';
337
            if ((waitcounter(5)) = '1') then
338
               nextstate <= RATECHANGE_DIVRESET;
339
               nextwaitcounter <= X"00";
340
               nextwaitcounter2 <= X"00";
341
            end if;
342
 
343
         -- ASSERT DIV RESET FOR 16 CLOCK CYCLES
344
         when RATECHANGE_DIVRESET =>
345
            OUT_DIV_RESET_c <= '1';
346
            USER_PHYSTATUS_c <= '0';
347
            TXALIGNDISABLE_c <= '1';
348
            if ((waitcounter(4)) = '1') then
349
               nextstate <= RATECHANGE_DIVRESET_POST;
350
               nextwaitcounter <= X"00";
351
               nextwaitcounter2 <= X"00";
352
            end if;
353
 
354
         -- WAIT FOR 32 CLOCK CYCLES BEFORE NEXT STEP
355
         when RATECHANGE_DIVRESET_POST =>
356
            USER_PHYSTATUS_c <= '0';
357
            TXALIGNDISABLE_c <= '1';
358
            if ((waitcounter(5)) = '1') then
359
               nextstate <= RATECHANGE_PMARESET;
360
               nextwaitcounter <= X"00";
361
               nextwaitcounter2 <= X"00";
362
            end if;
363
 
364
         -- ASSERT PMA RESET FOR 32K CYCLES
365
         when RATECHANGE_PMARESET =>
366
            PMASETPHASE_c <= '1';
367
            USER_PHYSTATUS_c <= '0';
368
            TXALIGNDISABLE_c <= '1';
369
            if ((waitcounter2(PMARESET_IDX)) = '1') then
370
               nextstate <= RATECHANGE_PMARESET_POST;
371
               nextwaitcounter <= X"00";
372
               nextwaitcounter2 <= X"00";
373
            end if;
374
 
375
         -- WAIT FOR 32 CYCLES BEFORE DISABLING TXALIGNDISABLE
376
         when RATECHANGE_PMARESET_POST =>
377
            USER_PHYSTATUS_c <= '0';
378
            TXALIGNDISABLE_c <= '1';
379
            if ((waitcounter(5)) = '1') then
380
               nextstate <= RATECHANGE_DISABLE_TXALIGNDISABLE;
381
               nextwaitcounter <= X"00";
382
               nextwaitcounter2 <= X"00";
383
            end if;
384
 
385
         -- DISABLE TXALIGNDISABLE FOR 32 CYCLES
386
         when RATECHANGE_DISABLE_TXALIGNDISABLE =>
387
            USER_PHYSTATUS_c <= '0';
388
            if ((waitcounter(5)) = '1') then
389
               nextstate <= RATECHANGE_PCSRESET;
390
               nextwaitcounter <= X"00";
391
               nextwaitcounter2 <= X"00";
392
            end if;
393
 
394
         -- NOW ASSERT PCS RESET FOR 32 CYCLES
395
         when RATECHANGE_PCSRESET =>
396
            PCS_RESET_c <= '1';
397
            USER_PHYSTATUS_c <= '0';
398
            if ((waitcounter(5)) = '1') then
399
               nextstate <= RATECHANGE_PCSRESET_POST;
400
               nextwaitcounter <= X"00";
401
               nextwaitcounter2 <= X"00";
402
            end if;
403
 
404
         -- WAIT FOR RESETDONE BEFORE ASSERTING PHY_STATUS_OUT
405
         when RATECHANGE_PCSRESET_POST =>
406
            USER_PHYSTATUS_c <= '0';
407
            if (RESETDONE = '1') then
408
               nextstate <= RATECHANGE_ASSERTPHY;
409
            end if;
410
 
411
         -- ASSERT PHYSTATUSOUT MEANING RATECHANGE IS DONE AND GO BACK TO IDLE
412
         when RATECHANGE_ASSERTPHY =>
413
            USER_PHYSTATUS_c <= '1';
414
            nextstate <= IDLE;
415
 
416
         when others =>
417
            nextstate <= IDLE;
418
 
419
      end case;
420
   end process;
421
 
422
 
423
   -- Generate Ratechange Pulse
424
 
425
   process (USER_CLK)
426
   begin
427
      if (USER_CLK'event and USER_CLK = '1') then
428
 
429
         if (RESET = '1') then
430
 
431
            ratedone_r <= '0' after (TCQ)*1 ps;
432
            ratedone_r2 <= '0' after (TCQ)*1 ps;
433
            gt_phystatus_q <= '0' after (TCQ)*1 ps;
434
 
435
         else
436
 
437
            ratedone_r <= RATE after (TCQ)*1 ps;
438
            ratedone_r2 <= ratedone_r after (TCQ)*1 ps;
439
            gt_phystatus_q <= GT_PHYSTATUS after (TCQ)*1 ps;
440
 
441
         end if;
442
 
443
      end if;
444
   end process;
445
 
446
 
447
   ratedone_pulse_i <= to_stdlogic((ratedone_r /= ratedone_r2));
448
 
449
end v6_pcie;
450
 
451
 

powered by: WebSVN 2.1.0

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