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/] [gtx_tx_sync_rate_v6.v] - 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-2011 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.v
53
// Version    : 1.7
54
// Module TX_SYNC
55
 
56
`timescale 1ns / 1ps
57
 
58
module GTX_TX_SYNC_RATE_V6
59
#(
60
  parameter    TCQ                = 1,
61
  parameter    C_SIMULATION       = 0 // Set to 1 for simulation
62
)
63
(
64
  output  reg        ENPMAPHASEALIGN = 1'b0,
65
  output  reg        PMASETPHASE = 1'b0,
66
  output  reg        SYNC_DONE = 1'b0,
67
  output  reg        OUT_DIV_RESET = 1'b0,
68
  output  reg        PCS_RESET = 1'b0,
69
  output  reg        USER_PHYSTATUS = 1'b0,
70
  output  reg        TXALIGNDISABLE = 1'b0,
71
  output  reg        DELAYALIGNRESET = 1'b0,
72
  input              USER_CLK,
73
  input              RESET,
74
  input              RATE,
75
  input              RATEDONE,
76
  input              GT_PHYSTATUS,
77
  input              RESETDONE
78
 
79
);
80
 
81
  reg                ENPMAPHASEALIGN_c;
82
  reg                PMASETPHASE_c;
83
  reg                SYNC_DONE_c;
84
  reg                OUT_DIV_RESET_c;
85
  reg                PCS_RESET_c;
86
  reg                USER_PHYSTATUS_c;
87
  reg                DELAYALIGNRESET_c;
88
  reg                TXALIGNDISABLE_c;
89
 
90
 
91
  reg [7:0]         waitcounter2;
92
  reg [7:0]         nextwaitcounter2;
93
  reg [7:0]         waitcounter;
94
  reg [7:0]         nextwaitcounter;
95
  reg [24:0]        state;
96
  reg [24:0]        nextstate;
97
  reg               ratedone_r, ratedone_r2;
98
  wire              ratedone_pulse_i;
99
  reg               gt_phystatus_q;
100
 
101
 
102
  localparam    IDLE                              =  25'b0000000000000000000000001;
103
  localparam    PHASEALIGN                        =  25'b0000000000000000000000010;
104
  localparam    RATECHANGE_DIVRESET               =  25'b0000000000000000000000100;
105
  localparam    RATECHANGE_DIVRESET_POST          =  25'b0000000000000000000001000;
106
  localparam    RATECHANGE_ENPMADISABLE           =  25'b0000000000000000000010000;
107
  localparam    RATECHANGE_ENPMADISABLE_POST      =  25'b0000000000000000000100000;
108
  localparam    RATECHANGE_PMARESET               =  25'b0000000000000000001000000;
109
  localparam    RATECHANGE_IDLE                   =  25'b0000000000000000010000000;
110
  localparam    RATECHANGE_PCSRESET               =  25'b0000000000000000100000000;
111
  localparam    RATECHANGE_PCSRESET_POST          =  25'b0000000000000001000000000;
112
  localparam    RATECHANGE_ASSERTPHY              =  25'b0000000000000010000000000;
113
  localparam    RESET_STATE                       =  25'b0000000000000100000000000;
114
  localparam    WAIT_PHYSTATUS                    =  25'b0000000000010000000000000;
115
  localparam    RATECHANGE_PMARESET_POST          =  25'b0000000000100000000000000;
116
  localparam    RATECHANGE_DISABLEPHASE           =  25'b0000000001000000000000000;
117
  localparam    DELAYALIGNRST                     =  25'b0000000010000000000000000;
118
  localparam    SETENPMAPHASEALIGN                =  25'b0000000100000000000000000;
119
  localparam    TXALIGNDISABLEDEASSERT            =  25'b0000001000000000000000000;
120
  localparam    RATECHANGE_TXDLYALIGNDISABLE      =  25'b0000010000000000000000000;
121
  localparam    GTXTEST_PULSE_1                   =  25'b0000100000000000000000000;
122
  localparam    RATECHANGE_DISABLE_TXALIGNDISABLE =  25'b0001000000000000000000000;
123
  localparam    BEFORE_GTXTEST_PULSE1_1024CLKS    =  25'b0010000000000000000000000;
124
  localparam    BETWEEN_GTXTEST_PULSES            =  25'b0100000000000000000000000;
125
  localparam    GTXTEST_PULSE_2                   =  25'b1000000000000000000000000;
126
 
127
 
128
 
129
  localparam SYNC_IDX = C_SIMULATION ? 0 : 2;
130
  localparam PMARESET_IDX = C_SIMULATION ? 0: 7;
131
 
132
  always @(posedge USER_CLK) begin
133
 
134
    if(RESET) begin
135
 
136
      state            <= #(TCQ) RESET_STATE;
137
      waitcounter2     <= #(TCQ) 1'b0;
138
      waitcounter      <= #(TCQ) 1'b0;
139
      USER_PHYSTATUS   <= #(TCQ) GT_PHYSTATUS;
140
      SYNC_DONE        <= #(TCQ) 1'b0;
141
      ENPMAPHASEALIGN  <= #(TCQ) 1'b1;
142
      PMASETPHASE      <= #(TCQ) 1'b0;
143
      OUT_DIV_RESET    <= #(TCQ) 1'b0;
144
      PCS_RESET        <= #(TCQ) 1'b0;
145
      DELAYALIGNRESET  <= #(TCQ) 1'b0;
146
      TXALIGNDISABLE   <= #(TCQ) 1'b1;
147
 
148
    end else begin
149
 
150
      state            <= #(TCQ) nextstate;
151
      waitcounter2     <= #(TCQ) nextwaitcounter2;
152
      waitcounter      <= #(TCQ) nextwaitcounter;
153
      USER_PHYSTATUS   <= #(TCQ) USER_PHYSTATUS_c;
154
      SYNC_DONE        <= #(TCQ) SYNC_DONE_c;
155
      ENPMAPHASEALIGN  <= #(TCQ) ENPMAPHASEALIGN_c;
156
      PMASETPHASE      <= #(TCQ) PMASETPHASE_c;
157
      OUT_DIV_RESET    <= #(TCQ) OUT_DIV_RESET_c;
158
      PCS_RESET        <= #(TCQ) PCS_RESET_c;
159
      DELAYALIGNRESET  <= #(TCQ) DELAYALIGNRESET_c;
160
      TXALIGNDISABLE   <= #(TCQ) TXALIGNDISABLE_c;
161
 
162
    end
163
 
164
  end
165
 
166
  always @(*) begin
167
 
168
    // DEFAULT CONDITIONS
169
 
170
    DELAYALIGNRESET_c=0;
171
    SYNC_DONE_c=0;
172
    ENPMAPHASEALIGN_c=1;
173
    PMASETPHASE_c=0;
174
    OUT_DIV_RESET_c=0;
175
    PCS_RESET_c=0;
176
    TXALIGNDISABLE_c=0;
177
    nextstate=state;
178
    USER_PHYSTATUS_c=GT_PHYSTATUS;
179
    nextwaitcounter=waitcounter+1'b1;
180
    nextwaitcounter2= (waitcounter ==8'hff)? waitcounter2 + 1'b1 : waitcounter2 ;
181
 
182
    case(state)
183
 
184
      // START IN RESET
185
      RESET_STATE : begin
186
 
187
        TXALIGNDISABLE_c=1;
188
        ENPMAPHASEALIGN_c=0;
189
        nextstate=BEFORE_GTXTEST_PULSE1_1024CLKS;
190
        nextwaitcounter=0;
191
        nextwaitcounter2=0;
192
 
193
      end
194
 
195
      // Have to hold for 1024 clocks before asserting GTXTEST[1]
196
      BEFORE_GTXTEST_PULSE1_1024CLKS : begin
197
 
198
        OUT_DIV_RESET_c=0;
199
        TXALIGNDISABLE_c=1;
200
        ENPMAPHASEALIGN_c=0;
201
 
202
        if(waitcounter2[1]) begin
203
 
204
          nextstate=GTXTEST_PULSE_1;
205
          nextwaitcounter=0;
206
          nextwaitcounter2=0;
207
 
208
        end
209
 
210
      end
211
 
212
      // Assert GTXTEST[1] for 256 clocks.  Figure 3-9 UG366
213
      GTXTEST_PULSE_1: begin
214
 
215
        OUT_DIV_RESET_c=1;
216
        TXALIGNDISABLE_c=1;
217
        ENPMAPHASEALIGN_c=0;
218
 
219
        if(waitcounter[7]) begin
220
 
221
          nextstate=BETWEEN_GTXTEST_PULSES;
222
          nextwaitcounter=0;
223
          nextwaitcounter2=0;
224
 
225
        end
226
 
227
      end
228
 
229
      // De-assert GTXTEST[1] for 256 clocks. Figure 3-9 UG366
230
      BETWEEN_GTXTEST_PULSES: begin
231
 
232
        OUT_DIV_RESET_c=0;
233
        TXALIGNDISABLE_c=1;
234
        ENPMAPHASEALIGN_c=0;
235
 
236
        if(waitcounter[7]) begin
237
 
238
          nextstate=GTXTEST_PULSE_2;
239
          nextwaitcounter=0;
240
          nextwaitcounter2=0;
241
 
242
        end
243
 
244
      end
245
 
246
      // Assert GTXTEST[1] for 256 clocks a second time.  Figure 3-9 UG366 
247
      GTXTEST_PULSE_2: begin
248
 
249
        OUT_DIV_RESET_c=1;
250
        TXALIGNDISABLE_c=1;
251
        ENPMAPHASEALIGN_c=0;
252
 
253
        if(waitcounter[7]) begin
254
 
255
          nextstate=DELAYALIGNRST;
256
          nextwaitcounter=0;
257
          nextwaitcounter2=0;
258
 
259
        end
260
 
261
      end
262
 
263
 
264
 
265
      // ASSERT TXDLYALIGNRESET FOR 16 CLOCK CYCLES
266
      DELAYALIGNRST : begin
267
 
268
        DELAYALIGNRESET_c=1;
269
        ENPMAPHASEALIGN_c=0;
270
        TXALIGNDISABLE_c=1;
271
 
272
        if(waitcounter[4]) begin
273
 
274
          nextstate=SETENPMAPHASEALIGN;
275
          nextwaitcounter=0;
276
          nextwaitcounter2=0;
277
 
278
        end
279
 
280
      end
281
 
282
      // ASSERT ENPMAPHASEALIGN FOR 32 CLOCK CYCLES
283
      SETENPMAPHASEALIGN : begin
284
 
285
        TXALIGNDISABLE_c=1;
286
 
287
        if(waitcounter[5]) begin
288
 
289
          nextstate=PHASEALIGN;
290
          nextwaitcounter=0;
291
          nextwaitcounter2=0;
292
 
293
        end
294
 
295
      end
296
 
297
      // ASSERT PMASETPHASE OUT OF RESET for 32K CYCLES
298
      PHASEALIGN : begin
299
 
300
        PMASETPHASE_c=1;
301
        TXALIGNDISABLE_c=1;
302
 
303
          if(waitcounter2[PMARESET_IDX]) begin
304
 
305
            nextstate=TXALIGNDISABLEDEASSERT;
306
            nextwaitcounter=0;
307
            nextwaitcounter2=0;
308
 
309
          end
310
 
311
      end
312
 
313
      // KEEP TXALIGNDISABLE ASSERTED for 64 CYCLES
314
      TXALIGNDISABLEDEASSERT : begin
315
 
316
        TXALIGNDISABLE_c=1;
317
 
318
        if(waitcounter[6]) begin
319
 
320
            nextwaitcounter=0;
321
            nextstate=IDLE;
322
            nextwaitcounter2=0;
323
 
324
        end
325
 
326
      end
327
 
328
      // NOW IN IDLE, ASSERT SYNC DONE, WAIT FOR RATECHANGE
329
      IDLE : begin
330
 
331
        SYNC_DONE_c=1;
332
 
333
        if(ratedone_pulse_i) begin
334
 
335
          USER_PHYSTATUS_c=0;
336
          nextstate=WAIT_PHYSTATUS;
337
          nextwaitcounter=0;
338
          nextwaitcounter2=0;
339
 
340
        end
341
 
342
      end
343
 
344
      // WAIT FOR PHYSTATUS
345
      WAIT_PHYSTATUS : begin
346
 
347
        USER_PHYSTATUS_c=0;
348
 
349
        if(gt_phystatus_q) begin
350
 
351
          nextstate=RATECHANGE_IDLE;
352
          nextwaitcounter=0;
353
          nextwaitcounter2=0;
354
 
355
        end
356
 
357
      end
358
 
359
      // WAIT 64 CYCLES BEFORE WE START THE RATE CHANGE
360
      RATECHANGE_IDLE : begin
361
 
362
        USER_PHYSTATUS_c=0;
363
 
364
        if(waitcounter[6]) begin
365
 
366
          nextstate=RATECHANGE_TXDLYALIGNDISABLE;
367
          nextwaitcounter=0;
368
          nextwaitcounter2=0;
369
 
370
        end
371
 
372
      end
373
 
374
      // ASSERT TXALIGNDISABLE FOR 32 CYCLES
375
      RATECHANGE_TXDLYALIGNDISABLE : begin
376
 
377
        USER_PHYSTATUS_c=0;
378
        TXALIGNDISABLE_c=1;
379
 
380
        if(waitcounter[5]) begin
381
 
382
          nextstate=RATECHANGE_DIVRESET;
383
          nextwaitcounter=0;
384
          nextwaitcounter2=0;
385
 
386
        end
387
 
388
      end
389
 
390
      // ASSERT DIV RESET FOR 16 CLOCK CYCLES
391
      RATECHANGE_DIVRESET : begin
392
 
393
        OUT_DIV_RESET_c=1;
394
        USER_PHYSTATUS_c=0;
395
        TXALIGNDISABLE_c=1;
396
 
397
        if(waitcounter[4]) begin
398
 
399
          nextstate=RATECHANGE_DIVRESET_POST;
400
          nextwaitcounter=0;
401
          nextwaitcounter2=0;
402
 
403
        end
404
 
405
      end
406
 
407
      // WAIT FOR 32 CLOCK CYCLES BEFORE NEXT STEP
408
      RATECHANGE_DIVRESET_POST : begin
409
 
410
        USER_PHYSTATUS_c=0;
411
        TXALIGNDISABLE_c=1;
412
 
413
        if(waitcounter[5]) begin
414
 
415
          nextstate=RATECHANGE_PMARESET;
416
          nextwaitcounter=0;
417
          nextwaitcounter2=0;
418
 
419
        end
420
 
421
      end
422
 
423
      // ASSERT PMA RESET FOR 32K CYCLES
424
      RATECHANGE_PMARESET : begin
425
 
426
        PMASETPHASE_c=1;
427
        USER_PHYSTATUS_c=0;
428
        TXALIGNDISABLE_c=1;
429
 
430
        if(waitcounter2[PMARESET_IDX]) begin
431
 
432
            nextstate=RATECHANGE_PMARESET_POST;
433
            nextwaitcounter=0;
434
            nextwaitcounter2=0;
435
 
436
        end
437
 
438
      end
439
 
440
 
441
      // WAIT FOR 32 CYCLES BEFORE DISABLING TXALIGNDISABLE
442
      RATECHANGE_PMARESET_POST : begin
443
 
444
        USER_PHYSTATUS_c=0;
445
        TXALIGNDISABLE_c=1;
446
 
447
        if(waitcounter[5]) begin
448
 
449
          nextstate=RATECHANGE_DISABLE_TXALIGNDISABLE;
450
          nextwaitcounter=0;
451
          nextwaitcounter2=0;
452
 
453
        end
454
 
455
      end
456
 
457
      // DISABLE TXALIGNDISABLE FOR 32 CYCLES
458
      RATECHANGE_DISABLE_TXALIGNDISABLE : begin
459
 
460
        USER_PHYSTATUS_c=0;
461
 
462
        if(waitcounter[5]) begin
463
 
464
          nextstate=RATECHANGE_PCSRESET;
465
          nextwaitcounter=0;
466
          nextwaitcounter2=0;
467
 
468
        end
469
      end
470
 
471
      // NOW ASSERT PCS RESET FOR 32 CYCLES
472
      RATECHANGE_PCSRESET : begin
473
 
474
        PCS_RESET_c=1;
475
 
476
        USER_PHYSTATUS_c=0;
477
 
478
        if(waitcounter[5]) begin
479
 
480
          nextstate=RATECHANGE_PCSRESET_POST;
481
          nextwaitcounter=0;
482
          nextwaitcounter2=0;
483
 
484
        end
485
 
486
      end
487
 
488
      // WAIT FOR RESETDONE BEFORE ASSERTING PHY_STATUS_OUT
489
      RATECHANGE_PCSRESET_POST : begin
490
 
491
        USER_PHYSTATUS_c=0;
492
 
493
        if(RESETDONE) begin
494
 
495
          nextstate=RATECHANGE_ASSERTPHY;
496
 
497
        end
498
 
499
      end
500
 
501
      // ASSERT PHYSTATUSOUT MEANING RATECHANGE IS DONE AND GO BACK TO IDLE
502
      RATECHANGE_ASSERTPHY : begin
503
 
504
        USER_PHYSTATUS_c=1;
505
        nextstate=IDLE;
506
 
507
      end
508
 
509
    endcase
510
 
511
  end
512
 
513
  // Generate Ratechange Pulse
514
 
515
  always @(posedge USER_CLK) begin
516
 
517
    if (RESET) begin
518
 
519
      ratedone_r  <= #(TCQ) 1'b0;
520
      ratedone_r2 <= #(TCQ) 1'b0;
521
      gt_phystatus_q <= #(TCQ) 1'b0;
522
 
523
 
524
    end else begin
525
 
526
      ratedone_r  <= #(TCQ) RATE;
527
      ratedone_r2 <= #(TCQ) ratedone_r;
528
      gt_phystatus_q <= #(TCQ) GT_PHYSTATUS;
529
 
530
    end
531
 
532
  end
533
 
534
  assign ratedone_pulse_i = (ratedone_r != ratedone_r2);
535
 
536
endmodule
537
 
538
 
539
 

powered by: WebSVN 2.1.0

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