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_artix7/] [cl_a7pcie_x4_pipe_sync.v] - Blame information for rev 48

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 46 dsmv
//-----------------------------------------------------------------------------
2
//
3
// (c) Copyright 2010-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    : Series-7 Integrated Block for PCI Express
51
// File       : cl_a7pcie_x4_pipe_sync.v
52 48 dsmv
// Version    : 1.10
53 46 dsmv
//------------------------------------------------------------------------------
54
//  Filename     :  pipe_sync.v
55
//  Description  :  PIPE Sync Module for 7 Series Transceiver
56
//  Version      :  20.1
57
//------------------------------------------------------------------------------
58
//  PCIE_TXSYNC_MODE  : 0 = Manual TX sync (default).
59
//                    : 1 = Auto TX sync.
60
//  PCIE_RXSYNC_MODE  : 0 = Manual RX sync (default).
61
//                    : 1 = Auto RX sync.
62
//------------------------------------------------------------------------------
63
 
64
 
65
 
66
`timescale 1ns / 1ps
67
 
68
 
69
 
70
//---------- PIPE Sync Module --------------------------------------------------
71
module cl_a7pcie_x4_pipe_sync #
72
(
73
 
74
    parameter PCIE_GT_DEVICE       = "GTX",                 // PCIe GT device
75
    parameter PCIE_TXBUF_EN        = "FALSE",               // PCIe TX buffer enable for Gen1/Gen2 only
76
    parameter PCIE_RXBUF_EN        = "TRUE",                // PCIe TX buffer enable for Gen3      only
77
    parameter PCIE_TXSYNC_MODE     = 0,                     // PCIe TX sync mode
78
    parameter PCIE_RXSYNC_MODE     = 0,                     // PCIe RX sync mode
79
    parameter PCIE_LANE            = 1,                     // PCIe lane
80
    parameter PCIE_LINK_SPEED      = 3,                     // PCIe link speed
81
    parameter BYPASS_TXDELAY_ALIGN = 0,                     // Bypass TX delay align
82
    parameter BYPASS_RXDELAY_ALIGN = 0                      // Bypass RX delay align
83
 
84
)
85
 
86
(
87
 
88
    //---------- Input -------------------------------------
89
    input               SYNC_CLK,
90
    input               SYNC_RST_N,
91
    input               SYNC_SLAVE,
92
    input               SYNC_GEN3,
93
    input               SYNC_RATE_IDLE,
94
    input               SYNC_MMCM_LOCK,
95
    input               SYNC_RXELECIDLE,
96
    input               SYNC_RXCDRLOCK,
97
    input               SYNC_ACTIVE_LANE,
98
 
99
    input               SYNC_TXSYNC_START,
100
    input               SYNC_TXPHINITDONE,
101
    input               SYNC_TXDLYSRESETDONE,
102
    input               SYNC_TXPHALIGNDONE,
103
    input               SYNC_TXSYNCDONE,
104
 
105
    input               SYNC_RXSYNC_START,
106
    input               SYNC_RXDLYSRESETDONE,
107
    input               SYNC_RXPHALIGNDONE_M,
108
    input               SYNC_RXPHALIGNDONE_S,
109
    input               SYNC_RXSYNC_DONEM_IN,
110
    input               SYNC_RXSYNCDONE,
111
 
112
    //---------- Output ------------------------------------
113
    output              SYNC_TXPHDLYRESET,
114
    output              SYNC_TXPHALIGN,
115
    output              SYNC_TXPHALIGNEN,
116
    output              SYNC_TXPHINIT,
117
    output              SYNC_TXDLYBYPASS,
118
    output              SYNC_TXDLYSRESET,
119
    output              SYNC_TXDLYEN,
120
    output              SYNC_TXSYNC_DONE,
121
    output    [ 5:0]    SYNC_FSM_TX,
122
 
123
    output              SYNC_RXPHALIGN,
124
    output              SYNC_RXPHALIGNEN,
125
    output              SYNC_RXDLYBYPASS,
126
    output              SYNC_RXDLYSRESET,
127
    output              SYNC_RXDLYEN,
128
    output              SYNC_RXDDIEN,
129
    output              SYNC_RXSYNC_DONEM_OUT,
130
    output              SYNC_RXSYNC_DONE,
131
    output    [ 6:0]    SYNC_FSM_RX
132
 
133
);
134
 
135
    //---------- Input Register ----------------------------
136 48 dsmv
(* ASYNC_REG = "TRUE", SHIFT_EXTRACT = "NO" *)    reg                 gen3_reg1;
137
(* ASYNC_REG = "TRUE", SHIFT_EXTRACT = "NO" *)    reg                 rate_idle_reg1;
138
(* ASYNC_REG = "TRUE", SHIFT_EXTRACT = "NO" *)    reg                 mmcm_lock_reg1;
139
(* ASYNC_REG = "TRUE", SHIFT_EXTRACT = "NO" *)    reg                 rxelecidle_reg1;
140
(* ASYNC_REG = "TRUE", SHIFT_EXTRACT = "NO" *)    reg                 rxcdrlock_reg1;
141 46 dsmv
 
142 48 dsmv
(* ASYNC_REG = "TRUE", SHIFT_EXTRACT = "NO" *)    reg                 gen3_reg2;
143
(* ASYNC_REG = "TRUE", SHIFT_EXTRACT = "NO" *)    reg                 rate_idle_reg2;
144
(* ASYNC_REG = "TRUE", SHIFT_EXTRACT = "NO" *)    reg                 mmcm_lock_reg2;
145
(* ASYNC_REG = "TRUE", SHIFT_EXTRACT = "NO" *)    reg                 rxelecidle_reg2;
146
(* ASYNC_REG = "TRUE", SHIFT_EXTRACT = "NO" *)    reg                 rxcdrlock_reg2;
147 46 dsmv
 
148 48 dsmv
(* ASYNC_REG = "TRUE", SHIFT_EXTRACT = "NO" *)    reg                 txsync_start_reg1;
149
(* ASYNC_REG = "TRUE", SHIFT_EXTRACT = "NO" *)    reg                 txphinitdone_reg1;
150
(* ASYNC_REG = "TRUE", SHIFT_EXTRACT = "NO" *)    reg                 txdlysresetdone_reg1;
151
(* ASYNC_REG = "TRUE", SHIFT_EXTRACT = "NO" *)    reg                 txphaligndone_reg1;
152
(* ASYNC_REG = "TRUE", SHIFT_EXTRACT = "NO" *)    reg                 txsyncdone_reg1;
153 46 dsmv
 
154 48 dsmv
(* ASYNC_REG = "TRUE", SHIFT_EXTRACT = "NO" *)    reg                 txsync_start_reg2;
155
(* ASYNC_REG = "TRUE", SHIFT_EXTRACT = "NO" *)    reg                 txphinitdone_reg2;
156
(* ASYNC_REG = "TRUE", SHIFT_EXTRACT = "NO" *)    reg                 txdlysresetdone_reg2;
157
(* ASYNC_REG = "TRUE", SHIFT_EXTRACT = "NO" *)    reg                 txphaligndone_reg2;
158
(* ASYNC_REG = "TRUE", SHIFT_EXTRACT = "NO" *)    reg                 txsyncdone_reg2;
159 46 dsmv
 
160 48 dsmv
(* ASYNC_REG = "TRUE", SHIFT_EXTRACT = "NO" *)    reg                 txsync_start_reg3;
161
(* ASYNC_REG = "TRUE", SHIFT_EXTRACT = "NO" *)    reg                 txphinitdone_reg3;
162
(* ASYNC_REG = "TRUE", SHIFT_EXTRACT = "NO" *)    reg                 txdlysresetdone_reg3;
163
(* ASYNC_REG = "TRUE", SHIFT_EXTRACT = "NO" *)    reg                 txphaligndone_reg3;
164
(* ASYNC_REG = "TRUE", SHIFT_EXTRACT = "NO" *)    reg                 txsyncdone_reg3;
165
 
166
(* ASYNC_REG = "TRUE", SHIFT_EXTRACT = "NO" *)    reg                 rxsync_start_reg1;
167
(* ASYNC_REG = "TRUE", SHIFT_EXTRACT = "NO" *)    reg                 rxdlysresetdone_reg1;
168
(* ASYNC_REG = "TRUE", SHIFT_EXTRACT = "NO" *)    reg                 rxphaligndone_m_reg1;
169
(* ASYNC_REG = "TRUE", SHIFT_EXTRACT = "NO" *)    reg                 rxphaligndone_s_reg1;
170
(* ASYNC_REG = "TRUE", SHIFT_EXTRACT = "NO" *)    reg                 rxsync_donem_reg1;
171
(* ASYNC_REG = "TRUE", SHIFT_EXTRACT = "NO" *)    reg                 rxsyncdone_reg1;
172 46 dsmv
 
173 48 dsmv
(* ASYNC_REG = "TRUE", SHIFT_EXTRACT = "NO" *)    reg                 rxsync_start_reg2;
174
(* ASYNC_REG = "TRUE", SHIFT_EXTRACT = "NO" *)    reg                 rxdlysresetdone_reg2;
175
(* ASYNC_REG = "TRUE", SHIFT_EXTRACT = "NO" *)    reg                 rxphaligndone_m_reg2;
176
(* ASYNC_REG = "TRUE", SHIFT_EXTRACT = "NO" *)    reg                 rxphaligndone_s_reg2;
177
(* ASYNC_REG = "TRUE", SHIFT_EXTRACT = "NO" *)    reg                 rxsync_donem_reg2;
178
(* ASYNC_REG = "TRUE", SHIFT_EXTRACT = "NO" *)    reg                 rxsyncdone_reg2;
179 46 dsmv
 
180
    //---------- Output Register ---------------------------          
181
    reg                 txdlyen     = 1'd0;
182
    reg                 txsync_done = 1'd0;
183
    reg         [ 5:0]  fsm_tx      = 6'd0;
184
 
185
    reg                 rxdlyen     = 1'd0;
186
    reg                 rxsync_done = 1'd0;
187
    reg         [ 6:0]  fsm_rx      = 7'd0;
188
 
189
    //---------- FSM ---------------------------------------                                         
190
    localparam          FSM_TXSYNC_IDLE  = 6'b000001;
191
    localparam          FSM_MMCM_LOCK    = 6'b000010;
192
    localparam          FSM_TXSYNC_START = 6'b000100;
193
    localparam          FSM_TXPHINITDONE = 6'b001000;       // Manual TX sync only
194
    localparam          FSM_TXSYNC_DONE1 = 6'b010000;
195
    localparam          FSM_TXSYNC_DONE2 = 6'b100000;
196
 
197
    localparam          FSM_RXSYNC_IDLE  = 7'b0000001;
198
    localparam          FSM_RXCDRLOCK    = 7'b0000010;
199
    localparam          FSM_RXSYNC_START = 7'b0000100;
200
    localparam          FSM_RXSYNC_DONE1 = 7'b0001000;
201
    localparam          FSM_RXSYNC_DONE2 = 7'b0010000;
202
    localparam          FSM_RXSYNC_DONES = 7'b0100000;
203
    localparam          FSM_RXSYNC_DONEM = 7'b1000000;
204
 
205
 
206
 
207
//---------- Input FF ----------------------------------------------------------
208
always @ (posedge SYNC_CLK)
209
begin
210
 
211
    if (!SYNC_RST_N)
212
        begin
213
        //---------- 1st Stage FF --------------------------  
214
        gen3_reg1            <= 1'd0;
215
        rate_idle_reg1       <= 1'd0;
216
        mmcm_lock_reg1       <= 1'd0;
217
        rxelecidle_reg1      <= 1'd0;
218
        rxcdrlock_reg1       <= 1'd0;
219
 
220
        txsync_start_reg1          <= 1'd0;
221
        txphinitdone_reg1    <= 1'd0;
222
        txdlysresetdone_reg1 <= 1'd0;
223
        txphaligndone_reg1   <= 1'd0;
224
        txsyncdone_reg1      <= 1'd0;
225
 
226
        rxsync_start_reg1          <= 1'd0;
227
        rxdlysresetdone_reg1 <= 1'd0;
228
        rxphaligndone_m_reg1 <= 1'd0;
229
        rxphaligndone_s_reg1 <= 1'd0;
230
        rxsync_donem_reg1    <= 1'd0;
231
        rxsyncdone_reg1      <= 1'd0;
232
        //---------- 2nd Stage FF --------------------------
233
        gen3_reg2            <= 1'd0;
234
        rate_idle_reg2       <= 1'd0;
235
        mmcm_lock_reg2       <= 1'd0;
236
        rxelecidle_reg2      <= 1'd0;
237
        rxcdrlock_reg2       <= 1'd0;
238
 
239
        txsync_start_reg2          <= 1'd0;
240
        txphinitdone_reg2    <= 1'd0;
241
        txdlysresetdone_reg2 <= 1'd0;
242
        txphaligndone_reg2   <= 1'd0;
243
        txsyncdone_reg2      <= 1'd0;
244
 
245
        rxsync_start_reg2          <= 1'd0;
246
        rxdlysresetdone_reg2 <= 1'd0;
247
        rxphaligndone_m_reg2 <= 1'd0;
248
        rxphaligndone_s_reg2 <= 1'd0;
249
        rxsync_donem_reg2    <= 1'd0;
250
        rxsyncdone_reg2      <= 1'd0;
251 48 dsmv
        //---------- 3rd Stage FF --------------------------
252
        txsync_start_reg3          <= 1'd0;
253
        txphinitdone_reg3    <= 1'd0;
254
        txdlysresetdone_reg3 <= 1'd0;
255
        txphaligndone_reg3   <= 1'd0;
256
        txsyncdone_reg3      <= 1'd0;
257
 
258 46 dsmv
        end
259
    else
260
        begin
261
        //---------- 1st Stage FF --------------------------
262
        gen3_reg1            <= SYNC_GEN3;
263
        rate_idle_reg1       <= SYNC_RATE_IDLE;
264
        mmcm_lock_reg1       <= SYNC_MMCM_LOCK;
265
        rxelecidle_reg1      <= SYNC_RXELECIDLE;
266
        rxcdrlock_reg1       <= SYNC_RXCDRLOCK;
267
 
268
        txsync_start_reg1    <= SYNC_TXSYNC_START;
269
        txphinitdone_reg1    <= SYNC_TXPHINITDONE;
270
        txdlysresetdone_reg1 <= SYNC_TXDLYSRESETDONE;
271
        txphaligndone_reg1   <= SYNC_TXPHALIGNDONE;
272
        txsyncdone_reg1      <= SYNC_TXSYNCDONE;
273
 
274
        rxsync_start_reg1          <= SYNC_RXSYNC_START;
275
        rxdlysresetdone_reg1 <= SYNC_RXDLYSRESETDONE;
276
        rxphaligndone_m_reg1 <= SYNC_RXPHALIGNDONE_M;
277
        rxphaligndone_s_reg1 <= SYNC_RXPHALIGNDONE_S;
278
        rxsync_donem_reg1    <= SYNC_RXSYNC_DONEM_IN;
279
        rxsyncdone_reg1      <= SYNC_RXSYNCDONE;
280
        //---------- 2nd Stage FF --------------------------
281
        gen3_reg2            <= gen3_reg1;
282
        rate_idle_reg2       <= rate_idle_reg1;
283
        mmcm_lock_reg2       <= mmcm_lock_reg1;
284
        rxelecidle_reg2      <= rxelecidle_reg1;
285
        rxcdrlock_reg2       <= rxcdrlock_reg1;
286
 
287
        txsync_start_reg2    <= txsync_start_reg1;
288
        txphinitdone_reg2    <= txphinitdone_reg1;
289
        txdlysresetdone_reg2 <= txdlysresetdone_reg1;
290
        txphaligndone_reg2   <= txphaligndone_reg1;
291
        txsyncdone_reg2      <= txsyncdone_reg1;
292
 
293
        rxsync_start_reg2    <= rxsync_start_reg1;
294
        rxdlysresetdone_reg2 <= rxdlysresetdone_reg1;
295
        rxphaligndone_m_reg2 <= rxphaligndone_m_reg1;
296
        rxphaligndone_s_reg2 <= rxphaligndone_s_reg1;
297
        rxsync_donem_reg2    <= rxsync_donem_reg1;
298
        rxsyncdone_reg2      <= rxsyncdone_reg1;
299 48 dsmv
        //---------- 3rd Stage FF --------------------------
300
        txsync_start_reg3    <= txsync_start_reg2;
301
        txphinitdone_reg3    <= txphinitdone_reg2;
302
        txdlysresetdone_reg3 <= txdlysresetdone_reg2;
303
        txphaligndone_reg3   <= txphaligndone_reg2;
304
        txsyncdone_reg3      <= txsyncdone_reg2;
305 46 dsmv
        end
306
 
307
end
308
 
309
 
310
 
311
//---------- Generate TX Sync FSM ----------------------------------------------
312
generate if ((PCIE_LINK_SPEED == 3) || (PCIE_TXBUF_EN == "FALSE"))
313
 
314
    begin : txsync_fsm
315
 
316
    //---------- PIPE TX Sync FSM ----------------------------------------------
317
    always @ (posedge SYNC_CLK)
318
    begin
319
 
320
        if (!SYNC_RST_N)
321
            begin
322
            fsm_tx      <= FSM_TXSYNC_IDLE;
323
            txdlyen     <= 1'd0;
324
            txsync_done <= 1'd0;
325
            end
326
        else
327
            begin
328
 
329
            case (fsm_tx)
330
 
331
            //---------- Idle State ------------------------
332
            FSM_TXSYNC_IDLE :
333
 
334
                begin
335
                //---------- Exiting Reset or Rate Change --
336
                if (txsync_start_reg2)
337
                    begin
338
                    fsm_tx      <= FSM_MMCM_LOCK;
339
                    txdlyen     <= 1'd0;
340
                    txsync_done <= 1'd0;
341
                    end
342
                else
343
                    begin
344
                    fsm_tx      <= FSM_TXSYNC_IDLE;
345
                    txdlyen     <= txdlyen;
346
                    txsync_done <= txsync_done;
347
                    end
348
                end
349
 
350
            //---------- Check MMCM Lock -------------------
351
            FSM_MMCM_LOCK :
352
 
353
                begin
354
                fsm_tx      <= (mmcm_lock_reg2 ? FSM_TXSYNC_START : FSM_MMCM_LOCK);
355
                txdlyen     <= 1'd0;
356
                txsync_done <= 1'd0;
357
                end
358
 
359
            //---------- TX Delay Soft Reset --------------- 
360
            FSM_TXSYNC_START :
361
 
362
                begin
363 48 dsmv
                fsm_tx      <= (((!txdlysresetdone_reg3 && txdlysresetdone_reg2) || (((PCIE_GT_DEVICE == "GTH") || (PCIE_GT_DEVICE == "GTP")) && (PCIE_TXSYNC_MODE == 1) && SYNC_SLAVE)) ? FSM_TXPHINITDONE : FSM_TXSYNC_START);
364 46 dsmv
                txdlyen     <= 1'd0;
365
                txsync_done <= 1'd0;
366
                end
367
 
368
            //---------- Wait for TX Phase Init Done (Manual Mode Only)
369
            FSM_TXPHINITDONE :
370
 
371
                begin
372 48 dsmv
                fsm_tx      <= (((!txphinitdone_reg3 && txphinitdone_reg2) || (PCIE_TXSYNC_MODE == 1) || (!SYNC_ACTIVE_LANE)) ? FSM_TXSYNC_DONE1 : FSM_TXPHINITDONE);
373 46 dsmv
                txdlyen     <= 1'd0;
374
                txsync_done <= 1'd0;
375
                end
376
 
377
            //---------- Wait for TX Phase Alignment Done --
378
            FSM_TXSYNC_DONE1 :
379
 
380
                begin
381
                if (((PCIE_GT_DEVICE == "GTH") || (PCIE_GT_DEVICE == "GTP")) && (PCIE_TXSYNC_MODE == 1) && !SYNC_SLAVE)
382 48 dsmv
                   fsm_tx <= ((!txsyncdone_reg3 && txsyncdone_reg2)       || (!SYNC_ACTIVE_LANE) ? FSM_TXSYNC_DONE2 : FSM_TXSYNC_DONE1);
383 46 dsmv
                else
384 48 dsmv
                   fsm_tx <= ((!txphaligndone_reg3 && txphaligndone_reg2) || (!SYNC_ACTIVE_LANE) ? FSM_TXSYNC_DONE2 : FSM_TXSYNC_DONE1);
385 46 dsmv
 
386
                txdlyen     <= 1'd0;
387
                txsync_done <= 1'd0;
388
                end
389
 
390
            //---------- Wait for Master TX Delay Alignment Done 
391
            FSM_TXSYNC_DONE2 :
392
 
393
                begin
394 48 dsmv
                if ((!txphaligndone_reg3 && txphaligndone_reg2) || (!SYNC_ACTIVE_LANE) || SYNC_SLAVE || (((PCIE_GT_DEVICE == "GTH") || (PCIE_GT_DEVICE == "GTP")) && (PCIE_TXSYNC_MODE == 1)) || (BYPASS_TXDELAY_ALIGN == 1))
395 46 dsmv
                    begin
396
                    fsm_tx      <= FSM_TXSYNC_IDLE;
397
                    txdlyen     <= !SYNC_SLAVE;
398
                    txsync_done <= 1'd1;
399
                    end
400
                else
401
                    begin
402
                    fsm_tx      <= FSM_TXSYNC_DONE2;
403
                    txdlyen     <= !SYNC_SLAVE;
404
                    txsync_done <= 1'd0;
405
                    end
406
                end
407
 
408
            //---------- Default State ---------------------
409
            default :
410
                begin
411
                fsm_tx      <= FSM_TXSYNC_IDLE;
412
                txdlyen     <= 1'd0;
413
                txsync_done <= 1'd0;
414
                end
415
 
416
            endcase
417
 
418
            end
419
 
420
    end
421
 
422
    end
423
 
424
//---------- TX Sync FSM Default------------------------------------------------
425
else
426
 
427
    begin : txsync_fsm_disable
428
 
429
    //---------- Default -------------------------------------------------------
430
    always @ (posedge SYNC_CLK)
431
    begin
432
        fsm_tx      <= FSM_TXSYNC_IDLE;
433
        txdlyen     <= 1'd0;
434
        txsync_done <= 1'd0;
435
    end
436
 
437
    end
438
 
439
endgenerate
440
 
441
 
442
 
443
//---------- Generate RX Sync FSM ----------------------------------------------
444
generate if ((PCIE_LINK_SPEED == 3) && (PCIE_RXBUF_EN == "FALSE"))
445
 
446
    begin : rxsync_fsm
447
 
448
    //---------- PIPE RX Sync FSM ----------------------------------------------
449
    always @ (posedge SYNC_CLK)
450
    begin
451
 
452
        if (!SYNC_RST_N)
453
            begin
454
            fsm_rx      <= FSM_RXSYNC_IDLE;
455
            rxdlyen     <= 1'd0;
456
            rxsync_done <= 1'd0;
457
            end
458
        else
459
            begin
460
 
461
            case (fsm_rx)
462
 
463
            //---------- Idle State ------------------------
464
            FSM_RXSYNC_IDLE :
465
 
466
                begin
467
                //---------- Exiting Rate Change -----------
468
                if (rxsync_start_reg2)
469
                    begin
470
                    fsm_rx      <= FSM_RXCDRLOCK;
471
                    rxdlyen     <= 1'd0;
472
                    rxsync_done <= 1'd0;
473
                    end
474
                //---------- Exiting Electrical Idle without Rate Change 
475
                else if (gen3_reg2 && rate_idle_reg2 && ((rxelecidle_reg2 == 1'd1) && (rxelecidle_reg1 == 1'd0)))
476
                    begin
477
                    fsm_rx      <= FSM_RXCDRLOCK;
478
                    rxdlyen     <= 1'd0;
479
                    rxsync_done <= 1'd0;
480
                    end
481
                //---------- Idle --------------------------
482
                else
483
                    begin
484
                    fsm_rx      <= FSM_RXSYNC_IDLE;
485
                    rxdlyen     <= rxelecidle_reg2 ? 1'd0 : rxdlyen;
486
                    rxsync_done <= rxelecidle_reg2 ? 1'd0 : rxsync_done;
487
                    end
488
                end
489
 
490
            //---------- Wait for RX Electrical Idle Exit and RX CDR Lock 
491
            FSM_RXCDRLOCK :
492
 
493
                begin
494
                fsm_rx      <= ((!rxelecidle_reg2 && rxcdrlock_reg2) ? FSM_RXSYNC_START : FSM_RXCDRLOCK);
495
                rxdlyen     <= 1'd0;
496
                rxsync_done <= 1'd0;
497
                end
498
 
499
            //---------- Start RX Sync with RX Delay Soft Reset
500
            FSM_RXSYNC_START :
501
 
502
                begin
503
                fsm_rx      <= ((!rxdlysresetdone_reg2 && rxdlysresetdone_reg1) ? FSM_RXSYNC_DONE1 : FSM_RXSYNC_START);
504
                rxdlyen     <= 1'd0;
505
                rxsync_done <= 1'd0;
506
                end
507
 
508
            //---------- Wait for RX Phase Alignment Done --
509
            FSM_RXSYNC_DONE1 :
510
 
511
                begin
512
                if (SYNC_SLAVE)
513
                    begin
514
                    fsm_rx      <= ((!rxphaligndone_s_reg2 && rxphaligndone_s_reg1) ? FSM_RXSYNC_DONE2 : FSM_RXSYNC_DONE1);
515
                    rxdlyen     <= 1'd0;
516
                    rxsync_done <= 1'd0;
517
                    end
518
                else
519
                    begin
520
                    fsm_rx      <= ((!rxphaligndone_m_reg2 && rxphaligndone_m_reg1) ? FSM_RXSYNC_DONE2 : FSM_RXSYNC_DONE1);
521
                    rxdlyen     <= 1'd0;
522
                    rxsync_done <= 1'd0;
523
                    end
524
                end
525
 
526
            //---------- Wait for Master RX Delay Alignment Done 
527
            FSM_RXSYNC_DONE2 :
528
 
529
                begin
530
                if (SYNC_SLAVE)
531
                    begin
532
                    fsm_rx      <= FSM_RXSYNC_IDLE;
533
                    rxdlyen     <= 1'd0;
534
                    rxsync_done <= 1'd1;
535
                    end
536
                else if ((!rxphaligndone_m_reg2 && rxphaligndone_m_reg1) || (BYPASS_RXDELAY_ALIGN == 1))
537
                    begin
538
                    fsm_rx      <= ((PCIE_LANE == 1) ? FSM_RXSYNC_IDLE : FSM_RXSYNC_DONES);
539
                    rxdlyen     <=  (PCIE_LANE == 1);
540
                    rxsync_done <=  (PCIE_LANE == 1);
541
                    end
542
                else
543
                    begin
544
                    fsm_rx      <= FSM_RXSYNC_DONE2;
545
                    rxdlyen     <= 1'd1;
546
                    rxsync_done <= 1'd0;
547
                    end
548
                end
549
 
550
            //---------- Wait for Slave RX Phase Alignment Done 
551
            FSM_RXSYNC_DONES :
552
 
553
                begin
554
                if (!rxphaligndone_s_reg2 && rxphaligndone_s_reg1)
555
                    begin
556
                    fsm_rx      <= FSM_RXSYNC_DONEM;
557
                    rxdlyen     <= 1'd1;
558
                    rxsync_done <= 1'd0;
559
                    end
560
                else
561
                    begin
562
                    fsm_rx      <= FSM_RXSYNC_DONES;
563
                    rxdlyen     <= 1'd0;
564
                    rxsync_done <= 1'd0;
565
                    end
566
                end
567
 
568
            //---------- Wait for Master RX Delay Alignment Done 
569
            FSM_RXSYNC_DONEM :
570
 
571
                begin
572
                if ((!rxphaligndone_m_reg2 && rxphaligndone_m_reg1) || (BYPASS_RXDELAY_ALIGN == 1))
573
                    begin
574
                    fsm_rx      <= FSM_RXSYNC_IDLE;
575
                    rxdlyen     <= 1'd1;
576
                    rxsync_done <= 1'd1;
577
                    end
578
                else
579
                    begin
580
                    fsm_rx      <= FSM_RXSYNC_DONEM;
581
                    rxdlyen     <= 1'd1;
582
                    rxsync_done <= 1'd0;
583
                    end
584
                end
585
 
586
            //---------- Default State ---------------------
587
            default :
588
                begin
589
                fsm_rx      <= FSM_RXSYNC_IDLE;
590
                rxdlyen     <= 1'd0;
591
                rxsync_done <= 1'd0;
592
                end
593
 
594
                   endcase
595
 
596
            end
597
 
598
    end
599
 
600
    end
601
 
602
//---------- RX Sync FSM Default -----------------------------------------------
603
else
604
 
605
    begin : rxsync_fsm_disable
606
 
607
    //---------- Default -------------------------------------------------------
608
    always @ (posedge SYNC_CLK)
609
    begin
610
        fsm_rx      <= FSM_RXSYNC_IDLE;
611
        rxdlyen     <= 1'd0;
612
        rxsync_done <= 1'd0;
613
    end
614
 
615
    end
616
 
617
endgenerate
618
 
619
 
620
 
621
//---------- PIPE Sync Output --------------------------------------------------            
622
assign SYNC_TXPHALIGNEN      = ((PCIE_TXSYNC_MODE == 1) || (!gen3_reg2 && (PCIE_TXBUF_EN == "TRUE"))) ? 1'd0 : 1'd1;
623
assign SYNC_TXDLYBYPASS      = 1'd0;
624
//assign SYNC_TXDLYSRESET    = !(((PCIE_GT_DEVICE == "GTH") || (PCIE_GT_DEVICE == "GTP")) && (PCIE_TXSYNC_MODE == 1) && SYNC_SLAVE) ? (fsm_tx == FSM_TXSYNC_START) : 1'd0; 
625
assign SYNC_TXDLYSRESET      = (fsm_tx == FSM_TXSYNC_START);
626
assign SYNC_TXPHDLYRESET     =  (((PCIE_GT_DEVICE == "GTH") || (PCIE_GT_DEVICE == "GTP")) && (PCIE_TXSYNC_MODE == 1) && SYNC_SLAVE) ? (fsm_tx == FSM_TXSYNC_START) : 1'd0;
627
assign SYNC_TXPHINIT         = PCIE_TXSYNC_MODE ? 1'd0 : (fsm_tx == FSM_TXPHINITDONE);
628
assign SYNC_TXPHALIGN        = PCIE_TXSYNC_MODE ? 1'd0 : (fsm_tx == FSM_TXSYNC_DONE1);
629
assign SYNC_TXDLYEN          = PCIE_TXSYNC_MODE ? 1'd0 : txdlyen;
630
assign SYNC_TXSYNC_DONE      = txsync_done;
631
assign SYNC_FSM_TX           = fsm_tx;
632
 
633
assign SYNC_RXPHALIGNEN      = ((PCIE_RXSYNC_MODE == 1) || (!gen3_reg2) || (PCIE_RXBUF_EN == "TRUE")) ? 1'd0 : 1'd1;
634
assign SYNC_RXDLYBYPASS      = !gen3_reg2 || (PCIE_RXBUF_EN == "TRUE");
635
assign SYNC_RXDLYSRESET      = (fsm_rx == FSM_RXSYNC_START);
636
assign SYNC_RXPHALIGN        = PCIE_RXSYNC_MODE ? 1'd0 : (!SYNC_SLAVE ? (fsm_rx == FSM_RXSYNC_DONE1) : (rxsync_donem_reg2 && (fsm_rx == FSM_RXSYNC_DONE1)));
637
assign SYNC_RXDLYEN          = PCIE_RXSYNC_MODE ? 1'd0 : rxdlyen;
638
assign SYNC_RXDDIEN          = gen3_reg2 && (PCIE_RXBUF_EN == "FALSE");
639
assign SYNC_RXSYNC_DONE      = rxsync_done;
640
assign SYNC_RXSYNC_DONEM_OUT = (fsm_rx == FSM_RXSYNC_DONES);
641
assign SYNC_FSM_RX               = fsm_rx;
642
 
643
 
644
 
645
endmodule

powered by: WebSVN 2.1.0

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