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_qpll_reset.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_qpll_reset.v
52 48 dsmv
// Version    : 1.10
53 46 dsmv
//------------------------------------------------------------------------------
54
//  Filename     :  qpll_reset.v
55
//  Description  :  QPLL Reset Module for 7 Series Transceiver
56
//  Version      :  11.4
57
//------------------------------------------------------------------------------
58
 
59
 
60
`timescale 1ns / 1ps
61
 
62
 
63
 
64
//---------- QPLL Reset Module --------------------------------------------------
65
module cl_a7pcie_x4_qpll_reset #
66
(
67
 
68
    //---------- Global ------------------------------------
69
    parameter PCIE_PLL_SEL       = "CPLL",                  // PCIe PLL select for Gen1/Gen2 only
70
    parameter PCIE_POWER_SAVING  = "TRUE",                  // PCIe power saving
71
    parameter PCIE_LANE          = 1,                       // PCIe number of lanes
72
    parameter BYPASS_COARSE_OVRD = 1                        // Bypass coarse frequency override
73
 
74
)
75
 
76
(
77
 
78
    //---------- Input -------------------------------------
79
    input                           QRST_CLK,
80
    input                           QRST_RST_N,
81
    input                           QRST_MMCM_LOCK,
82
    input       [PCIE_LANE-1:0]     QRST_CPLLLOCK,
83
    input       [(PCIE_LANE-1)>>2:0]QRST_DRP_DONE,
84
    input       [(PCIE_LANE-1)>>2:0]QRST_QPLLLOCK,
85
    input       [ 1:0]              QRST_RATE,
86
    input       [PCIE_LANE-1:0]     QRST_QPLLRESET_IN,
87
    input       [PCIE_LANE-1:0]     QRST_QPLLPD_IN,
88
 
89
    //---------- Output ------------------------------------                     
90
    output                          QRST_OVRD,
91
    output                          QRST_DRP_START,
92
    output                          QRST_QPLLRESET_OUT,
93
    output                          QRST_QPLLPD_OUT,
94
    output                          QRST_IDLE,
95
    output      [ 3:0]              QRST_FSM
96
 
97
);
98
 
99
    //---------- Input Register ----------------------------
100 48 dsmv
(* ASYNC_REG = "TRUE", SHIFT_EXTRACT = "NO" *)    reg                             mmcm_lock_reg1;
101
(* ASYNC_REG = "TRUE", SHIFT_EXTRACT = "NO" *)    reg         [PCIE_LANE-1:0]     cplllock_reg1;
102
(* ASYNC_REG = "TRUE", SHIFT_EXTRACT = "NO" *)    reg         [(PCIE_LANE-1)>>2:0]drp_done_reg1;
103
(* ASYNC_REG = "TRUE", SHIFT_EXTRACT = "NO" *)    reg         [(PCIE_LANE-1)>>2:0]qplllock_reg1;
104
(* ASYNC_REG = "TRUE", SHIFT_EXTRACT = "NO" *)    reg         [ 1:0]              rate_reg1;
105
(* ASYNC_REG = "TRUE", SHIFT_EXTRACT = "NO" *)    reg         [PCIE_LANE-1:0]     qpllreset_in_reg1;
106
(* ASYNC_REG = "TRUE", SHIFT_EXTRACT = "NO" *)    reg         [PCIE_LANE-1:0]     qpllpd_in_reg1;
107 46 dsmv
 
108 48 dsmv
(* ASYNC_REG = "TRUE", SHIFT_EXTRACT = "NO" *)    reg                             mmcm_lock_reg2;
109
(* ASYNC_REG = "TRUE", SHIFT_EXTRACT = "NO" *)    reg         [PCIE_LANE-1:0]     cplllock_reg2;
110
(* ASYNC_REG = "TRUE", SHIFT_EXTRACT = "NO" *)    reg         [(PCIE_LANE-1)>>2:0]drp_done_reg2;
111
(* ASYNC_REG = "TRUE", SHIFT_EXTRACT = "NO" *)    reg         [(PCIE_LANE-1)>>2:0]qplllock_reg2;
112
(* ASYNC_REG = "TRUE", SHIFT_EXTRACT = "NO" *)    reg         [ 1:0]              rate_reg2;
113
(* ASYNC_REG = "TRUE", SHIFT_EXTRACT = "NO" *)    reg         [PCIE_LANE-1:0]     qpllreset_in_reg2;
114
(* ASYNC_REG = "TRUE", SHIFT_EXTRACT = "NO" *)    reg         [PCIE_LANE-1:0]     qpllpd_in_reg2;
115 46 dsmv
 
116
    //---------- Output Register  --------------------------
117
    reg                             ovrd              =  1'd0;
118
    reg                             qpllreset         =  1'd1;
119
    reg                             qpllpd            =  1'd0;
120
    reg         [ 3:0]              fsm               =  2;
121
 
122
    //---------- FSM ---------------------------------------                                         
123 48 dsmv
    localparam                      FSM_IDLE          = 1;
124
    localparam                      FSM_WAIT_LOCK     = 2;
125
    localparam                      FSM_MMCM_LOCK     = 3;
126
    localparam                      FSM_DRP_START_NOM = 4;
127
    localparam                      FSM_DRP_DONE_NOM  = 5;
128
    localparam                      FSM_QPLLLOCK      = 6;
129
    localparam                      FSM_DRP_START_OPT = 7;
130
    localparam                      FSM_DRP_DONE_OPT  = 8;
131
    localparam                      FSM_QPLL_RESET    = 9;
132
    localparam                      FSM_QPLLLOCK2     = 10;
133
    localparam                      FSM_QPLL_PDRESET  = 11;
134
    localparam                      FSM_QPLL_PD       = 12;
135 46 dsmv
 
136
 
137
 
138
//---------- Input FF ----------------------------------------------------------
139
always @ (posedge QRST_CLK)
140
begin
141
 
142
    if (!QRST_RST_N)
143
        begin
144
        //---------- 1st Stage FF --------------------------
145
        mmcm_lock_reg1    <=  1'd0;
146
        cplllock_reg1     <= {PCIE_LANE{1'd1}};
147
        drp_done_reg1     <= {(((PCIE_LANE-1)>>2)+1){1'd0}};
148
        qplllock_reg1     <= {(((PCIE_LANE-1)>>2)+1){1'd0}};
149
        rate_reg1         <=  2'd0;
150
        qpllreset_in_reg1 <= {PCIE_LANE{1'd1}};
151
        qpllpd_in_reg1    <= {PCIE_LANE{1'd0}};
152
        //---------- 2nd Stage FF --------------------------
153
        mmcm_lock_reg2    <=  1'd0;
154
        cplllock_reg2     <= {PCIE_LANE{1'd1}};
155
        drp_done_reg2     <= {(((PCIE_LANE-1)>>2)+1){1'd0}};
156
        qplllock_reg2     <= {(((PCIE_LANE-1)>>2)+1){1'd0}};
157
        rate_reg2         <=  2'd0;
158
        qpllreset_in_reg2 <= {PCIE_LANE{1'd1}};
159
        qpllpd_in_reg2    <= {PCIE_LANE{1'd0}};
160
        end
161
    else
162
        begin
163
        //---------- 1st Stage FF --------------------------
164
        mmcm_lock_reg1    <= QRST_MMCM_LOCK;
165
        cplllock_reg1     <= QRST_CPLLLOCK;
166
        drp_done_reg1     <= QRST_DRP_DONE;
167
        qplllock_reg1     <= QRST_QPLLLOCK;
168
        rate_reg1         <= QRST_RATE;
169
        qpllreset_in_reg1 <= QRST_QPLLRESET_IN;
170
        qpllpd_in_reg1    <= QRST_QPLLPD_IN;
171
        //---------- 2nd Stage FF --------------------------
172
        mmcm_lock_reg2    <= mmcm_lock_reg1;
173
        cplllock_reg2     <= cplllock_reg1;
174
        drp_done_reg2     <= drp_done_reg1;
175
        qplllock_reg2     <= qplllock_reg1;
176
        rate_reg2         <= rate_reg1;
177
        qpllreset_in_reg2 <= qpllreset_in_reg1;
178
        qpllpd_in_reg2    <= qpllpd_in_reg1;
179
        end
180
 
181
end
182
 
183
 
184
 
185
//---------- QPLL Reset FSM ----------------------------------------------------
186
always @ (posedge QRST_CLK)
187
begin
188
 
189
    if (!QRST_RST_N)
190
        begin
191
        fsm       <= FSM_WAIT_LOCK;
192
        ovrd      <= 1'd0;
193
        qpllreset <= 1'd1;
194
        qpllpd    <= 1'd0;
195
        end
196
    else
197
        begin
198
 
199
        case (fsm)
200
 
201
        //---------- Idle State ----------------------------
202
        FSM_IDLE :
203
 
204
            begin
205
            if (!QRST_RST_N)
206
                begin
207
                fsm       <= FSM_WAIT_LOCK;
208
                ovrd      <= 1'd0;
209
                qpllreset <= 1'd1;
210
                qpllpd    <= 1'd0;
211
                end
212
            else
213
                begin
214
                fsm       <= FSM_IDLE;
215
                ovrd      <= ovrd;
216
                qpllreset <= &qpllreset_in_reg2;
217
                qpllpd    <= &qpllpd_in_reg2;
218
                end
219
            end
220
 
221
        //---------- Wait for CPLL and QPLL to Lose Lock ---
222
        FSM_WAIT_LOCK :
223
 
224
            begin
225
            fsm       <= ((&(~cplllock_reg2)) && (&(~qplllock_reg2)) ? FSM_MMCM_LOCK : FSM_WAIT_LOCK);
226
            ovrd      <= ovrd;
227
            qpllreset <= qpllreset;
228
            qpllpd    <= qpllpd;
229
            end
230
 
231
        //---------- Wait for MMCM and CPLL Lock -----------
232
        FSM_MMCM_LOCK :
233
 
234
            begin
235
            fsm       <= ((mmcm_lock_reg2 && (&cplllock_reg2)) ? FSM_DRP_START_NOM : FSM_MMCM_LOCK);
236
            ovrd      <= ovrd;
237
            qpllreset <= qpllreset;
238
            qpllpd    <= qpllpd;
239
            end
240
 
241
        //---------- Start QPLL DRP for Normal QPLL Lock Mode 
242
        FSM_DRP_START_NOM:
243
 
244
            begin
245
            fsm       <= (&(~drp_done_reg2) ? FSM_DRP_DONE_NOM : FSM_DRP_START_NOM);
246
            ovrd      <= ovrd;
247
            qpllreset <= qpllreset;
248
            qpllpd    <= qpllpd;
249
            end
250
 
251
        //---------- Wait for QPLL DRP Done ----------------
252
        FSM_DRP_DONE_NOM :
253
 
254
            begin
255
            fsm       <= (&drp_done_reg2 ? FSM_QPLLLOCK : FSM_DRP_DONE_NOM);
256
            ovrd      <= ovrd;
257
            qpllreset <= qpllreset;
258
            qpllpd    <= qpllpd;
259
            end
260
 
261
        //---------- Wait for QPLL Lock --------------------
262
        FSM_QPLLLOCK :
263
 
264
            begin
265
            fsm       <= (&qplllock_reg2 ? ((BYPASS_COARSE_OVRD == 1) ? FSM_QPLL_PDRESET : FSM_DRP_START_OPT) : FSM_QPLLLOCK);
266
            ovrd      <= ovrd;
267
            qpllreset <= 1'd0;
268
            qpllpd    <= qpllpd;
269
            end
270
 
271
        //---------- Start QPLL DRP for Optimized QPLL Lock Mode 
272
        FSM_DRP_START_OPT:
273
 
274
            begin
275
            fsm       <= (&(~drp_done_reg2) ? FSM_DRP_DONE_OPT : FSM_DRP_START_OPT);
276
            ovrd      <= 1'd1;
277
            qpllreset <= qpllreset;
278
            qpllpd    <= qpllpd;
279
            end
280
 
281
        //---------- Wait for QPLL DRP Done ----------------
282
        FSM_DRP_DONE_OPT :
283
 
284
            begin
285
            if (&drp_done_reg2)
286
                begin
287
                fsm       <= ((PCIE_PLL_SEL == "QPLL") ? FSM_QPLL_RESET : FSM_QPLL_PDRESET);
288
                ovrd      <= ovrd;
289
                qpllreset <= (PCIE_PLL_SEL == "QPLL");
290
                qpllpd    <= qpllpd;
291
                end
292
            else
293
                begin
294
                fsm       <= FSM_DRP_DONE_OPT;
295
                ovrd      <= ovrd;
296
                qpllreset <= qpllreset;
297
                qpllpd    <= qpllpd;
298
                end
299
            end
300
 
301
        //---------- Reset QPLL ----------------------------
302
        FSM_QPLL_RESET :
303
 
304
            begin
305
            fsm       <= (&(~qplllock_reg2) ? FSM_QPLLLOCK2 : FSM_QPLL_RESET);
306
            ovrd      <= ovrd;
307
            qpllreset <= 1'd1;
308
            qpllpd    <= 1'd0;
309
            end
310
 
311
        //---------- Wait for QPLL Lock --------------------
312
        FSM_QPLLLOCK2 :
313
 
314
            begin
315
            fsm       <= (&qplllock_reg2 ? FSM_IDLE : FSM_QPLLLOCK2);
316
            ovrd      <= ovrd;
317
            qpllreset <= 1'd0;
318
            qpllpd    <= 1'd0;
319
            end
320
 
321
        //---------- Hold QPLL in Reset --------------------
322
        FSM_QPLL_PDRESET :
323
 
324
            begin
325
            fsm       <= FSM_QPLL_PD;
326
            ovrd      <= ovrd;
327
            qpllreset <= (PCIE_PLL_SEL == "CPLL") ? (rate_reg2 != 2'd2) : 1'd0;
328
            qpllpd    <= qpllpd;
329
            end
330
 
331
        //---------- Power-down QPLL ----------------------- 
332
        FSM_QPLL_PD :
333
 
334
            begin
335
            fsm       <= FSM_IDLE;
336
            ovrd      <= ovrd;
337
            qpllreset <= qpllreset;
338
            qpllpd    <= (PCIE_PLL_SEL == "CPLL") ? (rate_reg2 != 2'd2) : 1'd0;
339
            end
340
 
341
        //---------- Default State -------------------------
342
        default :
343
 
344
            begin
345
            fsm       <= FSM_WAIT_LOCK;
346
            ovrd      <= 1'd0;
347
            qpllreset <= 1'd0;
348
            qpllpd    <= 1'd0;
349
            end
350
 
351
        endcase
352
 
353
        end
354
 
355
end
356
 
357
 
358
 
359
//---------- QPLL Lock Output --------------------------------------------------
360
assign QRST_OVRD          = ovrd;
361
assign QRST_DRP_START     = (fsm == FSM_DRP_START_NOM) || (fsm == FSM_DRP_START_OPT);
362
assign QRST_QPLLRESET_OUT = qpllreset;
363
assign QRST_QPLLPD_OUT    = ((PCIE_POWER_SAVING == "FALSE") ? 1'd0 : qpllpd);
364
assign QRST_IDLE          = (fsm == FSM_IDLE);
365
assign QRST_FSM           = fsm;
366
 
367
 
368
 
369
endmodule

powered by: WebSVN 2.1.0

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