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_gtp_pipe_drp.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_gtp_pipe_drp.v
52
// Version    : 1.9
53
//------------------------------------------------------------------------------
54
//  Filename     :  gtp_pipe_drp.v
55
//  Description  :  GTP PIPE DRP Module for 7 Series Transceiver
56
//  Version      :  19.0
57
//------------------------------------------------------------------------------
58
 
59
 
60
 
61
`timescale 1ns / 1ps
62
 
63
 
64
 
65
//---------- GTP PIPE DRP Module -----------------------------------------------
66
module cl_a7pcie_x4_gtp_pipe_drp #
67
(
68
 
69
    parameter LOAD_CNT_MAX     = 2'd1,                      // Load max count
70
    parameter INDEX_MAX        = 1'd0                       // Index max count
71
 
72
)
73
 
74
(
75
 
76
    //---------- Input -------------------------------------
77
    input               DRP_CLK,
78
    input               DRP_RST_N,
79
    input               DRP_X16,
80
    input               DRP_START,
81
    input       [15:0]  DRP_DO,
82
    input               DRP_RDY,
83
 
84
    //---------- Output ------------------------------------
85
    output      [ 8:0]  DRP_ADDR,
86
    output              DRP_EN,
87
    output      [15:0]  DRP_DI,
88
    output              DRP_WE,
89
    output              DRP_DONE,
90
    output      [ 2:0]  DRP_FSM
91
 
92
);
93
 
94
    //---------- Input Registers ---------------------------
95
    reg                 x16_reg1;
96
    reg                 start_reg1;
97
    reg         [15:0]  do_reg1;
98
    reg                 rdy_reg1;
99
 
100
    reg                 x16_reg2;
101
    reg                 start_reg2;
102
    reg         [15:0]  do_reg2;
103
    reg                 rdy_reg2;
104
 
105
    //---------- Internal Signals --------------------------
106
    reg         [ 1:0]  load_cnt =  2'd0;
107
    reg         [ 4:0]  index    =  5'd0;
108
    reg         [ 8:0]  addr_reg =  9'd0;
109
    reg         [15:0]  di_reg   = 16'd0;
110
 
111
    //---------- Output Registers --------------------------
112
    reg                 done     =  1'd0;
113
    reg         [ 2:0]  fsm      =  1;
114
 
115
    //---------- DRP Address -------------------------------          
116
    localparam          ADDR_RX_DATAWIDTH  = 9'h011;
117
 
118
    //---------- DRP Mask ----------------------------------
119
    localparam          MASK_RX_DATAWIDTH  = 16'b1111011111111111;  // Unmask bit [   11]  
120
 
121
    //---------- DRP Data for x16 --------------------------
122
    localparam          X16_RX_DATAWIDTH   = 16'b0000000000000000;  // 2-byte (16-bit) internal data width
123
 
124
    //---------- DRP Data for x20 --------------------------                                  
125
    localparam          X20_RX_DATAWIDTH   = 16'b0000100000000000;  // 2-byte (20-bit) internal data width               
126
 
127
    //---------- DRP Data ----------------------------------                  
128
    wire        [15:0]  data_rx_datawidth;
129
 
130
    //---------- FSM ---------------------------------------  
131
    localparam          FSM_IDLE  = 0;
132
    localparam          FSM_LOAD  = 1;
133
    localparam          FSM_READ  = 2;
134
    localparam          FSM_RRDY  = 3;
135
    localparam          FSM_WRITE = 4;
136
    localparam          FSM_WRDY  = 5;
137
    localparam          FSM_DONE  = 6;
138
 
139
 
140
 
141
//---------- Input FF ----------------------------------------------------------
142
always @ (posedge DRP_CLK)
143
begin
144
 
145
    if (!DRP_RST_N)
146
        begin
147
        //---------- 1st Stage FF --------------------------
148
        x16_reg1   <=  1'd0;
149
        do_reg1    <= 16'd0;
150
        rdy_reg1   <=  1'd0;
151
        start_reg1 <=  1'd0;
152
        //---------- 2nd Stage FF --------------------------
153
        x16_reg2   <=  1'd0;
154
        do_reg2    <= 16'd0;
155
        rdy_reg2   <=  1'd0;
156
        start_reg2 <=  1'd0;
157
        end
158
 
159
    else
160
        begin
161
        //---------- 1st Stage FF --------------------------
162
        x16_reg1   <= DRP_X16;
163
        do_reg1    <= DRP_DO;
164
        rdy_reg1   <= DRP_RDY;
165
        start_reg1 <= DRP_START;
166
        //---------- 2nd Stage FF --------------------------
167
        x16_reg2   <= x16_reg1;
168
        do_reg2    <= do_reg1;
169
        rdy_reg2   <= rdy_reg1;
170
        start_reg2 <= start_reg1;
171
        end
172
 
173
end
174
 
175
 
176
 
177
//---------- Select DRP Data ---------------------------------------------------
178
assign data_rx_datawidth = x16_reg2 ? X16_RX_DATAWIDTH : X20_RX_DATAWIDTH;
179
 
180
 
181
 
182
//---------- Load Counter ------------------------------------------------------
183
always @ (posedge DRP_CLK)
184
begin
185
 
186
    if (!DRP_RST_N)
187
        load_cnt <= 2'd0;
188
    else
189
 
190
        //---------- Increment Load Counter ----------------
191
        if ((fsm == FSM_LOAD) && (load_cnt < LOAD_CNT_MAX))
192
            load_cnt <= load_cnt + 2'd1;
193
 
194
        //---------- Hold Load Counter ---------------------
195
        else if ((fsm == FSM_LOAD) && (load_cnt == LOAD_CNT_MAX))
196
            load_cnt <= load_cnt;
197
 
198
        //---------- Reset Load Counter --------------------
199
        else
200
            load_cnt <= 2'd0;
201
 
202
end
203
 
204
 
205
 
206
//---------- Update DRP Address and Data ---------------------------------------
207
always @ (posedge DRP_CLK)
208
begin
209
 
210
    if (!DRP_RST_N)
211
        begin
212
        addr_reg <=  9'd0;
213
        di_reg   <= 16'd0;
214
        end
215
    else
216
        begin
217
 
218
        case (index)
219
 
220
        //--------------------------------------------------     
221
        1'd0 :
222
            begin
223
            addr_reg <= ADDR_RX_DATAWIDTH;
224
            di_reg   <= (do_reg2 & MASK_RX_DATAWIDTH) | data_rx_datawidth;
225
            end
226
 
227
        //--------------------------------------------------
228
        default :
229
            begin
230
            addr_reg <=  9'd0;
231
            di_reg   <= 16'd0;
232
            end
233
 
234
        endcase
235
 
236
        end
237
 
238
end
239
 
240
 
241
 
242
//---------- PIPE DRP FSM ------------------------------------------------------
243
always @ (posedge DRP_CLK)
244
begin
245
 
246
    if (!DRP_RST_N)
247
        begin
248
        fsm   <= FSM_IDLE;
249
        index <= 5'd0;
250
        done  <= 1'd0;
251
        end
252
    else
253
        begin
254
 
255
        case (fsm)
256
 
257
        //---------- Idle State ----------------------------
258
        FSM_IDLE :
259
 
260
            begin
261
            //---------- Reset or Rate Change --------------
262
            if (start_reg2)
263
                begin
264
                fsm   <= FSM_LOAD;
265
                index <= 5'd0;
266
                done  <= 1'd0;
267
                end
268
            //---------- Idle ------------------------------
269
            else
270
                begin
271
                fsm   <= FSM_IDLE;
272
                index <= 5'd0;
273
                done  <= 1'd1;
274
                end
275
            end
276
 
277
        //---------- Load DRP Address  ---------------------
278
        FSM_LOAD :
279
 
280
            begin
281
            fsm   <= (load_cnt == LOAD_CNT_MAX) ? FSM_READ : FSM_LOAD;
282
            index <= index;
283
 
284
            done  <= 1'd0;
285
            end
286
 
287
        //---------- Read DRP ------------------------------
288
        FSM_READ :
289
 
290
            begin
291
            fsm   <= FSM_RRDY;
292
            index <= index;
293
            done  <= 1'd0;
294
            end
295
 
296
        //---------- Read DRP Ready ------------------------
297
        FSM_RRDY :
298
 
299
            begin
300
            fsm   <= rdy_reg2 ? FSM_WRITE : FSM_RRDY;
301
            index <= index;
302
            done  <= 1'd0;
303
            end
304
 
305
 
306
        //---------- Write DRP -----------------------------
307
        FSM_WRITE :
308
 
309
            begin
310
            fsm   <= FSM_WRDY;
311
            index <= index;
312
            done  <= 1'd0;
313
            end
314
 
315
        //---------- Write DRP Ready -----------------------
316
        FSM_WRDY :
317
 
318
            begin
319
            fsm   <= rdy_reg2 ? FSM_DONE : FSM_WRDY;
320
            index <= index;
321
            done  <= 1'd0;
322
            end
323
 
324
        //---------- DRP Done ------------------------------
325
        FSM_DONE :
326
 
327
            begin
328
            if (index == INDEX_MAX)
329
                begin
330
                fsm   <= FSM_IDLE;
331
                index <= 5'd0;
332
                done  <= 1'd0;
333
                end
334
            else
335
                begin
336
                fsm   <= FSM_LOAD;
337
                index <= index + 5'd1;
338
                done  <= 1'd0;
339
                end
340
            end
341
 
342
        //---------- Default State -------------------------
343
        default :
344
 
345
            begin
346
            fsm   <= FSM_IDLE;
347
            index <= 5'd0;
348
            done  <= 1'd0;
349
            end
350
 
351
        endcase
352
 
353
        end
354
 
355
end
356
 
357
 
358
 
359
//---------- PIPE DRP Output ---------------------------------------------------
360
assign DRP_ADDR = addr_reg;
361
assign DRP_EN   = (fsm == FSM_READ) || (fsm == FSM_WRITE);
362
assign DRP_DI   = di_reg;
363
assign DRP_WE   = (fsm == FSM_WRITE);
364
assign DRP_DONE = done;
365
assign DRP_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.