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_rxeq_scan.v] - Blame information for rev 46

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_rxeq_scan.v
52
// Version    : 1.9
53
//------------------------------------------------------------------------------
54
//  Filename     :  rxeq_scan.v
55
//  Description  :  PIPE RX Equalization Eye Scan Module for 7 Series Transceiver
56
//  Version      :  18.0
57
//------------------------------------------------------------------------------
58
 
59
 
60
`timescale 1ns / 1ps
61
 
62
 
63
 
64
//---------- RXEQ Eye Scan Module ----------------------------------------------
65
module cl_a7pcie_x4_rxeq_scan #
66
(
67
 
68
    parameter PCIE_SIM_MODE       = "FALSE",                // PCIe sim mode 
69
    parameter PCIE_GT_DEVICE      = "GTX",                  // PCIe GT device
70
    parameter PCIE_RXEQ_MODE_GEN3 = 1,                      // PCIe RX equalization mode
71
    parameter CONVERGE_MAX        = 22'd3125000,            // Convergence max count (12ms) 
72
    parameter CONVERGE_MAX_BYPASS = 22'd2083333             // Convergence max count for phase2/3 bypass mode (8ms)
73
)
74
 
75
(
76
 
77
    //---------- Input -------------------------------------
78
    input               RXEQSCAN_CLK,
79
    input               RXEQSCAN_RST_N,
80
 
81
    input       [ 1:0]  RXEQSCAN_CONTROL,
82
    input       [ 2:0]  RXEQSCAN_PRESET,
83
    input               RXEQSCAN_PRESET_VALID,
84
    input       [ 3:0]  RXEQSCAN_TXPRESET,
85
    input       [17:0]  RXEQSCAN_TXCOEFF,
86
    input               RXEQSCAN_NEW_TXCOEFF_REQ,
87
    input       [ 5:0]  RXEQSCAN_FS,
88
    input       [ 5:0]  RXEQSCAN_LF,
89
 
90
 
91
    //---------- Output ------------------------------------
92
    output              RXEQSCAN_PRESET_DONE,
93
    output      [17:0]  RXEQSCAN_NEW_TXCOEFF,
94
    output              RXEQSCAN_NEW_TXCOEFF_DONE,
95
    output              RXEQSCAN_LFFS_SEL,
96
    output              RXEQSCAN_ADAPT_DONE
97
 
98
);
99
 
100
    //---------- Input Register ----------------------------
101
    reg         [ 2:0]  preset_reg1;
102
    reg                 preset_valid_reg1;
103
    reg         [ 3:0]  txpreset_reg1;
104
    reg         [17:0]  txcoeff_reg1;
105
    reg                 new_txcoeff_req_reg1;
106
    reg         [ 5:0]  fs_reg1;
107
    reg         [ 5:0]  lf_reg1;
108
 
109
    reg         [ 2:0]  preset_reg2;
110
    reg                 preset_valid_reg2;
111
    reg         [ 3:0]  txpreset_reg2;
112
    reg         [17:0]  txcoeff_reg2;
113
    reg                 new_txcoeff_req_reg2;
114
    reg         [ 5:0]  fs_reg2;
115
    reg         [ 5:0]  lf_reg2;
116
 
117
    //---------- Internal Signals --------------------------
118
    reg                 adapt_done_cnt = 1'd0;
119
 
120
    //---------- Output Register ---------------------------          
121
    reg                 preset_done      =  1'd0;
122
    reg         [21:0]  converge_cnt     = 22'd0;
123
    reg         [17:0]  new_txcoeff      = 18'd0;
124
    reg                 new_txcoeff_done =  1'd0;
125
    reg                 lffs_sel         =  1'd0;
126
    reg                 adapt_done       =  1'd0;
127
    reg         [ 3:0]  fsm              =  4'd0;
128
 
129
    //---------- FSM ---------------------------------------                                         
130
    localparam          FSM_IDLE            = 4'b0001;
131
    localparam          FSM_PRESET          = 4'b0010;
132
    localparam          FSM_CONVERGE        = 4'b0100;
133
    localparam          FSM_NEW_TXCOEFF_REQ = 4'b1000;
134
 
135
    //---------- Simulation Speedup ------------------------
136
    //  Gen3:  32 bits / PCLK : 1 million bits / X PCLK
137
    //         X = 
138
    //------------------------------------------------------
139
    localparam converge_max_cnt        = (PCIE_SIM_MODE == "TRUE") ? 22'd1000 : CONVERGE_MAX;
140
    localparam converge_max_bypass_cnt = (PCIE_SIM_MODE == "TRUE") ? 22'd1000 : CONVERGE_MAX_BYPASS;
141
 
142
 
143
 
144
//---------- Input FF ----------------------------------------------------------
145
always @ (posedge RXEQSCAN_CLK)
146
begin
147
 
148
    if (!RXEQSCAN_RST_N)
149
        begin
150
        //---------- 1st Stage FF --------------------------  
151
        preset_reg1          <=  3'd0;
152
        preset_valid_reg1    <=  1'd0;
153
        txpreset_reg1        <=  4'd0;
154
        txcoeff_reg1         <= 18'd0;
155
        new_txcoeff_req_reg1 <=  1'd0;
156
        fs_reg1              <=  6'd0;
157
        lf_reg1              <=  6'd0;
158
        //---------- 2nd Stage FF --------------------------
159
        preset_reg2          <=  3'd0;
160
        preset_valid_reg2    <=  1'd0;
161
        txpreset_reg2        <=  4'd0;
162
        txcoeff_reg2         <= 18'd0;
163
        new_txcoeff_req_reg2 <=  1'd0;
164
        fs_reg2              <=  6'd0;
165
        lf_reg2              <=  6'd0;
166
        end
167
    else
168
        begin
169
        //---------- 1st Stage FF --------------------------  
170
        preset_reg1          <= RXEQSCAN_PRESET;
171
        preset_valid_reg1    <= RXEQSCAN_PRESET_VALID;
172
        txpreset_reg1        <= RXEQSCAN_TXPRESET;
173
        txcoeff_reg1         <= RXEQSCAN_TXCOEFF;
174
        new_txcoeff_req_reg1 <= RXEQSCAN_NEW_TXCOEFF_REQ;
175
        fs_reg1              <= RXEQSCAN_FS;
176
        lf_reg1              <= RXEQSCAN_LF;
177
        //---------- 2nd Stage FF -------------------------- 
178
        preset_reg2          <= preset_reg1;
179
        preset_valid_reg2    <= preset_valid_reg1;
180
        txpreset_reg2        <= txpreset_reg1;
181
        txcoeff_reg2         <= txcoeff_reg1;
182
        new_txcoeff_req_reg2 <= new_txcoeff_req_reg1;
183
        fs_reg2              <= fs_reg1;
184
        lf_reg2              <= lf_reg1;
185
        end
186
 
187
end
188
 
189
 
190
 
191
//---------- Eye Scan ----------------------------------------------------------
192
always @ (posedge RXEQSCAN_CLK)
193
begin
194
 
195
    if (!RXEQSCAN_RST_N)
196
        begin
197
        fsm              <=  FSM_IDLE;
198
        preset_done      <=  1'd0;
199
        converge_cnt     <= 22'd0;
200
        new_txcoeff      <= 18'd0;
201
        new_txcoeff_done <=  1'd0;
202
        lffs_sel         <=  1'd0;
203
        adapt_done       <=  1'd0;
204
        adapt_done_cnt   <=  1'd0;
205
        end
206
    else
207
 
208
        begin
209
 
210
        case (fsm)
211
 
212
        //---------- Idle State ----------------------------
213
        FSM_IDLE :
214
 
215
            begin
216
 
217
            //---------- Process RXEQ Preset ---------------
218
            if (preset_valid_reg2)
219
                begin
220
                fsm              <=  FSM_PRESET;
221
                preset_done      <=  1'd1;
222
                converge_cnt     <= 22'd0;
223
                new_txcoeff      <=  new_txcoeff;
224
                new_txcoeff_done <=  1'd0;
225
                lffs_sel         <=  1'd0;
226
                adapt_done       <=  1'd0;
227
                adapt_done_cnt   <=  adapt_done_cnt;
228
                end
229
            //---------- Request New TX Coefficient --------
230
            else if (new_txcoeff_req_reg2)
231
                begin
232
                fsm              <=  FSM_CONVERGE;
233
                preset_done      <=  1'd0;
234
                converge_cnt     <= 22'd0;
235
              //new_txcoeff      <= (PCIE_RXEQ_MODE_GEN3 == 0) ? txcoeff_reg2 : 18'd4;  // Default
236
                new_txcoeff      <= (PCIE_RXEQ_MODE_GEN3 == 0) ? txcoeff_reg2 : (PCIE_GT_DEVICE == "GTX") ? 18'd5 : 18'd4;  // Optimized for Gen3 RX JTOL
237
                new_txcoeff_done <=  1'd0;
238
                lffs_sel         <= (PCIE_RXEQ_MODE_GEN3 == 0) ? 1'd0 : 1'd1;
239
                adapt_done       <=  1'd0;
240
                adapt_done_cnt   <=  adapt_done_cnt;
241
                end
242
            //---------- Default ---------------------------
243
            else
244
                begin
245
                fsm              <=  FSM_IDLE;
246
                preset_done      <=  1'd0;
247
                converge_cnt     <= 22'd0;
248
                new_txcoeff      <=  new_txcoeff;
249
                new_txcoeff_done <=  1'd0;
250
                lffs_sel         <=  1'd0;
251
                adapt_done       <=  1'd0;
252
                adapt_done_cnt   <=  adapt_done_cnt;
253
                end
254
 
255
            end
256
 
257
        //---------- Process RXEQ Preset -------------------
258
        FSM_PRESET :
259
 
260
            begin
261
            fsm              <= (!preset_valid_reg2) ? FSM_IDLE : FSM_PRESET;
262
            preset_done      <=  1'd1;
263
            converge_cnt     <= 22'd0;
264
            new_txcoeff      <=  new_txcoeff;
265
            new_txcoeff_done <=  1'd0;
266
            lffs_sel         <=  1'd0;
267
            adapt_done       <=  1'd0;
268
            adapt_done_cnt   <=  adapt_done_cnt;
269
            end
270
 
271
        //---------- Wait for Convergence ------------------    
272
        FSM_CONVERGE :
273
 
274
            begin
275
            if ((adapt_done_cnt == 1'd0) && (RXEQSCAN_CONTROL == 2'd2))
276
                begin
277
                fsm              <= FSM_NEW_TXCOEFF_REQ;
278
                preset_done      <=  1'd0;
279
                converge_cnt     <= 22'd0;
280
                new_txcoeff      <= new_txcoeff;
281
                new_txcoeff_done <= 1'd0;
282
                lffs_sel         <= lffs_sel;
283
                adapt_done       <= 1'd0;
284
                adapt_done_cnt   <= adapt_done_cnt;
285
                end
286
            else
287
                begin
288
 
289
                //---------- Phase2/3 ----------------------
290
                if (RXEQSCAN_CONTROL == 2'd2)
291
                    fsm <= (converge_cnt == converge_max_cnt)        ? FSM_NEW_TXCOEFF_REQ : FSM_CONVERGE;
292
                //---------- Phase2/3 Bypass ---------------
293
                else
294
                    fsm <= (converge_cnt == converge_max_bypass_cnt) ? FSM_NEW_TXCOEFF_REQ : FSM_CONVERGE;
295
 
296
                preset_done      <= 1'd0;
297
                converge_cnt     <= converge_cnt + 1'd1;
298
                new_txcoeff      <= new_txcoeff;
299
                new_txcoeff_done <= 1'd0;
300
                lffs_sel         <= lffs_sel;
301
                adapt_done       <= 1'd0;
302
                adapt_done_cnt   <= adapt_done_cnt;
303
                end
304
            end
305
 
306
        //---------- Request New TX Coefficient ------------
307
        FSM_NEW_TXCOEFF_REQ :
308
 
309
            begin
310
            if (!new_txcoeff_req_reg2)
311
                begin
312
                fsm              <= FSM_IDLE;
313
                preset_done      <=  1'd0;
314
                converge_cnt     <= 22'd0;
315
                new_txcoeff      <= new_txcoeff;
316
                new_txcoeff_done <= 1'd0;
317
                lffs_sel         <= lffs_sel;
318
                adapt_done       <= 1'd0;
319
                adapt_done_cnt   <= (RXEQSCAN_CONTROL == 2'd3) ? 1'd0 : adapt_done_cnt + 1'd1;
320
                end
321
            else
322
                begin
323
                fsm              <= FSM_NEW_TXCOEFF_REQ;
324
                preset_done      <=  1'd0;
325
                converge_cnt     <= 22'd0;
326
                new_txcoeff      <= new_txcoeff;
327
                new_txcoeff_done <= 1'd1;
328
                lffs_sel         <= lffs_sel;
329
                adapt_done       <= (adapt_done_cnt == 1'd1) || (RXEQSCAN_CONTROL == 2'd3);
330
                adapt_done_cnt   <= adapt_done_cnt;
331
                end
332
            end
333
 
334
        //---------- Default State -------------------------
335
        default :
336
 
337
            begin
338
            fsm              <=  FSM_IDLE;
339
            preset_done      <=  1'd0;
340
            converge_cnt     <= 22'd0;
341
            new_txcoeff      <= 18'd0;
342
            new_txcoeff_done <=  1'd0;
343
            lffs_sel         <=  1'd0;
344
            adapt_done       <=  1'd0;
345
            adapt_done_cnt   <=  1'd0;
346
            end
347
 
348
        endcase
349
 
350
        end
351
 
352
end
353
 
354
 
355
 
356
//---------- RXEQ Eye Scan Output ----------------------------------------------
357
assign RXEQSCAN_PRESET_DONE      = preset_done;
358
assign RXEQSCAN_NEW_TXCOEFF      = new_txcoeff;
359
assign RXEQSCAN_NEW_TXCOEFF_DONE = new_txcoeff_done;
360
assign RXEQSCAN_LFFS_SEL         = lffs_sel;
361
assign RXEQSCAN_ADAPT_DONE       = adapt_done;
362
 
363
 
364
 
365
endmodule

powered by: WebSVN 2.1.0

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